/* ── Tokens ─────────────────────────────────────────────────────────── */

:root {
  --bg:           #fbfaf8;
  --bg-raised:    #ffffff;
  --text:         #1b1a18;
  --text-muted:   #5f5c56;
  /* Tuned against all three grounds this token actually lands on, not just
     --bg. It was #8b877f (3.43:1), then #75716a, which passed on --bg and
     --bg-raised but measured 4.38:1 on --accent-soft and failed AA there.
     This is 4.93 / 5.14 / 4.64:1 and keeps the warm hue. See BRAND.md. */
  --text-faint:   #716d67;
  --border:       #e3e0da;
  --border-firm:  #cfcbc3;
  --accent:       #9a3412;
  --accent-soft:  #fdf1ea;
  --shadow:       0 1px 2px rgba(27, 26, 24, .05), 0 8px 24px -12px rgba(27, 26, 24, .12);

  /* Battleships. Six grounds a square can be in, and they have to be told
     apart at a glance on a grid of sixty-four. None of them carries text —
     the coordinate is the button's accessible name — so these are judged as
     non-text against each other and against the board, not as body copy. */
  --bs-water:    #eae7e0;
  --bs-grid:     #cfcbc3;
  --bs-planned:  #f6d9c8;
  --bs-fired:    #a8a29a;
  --bs-hit:      #9a3412;
  --bs-miss:     #6f6b64;
  /* Game Boy DMG. Four shades, and they deliberately do NOT follow the site's
     theme the way everything else does — the panel is a physical object
     sitting on the page rather than part of it.

     Measured rather than eyeballed: ink on screen is 6.02:1 and on the alt
     shade 5.03:1, both clear of AA for text. Mid is 3.29:1 on screen but only
     2.75:1 on the alt shade, so mid is used for non-text ON THE SCREEN GROUND
     ONLY — moving it onto the alt shade drops it under the 3:1 non-text floor. */
  --dmg-screen:     #9bbc0f;
  --dmg-screen-alt: #8bac0f;
  --dmg-mid:        #306230;
  --dmg-ink:        #0f380f;
  --dmg-case:       rgba(15, 56, 15, .20);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --measure: 68ch;
  --page:    min(100% - 2.5rem, 60rem);
  --radius:  10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #131311;
    --bg-raised:    #1c1c19;
    --text:         #eceae5;
    --text-muted:   #a5a199;
    --text-faint:   #8c877f;
    --border:       #2e2d29;
    --border-firm:  #45433d;
    --accent:       #f0916a;
    --accent-soft:  #2a1c14;
    --shadow:       0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --bs-water:    #23231f;
    --bs-grid:     #45433d;
    --bs-planned:  #4a2e1e;
    --bs-fired:    #5c584f;
    --bs-hit:      #f0916a;
    --bs-miss:     #8c877f;
    /* Dimmed for a dark room: the ground drops from 0.43 to 0.33 relative
       luminance. Dimming alone would have COST contrast — near-black ink gets
       its ratio from how bright the ground is — so the ink goes darker to buy
       it back and the mid shade goes lighter to stay above 3:1.
       Ink 6.30:1 on screen, 5.26:1 on alt; mid 3.40:1 on screen. */
    --dmg-screen:     #8aa80d;
    --dmg-screen-alt: #7c990c;
    --dmg-mid:        #275027;
    --dmg-ink:        #082008;
    --dmg-case:       rgba(0, 0, 0, .45);
  }
}

:root[data-theme="dark"] {
  --bg:           #131311;
  --bg-raised:    #1c1c19;
  --text:         #eceae5;
  --text-muted:   #a5a199;
  --text-faint:   #8c877f;
  --border:       #2e2d29;
  --border-firm:  #45433d;
  --accent:       #f0916a;
  --accent-soft:  #2a1c14;
  --shadow:       0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --bs-water:    #23231f;
  --bs-grid:     #45433d;
  --bs-planned:  #4a2e1e;
  --bs-fired:    #5c584f;
  --bs-hit:      #f0916a;
  --bs-miss:     #8c877f;
  --dmg-screen:     #8aa80d;
  --dmg-screen-alt: #7c990c;
  --dmg-mid:        #275027;
  --dmg-ink:        #082008;
  --dmg-case:       rgba(0, 0, 0, .45);
}

/* ── Base ───────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 .5rem;
  font-weight: 640;
  text-wrap: balance;
}

h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); }
h2 { font-size: clamp(1.35rem, 1.15rem + .9vw, 1.75rem); }
h3 { font-size: 1.0625rem; }

p { margin: 0 0 1rem; max-width: var(--measure); }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

img, svg { max-width: 100%; height: auto; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg-raised);
  color: var(--text);
  padding: .6rem 1rem;
  border: 1px solid var(--border-firm);
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ── Layout ─────────────────────────────────────────────────────────── */

.wrap {
  width: var(--page);
  margin-inline: auto;
}

section { margin-block: 4rem; }
section:first-of-type { margin-top: 2.5rem; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: .6rem;
  margin-bottom: 1.75rem;
}
.section-head h2 { margin: 0; }
.section-head .note {
  color: var(--text-faint);
  font-size: .875rem;
}

/* ── Header / nav ───────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 660;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}
.brand:hover { color: var(--accent); }

/* The M inherits currentColor from .brand, so it follows the theme and the
   hover state without being restyled. Only the apostrophe is pinned to the
   accent — it is the part of the mark that carries the name. */
.brand-mark {
  width: 1.3rem;
  height: 1.3rem;
  flex: none;
  fill: currentColor;
}
.brand-mark .mark-a { fill: var(--accent); }

.nav {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9375rem;
  padding: .35rem .6rem;
  border-radius: 6px;
}
.nav a:hover { color: var(--text); background: var(--bg-raised); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 560; }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  margin-left: .35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-firm); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; }
.theme-toggle .icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-dark  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: none; }
}

/* ── Hero ───────────────────────────────────────────────────────────── */

.hero {
  padding-block: 4rem 1rem;
  margin-top: 0;
}

.hero .lede {
  font-size: 1.1875rem;
  color: var(--text-muted);
  max-width: 56ch;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: .75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-firm);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  font-weight: 520;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--text-faint); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
:root[data-theme="dark"] .btn-primary { color: #201009; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { color: #201009; }
}
.btn-primary:hover { filter: brightness(1.08); }

/* ── Project cards ──────────────────────────────────────────────────── */

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.25rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.card h3 { margin-bottom: .15rem; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { color: var(--accent); }

.card .role {
  font-size: .8125rem;
  color: var(--text-faint);
  margin-bottom: .75rem;
}

.card p {
  color: var(--text-muted);
  font-size: .9375rem;
  margin-bottom: 1.1rem;
}

.card .card-foot {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .9rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  list-style: none;
  padding: 0;
  margin: 0 0 .9rem;
}

.tags li {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .12rem .55rem;
}

.card-foot a {
  font-size: .875rem;
  font-weight: 520;
}

/* ── CV ─────────────────────────────────────────────────────────────── */

.cv-entry {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0 2rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--border);
}
.cv-entry:first-of-type { border-top: 0; padding-top: 0; }

.cv-entry .when {
  font-family: var(--font-mono);
  font-size: .8125rem;
  color: var(--text-faint);
  padding-top: .25rem;
}

.cv-entry h3 { margin-bottom: .1rem; }

.cv-entry .where {
  color: var(--text-muted);
  font-size: .9375rem;
  margin-bottom: .6rem;
}

.cv-entry ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
  font-size: .9375rem;
  max-width: var(--measure);
}
.cv-entry li { margin-bottom: .35rem; }

@media (max-width: 44rem) {
  .cv-entry { grid-template-columns: 1fr; gap: .35rem; }
  .cv-entry .when { padding-top: 0; }
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.25rem 2rem;
}
.skill-grid h3 { margin-bottom: .3rem; }
.skill-grid p { color: var(--text-muted); font-size: .9375rem; margin: 0; }

/* Fill-me-in markers — delete the class once the real content is in. */
.todo {
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  padding: .1rem .4rem;
  border-radius: 3px;
}

/* ── Write-up pages ─────────────────────────────────────────────────────
   Long-form project pages (agentic-delivery.html). Two audiences at once:
   a plain-English sentence carries each section, and the technical detail
   sits under it in a .detail block that reads as subordinate.

   Every colour here is an existing token — no new ones. Two deliberate
   choices worth knowing:

   1. .detail is marked by a hairline rule rather than a filled panel. It
      keeps the page quiet, and it keeps --text-faint on the page ground,
      where it measures 4.65:1 light / 4.62:1 dark. On --bg-raised that same
      token drops to 4.24:1 in dark mode and misses AA, so faint text is
      never placed on a raised ground here.
   2. No accent colour is spent on these components. Per BRAND.md the ember
      appears once per view, and on this page that is the brand mark.        */

.writeup section { margin-block: 3rem; }

.writeup h2 { margin-bottom: .75rem; }

/* The plain-English opener. Slightly larger than body copy so it reads as
   the sentence to stop at if you are reading only the headlines. */
.writeup .plain {
  font-size: 1.125rem;
  color: var(--text);
  max-width: var(--measure);
}

.detail {
  border-left: 2px solid var(--border);
  padding-left: 1.1rem;
  margin-block: 1.1rem;
  color: var(--text-muted);
  font-size: .9375rem;
}
.detail > :last-child { margin-bottom: 0; }

.detail .label {
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: .35rem;
}

/* Code. Nothing styled pre/code before this page, so both start here.
   Long lines scroll inside the block rather than widening the page. */
pre {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin: 0 0 1rem;
  overflow-x: auto;
  max-width: var(--measure);
}
pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: .8125rem;
  color: var(--text-muted);
}
code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .05rem .3rem;
  color: var(--text-muted);
}

/* The pipeline, as numbered steps. The counter sits in the mono stack so
   the step numbers match the eyebrows and dates elsewhere on the site. */
.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 1.25rem 0;
  max-width: var(--measure);
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: 1.1rem;
}
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: .15rem;
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: .08em;
  color: var(--text-faint);
}
.steps .who {
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: block;
}
.steps p { margin: .15rem 0 0; color: var(--text-muted); font-size: .9375rem; }

/* Small table. The wrapper scrolls, not the page. */
.table-scroll {
  overflow-x: auto;
  max-width: var(--measure);
  margin-bottom: 1rem;
}
.table-scroll table {
  border-collapse: collapse;
  width: 100%;
  font-size: .9375rem;
}
.table-scroll th {
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
  padding: .4rem .9rem .4rem 0;
  border-bottom: 1px solid var(--border);
}
.table-scroll td {
  color: var(--text-muted);
  padding: .55rem .9rem .55rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table-scroll tr:last-child td { border-bottom: 0; }

/* Where a screenshot will go once there is one to show. */
.shot {
  border: 1px dashed var(--border-firm);
  border-radius: var(--radius);
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--text-faint);
  font-size: .875rem;
  max-width: var(--measure);
}

/* ── Battleships ────────────────────────────────────────────────────────
   The game panel on battleships.html. Everything here is inside .bs, which
   the page ships empty — the prose around it is real markup and reads with
   scripting off.

   The board is sized in fractions rather than pixels so it survives 380px:
   `minmax(0, 1fr)` columns are what let the grid shrink instead of pushing
   the page sideways, and `aspect-ratio` keeps the squares square while it
   does. The plain look here is deliberate — the Game Boy screen treatment
   is a separate ticket, and it changes this section rather than the markup. */

.bs {
  margin-block: 1.5rem;
}

.bs-fallback {
  border: 1px dashed var(--border-firm);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .9375rem;
  max-width: var(--measure);
}

.bs-screen {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* ── Heads-up display ── */

.bs-round {
  margin: 0 0 .15rem;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.bs-sub {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: .9375rem;
}

.bs-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.75rem;
  list-style: none;
  padding: 0 0 1rem;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--border);
}

.bs-stats li {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.bs-stat-label {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.bs-stat-value {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Running low, on either shots or seconds. The accent is the site's one
   loud colour and it is not used anywhere else in the panel, so it reads as
   a warning without needing a red of its own. */
.bs-stat-value.is-low {
  color: var(--accent);
  font-weight: 640;
}

/* ── Board and side panel ── */

.bs-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 46rem) {
  .bs-body {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  }
}

.bs-board-wrap {
  max-width: 30rem;
  width: 100%;
}

.bs-board {
  display: grid;
  grid-template-columns: 1.4rem repeat(8, minmax(0, 1fr));
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem;
}

.bs-axis {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: .6875rem;
  color: var(--text-faint);
}

.bs-cell {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--bs-grid);
  border-radius: 2px;
  background: var(--bs-water);
  cursor: pointer;
  position: relative;
}

.bs-cell:disabled { cursor: default; }
.bs-cell:not(:disabled):hover { border-color: var(--text-faint); }

.bs-cell.is-planned {
  background: var(--bs-planned);
  border-color: var(--accent);
}

/* Fired at, result withheld — round 2's whole character in one square. The
   diagonal says "something happened here" without saying what. */
.bs-cell.is-fired {
  background: var(--bs-fired);
  border-color: var(--bs-fired);
}

.bs-cell.is-hit {
  background: var(--bs-hit);
  border-color: var(--bs-hit);
}

.bs-cell.is-miss {
  background: var(--bs-miss);
  border-color: var(--bs-miss);
  opacity: .55;
}

/* ── Fleet and reports ── */

.bs-aside h3 {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 .5rem;
}

.bs-fleet { margin-bottom: 1.25rem; }

.bs-fleet-list,
.bs-log-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.bs-ship {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .28rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}

.bs-ship-name { color: var(--text); }
.bs-ship-size {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-faint);
}

/* Rounds 1 and 2 do not say which ships have gone down, so their fleet list
   is deliberately undifferentiated. Only round 3 crosses anything off. */
.bs-ship.is-sunk .bs-ship-name {
  text-decoration: line-through;
  color: var(--text-faint);
}
.bs-ship.is-sunk .bs-ship-size { color: var(--accent); }

.bs-log-list {
  max-height: 16rem;
  overflow-y: auto;
}

.bs-log-line,
.bs-log-empty {
  font-size: .875rem;
  color: var(--text-muted);
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
}

.bs-log-empty { color: var(--text-faint); }
.bs-log-line.is-result { color: var(--text); font-weight: 520; }
.bs-log-line.is-warn,
.bs-log-line.is-time { color: var(--accent); }

/* ── Controls, results and the end of the game ── */

.bs-controls {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}

.bs-controls-note,
.bs-code-note {
  margin: 0;
  color: var(--text-faint);
  font-size: .875rem;
  max-width: var(--measure);
}

.bs-code-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}

.bs-code-label {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.bs-code-input {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  width: 6.5rem;
  padding: .5rem .6rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-firm);
  border-radius: var(--radius);
}

.bs-result,
.bs-summary { width: 100%; }

.bs-result h3,
.bs-summary h3 {
  margin: 0 0 .35rem;
  font-size: 1rem;
}

.bs-result-line {
  margin: 0;
  color: var(--text-muted);
  font-size: .9375rem;
}

.bs-summary-code {
  font-family: var(--font-mono);
  font-size: .8125rem;
  color: var(--text-faint);
  margin: 0 0 .75rem;
}

.bs-summary-list {
  margin: 0 0 .75rem;
  padding-left: 1.1rem;
}

.bs-summary-list li { margin-bottom: .5rem; }

.bs-summary-round {
  display: block;
  font-weight: 560;
}

.bs-summary-figures {
  display: block;
  font-family: var(--font-mono);
  font-size: .8125rem;
  color: var(--text-muted);
}

.bs-summary-note {
  color: var(--text-faint);
  font-size: .875rem;
  margin: 0;
  max-width: var(--measure);
}

/* ── The rules list on the page itself ── */

.bs-rounds {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.bs-rounds li {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.bs-rounds h3 { margin-bottom: .4rem; }
.bs-rounds p {
  margin: 0;
  color: var(--text-muted);
  font-size: .9375rem;
}

.bs-credit {
  color: var(--text-muted);
  font-size: .9375rem;
}

/* ── Battleships: the debrief ───────────────────────────────────────────
   Shown once round 3 is over. Two tables, a hand-drawn chart and a copy
   button. No new colour tokens: the three lines reuse --text-faint,
   --text-muted and --accent, which get stronger as the feedback loop gets
   faster — and each line also carries its own dash pattern, so colour is
   never the only thing telling them apart. */

.bs-debrief { width: 100%; }
.bs-debrief h3 { margin: 0 0 .35rem; font-size: 1rem; }

/* Both tables scroll inside their own box. Six columns will not fit a 380px
   phone, and a table taking the whole page sideways with it is the failure
   render.py checks for. */
.bs-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0 0 1.25rem;
}

.bs-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 26rem;
  font-size: .875rem;
}

.bs-table caption {
  caption-side: top;
  text-align: left;
  color: var(--text-faint);
  font-size: .8125rem;
  padding-bottom: .5rem;
}

.bs-table th,
.bs-table td {
  text-align: right;
  padding: .4rem .6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.bs-table thead th {
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 520;
}

.bs-table tbody th {
  text-align: left;
  font-weight: 560;
  color: var(--text);
}

.bs-table tbody td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.bs-table thead th:first-child { text-align: left; }
.bs-table-compact { min-width: 22rem; }

/* ── The chart ── */

.bs-chart {
  margin: 0 0 1.25rem;
  max-width: 30rem;
}

.bs-chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.bs-chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

/* Both `fill` and `color` are set to the same token. `fill` is what paints an
   SVG label; `color` is what a contrast audit reads off the element. Setting
   only one of them would leave the audit measuring a colour that is not on
   the screen, and passing for the wrong reason. */
.bs-chart-label {
  fill: var(--text-faint);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 9px;
}

.bs-chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.bs-chart-line.is-round-1 { stroke: var(--text-faint); stroke-dasharray: 2 4; }
.bs-chart-line.is-round-2 { stroke: var(--text-muted); stroke-dasharray: 8 4; }
.bs-chart-line.is-round-3 { stroke: var(--accent); }

.bs-chart-dot.is-round-1 { fill: var(--text-faint); }
.bs-chart-dot.is-round-2 { fill: var(--text-muted); }
.bs-chart-dot.is-round-3 { fill: var(--accent); }

.bs-chart figcaption {
  color: var(--text-faint);
  font-size: .8125rem;
  margin-top: .5rem;
}

.bs-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.1rem;
  list-style: none;
  padding: 0;
  margin: .6rem 0 0;
  font-size: .8125rem;
  color: var(--text-muted);
}

.bs-legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.bs-legend-swatch {
  width: 1.5rem;
  height: 0;
  border-top-width: 2px;
  border-top-style: solid;
  flex: none;
}

.bs-legend-item.is-round-1 .bs-legend-swatch {
  border-top-color: var(--text-faint);
  border-top-style: dotted;
}
.bs-legend-item.is-round-2 .bs-legend-swatch {
  border-top-color: var(--text-muted);
  border-top-style: dashed;
}
.bs-legend-item.is-round-3 .bs-legend-swatch {
  border-top-color: var(--accent);
}

/* ── The verdict and the copy control ── */

.bs-verdict { margin-bottom: 1rem; }

.bs-verdict-line {
  margin: 0 0 .5rem;
  font-size: 1rem;
  color: var(--text);
  max-width: var(--measure);
}

.bs-verdict-note {
  margin: 0;
  color: var(--text-muted);
  font-size: .875rem;
  max-width: var(--measure);
}

.bs-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  width: 100%;
}

.bs-copy-status {
  font-size: .875rem;
  color: var(--text-faint);
}
.bs-copy-status.is-ok { color: var(--accent); }
.bs-copy-status.is-manual { color: var(--text-muted); }

.bs-copy-fallback {
  width: 100%;
  font-family: var(--font-mono);
  font-size: .8125rem;
  line-height: 1.5;
  padding: .6rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-firm);
  border-radius: var(--radius);
  resize: vertical;
}

/* ── The written takeaway, which is real markup on the page ── */

.bs-mapping {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.bs-mapping li {
  border-left: 2px solid var(--border-firm);
  padding-left: 1rem;
}

.bs-mapping h3 { margin-bottom: .4rem; }
.bs-mapping p {
  margin: 0;
  color: var(--text-muted);
  font-size: .9375rem;
}

/* ── Battleships: the Game Boy screen ───────────────────────────────────
   Everything inside .bs-display is the handheld. The controls and the
   debrief below it stay on the site's own chrome, because a handheld shows
   the game — the write-up afterwards is a document, not a screen.

   The four shades have to cover five square states, which is one short. So
   the fifth is carried by a mark rather than a fill: a miss is the screen
   shade with a mid-green peg in it, the way a paper board is scored. That
   also means the states are not distinguished by colour alone. */

.bs-display {
  background: var(--dmg-screen);
  color: var(--dmg-ink);
  border: 1px solid var(--dmg-ink);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: inset 0 0 0 3px var(--dmg-case);
  position: relative;
  overflow: hidden;

  /* The square colours are redefined here rather than overridden rule by
     rule, so every .bs-cell inside the screen picks them up by inheritance. */
  --bs-water:    var(--dmg-screen);
  --bs-grid:     var(--dmg-ink);
  --bs-planned:  var(--dmg-screen);
  --bs-fired:    var(--dmg-mid);
  --bs-hit:      var(--dmg-ink);
  --bs-miss:     var(--dmg-screen);
}

/* Scanlines. Decorative, so it is marked aria-hidden by being a pseudo
   element, and it never sits over the text: pointer-events off, and it is
   switched off entirely under reduced motion below. */
.bs-display::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    var(--dmg-case) 0 1px,
    transparent 1px 3px
  );
  opacity: .35;
  animation: bs-flicker 4s steps(2) infinite;
}

@keyframes bs-flicker {
  0%, 92%  { opacity: .35; }
  96%      { opacity: .28; }
  100%     { opacity: .35; }
}

.bs-display .bs-round { color: var(--dmg-ink); }
.bs-display .bs-sub { color: var(--dmg-ink); }

.bs-display .bs-stats {
  border-bottom-color: var(--dmg-ink);
}

/* Ink for the labels too. A DMG has one ink colour, and the mid shade is
   3.29:1 — fine for a grid line, nowhere near the 4.5:1 that text needs. */
.bs-display .bs-stat-label,
.bs-display .bs-stat-value,
.bs-display .bs-aside h3,
.bs-display .bs-ship-name,
.bs-display .bs-ship-size,
.bs-display .bs-log-line,
.bs-display .bs-log-empty {
  color: var(--dmg-ink);
}

.bs-display .bs-stat-value.is-low {
  color: var(--dmg-ink);
  /* No second colour to reach for, so "low" is said with weight and a box
     rather than with hue — which is a better signal anyway. */
  background: var(--dmg-screen-alt);
  box-shadow: 0 0 0 2px var(--dmg-ink);
  border-radius: 2px;
  padding: 0 .25rem;
}

.bs-display .bs-board {
  background: var(--dmg-screen);
  border-color: var(--dmg-ink);
}

.bs-display .bs-axis { color: var(--dmg-ink); }

.bs-display .bs-ship,
.bs-display .bs-log-line,
.bs-display .bs-log-empty {
  border-bottom-color: var(--dmg-case);
}

.bs-display .bs-ship.is-sunk .bs-ship-name,
.bs-display .bs-ship.is-sunk .bs-ship-size { color: var(--dmg-ink); }

.bs-display .bs-cell {
  border-radius: 0;
  border-width: 1px;
  transition: none;
}

/* A planned shot: the screen shade, ringed and pipped in ink so it reads as
   "yours, not yet resolved" without spending one of the four shades on it. */
.bs-display .bs-cell.is-planned {
  border: 2px solid var(--dmg-ink);
}
.bs-display .bs-cell.is-planned::after,
.bs-display .bs-cell.is-miss::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  height: 34%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}
.bs-display .bs-cell.is-planned::after { background: var(--dmg-ink); }

/* A miss is the screen shade with a mid-green peg, which is 3.29:1 against
   it — the same way a miss is scored on paper, and the reason four shades
   can carry five states. */
.bs-display .bs-cell.is-miss {
  opacity: 1;
  border-color: var(--dmg-ink);
}
.bs-display .bs-cell.is-miss::after { background: var(--dmg-mid); }

.bs-display .bs-cell.is-fired { border-color: var(--dmg-ink); }
.bs-display .bs-cell.is-hit { border-color: var(--dmg-ink); }

.bs-display .bs-cell[aria-disabled="true"] { cursor: default; }
.bs-display .bs-cell[aria-disabled="false"]:hover { border-color: var(--dmg-mid); }

/* The focus ring is ink with a gap, so the gap always shows the screen shade
   behind it — 6.02:1 in light and 6.30:1 in dark, whatever the square itself
   is filled with, including a square filled with ink. */
.bs-display .bs-cell:focus-visible,
.bs-display .bs-sound:focus-visible {
  outline: 3px solid var(--dmg-ink);
  outline-offset: 2px;
  border-radius: 0;
  z-index: 1;
}

.bs-sound {
  margin-left: auto;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dmg-ink);
  background: var(--dmg-screen-alt);
  border: 1px solid var(--dmg-ink);
  border-radius: 3px;
  padding: .2rem .5rem;
  cursor: pointer;
}

.bs-display .bs-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: .25rem 1rem;
}
.bs-display .bs-round,
.bs-display .bs-sub { flex-basis: 100%; }
.bs-display .bs-stats { flex: 1 1 auto; }

/* The live region. Parked off-screen rather than hidden, because a region
   with display:none is never announced at all. Off to the left is also what
   keeps it out of the contrast audit, which skips anything whose box sits
   entirely off the canvas — the same treatment as the skip link. */
.bs-live {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Reduced motion: no scanline animation, no transitions anywhere in the
   panel. The scanline itself stays — it is texture, not movement — but it
   stops flickering. */
@media (prefers-reduced-motion: reduce) {
  .bs-display::after { animation: none; }
  .bs-display *,
  .bs-display *::before,
  .bs-display *::after { transition: none !important; }
}

/* Printed, the game panel is a grid of empty squares and a stopped clock.
   The prose prints; the panel does not, and this line says where the playable
   version lives. The rule that reveals it lives in the single @media print
   block at the foot of this file, with every other print rule. */
.bs-print-note { display: none; }

/* ── Footer ─────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 5rem;
  padding-block: 2rem 3rem;
  color: var(--text-faint);
  font-size: .875rem;
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  justify-content: space-between;
}
.site-footer a { color: var(--text-muted); }

/* ── Print (so the CV page prints cleanly) ──────────────────────────── */

@media print {
  :root {
    --bg: #fff; --bg-raised: #fff; --text: #000;
    --text-muted: #333; --text-faint: #555; --border: #ccc;
    --accent: #000; --accent-soft: #fff; --shadow: none;
  }
  .site-header, .site-footer, .actions, .skip-link { display: none; }
  /* ...except the CV's own contact block, which is the only way to reach
     Michael on a printed copy. index.html's .actions is navigation and stays
     hidden, so this un-hides one block rather than the selector. */
  .actions.contact { display: flex; margin-top: .6rem; }
  /* A "print this page" button is meaningless once the page is on paper. */
  .actions.contact [data-print] { display: none; }
  /* Flatten the buttons to plain text — a filled button wastes ink and reads
     badly in print. The email link's text is already the address itself. */
  .actions.contact .btn {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
  }
  body { font-size: 10.5pt; }
  section { margin-block: 1.5rem; page-break-inside: avoid; }
  .cv-entry { page-break-inside: avoid; }
  a { text-decoration: none; }
  .todo { background: none; border-left: 0; padding: 0; }
  /* Code cannot scroll on paper, so let it wrap instead of being clipped. */
  pre { white-space: pre-wrap; word-break: break-word; }
  .shot { display: none; }
  /* The counterpart to `.bs { display: none }` above: the panel goes, and a
     line of text pointing at the playable version takes its place. */
  .bs-print-note { display: block; font-size: 10pt; margin: 0 0 1rem; }
  /* An interactive board on paper is a grid of empty squares and a
     dead clock. The rules and the point of the exercise print; the
     panel does not. */
  .bs { display: none; }
}
