/* ============================================================
   SUBMARINE CATALYST — SHARED THEME LAYER
   Loaded on every page *after* the page's inline <style>, so it
   refines tokens and shared components without touching page logic.
   Fonts: Geist + Geist Mono (Google Fonts, linked per page).
   ============================================================ */

:root {
  /* Surfaces */
  --navy:    #050a14;
  --deep:    #08101d;
  --surface: #0c1625;
  --panel:   #111d30;
  --border:  #1c2b40;
  --hairline: rgba(148, 163, 184, 0.12);

  /* Accents */
  --accent:  #22d3ee;
  --accent2: #34e0a1;
  --amber:   #f6b440;
  --red:     #fb6b6b;

  /* Text */
  --text:    #c3cedc;
  --muted:   #7a8ca3;
  --white:   #f3f6fa;

  /* Type — --serif is kept as the display-face token name used across pages */
  --sans:  'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono:  'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Shape + depth */
  --radius:    14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --ring: 0 0 0 3px rgba(34, 211, 238, 0.22);
  --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, 0.65);
  --nav-h: 60px;

  color-scheme: dark;
}

/* ------------------------------------------------------------
   Base
   ------------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 12px); }
body {
  background-color: var(--navy);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'cv11';
}
h1, h2, h3 { text-wrap: balance; }
h1 { font-weight: 600; }
p { text-wrap: pretty; }
strong, b { font-weight: 600; }
::selection { background: rgba(34, 211, 238, 0.28); color: #fff; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
a, button { -webkit-tap-highlight-color: transparent; }

/* Ambient background: soft top glow + faint grid that fades out */
body::before {
  background-image:
    radial-gradient(1100px 520px at 50% -140px, rgba(34, 211, 238, 0.11), transparent 70%),
    radial-gradient(700px 380px at 92% 4%, rgba(52, 224, 161, 0.05), transparent 70%),
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: auto, auto, 56px 56px, 56px 56px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, rgba(0, 0, 0, 0.55) 55vh, rgba(0, 0, 0, 0.18) 100vh);
          mask-image: linear-gradient(to bottom, #000 0, rgba(0, 0, 0, 0.55) 55vh, rgba(0, 0, 0, 0.18) 100vh);
}
/* Film-grain overlay removed — it muddied text and cost paint time */
body::after { display: none; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #24364f transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #24364f; border-radius: 10px; border: 2px solid var(--navy); }
::-webkit-scrollbar-thumb:hover { background: #2f4565; }

/* Numbers line up in every table, stat and score */
td, .stat-val, .score-box-val, .sim-val, .price-amount, .page-stat-val, .stat-value,
.score-bar-val, .score-total-val, .coverage-num, .bo-mv, .account-field-val {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------
   Navigation
   ------------------------------------------------------------ */
body > nav {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--nav-h);
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  gap: 1rem;
  background: rgba(5, 10, 20, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
          backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--hairline);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
body > nav.sc-scrolled {
  background: rgba(5, 10, 20, 0.86);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.8);
}

.nav-logo { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; flex-shrink: 0; }
.nav-logo .sonar-icon { width: 28px; height: 28px; flex-shrink: 0; display: block; }
.sonar-icon svg { width: 100%; height: 100%; display: block; }
.nav-wordmark {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--white);
  white-space: nowrap;
}
.nav-wordmark span { color: var(--accent); margin-left: 0.32em; }

nav .nav-links, nav .nav-center { gap: 0.15rem; list-style: none; }
nav .nav-links a, nav .nav-center a, nav .nav-right .nav-link {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-transform: none;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}
nav .nav-links a:hover, nav .nav-center a:hover, nav .nav-right .nav-link:hover {
  color: var(--white);
  background: rgba(148, 163, 184, 0.08);
}
nav .nav-links a.active, nav .nav-center a.active, nav .nav-right .nav-link.active,
nav .nav-links a[aria-current="page"], nav .nav-center a[aria-current="page"], nav .nav-right .nav-link[aria-current="page"] {
  color: var(--white);
  background: rgba(148, 163, 184, 0.1);
}

nav .nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  letter-spacing: 0;
  color: var(--muted);
}
nav .nav-right > a:not(.nav-cta):not(.nav-signout):not(.nav-link) { color: var(--accent); font-weight: 500; }
nav .nav-actions { display: flex; align-items: center; gap: 0.35rem; }

nav .nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-transform: none;
  color: #03141b;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0.5rem 0.95rem;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 22px -10px rgba(34, 211, 238, 0.7);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
nav .nav-cta:hover { background: #67e8f9; color: #03141b; transform: translateY(-1px); }

nav .nav-login {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
}
nav .nav-login:hover { color: var(--white); background: rgba(148, 163, 184, 0.08); }

nav .nav-signout {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  white-space: nowrap;
}
nav .nav-signout:hover { color: var(--red); border-color: rgba(251, 107, 107, 0.4); background: rgba(251, 107, 107, 0.06); }
nav .nav-user {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile menu (button + panel injected by /js/sc-ui.js) */
.sc-menu-btn {
  display: none;
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.06);
  cursor: pointer;
}
.sc-menu-btn span {
  position: absolute;
  left: 11px;
  right: 11px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--white);
  transition: transform 0.2s ease, top 0.2s ease;
}
.sc-menu-btn span:nth-child(1) { top: 15px; }
.sc-menu-btn span:nth-child(2) { top: 23px; }
nav.sc-open .sc-menu-btn span:nth-child(1) { top: 19px; transform: rotate(45deg); }
nav.sc-open .sc-menu-btn span:nth-child(2) { top: 19px; transform: rotate(-45deg); }

.sc-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: grid;
  gap: 0.15rem;
  padding: 0.6rem 0.75rem 0.9rem;
  background: #070d18;
  border-bottom: 1px solid var(--hairline);
  box-shadow: 0 24px 40px -20px rgba(0, 0, 0, 0.85);
  animation: scMenuIn 0.18s ease both;
}
.sc-menu[hidden] { display: none; }
.sc-menu a {
  display: block;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
}
.sc-menu a:hover, .sc-menu a[aria-current="page"] { color: var(--white); background: rgba(148, 163, 184, 0.08); }
.sc-menu-user {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 0.85rem 0.6rem;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-menu-user[hidden] { display: none; }
@keyframes scMenuIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  body > nav { justify-content: flex-start; padding-left: 1rem; padding-right: 1rem; gap: 0.5rem; }
  body > nav > .nav-logo { margin-right: auto; }
  nav .nav-links, nav .nav-center, nav .nav-right .nav-link, nav .nav-user { display: none !important; }
  nav.sc-has-menu .sc-menu-btn { display: inline-block; }
}
@media (max-width: 560px) {
  .nav-wordmark { font-size: 0.72rem; letter-spacing: 0.1em; }
  .nav-logo .sonar-icon { width: 24px; height: 24px; }
  nav.sc-has-menu .nav-login { display: none; }
  nav .nav-right { font-size: 0.8rem; }
  /* Auth pages: "No account? Create one →" collapses to just the link */
  nav span.nav-right { font-size: 0; }
  nav span.nav-right > a { font-size: 0.85rem; }
}
@media (max-width: 380px) {
  .nav-wordmark span { display: none; }
}

/* ------------------------------------------------------------
   Footer
   ------------------------------------------------------------ */
body > footer {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0;
  color: var(--muted);
  background: rgba(8, 16, 29, 0.6);
  border-top: 1px solid var(--hairline);
  gap: 1rem 2rem;
}
body > footer a { color: var(--muted); transition: color 0.15s ease; }
body > footer a:hover { color: var(--white); }
body > footer .footer-disclaimer { font-size: 0.72rem; line-height: 1.65; color: #64768d; }
@media (max-width: 720px) {
  body > footer { flex-direction: column; text-align: center; padding: 1.5rem 1.25rem; }
  body > footer > div { flex-wrap: wrap; justify-content: center; gap: 0.75rem 1.25rem !important; }
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn-primary, .pricing-cta, .btn-submit, .gate-btn, .gate-cta, .btn-send, .btn-search, .upgrade-bar-cta {
  clip-path: none;
  border-radius: 11px;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: #03141b;
  background: linear-gradient(180deg, #5fe6f7 0%, var(--accent) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 12px 30px -12px rgba(34, 211, 238, 0.7);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}
.btn-primary:hover, .pricing-cta:hover, .btn-submit:not(:disabled):hover, .gate-btn:hover,
.gate-cta:hover, .btn-send:hover, .btn-search:hover, .upgrade-bar-cta:hover {
  opacity: 1;
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 16px 36px -12px rgba(34, 211, 238, 0.8);
}
.btn-primary:active, .pricing-cta:active, .btn-submit:active { transform: translateY(0); }
.btn-submit:disabled, .pricing-cta:disabled { filter: saturate(0.4); box-shadow: none; }

.btn-secondary {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.btn-portal, .btn-resend, .btn-inline {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 9px;
}
.btn-portal { color: var(--text); border-color: var(--hairline); background: rgba(148, 163, 184, 0.04); }

.show-pw-btn, .pw-show-btn {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 6px;
}

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
select, textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]) { border-radius: 9px; }
.form-input, .pw-input {
  font-family: var(--sans);
  font-size: 0.95rem;
  background: rgba(17, 29, 48, 0.75);
  border-color: var(--hairline);
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.form-input:hover, .pw-input:hover { border-color: rgba(148, 163, 184, 0.22); }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  outline: none;
}
.form-label, .account-field-label { letter-spacing: 0.12em; }
.filter-select, .search-input { font-size: 0.75rem; padding: 0.5rem 0.8rem; border-color: var(--hairline); }
select { cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); }

/* ------------------------------------------------------------
   Cards, panels, callouts
   ------------------------------------------------------------ */
.hero-terminal, .bucket, .score-panel, .pricing-card, .auth-card, .form-card, .callout,
.account-panel, .method-panel, .compare-wrap, .stat-strip, .origin-stats, .sim-stats,
.coverage-grid, .insight-callout, .example-box, .channel-card, .gate-card, .chat-container,
.content-card, .panel, .card, .detail-section, .chat-area, .irr-chart-wrap, .methodology,
.methodology-note, .pattern-card, .result-card, .search-section, .sources-section, .takeaway-section,
.term-block, .toc, .size-guide, .gen-panel, .modal, .runway-anomaly-panel, .info-block,
.disclaimer-box, .disclaimer-banner, .provenance-strip, .drug-item, .code-display, .stats-bar,
.stats-strip, .card-grid, .irr-secondary-stats, .bt-table-wrap, .irr-trade-wrap {
  border-radius: var(--radius);
}
.content-grid .sidebar-section { border-radius: var(--radius); overflow: hidden; }
.chat-area { overflow: hidden; }
.stat-strip, .origin-stats, .sim-stats, .coverage-grid, .stats-bar, .stats-strip, .card-grid, .irr-secondary-stats { overflow: hidden; }
.auth-card, .pricing-card, .account-panel, .form-card { box-shadow: var(--shadow-lg); }
.auth-card { background: linear-gradient(180deg, rgba(17, 29, 48, 0.9), rgba(12, 22, 37, 0.9)); border-color: var(--hairline); }

.disclaimer, .disclaimer-bar, .risk-reversal, .error-box, .info-box, .success-box,
.msg-box, .pw-msg, .verifying-banner, .welcome-banner, .not-found, .msg-warn,
.msg-ai, .msg-user, .msg-error, .msg-info, .msg-success, .msg-amber, .pw-msg-error, .pw-msg-success,
.toast, .price-tag, .upgrade-bar {
  border-radius: var(--radius-sm);
}
.suggestion, .ticker-chip, .sizing-btn, .detail-link, .crl-flag, .pipe-flag, .live-badge { border-radius: 8px; }

/* Scanner results become distinct cards instead of a hairline grid */
.scanner-grid { gap: 14px; background: transparent; border: 0; }
.scanner-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.scanner-card:hover {
  background: var(--surface);
  border-color: rgba(34, 211, 238, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -24px rgba(34, 211, 238, 0.45);
}
.card-scores { border-radius: var(--radius-sm); overflow: hidden; }

/* Pills and badges */
.card-grade, .days-pill, .event-badge, .pattern-pill, .bo-risk, .bo-new, .diff-badge,
.pricing-badge, .grade-badge, .risk-badge, .tag, .quick-chip, .admin-badge {
  border-radius: 999px;
}

/* Tabs */
.tab-btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-transform: none;
}

/* Tables */
.data-table th, .cal-table th { font-weight: 600; }
.data-table { border-radius: var(--radius-sm); }
@media (max-width: 768px) {
  .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ------------------------------------------------------------
   App shell: sidebar becomes a scrollable tab strip on small screens
   ------------------------------------------------------------ */
.dash-layout > .sidebar { top: var(--nav-h); height: calc(100vh - var(--nav-h)); }
.sidebar-item {
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: 9px;
  margin: 0.05rem 0.6rem;
  width: calc(100% - 1.2rem);
  padding: 0.55rem 0.75rem;
}
.sidebar-item.active { color: var(--white); background: rgba(34, 211, 238, 0.1); border-left: 0; box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-label { padding-left: 1.35rem; }

@media (max-width: 1024px) {
  .dash-layout > .sidebar {
    display: flex;
    position: sticky;
    top: var(--nav-h);
    z-index: 60;
    height: auto;
    gap: 0.35rem;
    padding: 0.6rem 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
    background: rgba(8, 16, 29, 0.92);
    -webkit-backdrop-filter: blur(14px);
            backdrop-filter: blur(14px);
    scrollbar-width: none;
  }
  .dash-layout > .sidebar::-webkit-scrollbar { display: none; }
  .dash-layout > .sidebar .sidebar-section { display: flex; gap: 0.35rem; margin: 0; flex-shrink: 0; }
  .dash-layout > .sidebar .sidebar-label { display: none; }
  .dash-layout > .sidebar .sidebar-item {
    width: auto;
    margin: 0;
    white-space: nowrap;
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    font-size: 0.8rem;
  }
  .dash-layout > .sidebar .sidebar-item.active { box-shadow: none; border-color: rgba(34, 211, 238, 0.45); }
}

/* ------------------------------------------------------------
   Headline accents
   ------------------------------------------------------------ */
.hero-headline, .section-heading, .page-title, .auth-heading, .section-title,
.bucket-title, .gate-msg, .gate-title, .sim-head .section-heading, .final-cta h2 {
  font-weight: 600;
  letter-spacing: -0.035em;
}
.hero-headline em, .auth-heading em {
  font-style: normal;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}

/* ------------------------------------------------------------
   Motion preferences
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
}
