/* MarketOS layout — shell, navigation, grid. Fanout Design System. */

/* ---- Shell header ------------------------------------------------- */

header.top,
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 var(--s-6);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: var(--bd);
}

.topbar__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  gap: var(--s-4);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  justify-self: start;
}

.brand-logo, .brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font: 650 15px/1 var(--sans);
  letter-spacing: -0.2px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-logo:hover, .brand:hover {
  text-decoration: none;
}
.brand-logo__mark {
  position: relative;
  width: 22px;
  height: 22px;
  display: inline-block;
  flex-shrink: 0;
}
.brand-logo__square-outline {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 14px;
  height: 14px;
  border-radius: 3.5px;
  border: 2px solid var(--ink);
  box-sizing: border-box;
}
.brand-logo__square-solid {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  border-radius: 3.5px;
  background: var(--signal);
  box-sizing: border-box;
}
.brand-logo__text {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.2px;
  color: var(--ink);
}
.brand-logo__sub {
  color: var(--muted);
  font-weight: 400;
}

.badge-tag {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-badge);
  background: var(--surface);
  border: var(--bd-strong);
  color: var(--muted);
  letter-spacing: 0.72px;
  text-transform: uppercase;
}

.tagline {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* Nav links - Center column */
nav.nav-links,
header.top nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  justify-self: center;
  margin: 0;
}

nav.nav-links a,
.nav-link,
header.top nav a {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  color: var(--ink-dim);
  font: 500 13px/1 var(--sans);
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

nav.nav-links a:hover,
.nav-link:hover,
header.top nav a:hover {
  background: var(--surface-3);
  color: var(--ink);
  text-decoration: none;
}

nav.nav-links a[aria-current="page"],
.nav-link.active,
header.top nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  border-color: var(--line-strong);
  box-shadow: var(--e-1);
}

/* Topbar right controls */
.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  justify-self: end;
}

/* Data Universe selector */
.universe {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 3px 9px;
  border: var(--bd);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 11.5px;
  min-width: 0;
}
.universe-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.universe-value {
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.universe-pick {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 2px 3px 2px 10px;
  border: var(--bd-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--e-1);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.universe-pick:hover {
  border-color: var(--border-strong);
}
.universe-pick:focus-within {
  border-color: var(--signal);
  box-shadow: var(--shadow-focus);
}
.universe-pick select {
  font: inherit;
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: var(--r-pill);
  outline: none;
  border-color: transparent;
  padding: 4px 2px;
  max-width: 32ch;
  cursor: pointer;
}
.universe-pick select option {
  background-color: var(--surface);
  color: var(--ink);
}
.universe-go {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-inv);
  background: var(--signal);
  border: 0;
  border-radius: var(--r-pill);
  padding: 5px 12px;
  cursor: pointer;
  box-shadow: var(--e-1);
  transition: background var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.universe-go:hover {
  background: var(--math-blue);
  opacity: 1;
}
.universe-go:active {
  transform: scale(0.94);
}

/* Sun/Moon Theme Toggle */
.theme-toggle,
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-pill);
  border: var(--bd-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  box-shadow: var(--e-1);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.theme-toggle:hover,
.theme-toggle-btn:hover {
  background: var(--surface-3);
  border-color: var(--signal);
  color: var(--signal);
}
.theme-toggle:active {
  transform: scale(0.92);
}

.theme-glyph {
  display: block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  transition: transform var(--dur) var(--ease);  /* Sun icon (shown in dark theme) */
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41'/%3E%3C/svg%3E");
}

/* Moon icon (shown in light theme) */
:root[data-theme="light"] .theme-glyph {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-glyph {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
  }
}

:root[data-theme="dark"] .theme-glyph {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41'/%3E%3C/svg%3E");
}

/* ---- Hero Section Layout --------------------------------------------- */
.hero-section {
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
  display: flex;
  align-items: center;
  padding: var(--s-6) 0;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.hero-section__inner {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--s-10);
  align-items: center;
  width: 100%;
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.hero-title {
  font: 700 48px/1.1 var(--sans);
  letter-spacing: -1.6px;
  color: var(--ink);
  margin: 0 0 var(--s-3) 0;
}

.hero-lead {
  font: 400 15.5px/1.55 var(--sans);
  color: var(--ink-dim);
  max-width: 560px;
  margin: 0 0 var(--s-5) 0;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3);
  width: 100%;
}

/* ---- Modules Grid Layout --------------------------------------------- */
.section-modules {
  padding: var(--s-10) 0 var(--s-16);
  border-top: var(--bd);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--s-6);
  gap: var(--s-4);
  flex-wrap: wrap;
}

.section-title {
  font: 700 28px/1.2 var(--sans);
  letter-spacing: -0.6px;
  color: var(--ink);
  margin: var(--s-1) 0 0 0;
}

.section-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-6);
}

/* ---- Page header band ------------------------------------------------ */

.page-header {
  border-bottom: var(--bd);
  background: var(--surface);
}

.page-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--s-6);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-6);
  flex-wrap: wrap;
}

.page-context {
  color: var(--ink-dim);
  font-size: 13px;
  white-space: nowrap;
}

/* ---- Main content ----------------------------------------------------- */

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--s-8) var(--s-6) var(--s-18);
  position: relative;
  z-index: 1;
}

main:focus {
  /* Programmatic skip-link target, not a keyboard-reachable control. */
  outline: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--s-6);
}

.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }

/* ---- Split layout ----------------------------------------------------- */
.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--s-6);
  margin-top: var(--s-6);
  align-items: start;
}
.split > section > h2:first-child { margin-top: 0; }

/* ---- Rich Modern Footer ----------------------------------------------- */

footer.foot,
.site-footer {
  border-top: var(--bd);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  z-index: 1;
  margin-top: var(--s-16);
  padding: var(--s-12) var(--s-6) var(--s-10);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: var(--s-8);
  padding-bottom: var(--s-10);
  border-bottom: var(--bd);
}

.footer-brand-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3);
}

.footer-tagline {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  max-width: 280px;
}

.footer-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 10px;
  background: var(--surface-2);
  border: var(--bd);
  border-radius: var(--r-pill);
  margin-top: var(--s-1);
}

.footer-heading {
  font: 650 11px/1.2 var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 var(--s-3) 0;
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  transition: color var(--dur-fast) var(--ease);
}
.footer-links a:hover {
  color: var(--signal);
  text-decoration: none;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-4);
  padding-top: var(--s-6);
  font-size: 12px;
}

.footer-disclaimer {
  max-width: 680px;
  color: var(--muted);
}

.footer-copy {
  font-size: 11px;
  color: var(--faint);
}

/* ---- Responsive Breakpoints (1099px & 719px) --------------------------- */

@media (max-width: 1099px) {
  .topbar__inner {
    grid-template-columns: auto 1fr auto;
    gap: var(--s-3);
  }
  
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  
  .hero-section {
    min-height: auto;
    padding: var(--s-8) 0 var(--s-10);
  }

  .hero-section__inner {
    grid-template-columns: 1fr;
    gap: var(--s-8);
  }

  .hero-title {
    font-size: 40px;
    letter-spacing: -1.3px;
  }
  
  .modules-grid {
    grid-template-columns: 1fr;
  }
  
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-8);
  }

  .verdict-readings { gap: var(--s-5); }
  .verdict-readings > * + * { padding-left: var(--s-5); }
}

@media (max-width: 719px) {
  header.top,
  .topbar {
    height: auto;
    min-height: var(--header-h);
    padding: var(--s-2) var(--s-4);
  }

  .topbar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
  }

  .topbar__left {
    order: 1;
  }

  .topbar__right {
    order: 2;
    margin-left: auto;
  }

  nav.nav-links,
  header.top nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0 4px;
    gap: var(--s-1);
    justify-content: flex-start;
  }

  nav.nav-links a,
  .nav-link,
  header.top nav a {
    flex-shrink: 0;
    font-size: 12px;
    height: 30px;
    padding: 0 10px;
  }

  header.top .tagline,
  .topbar .badge-tag { display: none; }
  
  header.top .universe-label,
  .topbar .universe-label { display: none; }
  header.top .universe,
  .topbar .universe { max-width: 48vw; }

  .hero-section {
    min-height: auto;
    padding: var(--s-5) 0 var(--s-8);
  }

  .hero-title {
    font-size: 32px;
    letter-spacing: -1px;
    line-height: 1.15;
  }

  .hero-lead {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: var(--s-4);
  }

  .statbar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-2);
  }

  main {
    padding: var(--s-4) var(--s-3) var(--s-12);
  }

  .grid { grid-template-columns: 1fr; }
  .modules-grid { grid-template-columns: 1fr; }

  .page-header-inner {
    align-items: flex-start;
    padding: var(--s-4);
  }

  .chain, .kv { grid-template-columns: 1fr; }
  .chain dt { border-bottom: 0; padding-bottom: 2px; }

  .filter-field, form.filters select { width: 100%; }
  .filter-field { flex: 1 1 100%; }
  form.filters { flex-direction: column; align-items: stretch; }

  .verdict { padding: var(--s-4); }
  .verdict-readings { flex-direction: column; gap: var(--s-4); }
  .verdict-readings > * + * { border-left: 0; padding-left: 0; }

  .coverage-row { flex-wrap: wrap; }
  .coverage-label { min-width: 100%; }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--s-6);
  }
  
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }

  details.evidence > summary { padding: var(--s-2) var(--s-3); }
}
