/*
 * The reading pages: guides, the blog and the update log (built by scripts/site/pages.ts). The game's palette
 * (src/ui/tokens.css), Archivo for text and Big Shoulders for display. No inline style. Dark by default; a light
 * palette when the device asks for it or the rider picks it with the header button (/gate/theme.js sets data-theme).
 */
@font-face {
  font-family: 'Archivo';
  src: url('/gate/archivo-var.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Big Shoulders';
  src: url('/gate/big-shoulders-800.woff2') format('woff2');
  font-weight: 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page: #151b20;
  --page-2: #11161a;
  --surface: #1e262c;
  --surface-2: #252f36;
  --border: #39444b;
  --text: #f1f3ee;
  --text-2: #b5c0c6;
  --crust: #d9a04e;
  --crust-2: #e8b56a;
  --ink: #151b20;
  --stripe: rgb(255 255 255 / 0.02);
  --measure: 42rem;
  --wide: 58rem;
  --radius: 10px;
}

/* Light: white page, black text. --crust darkens so links and kickers keep their contrast on white. */
:root[data-theme='light'] {
  color-scheme: light;
  --page: #ffffff;
  --page-2: #f7f6f2;
  --surface: #f4f2ed;
  --surface-2: #ebe8e1;
  --border: #d5d1c7;
  --text: #111418;
  --text-2: #4a5359;
  --crust: #8f5c10;
  --crust-2: #6f4609;
  --ink: #ffffff;
  --stripe: rgb(0 0 0 / 0.03);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;
    --page: #ffffff;
    --page-2: #f7f6f2;
    --surface: #f4f2ed;
    --surface-2: #ebe8e1;
    --border: #d5d1c7;
    --text: #111418;
    --text-2: #4a5359;
    --crust: #8f5c10;
    --crust-2: #6f4609;
    --ink: #ffffff;
    --stripe: rgb(0 0 0 / 0.03);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 400 1.0625rem/1.65 'Archivo', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
img { max-width: 100%; height: auto; }
a, button { -webkit-tap-highlight-color: rgb(217 160 78 / 0.25); }
.skip {
  position: absolute; left: 16px; top: -100px; z-index: 10; padding: 10px 16px; border-radius: 8px;
  background: var(--crust); color: var(--ink); font-weight: 700; text-decoration: none;
}
.skip:focus { top: 12px; }
a { color: var(--crust); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--crust-2); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }
code { font-size: 0.9em; color: var(--text-2); }

/* ---- Header ---------------------------------------------------------------------------------------------------- */
.top { border-bottom: 1px solid var(--border); background: var(--page-2); }
.top-in {
  max-width: 72rem; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap;
}
.mark { display: inline-flex; align-items: baseline; gap: 0.3em; text-decoration: none; color: var(--text); min-height: 44px; align-items: center; }
.mark-a { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; color: var(--text-2); }
.mark-b { font-family: 'Big Shoulders', 'Archivo', sans-serif; font-weight: 800; font-size: 1.75rem; line-height: 1; text-transform: uppercase; letter-spacing: 0.01em; }
.mark:hover .mark-b { color: var(--crust); }
.nav { order: 3; flex-basis: 100%; }
.nav ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 0.9375rem; border-radius: 8px;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current='page'] { color: var(--text); box-shadow: inset 0 -2px 0 var(--crust); border-radius: 0; }
.btn-top { margin-left: auto; }
.theme {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background: none; color: var(--text-2);
  font: 600 0.875rem/1 'Archivo', system-ui, sans-serif; cursor: pointer;
}
.theme[hidden] { display: none; }
.theme:hover { color: var(--text); border-color: var(--text-2); }
.theme-dot {
  width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
.theme:not([hidden]) { margin-left: auto; }
.theme:not([hidden]) + .btn-top { margin-left: 0; }
@media (min-width: 46rem) {
  .nav { order: 0; flex-basis: auto; }
  .btn-top { margin-left: auto; }
}

/* ---- Buttons ----------------------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px;
  border: 1px solid var(--crust); border-radius: 8px; color: var(--crust);
  font-weight: 600; font-size: 0.9375rem; line-height: 1.2; text-decoration: none;
}
.btn:hover { background: var(--surface); color: var(--text); }
.btn-go { background: var(--crust); color: var(--ink); }
.btn-go:hover { background: var(--crust-2); color: var(--ink); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 8px; }

/* ---- The article ------------------------------------------------------------------------------------------------- */
main { display: block; padding: 0 16px 72px; }
.doc { max-width: var(--wide); margin: 0 auto; }
.doc-head { max-width: var(--measure); margin: 0 auto; padding-top: 28px; }
.doc-head.wide { max-width: 72rem; }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 20px; padding: 0; list-style: none; font-size: 0.875rem; color: var(--text-2); }
.crumbs li:not(:last-child)::after { content: '/'; margin-left: 6px; color: var(--border); }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--crust); text-decoration: underline; }
.kicker { margin: 0 0 10px; color: var(--crust); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.02em; }
h1 {
  margin: 0 0 14px; font-family: 'Big Shoulders', 'Archivo', sans-serif; font-weight: 800;
  font-size: clamp(2.25rem, 1.5rem + 3.2vw, 3.75rem); line-height: 1.02; letter-spacing: 0.005em; text-transform: uppercase;
}
.lede { margin: 0 0 16px; font-size: 1.1875rem; line-height: 1.55; color: var(--text-2); }
.lede a { color: var(--crust); }
.stamp { margin: 0; color: var(--text-2); font-size: 0.8125rem; }
.hero { margin: 28px auto 0; max-width: var(--wide); }
.hero img { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.doc > .cta, .doc > .free { max-width: var(--measure); margin-left: auto; margin-right: auto; }
.free { margin-top: 8px; margin-bottom: 0; color: var(--text-2); font-size: 0.875rem; }

.prose { max-width: var(--measure); margin: 0 auto; }
.prose h2 {
  margin: 48px 0 10px; font-family: 'Big Shoulders', 'Archivo', sans-serif; font-weight: 800;
  font-size: 1.875rem; line-height: 1.1; text-transform: uppercase; letter-spacing: 0.01em; scroll-margin-top: 16px;
}
.prose h3 { margin: 28px 0 6px; font-size: 1.125rem; line-height: 1.35; }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 1.25rem; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--crust); }
.prose strong { color: var(--text); font-weight: 650; }

/* Pictures: one breaks out of the text column, two sit side by side. */
.solo, .pair { margin: 28px 0; }
.solo figure, .pair figure { margin: 0; }
.solo img, .pair img { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
figcaption { margin-top: 8px; color: var(--text-2); font-size: 0.875rem; line-height: 1.5; }
.pair { display: grid; gap: 16px; }
@media (min-width: 40rem) { .pair { grid-template-columns: 1fr 1fr; } }
@media (min-width: 62rem) {
  .solo, .pair, .prose > .table { margin-left: calc((var(--measure) - var(--wide)) / 2); margin-right: calc((var(--measure) - var(--wide)) / 2); }
}

.aside {
  margin: 24px 0; padding: 14px 18px; border-left: 3px solid var(--crust);
  background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0;
}
.aside p { margin: 0; color: var(--text); }

/* Tables scroll inside their own box on a narrow screen. */
.table { overflow-x: auto; margin: 20px 0 24px; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.45; font-variant-numeric: tabular-nums; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); }
thead th { background: var(--surface-2); font-weight: 650; white-space: nowrap; }
tbody th { font-weight: 650; }
tr:last-child th, tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: var(--stripe); }

.facts {
  max-width: var(--measure); margin: 40px auto 0; padding: 18px 20px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  font-size: 0.9375rem;
}
.facts p { margin: 0 0 8px; color: var(--text-2); }
.facts p:last-child { margin: 0; }
.facts strong { color: var(--text); margin-right: 6px; }

/* ---- Cards ------------------------------------------------------------------------------------------------------- */
.more, .group { max-width: 72rem; margin: 56px auto 0; }
.more h2, .group h2 {
  margin: 0 0 16px; font-family: 'Big Shoulders', 'Archivo', sans-serif; font-weight: 800;
  font-size: 1.75rem; text-transform: uppercase; letter-spacing: 0.01em;
}
.cards { display: grid; gap: 20px; margin: 0; padding: 0; list-style: none; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr)); }
.doc-head.wide + .cards, .story + .cards { max-width: 72rem; margin: 32px auto 0; }
.card { margin: 0; }
.card-a {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 0 0 16px;
  color: var(--text); text-decoration: none; border-radius: var(--radius);
}
.card-a img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 6px; }
.card-meta { color: var(--crust); font-size: 0.8125rem; font-weight: 600; }
.card-t { font-size: 1.125rem; font-weight: 700; line-height: 1.3; }
.card-x { color: var(--text-2); font-size: 0.9375rem; line-height: 1.5; }
.card-a:hover .card-t { color: var(--crust); text-decoration: underline; text-underline-offset: 0.2em; }
.card-a:hover img { border-color: var(--crust); }

.story {
  display: grid; gap: 16px 32px; max-width: 72rem; margin: 32px auto 0; color: var(--text); text-decoration: none;
}
.story img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.story-txt { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.story-t { font-family: 'Big Shoulders', 'Archivo', sans-serif; font-weight: 800; font-size: 2.25rem; line-height: 1.05; text-transform: uppercase; }
.story:hover .story-t { color: var(--crust); }
@media (min-width: 52rem) { .story { grid-template-columns: 3fr 2fr; } }

.pager { display: grid; gap: 12px; max-width: var(--measure); margin: 40px auto 0; }
@media (min-width: 40rem) { .pager { grid-template-columns: 1fr 1fr; } }
.pager-a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.pager-a:hover { border-color: var(--crust); }
.pager-old { text-align: right; }
.pager-k { color: var(--text-2); font-size: 0.8125rem; }
.pager-t { font-weight: 650; line-height: 1.35; }

/* ---- Footer ------------------------------------------------------------------------------------------------------ */
.foot { border-top: 1px solid var(--border); background: var(--page-2); }
.foot-in { max-width: 72rem; margin: 0 auto; padding: 40px 16px 48px; }
.foot-grid { display: grid; gap: 28px 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); }
.foot-h { margin: 0 0 8px; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); }
.foot-col ul { margin: 0; padding: 0; list-style: none; }
.foot-col li { margin: 0; }
.foot-col a { display: inline-block; padding: 6px 0; color: var(--text-2); text-decoration: none; font-size: 0.9375rem; line-height: 1.4; }
.foot-col a:hover { color: var(--crust); text-decoration: underline; }
.foot-col a[aria-current='page'] { color: var(--text); }
.foot-free { margin: 32px 0 6px; color: var(--text-2); font-size: 0.875rem; }
.foot-legal { margin: 0; color: var(--text-2); font-size: 0.875rem; }
.foot-legal a { color: var(--text-2); }

/* ---- The update log inside the site (with /gate/updates.css) ------------------------------------------------------ */
.log-main { max-width: var(--measure); margin: 0 auto; padding-top: 28px; }
.log-main h1 { margin-bottom: 8px; }
.rel-post { margin: 4px 0 0; font-size: 0.9375rem; font-weight: 600; }
@media (min-width: 640px) { .rel-post { grid-column: 2; } }

@media (prefers-reduced-motion: no-preference) {
  .card-a img, .pager-a, .btn { transition: border-color 0.15s, background-color 0.15s, color 0.15s; }
}

/* ---- Share links ------------------------------------------------------------------------------------------------ */
.share {
  max-width: var(--measure); margin: 32px auto 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  font-size: 0.875rem;
}
.share-k { color: var(--text-2); font-weight: 600; margin-right: 4px; }
.share a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 600;
}
.share a:hover { border-color: var(--crust); color: var(--crust); }

/* The supported trainers tables (scripts/site/trainers.ts). Status pills keep body text colour; the dot carries the hue. */
.jump { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.9375rem; }
.brand-more { margin: 4px 0 0; font-size: 0.9375rem; }
.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 600; font-size: 0.875rem; }
.st::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--text-2); flex: none; }
.st-ok::before { background: #3fae6a; }
.st-should::before { background: var(--crust); }
.st-power::before { background: transparent; border: 2px solid var(--text-2); width: 5px; height: 5px; }
.st-no::before { background: #c4574a; }
.src { display: block; margin-top: 4px; font-size: 0.8125rem; color: var(--text-2); }
/* On a phone each trainer is a small card: model on top, then labelled lines. */
@media (max-width: 56rem) {
  .tt table, .tt tbody, .tt tr, .tt th, .tt td { display: block; }
  .tt thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tt tr { padding: 12px 14px; border-top: 1px solid var(--border); }
  .tt tr:first-child { border-top: 0; }
  .tt th, .tt td { padding: 2px 0; border: 0; background: none; }
  .tt th { font-size: 1rem; padding-bottom: 6px; }
  .tt td[data-k]::before { content: attr(data-k) ': '; color: var(--text-2); font-weight: 600; }
  .tt td.tt-empty { display: none; }
}
