/*
  Dark only, deliberately — no light mode. This is an operations surface
  that runs on a projector in a dim room.
*/
:root {
  --plane: #0a0a0b;
  --surface: #131315;
  --panel: #1a1a1d;
  --cell: #232326;
  --ink: #f4f4f2;
  --ink-2: #b9b9bd;
  --muted: #7f7f85;
  --critical: #d03b3b;
  --good: #0ca30c;

  /* scarlet edge → claret → wine. Reserved for exactly two things:
     the header hairline, and marking "leaked" cells in data tables.
     Never a general UI color. */
  --brand-grad: linear-gradient(135deg, #c9364f 0%, #a02347 52%, #6f1d3a 100%);

  --border: rgba(255, 255, 255, 0.08);
  --radius: 8px;
  --max-width: 1120px;

  --font-serif: ui-serif, "New York", Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --radius-lg: 14px;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);

  font-synthesis: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font-serif);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3 { line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.875rem, 3.4vw + 1rem, 2.875rem); margin: 0 0 22px; }
h2 { font-size: clamp(1.5rem, 2vw + 1rem, 2.125rem); margin: 0 0 12px; }
h3 { font-size: 1.0625rem; margin: 0 0 6px; }
p { margin: 0 0 16px; color: var(--ink-2); }

a { color: inherit; }

.section-lead { font-size: 1.0625rem; max-width: 640px; margin-bottom: 32px; }
.section-lead a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

/* Numbers and code stay monospace, always. */
.kicker, .byline, .resource-link, .num, .takeaway-num, .finding-num, .example-tag, .footer-copyright {
  font-family: var(--font-mono);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--ink);
  color: var(--plane);
  padding: 10px 16px;
  border-radius: var(--radius);
  z-index: 100;
  transition: top 0.15s var(--ease);
  text-decoration: none;
  font-weight: 600;
  font-family: var(--font-mono);
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--ink-2);
  outline-offset: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9375rem;
  font-family: var(--font-serif);
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease),
    border-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: var(--ink);
  color: var(--plane);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 6px 16px -6px rgba(0, 0, 0, 0.5);
}
.btn-primary:hover { background: var(--ink-2); transform: translateY(-1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 10px 22px -8px rgba(0, 0, 0, 0.55); }
.btn-primary:active { transform: translateY(0); }
.btn-lg { padding: 14px 26px; font-size: 1rem; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-hairline {
  height: 2px;
  background: var(--brand-grad);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 64px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 1.0625rem;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}
.logo img { display: block; border-radius: 6px; }

.main-nav { display: flex; gap: 26px; }
.main-nav a {
  text-decoration: none;
  color: var(--ink-2);
  font-size: 0.9375rem;
  transition: color 0.15s var(--ease);
}
.main-nav a:hover { color: var(--ink); }

.header-actions { display: flex; gap: 10px; align-items: center; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
.site-header.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.site-header.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-nav {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 12px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.mobile-nav a { padding: 10px 4px; text-decoration: none; color: var(--ink); }
.mobile-nav .btn { margin-top: 8px; align-self: flex-start; }

.site-header.nav-open .mobile-nav { display: flex; }

@media (max-width: 780px) {
  .main-nav, .header-actions { display: none; }
  .nav-toggle { display: flex; }
}

/* Hero — single column, research-abstract shape */
.hero { padding: 72px 0 64px; border-bottom: 1px solid var(--border); }
.hero-inner { max-width: 760px; }
.kicker {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 18px;
}
.hero h1 { max-width: 22ch; }
.abstract { font-size: 1.125rem; max-width: 62ch; }
.byline { color: var(--muted); font-size: 0.8125rem; margin: 0 0 28px; }

.resource-links {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.resource-link {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s var(--ease);
}
.resource-link:hover { color: var(--ink); }

@media (max-width: 560px) {
  .resource-links { flex-direction: column; align-items: flex-start; gap: 14px; }
}

/* Results — leaderboard table */
.results { padding: 80px 0; border-bottom: 1px solid var(--border); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 48px;
}
.results-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.results-table th,
.results-table td {
  padding: 16px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.results-table thead th {
  background: var(--cell);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-serif);
}
.results-table tbody th {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.row-note { color: var(--muted); font-weight: 400; font-size: 0.875rem; }
.results-table tbody tr:last-child th,
.results-table tbody tr:last-child td { border-bottom: none; }
.results-table tbody tr { background: var(--panel); }
.results-table .num { font-family: var(--font-mono); font-size: 1rem; font-weight: 600; color: var(--ink); }
.cell-good { color: var(--good); }
.cell-zero { color: var(--muted); }
.cell-leak {
  background: var(--brand-grad);
  color: var(--ink);
}
.row-highlight { background: var(--cell); }
.row-highlight th, .row-highlight td { background: transparent; }

/* Takeaways — numbered list, academic style */
.takeaways {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 24px;
}
.takeaways li {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 18px;
  align-items: baseline;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.takeaways li:first-child { padding-top: 0; border-top: none; }
.takeaway-num { color: var(--muted); font-size: 0.8125rem; }
.takeaways p { margin: 0; font-size: 0.9375rem; }
.takeaways strong { color: var(--ink); }

@media (max-width: 560px) {
  .takeaways li { grid-template-columns: 1fr; gap: 6px; }
}

/* Method */
.method { padding: 80px 0; border-bottom: 1px solid var(--border); }
.method-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 48px;
  align-items: start;
}
.method-copy p { font-size: 0.9375rem; }
.method-categories { color: var(--ink-2); }
.method-categories strong { color: var(--ink); }

.method-figure { margin: 0; }
.method-figure img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 24px 48px -28px rgba(0, 0, 0, 0.6);
}
.method-figure figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-family: var(--font-mono);
}

@media (max-width: 860px) {
  .method-inner { grid-template-columns: 1fr; gap: 32px; }
  .method-figure { order: -1; max-width: 420px; }
}

/* Findings */
.findings { padding: 80px 0; border-bottom: 1px solid var(--border); }
.finding {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 18px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
}
.finding:first-of-type { border-top: none; padding-top: 8px; }
.finding-num { color: var(--muted); font-size: 0.8125rem; padding-top: 2px; }
.finding p { margin: 0; font-size: 0.9375rem; }

@media (max-width: 560px) {
  .finding { grid-template-columns: 1fr; gap: 8px; }
}

/* Worked example */
.example { padding: 80px 0; border-bottom: 1px solid var(--border); }
.example-card {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.example-setup {
  margin: 0;
  padding: 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}
.example-row {
  padding: 20px 24px;
  border-left: 3px solid transparent;
  background: var(--surface);
}
.example-row + .example-row { border-top: 1px solid var(--border); }
.example-row-bad { border-left-color: var(--critical); }
.example-row-good { border-left-color: var(--good); }
.example-tag {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}
.example-row-bad .example-tag { color: var(--critical); }
.example-row-good .example-tag { color: var(--good); }
.example-row p { margin: 0; font-size: 0.9375rem; }

/* Why this matters — plain prose, same seriousness as Limits */
.why { padding: 72px 0; border-bottom: 1px solid var(--border); }
.why-inner { max-width: 680px; }
.why p { font-size: 0.9375rem; }
.why p:last-child { margin-bottom: 0; }

/* Limits — deliberately plain and unstyled, so it reads as an honest
   caveat section given equal seriousness, not a footnote to skip. */
.limits { padding: 72px 0; }
.limits-inner { max-width: 680px; }
.limits h2 { font-size: 1.25rem; }
.limits ul { margin: 0; padding: 0 0 0 20px; list-style: disc; }
.limits li { color: var(--ink-2); font-size: 0.9375rem; margin-bottom: 10px; }
.limits li:last-child { margin-bottom: 0; }

/* Access / CTA */
.access { padding: 32px 0 96px; }
.access-inner {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 24px 48px -28px rgba(0, 0, 0, 0.6);
}
.access h2 { margin-bottom: 8px; }
.access p { font-size: 1.0625rem; }
.access-form {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.email-input {
  flex: 1;
  min-width: 220px;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--cell);
  color: var(--ink);
  font-size: 0.9375rem;
  font-family: var(--font-serif);
  transition: border-color 0.15s var(--ease);
}
.email-input:focus { outline: 2px solid var(--ink-2); outline-offset: 1px; border-color: var(--ink-2); }

.access-message {
  margin: 24px 0 0;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  color: var(--good);
}
.access-message-error { color: var(--critical); }

@media (max-width: 480px) {
  .access-inner { padding: 36px 24px; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 48px 0; }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: center;
  justify-content: space-between;
}
.footer-brand { display: flex; flex-direction: column; gap: 6px; max-width: 320px; }
.footer-brand .logo { margin: 0; font-size: 1rem; }
.footer-brand p { margin: 0; font-size: 0.875rem; }
.footer-links { display: flex; gap: 20px; }
.footer-links a { text-decoration: none; color: var(--muted); font-size: 0.9375rem; transition: color 0.15s var(--ease); }
.footer-links a:hover { color: var(--ink); }
.footer-copyright { margin: 0; color: var(--muted); font-size: 0.8125rem; }
