/* Accessible Games
   Off-white and charcoal rather than pure white and black, which are hard on the eyes
   on a bright screen (same values as jacobwood.me). Layout and type scale follow
   jacobwood.me. Every pairing is checked by scripts/check-contrast.mjs: body text meets
   WCAG AAA (7:1) and component edges meet 3:1, in both themes. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/assets/fonts/AtkinsonHyperlegibleNext-Variable.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/assets/fonts/AtkinsonHyperlegibleNext-Italic-Variable.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

/* === Color tokens === */
:root {
  color-scheme: light;
  --bg: #f9f9f7;          /* off-white */
  --surface: #efefec;
  --text: #1f1f1f;        /* charcoal */
  --muted: #4a4a48;
  --border: #767674;
  --rule: #d6d6d2;        /* decorative dividers only */
  --inverse-bg: #1f1f1f;
  --inverse-text: #f9f9f7;
  --focus: #1f1f1f;
  --focus-halo: #f9f9f7;
  --logo-border: transparent;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1f1f1f;          /* charcoal, not black */
  --surface: #2a2a2a;
  --text: #f9f9f7;
  --muted: #c8c8c4;
  --border: #949490;
  --rule: #3d3d3b;
  --inverse-bg: #141414;
  --inverse-text: #f9f9f7;
  --focus: #f9f9f7;
  --focus-halo: #1f1f1f;
  --logo-border: #c8c8c4; /* the logo's own near-black would vanish on charcoal */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1f1f1f;          /* charcoal, not black */
    --surface: #2a2a2a;
    --text: #f9f9f7;
    --muted: #c8c8c4;
    --border: #949490;
    --rule: #3d3d3b;
    --inverse-bg: #141414;
    --inverse-text: #f9f9f7;
    --focus: #f9f9f7;
    --focus-halo: #1f1f1f;
    --logo-border: #c8c8c4; /* the logo's own near-black would vanish on charcoal */
  }
}

/* === Base === */
/* Class styles like .button { display: inline-block } must never un-hide a hidden element. */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  font-family: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  font-size: 1.125rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: break-word;
}
button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 3px; }

/* One focus style everywhere: a thick ring with a contrasting halo, visible on any background. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--focus-halo);
}
main:focus { outline: none; }

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

h1, h2, h3, h4, h5, h6 { line-height: 1.2; font-weight: 700; margin: 2rem 0 0.75rem; }
h1 { font-size: 2.5rem; margin-top: 0.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5, h6 { font-size: 1.125rem; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
@media (min-width: 640px) { .container { padding: 0 1.5rem; } }

.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 50;
  background: var(--inverse-bg); color: var(--inverse-text);
  padding: 0.75rem 1.25rem; font-weight: 700; border-radius: 0.5rem;
}
.skip-link:focus { top: 1rem; }

/* === Header === */
.site-header { border-bottom: 1px solid var(--rule); padding: 1.5rem 0; }
.header-inner { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
@media (min-width: 900px) { .header-inner { flex-direction: row; justify-content: space-between; } }

.brand { display: flex; align-items: center; gap: 1rem; text-decoration: none; }
.brand img { width: 72px; height: auto; border-radius: 8px; border: 2px solid var(--logo-border); }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 1.75rem; font-weight: 800; line-height: 1.1; }
.brand-tagline { color: var(--muted); font-size: 1rem; }
.brand:hover .brand-name { text-decoration: underline; }

.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.25rem; }
.site-nav a { display: inline-block; padding: 0.5rem 0.125rem; font-weight: 700; text-decoration: none; border-bottom: 3px solid transparent; }
.site-nav a:hover { border-bottom-color: var(--border); }
.site-nav a[aria-current] { border-bottom-color: var(--text); }

/* === Main content === */
main { padding: 2.5rem 0 4rem; display: block; }
.prose-wrap { max-width: 48rem; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.25rem; }
.prose li { margin-bottom: 0.4rem; }
.prose blockquote {
  margin: 1.5rem 0; padding: 0.75rem 1.25rem;
  border-left: 6px solid var(--text); background: var(--surface);
}
.prose figure { margin: 1.5rem 0; }
.prose figcaption { color: var(--muted); font-size: 1rem; margin-top: 0.5rem; }
.prose table { border-collapse: collapse; width: 100%; margin: 1.5rem 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; }
.prose th { background: var(--surface); }
.prose code { font-size: 0.95em; background: var(--surface); padding: 0.1em 0.3em; border-radius: 3px; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

.prose iframe { max-width: 100%; border: 0; }
.video { position: relative; aspect-ratio: 16 / 9; margin: 1.5rem 0; background: var(--surface); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.gallery { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; border-radius: 4px; }

.download a { font-weight: 700; }
.download, .file-info { color: var(--muted); }

/* === Posts === */
.eyebrow { margin: 0; font-weight: 700; }
.entry-meta { color: var(--muted); margin: 0.25rem 0 1rem; }
.entry-meta a { color: var(--muted); }
.series-note, .rating {
  background: var(--surface); border-left: 6px solid var(--text);
  padding: 0.5rem 1rem; margin: 0 0 1rem;
}
.entry-header { margin-bottom: 2rem; }
.entry-footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.small-heading { font-size: 1.125rem; margin-top: 0; }
.tag-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-list a { display: inline-block; padding: 0.25rem 0.75rem; border: 1px solid var(--border); border-radius: 2rem; text-decoration: none; font-size: 1rem; }
.tag-list a:hover { background: var(--surface); }

.post-nav { margin-top: 3rem; border-top: 1px solid var(--rule); padding-top: 1.5rem; }
.post-nav ul { list-style: none; padding: 0; display: grid; gap: 1rem; }
@media (min-width: 640px) { .post-nav ul { grid-template-columns: 1fr 1fr; } .post-nav .newer { text-align: right; grid-column: 2; } }
.post-nav .label { display: block; color: var(--muted); font-size: 1rem; }
.post-nav a { font-weight: 700; }

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list > li { border-bottom: 1px solid var(--rule); padding: 1.25rem 0; }
.post-summary h2, .post-summary h3 { font-size: 1.5rem; margin: 0 0 0.25rem; }
.post-summary p { margin: 0.25rem 0 0; }
.post-summary .entry-meta { margin-bottom: 0.5rem; }

.archive-list, .term-list, .download-list { padding-left: 1.25rem; }
.archive-list li, .download-list li { margin-bottom: 0.5rem; }
.archive-list time { color: var(--muted); white-space: nowrap; font-size: 1rem; }
.count { color: var(--muted); font-weight: 400; font-size: 1.125rem; }

.pager ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; margin-top: 2rem; }
.pager a { font-weight: 700; }
.pager-status { color: var(--muted); }

/* === Pages === */
.breadcrumbs ol { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: 0.25rem; font-size: 1rem; }
.breadcrumbs li:not(:last-child)::after { content: "/"; margin-left: 0.4rem; color: var(--muted); }
.breadcrumbs a[aria-current] { text-decoration: none; font-weight: 700; }

.section { margin-top: 3.5rem; }
.card-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 0.5rem; padding: 1.25rem 1.5rem; }
.card h3 { font-size: 1.25rem; margin: 0 0 0.5rem; }
.card p { margin: 0; color: var(--muted); font-size: 1rem; }

/* === Home === */
.hero { text-align: center; padding: 1.5rem 0 1rem; max-width: 46rem; margin: 0 auto; }
.hero h1 { font-size: clamp(2.25rem, 6vw, 3.25rem); margin-top: 0; }
.lede { font-size: 1.3rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; margin-top: 1.5rem; }
.more-link { font-weight: 700; }

/* === Buttons and forms === */
.button {
  display: inline-block; cursor: pointer;
  background: var(--text); color: var(--bg);
  border: 2px solid var(--text); border-radius: 2rem;
  padding: 0.7rem 1.75rem; font-weight: 700; text-decoration: none;
}
.button:hover { background: var(--bg); color: var(--text); }
.button-secondary { background: var(--bg); color: var(--text); }
.button-secondary:hover { background: var(--surface); }

.contact-form { max-width: 36rem; margin-top: 1rem; }
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.field input, .field textarea {
  width: 100%; padding: 0.65rem 0.75rem; background: var(--bg);
  border: 2px solid var(--border); border-radius: 0.375rem;
}
.field input:focus-visible, .field textarea:focus-visible { border-color: var(--text); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* === Footer === */
.site-footer { background: var(--inverse-bg); color: var(--inverse-text); padding: 2.5rem 0; font-size: 1rem; }
.site-footer a { color: var(--inverse-text); }
.site-footer { --focus: var(--inverse-text); --focus-halo: var(--inverse-bg); }
.footer-inner { display: grid; gap: 2rem; }
@media (min-width: 800px) { .footer-inner { grid-template-columns: 2fr 1.5fr 1.5fr 1fr; } }
.footer-name { font-weight: 800; font-size: 1.25rem; margin: 0 0 0.25rem; }
.footer-label { font-weight: 700; margin: 0 0 0.5rem; }
.site-footer p { margin: 0 0 0.5rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 0.4rem; }
.theme-toggle {
  background: transparent; color: var(--text); cursor: pointer; white-space: nowrap;
  border: 2px solid var(--border); border-radius: 2rem; padding: 0.35rem 1rem; font-weight: 700; font-size: 1rem;
}
.theme-toggle:hover { border-color: var(--text); }

@media (forced-colors: active) {
  .button, .theme-toggle, .card, .tag-list a { border: 2px solid ButtonText; }
  .site-nav a[aria-current] { border-bottom-color: Highlight; }
}

/* === Topics === */
.term-descriptions dt { font-weight: 700; margin-top: 1rem; }
.term-descriptions dd { margin: 0.25rem 0 0; color: var(--muted); }
.term-columns { columns: 16rem; column-gap: 2rem; }
.term-columns li { break-inside: avoid; margin-bottom: 0.35rem; }
.topic-nav { margin: 1rem 0 0.5rem; }
.related { margin-top: 3rem; }
.related ul { padding-left: 1.25rem; }
.related time { color: var(--muted); font-size: 1rem; white-space: nowrap; }

/* === Table of contents === */
.toc {
  background: var(--surface); border: 1px solid var(--border); border-radius: 0.5rem;
  padding: 1rem 1.5rem; margin: 0 0 2rem;
}
.toc h2 { font-size: 1.25rem; margin: 0 0 0.5rem; }
.toc ol { margin: 0; padding-left: 1.5rem; }
.toc ol ol { margin-top: 0.25rem; list-style: lower-alpha; }
.toc li { margin-bottom: 0.3rem; }
.prose :is(h2, h3)[id] { scroll-margin-top: 1rem; }

/* === Click-to-play videos === */
.video-play {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; padding: 0; margin: 0; border: 0; cursor: pointer;
  background: #000; color: #fff; text-align: left; font: inherit; text-decoration: none;
}
.video-play img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.75rem 1rem; background: rgba(0, 0, 0, 0.88); /* white text stays above 15:1 */
}
.video-icon {
  flex: none; width: 3rem; height: 3rem; border-radius: 50%; background: #fff; position: relative;
}
.video-icon::after {
  content: ""; position: absolute; left: 1.2rem; top: 0.85rem;
  border-style: solid; border-width: 0.65rem 0 0.65rem 1.05rem; border-color: transparent transparent transparent #000;
}
.video-text { display: flex; flex-direction: column; line-height: 1.3; }
.video-action { font-weight: 800; }
.video-sep { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.video-title { font-size: 1rem; }
.video-play:hover .video-action { text-decoration: underline; }
.video-play:hover .video-icon { outline: 3px solid #fff; outline-offset: 2px; }
.video-play:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 3px var(--focus-halo); }
@media (forced-colors: active) {
  .video-label { background: Canvas; color: CanvasText; border-top: 2px solid CanvasText; }
  .video-icon { background: ButtonText; }
}
/* On narrow screens the title sits below the thumbnail instead of covering it. */
@media (max-width: 600px) {
  .video.video-facade { aspect-ratio: auto; }
  .video-facade .video-play { position: static; height: auto; }
  .video-facade .video-play img { aspect-ratio: 16 / 9; height: auto; }
  .video-facade .video-label { position: static; background: #000; }
  .video-icon { width: 2.5rem; height: 2.5rem; }
  .video-icon::after { left: 1rem; top: 0.7rem; border-width: 0.55rem 0 0.55rem 0.9rem; }
}

/* === Accordion === */
.accordion { margin-top: 1.5rem; border-top: 1px solid var(--border); }
.accordion-heading { margin: 0; font-size: 1.375rem; border-bottom: 1px solid var(--border); }
.accordion-heading button {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 1rem 0.25rem; background: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--text); text-align: left;
}
.accordion-heading button::before {
  content: ""; flex: none; width: 0.6rem; height: 0.6rem; margin: 0 0.4rem 0 0.2rem;
  border-right: 3px solid currentColor; border-bottom: 3px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s;
}
.accordion-heading button[aria-expanded="true"]::before { transform: rotate(45deg); }
.accordion-heading button:hover .accordion-title { text-decoration: underline; }
.accordion-count { font-weight: 400; color: var(--muted); font-size: 1.125rem; }
.accordion-panel { padding: 0.25rem 0 1rem; border-bottom: 1px solid var(--border); }
.accordion-panel .download-list { margin: 0.5rem 0 0; }
@media (prefers-reduced-motion: reduce) { .accordion-heading button::before { transition: none; } }
@media (forced-colors: active) { .accordion-heading button::before { border-color: ButtonText; } }

/* === Search === */
.search-form label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.search-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.search-row input {
  flex: 1 1 16rem; padding: 0.65rem 0.75rem; background: var(--bg);
  border: 2px solid var(--border); border-radius: 0.375rem;
}
.search-row input:focus-visible { border-color: var(--text); }
.search-status { margin: 1.5rem 0 0.5rem; font-weight: 700; min-height: 1.6em; }
.search-results { padding-left: 1.5rem; }
.search-results > li { border-bottom: 1px solid var(--rule); padding: 1rem 0; }
.search-results h2 { font-size: 1.375rem; margin: 0 0 0.25rem; }
.search-results p { margin: 0.25rem 0 0; }
/* Matched words: bold and underlined in the page's own colors (default yellow fails in dark mode). */
.search-results mark { background: transparent; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; }
