/* ---------------------------------------------
   /src/css/components/footer/footer.css
   THE 3Y FOOTER — theme-aware
---------------------------------------------- */

/* =========================================================
   ROOT FOOTER CONTAINER
   ========================================================= */

footer {
  background: linear-gradient(
    to bottom,
    var(--color-surface),
    var(--color-surface-sunken)
  );
  color: var(--color-text-primary);
  padding: 80px 0 40px;
  border-top: 1px solid var(--color-border-subtle);
  font-family: var(--font-sans, sans-serif);
}

.footer-wrapper {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 72px);
}

/* =========================================================
   PRIMARY FOOTER LAYOUT
   Brand column + main navigation columns
   ========================================================= */

.footer-content {
  display: flex;
  justify-content: space-between;
  gap: 60px;
  margin-bottom: 60px;
}

.footer-brand-section {
  flex: 0 1 300px;
}

/* Logo is a single-color PNG.
   Dark theme → white via invert.
   Light theme → black via filter reset. */
.footer-logo {
  height: 42px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.9;
  margin-bottom: 20px;
}

:root[data-theme="light"] .footer-logo {
  filter: brightness(0);
}

.footer-tagline {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* =========================================================
   PRIMARY NAVIGATION COLUMNS
   ========================================================= */

.footer-column-group {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(112px, 1fr));
  gap: clamp(24px, 3vw, 40px);
}

.footer-column .footer-column-title,
.footer-meta-block .footer-column-title {
  display: block;
  margin: 0 0 25px;
  padding: 0;
  border: 0;
  color: var(--color-text-primary);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.footer-meta-block .footer-column-title {
  margin-bottom: 16px;
}

.footer-column a {
  display: block;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 12px;
  transition: color 0.2s ease;
}

.footer-column a:hover {
  color: var(--color-brand);
}

/* =========================================================
   SECONDARY META ROW
   Social + support blocks beneath main columns
   ========================================================= */

.footer-meta {
  display: flex;
  gap: 60px;
  padding: 32px 0 4px;
  margin-top: 16px;
  border-top: 1px solid var(--color-border-subtle);
}

.footer-meta::before {
  content: "";
  flex: 0 1 300px;
}

.footer-meta-blocks {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 40px;
}

.footer-meta-block a {
  display: block;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.footer-meta-block a:hover {
  color: var(--color-brand);
}

/* =========================================================
   ASK AI STRIP
   Under the brand tagline
   ========================================================= */

.footer-ai-strip {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-ai-strip__label {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.footer-ai-strip__icons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.footer-ai-strip__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted) !important;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease;
  margin-bottom: 0 !important;
}

.footer-ai-strip__link:hover {
  border-color: var(--color-brand);
  color: var(--color-brand) !important;
  background: color-mix(in srgb, var(--color-brand) 8%, transparent);
}

.footer-ai-strip__link svg {
  width: 16px;
  height: 16px;
  display: block;
}

.footer-ai-strip__icon--claude {
  width: 16px;
  height: 16px;
  display: block;
  background-color: currentColor;
  -webkit-mask: url("/assets/images/claude.svg") no-repeat center / contain;
  mask: url("/assets/images/claude.svg") no-repeat center / contain;
}

.footer-ai-strip__icon-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.footer-ai-strip__status {
  min-height: 1.35rem;
  margin: 2px 0 0;
  color: var(--color-text-secondary);
  font-size: 0.78rem;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.footer-ai-strip__status[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}

.footer-theme {
  margin-top: 18px;
}

@media (prefers-reduced-motion: reduce) {
  .footer-ai-strip__status {
    transition: opacity 0.01ms linear;
    transform: none;
  }

  .footer-ai-strip__status[data-visible="true"] {
    transform: none;
  }
}

/* =========================================================
   THEME TOGGLE
   Bottom of the brand column
   ========================================================= */

.footer-theme {
  margin-top: 28px;
}

.footer-theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

.footer-theme-toggle:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 8%, transparent);
  transform: translateY(-1px);
}

.footer-theme-toggle:active {
  transform: translateY(0);
}

.footer-theme-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}

.footer-theme-toggle .icon-sun {
  display: none;
}

.footer-theme-toggle .icon-moon {
  display: block;
}

:root[data-theme="dark"] .footer-theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .footer-theme-toggle .icon-moon {
  display: none;
}

/* =========================================================
   FOOTER MARKETS DROPDOWN
   ========================================================= */

.footer-markets {
  margin: 42px 0 34px;
  padding: 0;
  border-top: 1px solid var(--color-border-subtle);
}

.footer-markets summary {
  list-style: none;
  cursor: pointer;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--color-text-primary);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  user-select: none;
  text-align: center;
  transition: color 0.18s ease;
}

.footer-markets summary::-webkit-details-marker {
  display: none;
}

.footer-markets summary:hover {
  color: var(--color-brand);
}

.footer-markets-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 1.05rem;
  line-height: 1;
  transform: translateY(-1px);
  transition:
    transform 0.18s ease,
    color 0.18s ease;
}

.footer-markets[open] .footer-markets-icon {
  color: var(--color-brand);
  transform: translateY(-1px) rotate(180deg);
}

.footer-markets-list {
  padding: 0 0 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.footer-markets-loading {
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.footer-markets-fallback {
  color: var(--color-text-secondary);
  font-size: 0.96rem;
  text-align: center;
}

.footer-markets-fallback a {
  color: var(--color-text-primary);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--color-brand) 45%, transparent);
}

.footer-markets-fallback a:hover {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}

.footer-markets-state {
  max-width: 980px;
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
}

.footer-markets-state-name {
  color: var(--color-text-primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: right;
}

.footer-markets-state-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 7px 0;
  min-width: 0;
  text-align: center;
}

.footer-markets-state-links a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.7;
  white-space: nowrap;
  transition: color 0.16s ease;
}

.footer-markets-state-links a:not(:last-child)::after {
  content: "|";
  color: var(--color-border-strong);
  margin: 0 10px;
}

.footer-markets-state-links a:hover {
  color: var(--color-brand);
}

/* =========================================================
   INSTITUTIONAL DISCLAIMER
   ========================================================= */

.footer-disclaimer {
  border-top: 1px solid var(--color-border-subtle);
  padding: 32px 0;
  margin-bottom: 20px;
}

.footer-disclaimer p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  line-height: 1.7;
  max-width: 1000px;
}

.footer-disclaimer p + p {
  margin-top: 0.75rem;
}

.footer-disclaimer a {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-disclaimer a:hover {
  color: var(--color-text-primary);
}

/* =========================================================
   BOTTOM ROW
   Copyright + live system status + back to top
   ========================================================= */

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.footer-status-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-separator {
  width: 3px;
  height: 3px;
  background: var(--color-text-muted);
  border-radius: 50%;
  display: inline-block;
  margin: 0 12px;
  vertical-align: middle;
}

.status-label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.footer-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  transition: color 0.2s ease;
}

.footer-status-pill:hover {
  color: var(--color-text-primary);
}

.footer-status-pill:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 4px;
  border-radius: 999px;
}

.footer-status-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-text-muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-text-muted) 18%, transparent);
}

.footer-status-dot[data-level="operational"],
.footer-status-dot[data-level="ok"] {
  background: var(--color-success, #8dc143);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-success, #8dc143) 22%, transparent);
}

.footer-status-dot[data-level="warn"],
.footer-status-dot[data-level="degraded"] {
  background: var(--color-warning, #f59e0b);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-warning, #f59e0b) 22%, transparent);
}

.footer-status-dot[data-level="down"],
.footer-status-dot[data-level="outage"] {
  background: var(--color-danger, #ef4444);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger, #ef4444) 22%, transparent);
}

.footer-status-pill[data-level="operational"],
.footer-status-pill[data-level="ok"],
.footer-status-pill.status-operational,
.status-operational {
  color: var(--color-success, #8dc143);
  font-weight: 700;
}

.footer-status-pill[data-level="operational"]:hover,
.footer-status-pill[data-level="ok"]:hover,
.footer-status-pill.status-operational:hover,
.status-operational:hover {
  color: var(--color-brand, #8dc143);
}

.footer-status-pill[data-level="warn"],
.footer-status-pill[data-level="degraded"] {
  color: var(--color-warning, #f59e0b);
}

.footer-status-pill[data-level="down"],
.footer-status-pill[data-level="outage"] {
  color: var(--color-danger, #ef4444);
}

.back-to-top {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: color 0.2s;
}

.back-to-top:hover {
  color: var(--color-text-primary);
}

.back-to-top:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 4px;
  border-radius: 999px;
}

/* =========================================================
   RESPONSIVE LAYOUT
   ========================================================= */

@media (max-width: 900px) {
  .footer-content {
    flex-direction: column;
  }

  .footer-column-group {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-meta {
    gap: 40px;
  }

  .footer-meta::before {
    display: none;
  }

  .footer-meta-blocks {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  .footer-markets summary {
    min-height: 74px;
    font-size: 0.82rem;
    letter-spacing: 0.13em;
  }

  .footer-markets-state {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .footer-markets-state-name {
    text-align: center;
  }

  .footer-markets-state-links {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .footer-column-group {
    grid-template-columns: 1fr;
  }

  .footer-meta-blocks {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 20px;
    align-items: flex-start;
  }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .footer-theme-toggle,
  .footer-theme-toggle:hover {
    transition: none;
    transform: none;
  }
}

/* =========================================================
   LIGHT THEME CONTRAST HARDENING
   Keeps footer secondary text WCAG AA on the light footer surface.
   ========================================================= */

:root[data-theme="light"] footer .footer-tagline,
:root[data-theme="light"] footer .footer-ai-strip__label,
:root[data-theme="light"] footer .footer-column a,
:root[data-theme="light"] footer .footer-meta-block a,
:root[data-theme="light"] footer .footer-markets-loading,
:root[data-theme="light"] footer .footer-markets-state-links a,
:root[data-theme="light"] footer .footer-disclaimer p,
:root[data-theme="light"] footer .footer-disclaimer a,
:root[data-theme="light"] footer .footer-bottom,
:root[data-theme="light"] footer .status-label,
:root[data-theme="light"] footer .back-to-top {
  color: #4b5563;
}

:root[data-theme="light"] footer .footer-disclaimer strong,
:root[data-theme="light"] footer .footer-disclaimer a:hover,
:root[data-theme="light"] footer .footer-column a:hover,
:root[data-theme="light"] footer .footer-meta-block a:hover,
:root[data-theme="light"] footer .footer-markets-state-links a:hover,
:root[data-theme="light"] footer .back-to-top:hover {
  color: #111827;
}

:root[data-theme="light"] footer .status-separator {
  background: #4b5563;
}

:root[data-theme="light"] footer .footer-status-pill[data-level="operational"],
:root[data-theme="light"] footer .footer-status-pill[data-level="ok"],
:root[data-theme="light"] footer .footer-status-pill.status-operational,
:root[data-theme="light"] footer .status-operational {
  color: #166534;
}

:root[data-theme="light"] footer .footer-status-dot[data-level="operational"],
:root[data-theme="light"] footer .footer-status-dot[data-level="ok"] {
  background: #166534;
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.18);
}
