/* ===========================================================================
   Worth the Test — shared stylesheet for static prose pages (content/*.md).
   Mirrors the app's design language (src/app.css + public/privacy.html): same
   tokens, self-hosted Inter/Fraunces, light + dark via prefers-color-scheme.
   No CSS framework, no external resources — CSP-safe (self + fonts only).
   =========================================================================== */

/* Self-hosted variable webfonts (same files the app uses; latin subset). */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/fraunces-latin-variable.woff2') format('woff2');
}

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #dfe3e8;
  --text: #1f2430;
  --text-muted: #5b6472;
  --accent: #0072b2;
  --accent-bg: rgba(0, 114, 178, 0.08);

  /* Okabe–Ito cohort hues (used by the header glyph + try-it accent). */
  --c-tp: #009e73;
  --c-fp: #e69f00;
  --c-tn: #56b4e9;
  --c-missed: #cc79a7;
  --c-harmed: #d55e00;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.05);

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --measure: 68ch; /* readable prose line length */

  color-scheme: light dark;
  font: 16px/1.65 var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e7eaf0;
    --text-muted: #9aa3b0;
    --accent: #56b4e9;
    --accent-bg: rgba(86, 180, 233, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Skip link ──────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 20;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
}

/* ── Site header / primary nav ──────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
}
.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.site-brand-glyph {
  width: 1.25rem;
  height: 1.25rem;
}
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
}
.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.25rem 0.1rem;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover {
  color: var(--accent);
}
.site-nav a[aria-current='page'] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Main column ────────────────────────────────────────────────────────── */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
}

/* ── Breadcrumb ─────────────────────────────────────────────────────────── */
.breadcrumb {
  margin: 0.25rem 0 1.5rem;
}
.breadcrumb ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.breadcrumb li + li::before {
  content: '›';
  margin-right: 0.3rem;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}
.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.breadcrumb li[aria-current='page'] {
  color: var(--text);
}

/* ── Prose ──────────────────────────────────────────────────────────────── */
.prose h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.6rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 0.4rem;
}
.prose h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 2.2rem 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--border);
}
.prose h3 {
  font-weight: 600;
  font-size: 1.1rem;
  margin: 1.6rem 0 0.4rem;
}
.prose p,
.prose li {
  color: var(--text);
}
.prose p {
  margin: 0 0 1rem;
}
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose ul,
.prose ol {
  padding-left: 1.4rem;
  margin: 0 0 1rem;
}
.prose li {
  margin-bottom: 0.4rem;
}
.prose strong {
  font-weight: 600;
}
.prose code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.4rem 0 0.4rem 1rem;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}
.prose img {
  max-width: 100%;
  height: auto;
}
.prose figure {
  margin: 1.5rem 0;
}
.prose figcaption {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.4rem;
}
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Tables (wide content scrolls inside its own container). */
.prose .table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}
.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
}
.prose th {
  background: var(--surface-2);
  font-weight: 600;
}

/* Byline row (muted, under the h1). */
.byline,
.prose .updated {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 1.75rem;
}

/* ── "Try it" callout — links that open the calculator preloaded ───────── */
.try-it {
  position: relative;
  margin: 1.75rem 0;
  padding: 1.1rem 1.25rem;
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}
.try-it > :first-child {
  margin-top: 0;
}
.try-it > :last-child {
  margin-bottom: 0;
}
.try-it .try-it-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.5rem;
}
.try-it .try-it-label::before {
  content: '▸';
}
.try-it p {
  margin: 0 0 0.6rem;
}
.try-it a,
a.try-it-link {
  display: inline-block;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.try-it a:hover {
  border-bottom-color: var(--accent);
}

/* Surface card (e.g. the privacy-page Contact box). */
.prose .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── References list ────────────────────────────────────────────────────── */
.references {
  margin: 2rem 0 0;
  font-size: 0.9rem;
}
.references h2 {
  font-size: 1.2rem;
}
.references ol {
  padding-left: 1.4rem;
}
.references li {
  margin-bottom: 0.6rem;
  color: var(--text-muted);
}
.references a {
  color: var(--accent);
}

/* ── Disclaimer box ─────────────────────────────────────────────────────── */
.disclaimer {
  max-width: var(--measure);
  margin: 2.5rem auto 0;
  padding: 0 1.25rem;
}
.disclaimer p {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ── Related-pages block ────────────────────────────────────────────────── */
.related {
  max-width: var(--measure);
  margin: 2.5rem auto 0;
  padding: 0 1.25rem;
}
.related h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
}
.related ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.related a {
  display: block;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.related a:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

/* ── Footer (grouped columns, responsive) ───────────────────────────────── */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  margin-top: 3rem;
}
.site-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
}
.footer-col h2 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.7rem;
}
.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.footer-col a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}
.footer-col a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.site-footer-legal {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ── Accessibility ──────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 560px) {
  .site-header-inner {
    padding: 0.55rem 1rem;
  }
  .page {
    padding: 1.25rem 1rem 3rem;
  }
}
