/* Brand colours come from assets/brand/palette.css (--pc-*). Everything below uses the
   theme tokens, so dark mode only redefines the token block. The theme is set on <html>
   (data-theme) by the inline script in index.html; without JavaScript the page is light. */
:root {
  --bg: var(--pc-paper);
  --bg-2: var(--pc-mist);
  --surface: var(--pc-paper);              /* cards that sit on a tinted band */
  --text: var(--pc-ink);
  --text-soft: rgba(20, 27, 36, 0.78);
  --muted: rgba(20, 27, 36, 0.62);
  --line: rgba(20, 27, 36, 0.14);
  --line-strong: rgba(20, 27, 36, 0.28);
  --c-indigo: var(--pc-indigo);
  --c-teal: var(--pc-teal);
  --c-cobalt: var(--pc-cobalt);
  --c-lagoon: var(--pc-lagoon);
  --on-accent: #fff;                       /* text on a teal or indigo fill */
  --shaft-a: var(--pc-shaft-start);
  --shaft-b: var(--pc-shaft-end);
  --art-a: #e3efec;
  --art-b: #dfe5f1;
  --fade: 0.12;                            /* the faded picture behind a flipped tile */
  --term-bg: var(--pc-ink);
  --term-bar: #1d2633;
  --foot-bg: var(--pc-ink);                /* the footer is dark in both themes */
  --foot-text: rgba(236, 239, 241, 0.64);
  --foot-strong: #ECEFF1;
  --foot-w1: #A3B1F5;                      /* wordmark hues lightened for the dark footer */
  --foot-w2: #41C4BE;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: Fraunces, Georgia, "Times New Roman", serif;
  --radius: 18px;
  color-scheme: light;
}

/* Dark: the brand hues, lightened to read on a dark page (contrast 6.6–8.7 on --bg). */
:root[data-theme="dark"] {
  --bg: #11171F;
  --bg-2: #19212B;
  --surface: #212A35;
  --text: #ECEFF1;
  --text-soft: rgba(236, 239, 241, 0.8);
  --muted: rgba(236, 239, 241, 0.64);
  --line: rgba(236, 239, 241, 0.14);
  --line-strong: rgba(236, 239, 241, 0.3);
  --c-indigo: #A3B1F5;
  --c-teal: #3FC9A0;
  --c-cobalt: #5EB0E8;
  --c-lagoon: #41C4BE;
  --on-accent: #11171F;
  --shaft-a: #7389E6;
  --shaft-b: #2FB8AC;
  --art-a: #15302D;
  --art-b: #1A2240;
  --fade: 0.2;
  --term-bg: #0B1016;
  --term-bar: #151C25;
  --foot-bg: #0B1016;
  color-scheme: dark;
}

/* Light and dark copies of the same image; only one shows. */
.only-dark { display: none !important; }
[data-theme="dark"] .only-dark { display: block !important; }
[data-theme="dark"] .only-light { display: none !important; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
::selection { background: color-mix(in srgb, var(--c-lagoon) 30%, transparent); }  /* text keeps its own colour */
a { color: var(--c-indigo); }
a:hover { color: var(--c-lagoon); }
code, pre { font-family: var(--mono); font-size: 0.875em; }
.statement code { font-size: 0.7em; background: var(--bg-2); padding: 0.1em 0.35em; border-radius: 4px; vertical-align: 0.1em; }
.serif { font-family: var(--serif); font-weight: 400; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
section { padding: 96px 0; }
section { --card: var(--bg-2); }        /* cards: tinted on a plain band, lighter on a tinted one */
section.tint { background: var(--bg-2); --card: var(--surface); }

/* Section head: hairline label, then a two-weight statement (headline + one line) */
.sec-label { border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 28px; font-size: 0.9rem; font-weight: 600; }
.statement { font: 400 clamp(1.5rem, 2.8vw, 2.15rem)/1.22 var(--serif); letter-spacing: -0.01em; max-width: 880px; margin: 0 0 48px; color: var(--text-soft); }
.statement b { font-weight: 600; color: var(--text); }
.serif, .statement { font-variation-settings: "SOFT" 50, "WONK" 0; }
.statement.xl { font-size: clamp(2rem, 4.4vw, 3.5rem); line-height: 1.12; max-width: 1040px; margin: 0; }

/* Meta row: pill tag + label */
.meta { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--muted); margin: 0 0 10px; }
.tag { white-space: nowrap; font: 500 0.72rem var(--mono); padding: 2px 9px; border-radius: 999px; background: var(--bg-2); color: var(--c-indigo); border: 1px solid var(--line); }

.wordmark { font-family: var(--sans); font-weight: 600; letter-spacing: -0.02em; }
.wordmark .w1 { color: var(--c-indigo); }
.wordmark .w2 { color: var(--c-lagoon); }

/* Pills: nav and buttons */
.pill, .pills a { display: inline-block; font: 500 0.88rem var(--sans); padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap; }
.pill:hover, .pills a:hover { background: var(--bg-2); color: var(--text); }
.pill.on, .pill.dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.pill.dark:hover { background: var(--text); color: var(--bg); opacity: 0.9; }
.pill[aria-disabled="true"] { opacity: 0.5; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 1.25rem; }
.pills { display: flex; gap: 6px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.theme-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; }
.theme-btn:hover { background: var(--bg-2); }
.theme-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-btn .moon { display: block; }
.theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: block; }

/* Hero: the claim and the paper on the left, the mark on the right */
.hero { padding: 56px 0 32px; }
.hero-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 56px; align-items: center; }
.hero .statement.xl { font-size: clamp(2rem, 3.8vw, 3.1rem); margin: 4px 0 32px; }
.hl { background: linear-gradient(transparent 64%, color-mix(in srgb, var(--c-lagoon) 30%, transparent) 64% 92%, transparent 92%); padding: 0 0.08em; margin: 0 -0.08em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.paper-line { display: flex; flex-direction: column; gap: 2px; margin: 0 0 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.paper-line span:first-child { font-size: 0.82rem; color: var(--muted); }
.paper-line .serif { font-size: 1.3rem; line-height: 1.3; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-art { background: linear-gradient(160deg, var(--art-a), var(--art-b)); border-radius: var(--radius); aspect-ratio: 1; display: grid; place-items: center; padding: 40px; }
.hero-art img { width: min(320px, 100%); }

/* Hairline row list */
.rows { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 0.92rem; text-decoration: none; color: var(--text); }
.row span:last-child { color: var(--muted); text-align: right; }
a.row:hover span:last-child { color: var(--c-lagoon); }
a.row[aria-disabled="true"] { pointer-events: none; }

/* Gallery: rows whose tiles grow with their image ratio, so each row shares one height */
.gallery { display: flex; flex-direction: column; gap: 56px; }
.grow { display: flex; gap: 28px; }
.tile { margin: 0; flex: var(--r) 1 0; min-width: 0; display: flex; flex-direction: column; }

/* The group colours the tag: sensor teal, science cobalt, media indigo */
.tile[data-group="sensor"] { --cat: var(--c-teal); }
.tile[data-group="science"] { --cat: var(--c-cobalt); }
.tile[data-group="media"] { --cat: var(--c-indigo); }
.tile[data-group="any"] { --cat: var(--muted); }
.tile .tag { color: var(--cat); background: color-mix(in srgb, var(--cat) 10%, var(--bg)); border-color: color-mix(in srgb, var(--cat) 45%, transparent); }
.yours .tag { border-style: dashed; }

.front img, .yours-box { width: 100%; aspect-ratio: var(--r); object-fit: cover; border-radius: 6px; }
.front img { transition: transform 0.3s; }
.tile:hover .front img { transform: scale(1.015); }
.cap { padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.cap b, .back b { font-size: 1.45rem; line-height: 1.15; }
.cap span { color: var(--muted); font-size: 0.93rem; line-height: 1.5; max-width: 52ch; }
.tile .metric { margin-top: 4px; font: 0.78rem var(--mono); color: var(--cat); }
a.metric { text-decoration: none; }
a.metric[aria-disabled="true"] { opacity: 0.6; }
.yours-box { border: 2px dashed var(--line-strong); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--c-teal) 5%, transparent) 14px 28px); }
.yours-box svg { width: 44px; height: 44px; fill: none; stroke: var(--c-teal); stroke-width: 3; stroke-linecap: round; }
.yours-box span { font: 0.82rem var(--mono); color: var(--muted); }

/* Flip: both faces share one grid cell, so the card is as tall as its taller face */
.flip { flex: 1; display: grid; cursor: pointer; transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.tile.flipped .flip { transform: rotateY(180deg); }
.face { grid-area: 1 / 1; min-width: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.tile:not(.flipped) .back, .tile.flipped .front { pointer-events: none; }
.back { transform: rotateY(180deg); position: relative; overflow: hidden; border-radius: 6px; background: var(--bg-2); padding: 16px 20px 18px; display: flex; flex-direction: column; }
.back .bg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; opacity: var(--fade); pointer-events: none; }
.back > :not(.bg) { position: relative; }
.why { margin: 8px 0 auto; color: var(--text-soft); font-size: 0.95rem; line-height: 1.55; max-width: 60ch; }
.gain { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line-strong); display: flex; flex-direction: column; gap: 4px; }
.gain-head { font-size: 0.8rem; font-weight: 600; color: var(--cat); }
.gain-row { display: flex; justify-content: space-between; gap: 12px; font: 0.8rem var(--mono); color: var(--muted); }
.flip-btn { margin-left: auto; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 0.95rem; cursor: pointer; }
.tile:hover .flip-btn, .flip-btn:focus-visible { color: var(--text); border-color: var(--line-strong); }

/* Flow: four columns split by hairlines */
.flow { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.flow li { padding: 22px 24px 8px; display: flex; flex-direction: column; gap: 6px; border-left: 1px solid var(--line); }
.flow li:first-child { border-left: none; padding-left: 0; }
.flow .num { font: 600 0.8rem var(--mono); color: var(--muted); }
.flow svg { width: 40px; height: 40px; fill: none; stroke: var(--c-teal); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; margin: 20px 0 8px; }
.flow li.agent svg { stroke: var(--c-cobalt); }
.flow b { font-size: 1.45rem; line-height: 1.2; }
.flow li > span:last-child { color: var(--muted); font-size: 0.93rem; line-height: 1.5; }

/* E-RSI panels */
.compare { display: grid; grid-template-columns: 1fr 1.25fr; gap: 24px; }
.panel { margin: 0; background: var(--card); border-radius: var(--radius); padding: 24px 28px 28px; display: flex; flex-direction: column; }
.panel svg { width: 100%; height: auto; margin: 8px 0 auto; }
.panel figcaption { margin-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.panel figcaption b { font-size: 1.45rem; }
.panel figcaption span { color: var(--muted); font-size: 0.93rem; }
.edge { stroke: var(--c-cobalt); stroke-width: 2.5; fill: none; opacity: 0.55; }
.edge.dead { stroke: var(--muted); stroke-dasharray: 5 5; }
.edge.best { stroke: url(#shaft); opacity: 1; stroke-width: 4; }
.eye ellipse { fill: var(--card); stroke: var(--c-teal); stroke-width: 3; }
.eye .in { fill: var(--c-cobalt); stroke: none; }
.eye.best ellipse { stroke: var(--c-indigo); stroke-width: 4; }
.eye.best .in { fill: var(--c-indigo); }
.eye.dead ellipse { stroke: var(--line-strong); stroke-dasharray: 4 4; }
.ctx { fill: var(--line); stroke: var(--line-strong); }
.doc rect { fill: var(--card); stroke: var(--c-indigo); stroke-width: 1.6; }
.doc path { stroke: var(--c-indigo); stroke-width: 1.6; }
.lbl { font: 12px var(--mono); fill: var(--muted); }

/* Agent cards */
.agent-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.acard { background: var(--card); border-radius: var(--radius); padding: 22px 22px 14px; display: flex; flex-direction: column; }
.acard h3 { font: 600 1.25rem var(--sans); margin: 4px 0 40px; }
.acard .rows { margin-top: auto; }
.acard.open .tag { color: var(--c-teal); }
.acard.yours { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 16px 48px; padding: 22px 28px; background: transparent; border: 2px dashed var(--line-strong); }
.acard.yours h3 { margin: 4px 0 0; white-space: nowrap; }
.acard.yours .tag { color: var(--muted); border-style: dashed; }
.acard-text { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.55; max-width: 72ch; }
.acard-text code { font-size: 0.78rem; overflow-wrap: anywhere; }
.foot-note { color: var(--muted); font-size: 0.92rem; margin: 20px 0 0; }

/* Results placeholder */
.skeleton { position: relative; background: var(--card); border-radius: var(--radius); padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.sk-row { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }
.sk-label { height: 12px; border-radius: 6px; background: var(--line); }
.sk-bar { height: 22px; width: var(--w); border-radius: 6px; background: linear-gradient(90deg, var(--line), var(--line-strong), var(--line)); background-size: 200% 100%; animation: shimmer 2.4s infinite linear; }
.sk-badge { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font: 600 0.9rem var(--mono); background: var(--card); border: 1px solid var(--line); padding: 8px 16px; border-radius: 999px; color: var(--c-indigo); }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk-bar { animation: none; } .front img, .flip { transition: none; } }

/* Terminal (always dark) and citation */
.term { background: var(--term-bg); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 12px 16px; background: var(--term-bar); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #3a4656; }
.term-bar span { margin-left: 8px; font: 0.78rem var(--mono); color: #8a96a6; }
.term pre { margin: 0; padding: 20px 22px; color: #e8ecef; overflow-x: auto; line-height: 1.6; }
.term .pr { color: #5fd0c4; }
pre.bib { background: var(--card); padding: 22px 24px; border-radius: var(--radius); overflow-x: auto; margin: 0; }

/* Footer */
.site-foot { background: var(--foot-bg); padding: 40px 0; font-size: 0.88rem; color: var(--foot-text); }
.foot-inner { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; }
.foot-inner .wordmark { font-size: 1.05rem; }
.site-foot .wordmark .w1 { color: var(--foot-w1); }
.site-foot .wordmark .w2 { color: var(--foot-w2); }
.foot-links { display: flex; gap: 20px; margin-left: auto; }
.foot-links a { color: var(--foot-text); text-decoration: none; }
.foot-links a:hover { color: var(--foot-strong); }
.foot-links a[aria-disabled="true"] { opacity: 0.5; }

/* Tablet */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr 240px; gap: 32px; }
  .hero-art { padding: 28px; }
  .flow { grid-template-columns: repeat(2, 1fr); }
  .flow li:nth-child(3) { border-left: none; padding-left: 0; }
  .compare { grid-template-columns: 1fr; }
  .agent-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Phone */
@media (max-width: 680px) {
  section { padding: 64px 0; }
  .pills { display: none; }
  .hero { padding: 24px 0 56px; }
  .hero-grid { grid-template-columns: 1fr; gap: 24px; }
  .hero-art { order: -1; width: 132px; padding: 16px; }
  .grow { flex-direction: column; gap: 40px; }
  .tile { flex: none; width: 100%; }
  .gallery { gap: 40px; }
  .yours-box { aspect-ratio: 2; }
  .flow { grid-template-columns: 1fr; }
  .flow li { border-left: none; padding-left: 0; border-top: 1px solid var(--line); }
  .flow li:first-child { border-top: none; }
  .agent-cards { grid-template-columns: 1fr; }
  .acard.yours { flex-direction: column; align-items: flex-start; }
  .sk-row { grid-template-columns: 60px 1fr; }
  .foot-links { margin-left: 0; width: 100%; }
}
