/* Polyers design system. Dark "trading terminal" by default, light theme via prefers-color-scheme.
   One accent (amber). Positive/negative are never conveyed by colour alone: values carry +/- signs and ▲/▼ icons.
   test/contrast.test.js checks these tokens against WCAG AA (4.5:1 for text). */
:root {
  color-scheme: dark light;
  --bg: #090b0e;
  --surface: #10141a;
  --surface-2: #161b22;
  --line: #2a323d;
  --field: #738093;       /* borders of inputs/selects: 3:1+ against surfaces (WCAG 1.4.11) */
  --text: #e8ecf1;
  --muted: #9aa4b2;
  --accent: #f5b544;      /* fills: primary button, glyph */
  --accent-ink: #1b1305;  /* text on accent fills */
  --accent-fg: #f5b544;   /* accent used as text/links/icons on bg */
  --pos: #4fd6a0;
  --neg: #ff8080;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 12px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --line: #cfd6df;
    --field: #6b7788;
    --text: #11151a;
    --muted: #4a5565;
    --accent: #f5b544;
    --accent-ink: #1b1305;
    --accent-fg: #8a4b00;
    --pos: #0b7a4f;
    --neg: #b3261e;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
a { color: var(--accent-fg); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent-fg); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; font-weight: 700; z-index: 10; }
.skip:focus { top: 8px; }
.num, .stat-v, td, .mono { font-variant-numeric: tabular-nums; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.wordmark { height: 30px; width: auto; display: block; }
.wordmark .wm-glyph { stroke: var(--accent-fg); fill: none; }
.wordmark .wm-dot { fill: var(--accent-fg); stroke: none; }
.wordmark text { fill: var(--text); font: 700 24px/1 var(--font); letter-spacing: -0.02em; }
.nav { display: flex; gap: 18px; font-size: 14px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); text-decoration: underline; }

/* ---------- hero ---------- */
.hero { padding-top: 40px; padding-bottom: 8px; }
.eyebrow { color: var(--muted); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; margin: 0 0 12px; }
.hero h1 { font-size: clamp(28px, 5.2vw, 48px); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 14px; max-width: 24ch; text-wrap: balance; }
.hero h1 .hl { color: var(--accent-fg); }
.lede { font-size: 18px; color: var(--muted); max-width: 60ch; margin: 0 0 24px; }
.analyze { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: stretch; }
.analyze input, .analyze select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--field); border-radius: var(--radius); padding: 14px 14px; min-width: 0; }
.analyze input { font-family: var(--mono); font-size: 15px; }
.analyze input::placeholder { color: var(--muted); opacity: 1; }
.analyze input[aria-invalid="true"] { border-color: var(--neg); }
.field-error { color: var(--neg); font-size: 14px; margin: 8px 0 0; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0 0; color: var(--muted); font-size: 14px; }

.btn { font: inherit; font-weight: 650; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.2; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 750; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-lg { padding: 14px 26px; font-size: 17px; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- sample preview in the hero ---------- */
.sample { margin-top: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
  /* reserve the space the rendered sample will take (414px of fixed content + a chart that scales with width), so the page does not jump when it fills in */
  min-height: calc(414px + (min(100vw - 32px, 1008px) - 42px) / 3); }
.sample .tag { display: inline-block; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; margin-bottom: 10px; }
.sample .v-text { margin: 0 0 12px; font-size: 16px; }

/* ---------- state boxes (loading, error, empty) ---------- */
.notice { margin: 20px auto 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.notice.error { border-color: var(--neg); }
.notice .title { font-weight: 700; margin: 0 0 4px; }
.notice p { margin: 0; color: var(--muted); }
.notice .btn { margin-top: 12px; }
.loading { display: flex; align-items: center; gap: 14px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent-fg); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } html { scroll-behavior: auto; } }
.skeleton { display: grid; gap: 12px; margin-top: 18px; }
.skeleton i { display: block; height: 70px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton i { animation: none; } }

/* ---------- results ---------- */
#results { padding-top: 12px; padding-bottom: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-top: 18px; }
.panel h2, .section-title { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 650; }
h2.section { font-size: 20px; letter-spacing: -0.01em; margin: 34px 0 10px; }
.note { color: var(--muted); font-size: 14px; }
.tracked { border-left: 4px solid var(--accent); }
.tracked .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tracked .meta { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* stat row: items grow to fill each line, so there are never empty grid slots */
.stats { display: flex; flex-wrap: wrap; gap: 1px; margin: 16px 0 0; padding: 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stats > div { flex: 1 1 150px; background: var(--surface); padding: 12px 14px; min-width: 0; }
.stats dt { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.stats dd { margin: 2px 0 0; }
.stat-v { font: 700 24px/1.2 var(--mono); letter-spacing: -0.02em; }
.stat-s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.sign { font-size: 0.7em; margin-right: 3px; vertical-align: 0.1em; }

.verdict-text { font-size: 18px; margin: 0; max-width: 75ch; }
.verdict-text + .verdict-text { margin-top: 8px; }
.verdict-more { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.verdict-more li { margin: 3px 0; }

.nudge { border-left: 4px solid var(--accent); }
.nudge p { margin: 0; }

.tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 12px 0 0; }
.check { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 150px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: 0.03em; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr.low td { color: var(--muted); }
td .sub { color: var(--muted); font-size: 12px; margin-left: 4px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.b-pos { color: var(--pos); border-color: var(--pos); }
.badge.b-neg { color: var(--neg); border-color: var(--neg); }
.tnote { margin: 6px 2px 0; }
.need { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; cursor: help; }
.badge.b-unclear { color: var(--muted); }
td.c-evidence { white-space: normal; min-width: 170px; }

/* stacked rows on narrow screens: no clipped columns, every value labelled */
@media (max-width: 720px) {
  .table-wrap { overflow: visible; background: transparent; border: 0; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
  td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 8px; text-align: right; white-space: normal; }
  td { white-space: nowrap; align-items: center; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; text-align: left; white-space: nowrap; }
  td:first-child { grid-column: 1 / -1; font-weight: 700; font-size: 16px; text-align: left; min-width: 0; white-space: normal; }
  td:first-child::before { content: none; }
  td.c-evidence, td.c-range { grid-column: 1 / -1; }
}

/* ---------- accordion ---------- */
details.acc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 28px; }
details.acc summary { cursor: pointer; padding: 14px 18px; font-weight: 650; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: "+"; font: 700 20px/1 var(--mono); color: var(--accent-fg); }
details.acc[open] summary::after { content: "\2212"; }
details.acc .acc-body { padding: 0 18px 14px; color: var(--muted); font-size: 14px; }
details.acc ul { margin: 6px 0; padding-left: 20px; }
details.acc li { margin: 6px 0; }

/* ---------- signup (lead engine) ---------- */
.signup { border: 1px dashed var(--line); }
.signup h2 { text-transform: none; letter-spacing: -0.01em; font-size: 20px; color: var(--text); margin: 0 0 6px; }
.signup p { margin: 0 0 12px; color: var(--muted); }
.signup form, .mini-signup form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.signup input[type=email], .mini-signup input[type=email] { flex: 1 1 240px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--field); border-radius: var(--radius); padding: 11px 12px; min-width: 0; }
.signup .opts { display: flex; gap: 8px 22px; flex-wrap: wrap; width: 100%; margin-top: 2px; }
.signup .check { color: var(--text); font-size: 15px; }
.fine { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.msg { font-size: 14px; margin: 10px 0 0; min-height: 1.3em; }
.msg.error { color: var(--neg); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- about + footer ---------- */
#about { padding-top: 36px; }
#about p, #about li { color: var(--muted); max-width: 70ch; }
#about h2 { font-size: 20px; margin: 0 0 8px; letter-spacing: -0.01em; }
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); padding: 22px 0 40px; color: var(--muted); font-size: 13px; }
.site-footer .legal { max-width: 80ch; }
.mini-signup { margin: 14px 0; }
.mini-signup p { margin: 0 0 6px; color: var(--text); font-size: 14px; }
.mini-signup input[type=email] { padding: 8px 10px; font-size: 14px; }
.mini-signup .btn { padding: 8px 14px; font-size: 14px; }

/* ---------- long-form pages (terms, privacy) ---------- */
.doc { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }
.doc h1 { font-size: 28px; letter-spacing: -0.02em; margin: 8px 0 4px; }
.doc h2 { font-size: 18px; margin: 28px 0 6px; }
.doc .meta { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.draft { border: 1px solid var(--accent-fg); color: var(--accent-fg); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; margin: 12px 0 20px; }

@media (max-width: 720px) {
  .analyze { grid-template-columns: 1fr; }
  .analyze .btn { width: 100%; }
  .hero { padding-top: 24px; }
  .nav { gap: 12px; }
}

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.ch-label { fill: var(--muted); font: 12px var(--mono); }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-zero { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 3; }
.ch-line { stroke: var(--accent-fg); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ch-area { fill: var(--accent-fg); opacity: .12; }
.ch-dot { fill: var(--accent-fg); }
.ch-end { fill: var(--surface); stroke: var(--accent-fg); stroke-width: 2.5; }
.rbar { display: block; margin-left: auto; overflow: visible; }
.rbar .rb-zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 2; }
.rbar .rb-whisker, .rbar .rb-cap, .rbar .rb-clip { stroke: var(--muted); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.rbar .rb-dot { fill: var(--muted); }
.rbar .rb-none { stroke: var(--line); stroke-width: 2; stroke-dasharray: 2 4; }
.rbar.r-positive .rb-whisker, .rbar.r-positive .rb-cap, .rbar.r-positive .rb-clip { stroke: var(--pos); }
.rbar.r-positive .rb-dot { fill: var(--pos); }
.rbar.r-negative .rb-whisker, .rbar.r-negative .rb-cap, .rbar.r-negative .rb-clip { stroke: var(--neg); }
.rbar.r-negative .rb-dot { fill: var(--neg); }
td.c-range { min-width: 160px; }
.rng-text { display: none; }
.legend { margin: 0 0 8px; }
.sample-chart { margin: 14px 0 4px; }
.sample-bars { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.sample-bars li { display: grid; grid-template-columns: minmax(120px, 1fr) 150px auto; align-items: center; gap: 12px; font-size: 14px; }
.sample .note { margin: 12px 0 0; }
@media (max-width: 720px) {
  .rng-text { display: inline; font-size: 12px; color: var(--muted); margin-left: 8px; }
  td.c-range { justify-content: flex-start; align-items: center; min-width: 0; }
  td.c-range .rbar { margin-left: 0; }
  .sample-bars li { grid-template-columns: 1fr; gap: 4px; }
}

.ev-body { display: inline-flex; flex-direction: column; align-items: flex-end; }
.ev-body .need { text-align: right; }

/* ---------- share panel ---------- */
.share-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.share-canvas { width: 100%; height: auto; display: block; border-radius: 12px; border: 1px solid var(--line); background: #090b0e; }
.share-actions { display: grid; gap: 10px; align-content: start; }
.share-actions .btn { width: 100%; }
.share-actions .note { margin: 4px 0 0; }
@media (max-width: 720px) { .share-body { grid-template-columns: 1fr; } }
