/* Ledger paper, one civic typeface, one signal colour spent on the sieve and the scale markers. */
:root {
  --paper: #edefea;
  --paper-2: #f6f7f3;
  --ink: #1d2420;
  --ink-2: #4f5a53;
  --rule: #c8cdc3;
  --signal: #e2a400;
  --signal-ink: #3a2a00;
  --severe: #a3261b;
  --link: #2a4b7c;
  --s3: #1d2420;
  --s2: #5f6b63;
  --s1: #a9b1a6;
  --s0: transparent;
  --measure: 68ch;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161a17;
    --paper-2: #1d221e;
    --ink: #e4e8e1;
    --ink-2: #a3ada5;
    --rule: #333b35;
    --signal: #e8b425;
    --signal-ink: #221800;
    --severe: #e2725f;
    --link: #9db8e0;
    --s3: #e4e8e1;
    --s2: #8d988f;
    --s1: #4d564f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-family: "Public Sans", ui-sans-serif, system-ui, sans-serif; font-size: 17px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-variant-numeric: tabular-nums; }
a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 80px; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); font-weight: 850; margin: 0.35em 0 0.3em; max-width: 15em; letter-spacing: -0.035em; }
h2 { font-size: 1.45rem; font-weight: 750; margin: 2.6em 0 0.5em; }
h3 { font-size: 1rem; font-weight: 700; margin: 0 0 0.6em; letter-spacing: 0; }
p, li { max-width: var(--measure); }
.lede { font-size: 1.2rem; color: var(--ink-2); line-height: 1.5; }
.muted { color: var(--ink-2); }
.section-intro { color: var(--ink-2); margin-top: 0; }

/* Header and footer */
.site-header { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: baseline; justify-content: space-between; max-width: 1040px; margin: 0 auto; padding: 18px 16px 14px; border-bottom: 2px solid var(--ink); }
.brand { font-weight: 850; font-size: 1.05rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-header nav a { color: var(--ink-2); text-decoration: none; font-size: 0.95rem; }
.site-header nav a:hover { color: var(--ink); }
.site-header nav a[aria-current] { color: var(--ink); font-weight: 700; box-shadow: inset 0 -3px 0 var(--signal); }
.site-footer { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; border-top: 1px solid var(--rule); color: var(--ink-2); font-size: 0.88rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 20px; }

/* Hero */
.hero { padding-top: 28px; }
.subscribe { margin: 28px 0 8px; max-width: 34rem; }
.subscribe label { display: block; font-weight: 700; margin-bottom: 8px; }
.subscribe div { display: flex; gap: 8px; }
.subscribe input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--paper-2); color: var(--ink); }
.subscribe button { font: inherit; font-weight: 700; padding: 10px 18px; border: 0; border-radius: 3px; background: var(--ink); color: var(--paper); }
.subscribe small { display: block; margin-top: 6px; color: var(--ink-2); }

/* The sieve: the one bold element */
.sieve { margin-top: 56px; padding-top: 4px; border-top: 2px solid var(--ink); }
.sieve h2 { margin-top: 0.9em; }
.sieve-intro, .sieve-foot { color: var(--ink-2); }
.sieve ol { list-style: none; padding: 0; margin: 28px 0 20px; }
.stage { display: grid; grid-template-columns: 7.5ch 1fr; grid-template-areas: "bar bar" "n text"; column-gap: 16px; row-gap: 6px; margin: 0 0 22px; max-width: none; }
.stage-bar { grid-area: bar; height: 22px; background: repeating-linear-gradient(135deg, transparent 0 4px, var(--rule) 4px 6px); }
.stage-bar span { display: block; height: 100%; width: max(var(--w), 3px); background: var(--ink); transform-origin: left; }
.stage.is-final .stage-bar span { background: var(--signal); }
.stage-n { grid-area: n; font-size: 1.7rem; font-weight: 850; line-height: 1; letter-spacing: -0.03em; }
.stage.is-final .stage-n { font-size: 2.6rem; }
.stage-text { grid-area: text; color: var(--ink-2); max-width: 60ch; }
.stage-text strong { color: var(--ink); }
/* .anim is added by script on the first painted frame, so bars stay full-size wherever animation never runs. */
@media (prefers-reduced-motion: no-preference) {
  .anim .stage-bar span { animation: sieve 900ms cubic-bezier(.2,.7,.2,1) both; }
  .anim .stage:nth-child(2) .stage-bar span { animation-delay: 150ms; }
  .anim .stage:nth-child(3) .stage-bar span { animation-delay: 300ms; }
  .anim .stage:nth-child(4) .stage-bar span { animation-delay: 450ms; }
  @keyframes sieve { from { transform: scaleX(0); } }
}

/* How sure we are: stacked bars on the home page */
.sure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 28px; margin-top: 20px; }
.stack { display: flex; height: 14px; border: 1.5px solid var(--ink); gap: 2px; padding: 1px; }
.seg, .key { background: var(--s0); }
.seg.s3, .key.s3 { background: var(--s3); }
.seg.s2, .key.s2 { background: var(--s2); }
.seg.s1, .key.s1 { background: var(--s1); }
.seg.s0 { background: repeating-linear-gradient(135deg, transparent 0 3px, var(--rule) 3px 5px); }
.stack-key { list-style: none; padding: 0; margin: 10px 0 0; font-size: 0.92rem; }
.stack-key li { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.stack-key b { margin-left: auto; }
.key { width: 12px; height: 12px; border: 1px solid var(--ink); flex: none; }
.key.s0 { background: repeating-linear-gradient(135deg, transparent 0 2px, var(--rule) 2px 4px); }

/* Pattern bars */
.bars { list-style: none; padding: 0; max-width: 720px; }
.bars li { display: grid; grid-template-columns: minmax(12em, 18em) 1fr 2.5em; gap: 14px; align-items: center; margin: 8px 0; max-width: none; }
.bar { height: 10px; width: var(--w); background: var(--ink); }
.bar-n { text-align: right; font-weight: 700; }

/* Case list */
.caselist { list-style: none; padding: 0; margin: 12px 0; border-top: 1px solid var(--rule); }
.case-row { max-width: none; border-bottom: 1px solid var(--rule); }
.case-row a { display: grid; grid-template-columns: 9.5em 1fr; gap: 4px 20px; padding: 12px 12px 12px 14px; color: var(--ink); text-decoration: none; border-left: 4px solid transparent; }
.case-row.is-severe a { border-left-color: var(--severe); }
.case-row a:hover { background: var(--paper-2); }
.case-row a:hover .case-sum { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.case-id { font-weight: 700; color: var(--ink-2); font-size: 0.9rem; white-space: nowrap; }
.case-sum { font-weight: 600; }
.case-meta { grid-column: 2; display: flex; flex-wrap: wrap; gap: 2px 18px; color: var(--ink-2); font-size: 0.87rem; }
.grade { display: inline-grid; place-items: center; min-width: 1.45em; height: 1.45em; border: 1.5px solid var(--ink); font-weight: 800; font-size: 0.8rem; color: var(--ink); vertical-align: 0.05em; }
.grade-A { background: var(--ink); color: var(--paper); }
.grade-C { border-style: dashed; color: var(--ink-2); }

.filters input { width: 100%; max-width: 380px; font: inherit; padding: 9px 12px; margin: 6px 0 10px; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--paper-2); color: var(--ink); }

/* Case page */
.crumb { color: var(--ink-2); font-size: 0.92rem; margin-top: 24px; }
.case { border-left: 4px solid var(--rule); padding-left: 20px; margin-top: 8px; }
.case.is-severe { border-left-color: var(--severe); }
.case-title { font-size: clamp(1.7rem, 4.5vw, 2.6rem); max-width: 22em; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 28px; margin: 20px 0; padding: 0; }
.facts div { border-top: 1px solid var(--rule); padding-top: 8px; }
.facts dt { color: var(--ink-2); font-size: 0.85rem; }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.facts-plain { margin-top: 28px; }
.source { font-weight: 700; }

/* The three scales */
.sure-case { margin-top: 48px; padding: 4px 24px 12px; background: var(--paper-2); border: 1.5px solid var(--ink); }
.sure-case h2 { margin-top: 0.8em; }
.scale { display: grid; grid-template-columns: 12em minmax(0, 26em) 1fr; gap: 6px 24px; align-items: center; padding: 14px 0; border-top: 1px solid var(--rule); }
.scale-label { font-weight: 700; }
.scale-track { display: grid; grid-template-columns: repeat(3, 1fr); position: relative; padding-top: 22px; }
.scale-track::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 2px; background: var(--ink); }
.stop { position: relative; text-align: center; font-size: 0.8rem; color: var(--ink-2); }
.stop::before { content: ""; position: absolute; left: 50%; top: -18px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--paper-2); border: 2px solid var(--ink); }
.stop.is-here { color: var(--ink); font-weight: 700; }
.stop.is-here::before { width: 20px; height: 20px; margin-left: -10px; top: -23px; background: var(--signal); }
.scale-note { color: var(--ink-2); font-size: 0.92rem; }

/* Notes, cards, guards, prose */
.note { border-left: 4px solid var(--signal); background: var(--paper-2); padding: 12px 16px; margin: 18px 0; max-width: var(--measure); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 0 28px; }
.card { display: block; padding: 16px 0 18px; border-top: 2px solid var(--ink); color: var(--ink); text-decoration: none; }
.card h3 { margin-bottom: 6px; }
.card:hover h3 { text-decoration: underline; }
.card p { color: var(--ink-2); margin: 0 0 8px; }
.guard { border-top: 2px solid var(--ink); padding-top: 4px; margin-top: 36px; max-width: var(--measure); }
.guard h2 { margin-top: 0.6em; }
pre { background: var(--paper-2); border: 1px solid var(--rule); padding: 12px 14px; overflow-x: auto; max-width: var(--measure); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88em; }
.prose { max-width: var(--measure); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.issue-list li { margin: 6px 0; }
.definition { padding-left: 1.3em; }
.definition li { margin: 0.5em 0; }

@media (max-width: 640px) {
  html { font-size: 16px; }
  .stage { grid-template-columns: 1fr; grid-template-areas: "bar" "n" "text"; }
  .case-row a { grid-template-columns: 1fr; }
  .case-meta { grid-column: 1; }
  .bars li { grid-template-columns: 1fr 2.5em; }
  .bars .bar { grid-column: 1 / -1; grid-row: 2; }
  .scale { grid-template-columns: 1fr; }
  .sure-case { padding: 4px 16px 12px; }
  .case { padding-left: 14px; }
}
