/*
 * The Puzzle Picnic blog. Direction: PAPER & INK, an editorial newsprint page, same tokens as the app and the site
 * (src/shell/theme.css, site/static/site.css): warm paper, near-black ink, one signal red, hairline rules, hard offset
 * shadows. Each game brings its own hue through [data-game]. System fonts only; light and dark follow the OS.
 */

:root {
  --paper: #f2ecdf;
  --paper-raised: #faf6ec;
  --paper-sunk: #e7dfcd;
  --ink: #1c1a16;
  --ink-soft: #4f493e;
  --rule: rgb(28 26 22 / 0.16);
  --rule-strong: rgb(28 26 22 / 0.88);
  --signal: #c8402a;
  --on-signal: #fffaf0;
  --hue-sudoku: #3a54c9;
  --hue-bridges: #b9520a;
  --hue-ships: #08767e;
  --hue-lines: #9131b0;
  --hue-stars: #b02a5f;
  --hue-trail: #3a7a14;
  --game: var(--signal);

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Noto Serif", Georgia, serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;

  --text-sm: 0.875rem;
  --text-body: 1.0625rem;
  --text-md: 1.1875rem;
  --text-lg: 1.375rem;
  --text-xl: clamp(1.55rem, 1.25rem + 1.3vw, 2rem);
  --text-display: clamp(2.3rem, 1.5rem + 3.6vw, 3.9rem);
  --track-eyebrow: 0.16em;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 22px;
  --offset: 6px;
  --measure: 68ch;
  --page: 74rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light dark;
}

/*
 * Dark tokens. Auto (no data-theme) follows the OS; the theme button (static/theme.js) sets data-theme="light" or
 * "dark" on <html> to override it. The two dark blocks must stay identical (scripts/css.test.mjs checks).
 */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #15130f;
  --paper-raised: #1e1b16;
  --paper-sunk: #0f0d0a;
  --ink: #efe7d6;
  --ink-soft: #c2baa8;
  --rule: rgb(239 231 214 / 0.16);
  --rule-strong: rgb(239 231 214 / 0.85);
  --signal: #ff7f5f;
  --on-signal: #1a0f0a;
  --hue-sudoku: #93a9ff;
  --hue-bridges: #ffae5c;
  --hue-ships: #4fd6cf;
  --hue-lines: #e39cf8;
  --hue-stars: #ff8fbd;
  --hue-trail: #9bdc6a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #15130f;
    --paper-raised: #1e1b16;
    --paper-sunk: #0f0d0a;
    --ink: #efe7d6;
    --ink-soft: #c2baa8;
    --rule: rgb(239 231 214 / 0.16);
    --rule-strong: rgb(239 231 214 / 0.85);
    --signal: #ff7f5f;
    --on-signal: #1a0f0a;
    --hue-sudoku: #93a9ff;
    --hue-bridges: #ffae5c;
    --hue-ships: #4fd6cf;
    --hue-lines: #e39cf8;
    --hue-stars: #ff8fbd;
    --hue-trail: #9bdc6a;
  }
}

[data-game="sudoku"] { --game: var(--hue-sudoku); }
[data-game="bridges"] { --game: var(--hue-bridges); }
[data-game="ships"] { --game: var(--hue-ships); }
[data-game="lines"] { --game: var(--hue-lines); }
[data-game="stars"] { --game: var(--hue-stars); }
[data-game="trail"] { --game: var(--hue-trail); }

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--space-5);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.65;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }
main:focus { outline: none; }

svg { max-width: 100%; }

a {
  color: var(--ink);
  text-decoration-color: var(--game);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

a:hover { color: var(--signal); }

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

::selection {
  background: var(--signal);
  color: var(--on-signal);
}

.skip {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-m);
}

.skip:focus { top: var(--space-3); }

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: max(var(--space-5), env(safe-area-inset-left, 0px)) max(var(--space-5), env(safe-area-inset-right, 0px));
}

/* ---- Type ---- */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-4); }

.lede {
  font-size: var(--text-md);
  color: var(--ink-soft);
  max-width: 52ch;
  margin-top: var(--space-4);
}

.muted {
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.eyebrow {
  margin: 0 0 var(--space-3);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink-soft);
}

.eyebrow a { text-decoration: none; color: inherit; }
.eyebrow a:hover { color: var(--signal); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--paper-sunk);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

/* ---- Masthead ---- */
.masthead {
  border-bottom: 1px solid var(--rule-strong);
  padding-top: env(safe-area-inset-top, 0px);
}

.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  padding-block: var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.brand-name {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-blog {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--signal);
  line-height: 1;
}

.logo-mark {
  --mk-edge: #221b35;
  --mk-sudoku: #3a54c9;
  --mk-bridges: #b9520a;
  --mk-ships: #08767e;
  --mk-lines: #9131b0;
  flex: none;
  overflow: visible;
}
.mk-depth { fill: var(--mk-edge); }
.mk-tile { stroke: var(--mk-edge); stroke-width: 26px; }
.mk-sudoku { fill: var(--mk-sudoku); }
.mk-bridges { fill: var(--mk-bridges); }
.mk-ships { fill: var(--mk-ships); }
.mk-lines { fill: var(--mk-lines); }
:root[data-theme="dark"] .logo-mark {
  --mk-edge: #07050f;
  --mk-sudoku: #93a9ff;
  --mk-bridges: #ffae5c;
  --mk-ships: #4fd6cf;
  --mk-lines: #e39cf8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-mark {
    --mk-edge: #07050f;
    --mk-sudoku: #93a9ff;
    --mk-bridges: #ffae5c;
    --mk-ships: #4fd6cf;
    --mk-lines: #e39cf8;
  }
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-5);
  list-style: none;
  margin: 0;
  padding: 0;
  font-weight: 600;
  font-size: var(--text-sm);
}

.nav a {
  display: inline-block;
  padding-block: var(--space-2);
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--signal);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

.nav .nav-play {
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: var(--space-1) var(--space-4);
  box-shadow: 3px 3px 0 var(--ink);
}

.nav .nav-play:hover {
  text-decoration: none;
  color: var(--ink);
  background: var(--paper-raised);
}

/* ---- Buttons ---- */
.btn,
.btn-plain {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  padding: var(--space-3) var(--space-5);
  border: 2px solid var(--ink);
  border-radius: var(--radius-m);
  font-weight: 700;
  text-decoration: none;
  margin: 0 var(--space-3) var(--space-3) 0;
}

.btn {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--on-signal);
  box-shadow: 4px 4px 0 var(--ink);
}

.btn-plain {
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.btn:hover,
.btn-plain:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.btn:hover { color: var(--on-signal); }
.btn-plain:hover { color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .btn, .btn-plain, .card { transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out); }
}

/* ---- Breadcrumbs ---- */
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 600;
}

.crumbs li + li::before {
  content: "/";
  margin-right: var(--space-2);
  color: var(--ink-soft);
}

.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---- Drawings ---- */
.motif { display: block; width: 100%; height: auto; overflow: visible; }
.m-ink { stroke: var(--ink); stroke-opacity: 0.7; fill: none; }
.m-game { fill: var(--game); }
.m-digit { font: 600 13px var(--font-display); fill: var(--ink); text-anchor: middle; }
.m-small { font: 700 9px var(--font-body); text-anchor: middle; }
.m-on { fill: var(--paper-raised); }
.m-bridge { stroke: var(--ink); stroke-width: 3; }
.m-island { fill: var(--game); stroke: var(--ink); stroke-width: 2.5; }
.m-sea { fill: color-mix(in srgb, var(--game) 14%, var(--paper-raised)); stroke: var(--rule-strong); stroke-width: 1; }
.m-line { fill: none; stroke: var(--game); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.m-head { fill: var(--game); }
.m-soft { stroke: var(--ink); stroke-opacity: 0.55; }
.m-soft-fill { fill: var(--ink); fill-opacity: 0.55; }
.m-wall { stroke: var(--ink); stroke-width: 3.5; stroke-linecap: square; }
.m-frame { fill: none; stroke: var(--ink); stroke-width: 3.5; }
.m-t { stroke: #221b35; stroke-width: 3; }
.m-t1 { fill: var(--hue-sudoku); }
.m-t2 { fill: var(--hue-bridges); }
.m-t3 { fill: var(--hue-ships); }
.m-t4 { fill: var(--hue-lines); }
.m-t5 { fill: var(--hue-stars); }
.m-t6 { fill: var(--hue-trail); }

/* ---- Home and topic heroes ---- */
.hero {
  padding-block: var(--space-7) var(--space-6);
}

.hero h1 { max-width: 18ch; }

.topic-hero h1 { max-width: 20ch; }

/* ---- Cards ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-5);
  margin-block: var(--space-5) var(--space-7);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper-raised);
  border: 2px solid var(--ink);
  border-top: 8px solid var(--game);
  border-radius: var(--radius-m);
  padding: var(--space-5);
  box-shadow: var(--offset) var(--offset) 0 var(--ink);
}

.card:hover {
  transform: translate(-2px, -2px);
  box-shadow: calc(var(--offset) + 2px) calc(var(--offset) + 2px) 0 var(--game);
}

.card-title {
  font-size: 1.3rem;
  margin-bottom: var(--space-3);
}

.card-title a { text-decoration: none; }
/* The whole card is the post's link. */
.card-title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-m); }
.card .eyebrow a { position: relative; z-index: 1; }

.card-text {
  color: var(--ink-soft);
  font-size: 0.95rem;
  flex: 1;
}

.card-meta { margin: 0; }

.featured h2,
.related h2 {
  font-size: var(--text-xl);
  padding-top: var(--space-4);
  border-top: 2px solid var(--rule-strong);
}

/* ---- Topic bands on the home page ---- */
.topic-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  padding-block: var(--space-6);
  border-top: 2px solid var(--rule-strong);
}

.topic-band-head {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.topic-band h2 a { text-decoration: none; }
.topic-band h2 a:hover { text-decoration: underline; }
.topic-band h2 { margin-bottom: var(--space-2); }

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2 22rem;
  column-gap: var(--space-6);
}

.post-list li {
  break-inside: avoid;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--rule);
}

.post-list a {
  font-weight: 600;
  text-decoration-color: var(--game);
}

@media (min-width: 60rem) {
  .topic-band { grid-template-columns: 22rem minmax(0, 1fr); gap: var(--space-7); }
  .topic-band-head { grid-template-columns: 1fr; }
  .topic-art { max-width: 14rem; }
}

/* ---- Post ---- */
.post-head {
  padding-block: var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--rule-strong);
}

.post-head-grid {
  display: grid;
  gap: var(--space-5);
  align-items: end;
}

.post-head h1 { max-width: 22ch; }

.post-art {
  max-width: 15rem;
  padding: var(--space-4);
  background: var(--paper-raised);
  border: 2px solid var(--ink);
  border-radius: var(--radius-l);
  box-shadow: var(--offset) var(--offset) 0 var(--game);
}

@media (min-width: 52rem) {
  .post-head-grid { grid-template-columns: minmax(0, 1fr) 15rem; }
  .post-art { transform: rotate(1.5deg); }
}

.byline {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin: var(--space-4) 0 0;
}

.post-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "takeaways" "toc" "body" "play" "author";
  gap: 0 var(--space-7);
  padding-block: var(--space-6) var(--space-7);
}

.takeaways { grid-area: takeaways; }
.toc { grid-area: toc; }
.post-grid > .prose { grid-area: body; }
.play-box { grid-area: play; }
.author { grid-area: author; }

@media (min-width: 64rem) {
  .post-grid {
    grid-template-columns: 15rem minmax(0, var(--measure));
    grid-template-areas: "toc takeaways" "toc body" "toc play" "toc author";
    justify-content: start;
  }
  .toc { position: sticky; top: var(--space-5); align-self: start; max-height: calc(100dvh - 3rem); overflow-y: auto; }
}

.takeaways {
  background: var(--paper-raised);
  border: 2px solid var(--ink);
  border-radius: var(--radius-m);
  padding: var(--space-5);
  box-shadow: var(--offset) var(--offset) 0 var(--game);
  margin-bottom: var(--space-6);
}

.takeaways-title,
.toc-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: var(--space-3);
}

.takeaways ul {
  margin: 0;
  padding-left: 1.2rem;
}

.takeaways li { margin-bottom: var(--space-2); }
.takeaways li:last-child { margin-bottom: 0; }
.takeaways li::marker { color: var(--game); }

.toc {
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
  border-bottom: 1px solid var(--rule);
}

.toc a {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  padding: var(--space-2) 0;
  text-decoration: none;
  line-height: 1.35;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--game);
  padding-top: 0.15em;
}

.toc a:hover { color: var(--signal); }

/* ---- Prose ---- */
.prose h2 {
  margin: var(--space-7) 0 var(--space-4);
  padding-top: var(--space-4);
  border-top: 2px solid var(--rule-strong);
}

.prose h3 { margin: var(--space-6) 0 var(--space-3); }
.prose h2 + h3 { margin-top: var(--space-4); }
.prose > :first-child { margin-top: 0; }

.prose > p:first-child {
  font-size: var(--text-md);
  line-height: 1.6;
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
  margin: 0 0 var(--space-4);
}

.prose li { margin-bottom: var(--space-2); }

.prose li::marker {
  color: var(--game);
  font-weight: 700;
}

.callout {
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  border-left: 6px solid var(--game);
  background: color-mix(in srgb, var(--game) 9%, var(--paper-raised));
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
}

.callout p { margin: 0; }

.diagram {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.4;
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-m);
  padding: var(--space-4);
  overflow-x: auto;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: var(--space-5) 0;
  border: 2px solid var(--ink);
  border-radius: var(--radius-m);
  background: var(--paper-raised);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table-wrap th,
.table-wrap td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
}

.table-wrap thead th {
  background: var(--ink);
  color: var(--paper);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
}

.table-wrap tbody tr:last-child td { border-bottom: 0; }

/* Puzzle diagrams (```grid blocks) */
.grid-figure {
  margin: var(--space-6) 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
}

.puzzle-grid {
  border-collapse: collapse;
  border: 3px solid var(--ink);
  background: var(--paper-raised);
  box-shadow: var(--offset) var(--offset) 0 var(--game);
  font-family: var(--font-display);
  font-weight: 600;
}

.puzzle-grid td {
  width: 2.4rem;
  height: 2.4rem;
  min-width: 2.4rem;
  border: 1px solid var(--rule-strong);
  text-align: center;
  vertical-align: middle;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
}

.puzzle-grid .fill { background: var(--ink); }
.puzzle-grid .water { background: color-mix(in srgb, var(--hue-ships) 22%, var(--paper-raised)); }
.puzzle-grid .star { color: var(--game); font-size: 1.4rem; }
.puzzle-grid .x { color: var(--ink-soft); font-family: var(--font-body); font-weight: 400; }
.puzzle-grid .hl { background: color-mix(in srgb, var(--game) 30%, var(--paper-raised)); box-shadow: inset 0 0 0 3px var(--game); }
.puzzle-grid .fill.hl { background: var(--game); }

@media (max-width: 30rem) {
  .puzzle-grid td { width: 2rem; height: 2rem; min-width: 2rem; font-size: 1rem; }
}

.grid-figure figcaption {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  max-width: 56ch;
}

/* ---- Play box and author ---- */
.play-box {
  display: grid;
  gap: var(--space-4);
  align-items: center;
  margin: var(--space-7) 0 var(--space-5);
  padding: var(--space-6);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-l);
  box-shadow: var(--offset) var(--offset) 0 var(--game);
}

.play-box .eyebrow,
.play-box .muted { color: color-mix(in srgb, var(--paper) 75%, transparent); }
.play-box a { color: var(--paper); }
.play-box .btn { color: var(--on-signal); box-shadow: 4px 4px 0 var(--game); margin: 0; }
.play-box p:last-child { margin-bottom: 0; }

.play-title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}

@media (min-width: 40rem) {
  .play-box { grid-template-columns: minmax(0, 1fr) auto; }
}

.author {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  border-top: 1px solid var(--rule-strong);
  padding-top: var(--space-4);
}

.related { padding-bottom: var(--space-4); }

.about,
.not-found { padding-block: var(--space-7); }
.about > *, .not-found > * { max-width: var(--measure); }

/* ---- Footer ---- */
.footer {
  border-top: 2px solid var(--rule-strong);
  background: var(--paper-sunk);
  padding-block: var(--space-7);
  padding-bottom: max(var(--space-7), env(safe-area-inset-bottom, 0px));
}

.footer-grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
}

.footer-grid > div:first-child { grid-column: span 2; max-width: 32rem; }

@media (max-width: 30rem) {
  .footer-grid > div:first-child { grid-column: auto; }
}

.footer-brand {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.footer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
}

.footer-list li { margin-bottom: var(--space-2); }
.footer-list a { text-decoration: none; }
.footer-list a:hover, .footer-list a[aria-current="page"] { text-decoration: underline; }

@media print {
  .masthead, .footer, .toc, .play-box, .related, .post-art { display: none; }
  .post-grid { display: block; }
}

/* ---- Home hero: the six games as tiles ---- */
.home-hero {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

.hero-art {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  max-width: 30rem;
}

.hero-tile {
  display: block;
  padding: var(--space-3);
  background: var(--paper-raised);
  border: 2px solid var(--ink);
  border-radius: var(--radius-m);
  box-shadow: 4px 4px 0 var(--game);
}

.hero-tile:nth-child(odd) { transform: rotate(-2deg); }
.hero-tile:nth-child(3n) { transform: rotate(2.5deg); }

.hero-tile:hover {
  box-shadow: 6px 6px 0 var(--game);
  transform: rotate(0) translate(-2px, -2px);
}

@media (prefers-reduced-motion: no-preference) {
  .hero-tile { transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out); }
}

@media (min-width: 60rem) {
  .home-hero { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
}

/* Path-puzzle walls drawn from ".|" / "._" grid cells. */
.puzzle-grid .wall-r { border-right: 4px solid var(--ink); }
.puzzle-grid .wall-b { border-bottom: 4px solid var(--ink); }

/* ---- Theme button (masthead) ---- */
.nav li:has(> .theme-toggle[hidden]) { display: none; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.25rem;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.theme-toggle:hover { background: var(--paper-raised); }
.theme-toggle:active { transform: translateY(1px); }

.theme-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  display: none;
}

.theme-icon .theme-fill { fill: currentColor; stroke: none; }
.theme-icon-dark .theme-fill { fill: currentColor; }
.theme-toggle[data-state="auto"] .theme-icon-auto,
.theme-toggle[data-state="light"] .theme-icon-light,
.theme-toggle[data-state="dark"] .theme-icon-dark { display: block; }

@media (max-width: 30rem) {
  .nav { gap: var(--space-1) var(--space-4); }
  .theme-toggle { padding-inline: var(--space-2); }
  /* Icon only on small phones; the button keeps its full name through aria-label. */
  .theme-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
