/* Wrong Train Support. Tokens are taken from the live wrongtrain.com landing
   page (light "signal discipline" palette, B612 / Newsreader), with its night
   tokens reused for dark mode. Fonts are self-hosted: no third-party requests. */

@font-face { font-family: "B612"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/b612-400.f25e3d3c4dc7.woff2") format("woff2"); }
@font-face { font-family: "B612"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/b612-700.da25e53a1919.woff2") format("woff2"); }
@font-face { font-family: "B612 Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/b612-mono-400.36625fd3471c.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 500; font-display: swap; src: url("/assets/fonts/newsreader.01817351be3e.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400; font-display: swap; src: url("/assets/fonts/newsreader-italic.e384e31812c1.woff2") format("woff2"); }

:root {
  --paper: #ECEDE8;
  --paper-deep: #E3E5DE;
  --surface: #F5F6F2;
  --ink: #191C1E;
  --steel: #50575B;
  --rail: #C7CAC1;
  --rail-strong: #8A8F86;
  /* Form field outlines: at least 3:1 against paper and surface (WCAG 1.4.11). */
  --control-border: #767B73;
  --green: #1B5E44;
  --green-soft: #DCE7E0;
  --amber: #7E5A10;
  --amber-soft: #EEE4CC;
  --focus: #1B5E44;
  --serif: "Newsreader", Georgia, serif;
  --sans: "B612", system-ui, sans-serif;
  --mono: "B612 Mono", ui-monospace, monospace;
  /* About 70 characters per line of B612 body text (spec: 65 to 75). */
  --measure: 34rem;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141815;
    --paper-deep: #1A1F1B;
    --surface: #1C211D;
    --ink: #D8DCD3;
    --steel: #A4ABA5;
    --rail: #2A302B;
    --rail-strong: #56605A;
    --control-border: #737E77;
    --green: #8FCBAE;
    --green-soft: #1F3329;
    --amber: #E1BC6C;
    --amber-soft: #3A3120;
    --focus: #8FCBAE;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }

a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
main:focus { outline: none; }

.skip-link {
  position: absolute; left: var(--gutter); top: -100px; z-index: 10;
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; border-radius: 4px;
  font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

.wrap { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 720px) { :root { --gutter: 32px; } }

.preview-banner {
  background: var(--amber-soft); color: var(--ink); border-bottom: 1px solid var(--amber);
  padding: 0.5rem var(--gutter); font-family: var(--mono); font-size: 0.85rem; text-align: center;
}

/* Header */
.site-header { border-bottom: 1px solid var(--rail); background: var(--paper); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 0.9rem; padding-bottom: 0.9rem; }
.brand { display: inline-flex; align-items: baseline; gap: 0.6rem; color: var(--ink); text-decoration: none; min-height: 44px; align-items: center; }
.brand-mark { font-weight: 700; letter-spacing: 0.01em; font-size: 1.05rem; }
.brand-tag {
  font-family: var(--mono); font-size: 0.78rem; color: var(--steel);
  border: 1px solid var(--rail-strong); border-radius: 3px; padding: 0.05rem 0.45rem;
}
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px; color: var(--ink);
  text-decoration: none; font-size: 0.95rem; border-bottom: 2px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--rail-strong); }
.site-nav a[aria-current] { border-bottom-color: var(--green); }
.site-nav a.external { color: var(--steel); }

/* Type */
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 2.9rem); margin: 1.5rem 0 0.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.55rem; margin: 2.25rem 0 0.75rem; }
h3 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
.lead { font-size: 1.12rem; color: var(--steel); max-width: var(--measure); margin: 0 0 1.25rem; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--paper-deep); padding: 0.05em 0.3em; border-radius: 3px; overflow-wrap: anywhere; }

.prose { max-width: var(--measure); overflow-wrap: break-word; }
.prose p, .prose li { font-size: 1.02rem; }
.prose ul, .prose ol { padding-left: 1.35rem; }
.prose li + li { margin-top: 0.35rem; }
.prose h2 { scroll-margin-top: 1rem; }
.note {
  border-left: 3px solid var(--green); background: var(--surface);
  padding: 0.75rem 1rem; margin: 1.25rem 0; border-radius: 0 4px 4px 0;
}
.note p { margin: 0; }

/* Breadcrumbs, metadata */
.breadcrumbs ol { list-style: none; margin: 1.25rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; font-size: 0.88rem; color: var(--steel); }
.breadcrumbs li + li::before { content: "/"; margin: 0 0.45rem 0 0.2rem; color: var(--rail-strong); }
.breadcrumbs a { color: var(--steel); }
.entry-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-family: var(--mono); font-size: 0.82rem; color: var(--steel); margin: 0 0 1.5rem; }
.entry-meta .unreviewed { color: var(--amber); }
.entry-header { border-bottom: 1px solid var(--rail); margin-bottom: 1.5rem; }

.toc { border: 1px solid var(--rail); border-radius: 4px; padding: 0.75rem 1rem; margin: 0 0 1.5rem; max-width: var(--measure); background: var(--surface); }
.toc-label { margin: 0 0 0.25rem; font-family: var(--mono); font-size: 0.82rem; color: var(--steel); }
.toc ol { margin: 0; padding-left: 1.2rem; }

/* Hero and search */
.hero { padding: 2rem 0 1rem; }
.hero h1 { margin-top: 0.5rem; }
.search { margin: 1.5rem 0 0.5rem; max-width: 44rem; }
/* Reserve the search box's space until search.js reveals it, so the page
   does not shift. It stays invisible and out of the accessibility tree.
   assets/nojs.css collapses it when JavaScript is off, and if the script
   never arrives the space collapses after a few seconds instead of leaving
   a blank gap (a zero-length animation with a delay, not motion). */
.search[hidden] { display: block; visibility: hidden; overflow: hidden; max-height: 20rem; animation: wt-search-collapse 0s linear 4s forwards; }
@keyframes wt-search-collapse { to { max-height: 0; margin: 0; } }
.search label { display: block; font-weight: 700; margin-bottom: 0.2rem; }
.search .hint { margin: 0 0 0.6rem; color: var(--steel); font-size: 0.92rem; }
.search-row { display: flex; gap: 0.5rem; }
.search input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0.6rem 0.8rem;
  font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--control-border); border-radius: 4px;
}
.search button, .button-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0.55rem 1.1rem;
  font: inherit; font-weight: 700; color: var(--paper); background: var(--ink); border: 1px solid var(--ink);
  border-radius: 4px; cursor: pointer; text-decoration: none;
}
.search button:hover, .button-link:hover { background: var(--green); border-color: var(--green); }
.search-status { margin: 0.75rem 0 0.25rem; color: var(--steel); min-height: 1.5em; }
.search-results { list-style: none; padding: 0; margin: 0; }
.search-results li { padding: 0.75rem 0; border-bottom: 1px solid var(--rail); }
.search-results .result-title { font-size: 1.08rem; font-weight: 700; }
.search-results .result-kicker { font-family: var(--mono); font-size: 0.78rem; color: var(--steel); margin: 0; }
.search-results .result-excerpt { margin: 0.2rem 0 0; color: var(--steel); }
.browse-fallback { color: var(--steel); }

/* Cards */
.section { margin: 2.5rem 0; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.card { background: var(--surface); border: 1px solid var(--rail); border-radius: 6px; padding: 1.1rem 1.2rem; }
.card-title { margin: 0 0 0.1rem; font-size: 1.2rem; }
.card-title a { color: var(--ink); text-decoration-color: var(--rail-strong); display: inline-flex; align-items: center; min-height: 44px; }
.card-title a:hover { color: var(--green); }
.card p { margin: 0; color: var(--steel); }
.card .card-kicker, .card .card-meta { font-family: var(--mono); font-size: 0.78rem; margin-top: 0.5rem; }
.card .card-kicker { margin: 0 0 0.35rem; }
.link-list { padding-left: 1.2rem; }
.link-list li { margin: 0.1rem 0; }
/* Standalone links get full-size targets (design target about 44px). */
.link-list a, .toc a, .breadcrumbs a { display: inline-flex; align-items: center; min-height: 44px; }
.prose p.action { margin: 0.75rem 0; }
.prose p.action a, p.action .button-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0.4rem 1rem;
  border: 1px solid var(--control-border); border-radius: 4px; text-decoration: none; font-weight: 700;
}
.prose p.action a:hover { border-color: var(--green); }
p.action .button-link { border-color: var(--ink); }
.contact-callout { border-top: 1px solid var(--rail); padding-top: 1rem; }
.home-body { margin-top: 1rem; }
.unclear-link { margin: 2.5rem 0; padding-top: 1rem; border-top: 1px solid var(--rail); color: var(--steel); max-width: var(--measure); }

/* Footer */
.site-footer { border-top: 1px solid var(--rail); margin-top: 3rem; background: var(--paper-deep); }
.footer-inner { padding-top: 1.5rem; padding-bottom: 2rem; }
.footer-notice { max-width: var(--measure); margin: 0 0 1rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }
.footer-owner { font-family: var(--mono); font-size: 0.8rem; color: var(--steel); margin: 0; }

@media (prefers-reduced-motion: reduce) {
  /* The only animation is the zero-length search collapse, which moves nothing. */
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  :root {
    --ink: #000; --steel: #333; --green: #1B5E44; --paper: #fff; --paper-deep: #fff;
    --surface: #fff; --rail: #999; --rail-strong: #666; color-scheme: light;
  }
  .site-header, .site-footer nav, .footer-owner, .search, .browse-fallback, .skip-link, .unclear-link, .preview-banner { display: none; }
  body { background: #fff; color: #000; }
}

/* Phones: the main-site link is also in the footer, so drop it from the
   header and keep the three help links on one row. */
@media (max-width: 480px) {
  .site-nav .nav-main-site { display: none; }
  .site-nav ul { gap: 0 1rem; }
}
