/* styles.css — SponsorScope's one stylesheet. Dark is the primary theme now
   (see "SponsorScope 2.0.2" in README's Implementation notes); light stays
   fully available, chosen automatically for a signed-in visitor whose system
   prefers it, or by anyone through the nav's theme toggle (ui.js), which
   persists the choice in a cookie read server-side (layout.js). Plus Jakarta
   Sans (headlines, numbers, UI labels) + Hanken Grotesk (body), both
   self-hosted from /fonts — no external font host. */

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/plus-jakarta-sans-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/plus-jakarta-sans-800.woff2') format('woff2');
}
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/hanken-grotesk-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/hanken-grotesk-600.woff2') format('woff2');
}

/* Light tokens as the CSS base; dark is layered on top via [data-theme="dark"]
   (an explicit, server-rendered choice: the visitor's cookie, or "signed out
   with no cookie yet" defaulting to dark) and via prefers-color-scheme for a
   signed-in visitor with no cookie who hasn't chosen either way. */
:root {
  --surface: #F7F8FA;
  --surface-2: #EEF0F4;
  --card: #FFFFFF;
  --card-alt: #F2F4F8;
  --ink: #151A24;
  --muted: #5B6474;
  --line: #DDE1E8;
  --accent: #2F5BFF;
  --accent-hover: #1E46E0;
  /* Small blue TEXT needs its own value: #2F5BFF is only 3.7:1 on the dark page (AA needs 4.5:1).
     Buttons and fills keep --accent; links, labels and price figures use --accent-text. */
  --accent-text: #2349E0;
  --grad-a: #2349E0;
  --grad-b: #2F5BFF;
  --accent-soft: #E6ECFF;
  --on-accent: #FFFFFF;
  --warn: #A24A08;
  --warn-soft: #FBEEE0;
  --danger: #B42318;
  --danger-soft: #FBEAE8;
  --shadow: 0 10px 30px rgba(21, 26, 36, 0.08);
  --display: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
  --body: 'Hanken Grotesk', ui-sans-serif, system-ui, sans-serif;
  --radius-card: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --surface: #0B0F1A;
    --surface-2: #111726;
    --card: #141B2E;
    --card-alt: #171F35;
    --ink: #F3F5FA;
    --muted: #8B96AC;
    --line: #232B42;
    --accent: #2F5BFF;
    --accent-hover: #1E46E0;
    --accent-text: #7C9BFF;
    --grad-a: #7C9BFF;
    --grad-b: #B5C7FF;
    --accent-soft: #1B2547;
    --on-accent: #FFFFFF;
    --warn: #F59E0B;
    --warn-soft: #2A2013;
    --danger: #F97066;
    --danger-soft: #2A1614;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
/* Dark values, applied by an explicit data-theme="dark" (the visitor's cookie, or
   the "signed out, no cookie yet" default computed server-side in layout.js). */
:root[data-theme="dark"] {
  --surface: #0B0F1A;
  --surface-2: #111726;
  --card: #141B2E;
  --card-alt: #171F35;
  --ink: #F3F5FA;
  --muted: #8B96AC;
  --line: #232B42;
  --accent: #2F5BFF;
  --accent-hover: #1E46E0;
  --accent-text: #7C9BFF;
  --grad-a: #7C9BFF;
  --grad-b: #B5C7FF;
  --accent-soft: #1B2547;
  --on-accent: #FFFFFF;
  --warn: #F59E0B;
  --warn-soft: #2A2013;
  --danger: #F97066;
  --danger-soft: #2A1614;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); }
a:hover { text-decoration: underline; }
h1, h2, h3, .display { font-family: var(--display); font-weight: 800; letter-spacing: -0.3px; }
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 14px; }
h2 { font-size: 20px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 18px 0 6px; }
p { margin: 0 0 10px; }
code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--warn); }
.tnum { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.label { font-family: var(--display); font-weight: 600; font-size: 13px; color: var(--muted); }
.eyebrow { font-family: var(--display); font-weight: 700; font-size: 13px; color: var(--accent-text); margin: 0 0 8px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.main { flex: 1; padding-top: 32px; padding-bottom: 64px; }
.narrow { max-width: 440px; margin: 0 auto; }
/* A lone auth form or message card (signup, login, 404…) is a single focused task —
   center it rather than leaving a page's worth of empty space beneath it. Progressive
   enhancement: browsers without :has() just keep the top-aligned layout. */
.main:has(> .narrow:only-child) { display: flex; align-items: center; min-height: calc(100vh - 210px); }
.main:has(> .narrow:only-child) > .narrow { width: 100%; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--card); color: var(--ink); border: 1px solid var(--accent); border-radius: 999px; padding: 8px 16px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* Header and footer */
.site-header { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 68px; position: relative; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 7px; display: block; }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a:not(.btn) { color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; }
.nav-links a:not(.btn):hover { color: var(--accent-text); }
.nav-actions { display: flex; align-items: center; gap: 12px; }
.inline-form { display: inline; margin: 0; }
.theme-toggle {
  appearance: none; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; padding: 0;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun { display: none; }
  :root:not([data-theme]) .icon-moon { display: block; }
}
.menu-toggle { display: none; appearance: none; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px; font: inherit; font-weight: 600; font-size: 14px; color: var(--ink); cursor: pointer; }
.site-footer { border-top: 1px solid var(--line); padding: 48px 0 28px; margin-top: 64px; background: var(--card); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-brand .brand { margin-bottom: 8px; }
.footer-tagline { color: var(--muted); font-size: 14px; max-width: 260px; }
.footer-col h3 { font-family: var(--display); font-weight: 700; font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.footer-col a { color: var(--ink); font-size: 14px; text-decoration: none; }
.footer-col a:hover { color: var(--accent-text); }
.footer-bottom { border-top: 1px solid var(--line); margin-top: 40px; padding-top: 20px; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .menu-toggle { display: inline-flex; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--card); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; gap: 0; padding: 4px 0; box-shadow: var(--shadow); z-index: 10; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 20px; }
  .nav-links a.btn { margin: 10px 20px; justify-content: center; }
}

/* Cards, notices */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 24px; margin-bottom: 16px; }
.card.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.card.result { padding: 0; overflow: hidden; }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 11px 16px; font-size: 14px; }
.error { color: var(--danger); background: var(--danger-soft); border-radius: 12px; padding: 11px 16px; font-size: 14px; }
.field-error { color: var(--danger); font-size: 13px; margin-top: -2px; }
.devnote { font-size: 13px; color: var(--warn); border: 1px dashed var(--warn); border-radius: 12px; padding: 9px 12px; }
.banner { background: var(--warn-soft); border-bottom: 1px solid var(--line); padding: 10px 0; font-size: 14px; }
.status-pill { display: inline-flex; align-items: center; font-family: var(--display); font-weight: 600; font-size: 12px; padding: 3px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.status-pill.ok { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }
.status-pill.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }

/* Forms and buttons */
.form { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.form.inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
.form label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; }
.form label.check input { margin-top: 4px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 160px; }
.subform { border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px; margin-top: 12px; }
.subform[open] { padding-bottom: 18px; }
.subform summary { cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 14px; padding: 4px 0; }
.subform summary::marker { color: var(--muted); }
.subform .form { margin-top: 10px; margin-bottom: 0; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"], input[type="number"], select {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  min-width: 0;
}
input[aria-invalid="true"] { border-color: var(--danger); }
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  padding: 11px 22px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn.small { padding: 8px 16px; font-size: 13px; }
.btn.block { display: flex; width: 100%; justify-content: center; }
.btn svg { width: 18px; height: 18px; flex: none; }
/* The Chrome extension button (home page, dashboard): disabled with a "Coming soon" tag until CHROME_STORE_URL is set. */
.chrome-btn, .soon-tag { white-space: nowrap; }
.chrome-btn.is-soon { cursor: not-allowed; border-style: dashed; }
.chrome-btn.is-soon:hover { background: transparent; }
.soon-tag { margin-left: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent-text); border: 1px solid color-mix(in srgb, var(--accent-text) 35%, transparent); }
.btn.large { padding: 14px 30px; font-size: 15px; }
.btn.ghost { background: transparent; color: var(--accent-text); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--accent-text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btnrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.linkbtn { appearance: none; background: none; border: none; color: var(--accent-text); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.btn:focus-visible, .linkbtn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .menu-toggle:focus-visible, .theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table tbody tr:nth-child(even) { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; }

/* FAQ accordion */
.faq { max-width: 760px; margin: 0 auto; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 4px; font-family: var(--display); font-weight: 700; font-size: 16px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-chevron { flex: none; transition: transform 200ms ease; color: var(--muted); font-family: var(--display); }
.faq-item[open] .faq-chevron { transform: rotate(180deg); }
.faq-item p { padding: 0 4px 20px; color: var(--muted); max-width: 640px; }
@media (prefers-reduced-motion: reduce) { .faq-chevron { transition: none; } }

.lead { font-size: 18px; color: var(--muted); max-width: 480px; }
.hero-example-label { font-size: 12px; color: var(--muted); margin-top: 10px; }

.plan { max-width: 440px; margin: 0 auto; }
.plan.featured { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.plan .notice { background: var(--card); border: 1px solid var(--line); }
.price { font-family: var(--display); font-size: 48px; font-weight: 800; letter-spacing: -1px; }
.price .price-suffix { font-family: var(--body); font-size: 16px; font-weight: 400; color: var(--muted); }
.plan-tagline { font-family: var(--display); font-weight: 700; font-size: 16px; margin: 2px 0 0; }
.checklist { list-style: none; margin: 18px 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.checklist li { display: flex; align-items: flex-start; gap: 10px; }
.checklist li > span { display: block; }
.checklist strong { display: block; font-family: var(--display); font-weight: 700; }
.checklist .plan-desc { display: block; color: var(--muted); font-size: 14px; line-height: 1.5; }
.checklist li::before { content: '✓'; flex: none; width: 20px; height: 20px; border-radius: 999px; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-top: 1px; }

/* Result card (deal sheet — landing example and the dashboard) */
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.result-chan { display: flex; align-items: center; gap: 10px; min-width: 0; }
.result-avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.result-chan-name { font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; }
.result-body { padding: 22px; }
.bignum-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.bignum { font-family: var(--display); font-size: 46px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; margin: 4px 0 18px; }
.price-block { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.price-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.price-range { font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--accent-text); }
.rangebar { position: relative; height: 8px; margin-top: 8px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.rangebar-fill { position: absolute; top: 0; height: 100%; background: var(--accent); border-radius: 999px; }
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.stat-strip .stat-val { font-family: var(--display); font-weight: 700; font-size: 17px; }
.stat-strip .stat-label { font-size: 12px; color: var(--muted); }
.src { display: inline-block; font-size: 11px; padding: 1px 9px; border-radius: 999px; white-space: nowrap; }
.src-yt { color: var(--muted); border: 1px solid var(--line); }
.src-est { color: var(--accent-text); background: var(--accent-soft); }

/* Contact-info and audience mockups used in the feature rows */
.mock-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; width: 100%; max-width: 320px; }
.mock-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.mock-row:last-child { border-bottom: none; }
.mock-row .k { color: var(--muted); }
.mock-row .v { font-weight: 600; }
.region-bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 8px 0; }
.region-bar-row .region { width: 34px; flex: none; color: var(--muted); }
.region-bar-track { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.region-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.region-bar-pct { width: 36px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }

/* Dashboard */
.lookup { display: flex; gap: 10px; flex-wrap: wrap; }
.lookup input { flex: 1; min-width: 240px; }
.usage-line { margin: 10px 0 18px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .dash-grid { grid-template-columns: 1fr; } }
.panel-slot { min-height: 160px; min-width: 0; }
.empty-card { text-align: left; padding: 32px 22px; }
.empty-card .display { font-size: 17px; margin-bottom: 6px; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }

.dash-side { min-width: 0; }

/* Settings page (worker/src/pages/settings.js) */
.table-scroll { overflow-x: auto; }
.settings-table input[type="number"] { width: 92px; }
.settings-table input.note { width: 100%; min-width: 220px; }
.settings-table td { vertical-align: middle; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 10px; }
.settings-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.settings-grid input, .settings-grid select { width: 100%; }
.settings-reset { margin-top: 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.error-list { margin: 6px 0 0; padding-left: 20px; }

/* Legal pages */
.legal { max-width: 760px; }
.legal h2 { margin-top: 26px; font-size: 16px; }
.placeholder { background: var(--warn-soft); border-radius: 4px; padding: 0 4px; font-weight: 600; }

/* Admin */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat-box .n { font-family: var(--display); font-size: 24px; font-weight: 800; }

/* Toast (js/ui.js) */
#toast-region { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink);
  color: var(--surface);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast.error-toast { background: var(--danger); color: var(--on-accent); }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 1ms linear; transform: none; }
}
