/* Operation Thunderstick — front page.
 *
 * Palette, type and the mark all come from docs/BRAND.md. Nothing here invents a colour.
 *
 * Loaded as an external file rather than inlined because the site CSP is
 * `style-src 'self' 'unsafe-inline'` and an external sheet is cacheable across pages; the JS
 * has to be external regardless (`script-src 'self'`).
 *
 * Everything is self-hosted: no CDN, no font service, no analytics. That is why the CSP did not
 * have to be loosened by one character to build this page.
 */

/* ---------------------------------------------------------------- fonts */
/* `swap` on purpose: a display face blocking first paint is worse than one frame of fallback. */
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-latin-800-normal.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}
/* The game's own title face, so the site and the game are one brand (docs/BRAND.md §3). */
@font-face {
  font-family: 'Kenney Blocks';
  src: url('fonts/kenney_blocks.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Kenney Future';
  src: url('fonts/kenney_future.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* ---------------------------------------------------------------- tokens */
:root {
  --ink: #0d0f12;
  --ink-lift: #1d2129;
  --ink-card: #14171c;
  --line: #23282f;
  --paper: #e8e6e3;
  --muted: #8b949e;
  --red: #c9302c;
  --red-lit: #ea5652;
  --red-glow: rgba(234, 86, 82, .35);
  --green: #3fb950;
  --amber: #d29922;

  --measure: 68ch;
  --wrap: 1180px;
  --radius: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font: 400 clamp(15px, 1.05vw, 17px)/1.7 'Inter', -apple-system, BlinkMacSystemFont,
        'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* The animated city. Fixed and behind everything; `pointer-events:none` so it never eats a
 * click. JS removes the canvas entirely under prefers-reduced-motion. */
#bg {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  /* Fade the canvas out at the TOP, not the bottom.
   *
   * The city is drawn along the bottom edge of the viewport, and the headline sits at the top —
   * so the first version had this exactly backwards: it washed out the city where the city is,
   * and left it at full strength behind the words. Transparent at the top means the type always
   * sits on clean background, and the skyline is strongest where nothing is competing with it. */
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,.35) 38%, #000 72%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,.35) 38%, #000 72%);
}

main, header, footer { position: relative; z-index: 1; }

.wrap { width: min(var(--wrap), 100% - 2.5rem); margin-inline: auto; }

/* ---------------------------------------------------------------- skip link (a11y) */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--red); color: #fff; padding: .7rem 1.1rem; z-index: 100;
  border-radius: 0 0 8px 0; font-weight: 600;
}
.skip:focus { left: 0; }

/* ---------------------------------------------------------------- nav */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.4rem;
  padding: .7rem 0;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(13, 15, 18, .72);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.nav.stuck { border-bottom-color: var(--line); background: rgba(13, 15, 18, .93); }
.nav .wrap { display: flex; align-items: center; gap: 1.3rem; width: min(var(--wrap), 100% - 2.5rem); }

.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--paper); }
.brand img { width: 30px; height: 30px; display: block; }
.brand b {
  font: 400 1rem/1 'Kenney Blocks', system-ui, sans-serif;
  letter-spacing: .04em; white-space: nowrap;
}
.nav nav { margin-left: auto; display: flex; gap: .35rem; flex-wrap: wrap; }
.nav nav a {
  color: var(--muted); text-decoration: none; font-size: .88rem; font-weight: 600;
  padding: .45rem .7rem; border-radius: 8px;
  transition: color .2s, background .2s;
}
.nav nav a:hover, .nav nav a:focus-visible { color: var(--paper); background: #ffffff0f; }
.nav nav a[aria-current="true"] { color: var(--red-lit); }

/* ---------------------------------------------------------------- hero */
.hero { padding: clamp(3rem, 9vh, 6.5rem) 0 clamp(2rem, 6vh, 4rem); }
.hero-grid {
  display: grid; gap: clamp(1.5rem, 4vw, 3.5rem);
  grid-template-columns: 1.15fr .85fr; align-items: center;
}
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }

.kicker {
  font: 400 .72rem/1 'Kenney Future', system-ui, sans-serif;
  letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: .6rem;
}
.kicker::before {
  content: ''; width: 26px; height: 2px; background: var(--red); display: inline-block;
}

h1.title {
  font: 400 clamp(2.1rem, 6.4vw, 4.1rem)/1.02 'Kenney Blocks', system-ui, sans-serif;
  margin: .8rem 0 .2rem; letter-spacing: .01em;
  text-wrap: balance;
}
h1.title .brk {
  color: var(--red-lit);
  text-shadow: 0 0 34px var(--red-glow);
}

.lede { font-size: clamp(1.02rem, 1.5vw, 1.2rem); color: #b9c1cb; max-width: 46ch; }
.lede strong { color: var(--paper); font-weight: 600; }

.cta-row { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.8rem; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .85rem 1.4rem; border-radius: 10px; text-decoration: none;
  font-weight: 700; letter-spacing: .01em; font-size: .95rem;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .18s var(--ease), background .2s, box-shadow .25s, border-color .2s;
}
.btn-primary {
  background: var(--red); color: #fff;
  box-shadow: 0 10px 30px -12px var(--red-glow);
}
.btn-primary:hover { background: var(--red-lit); transform: translateY(-2px); }
.btn-ghost { border-color: var(--line); color: var(--paper); background: #ffffff08; }
.btn-ghost:hover { border-color: #3a424d; background: #ffffff12; transform: translateY(-2px); }
.btn[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed; pointer-events: none;
}

/* Development status. Deliberately prominent: there is no public build, and a marketing page
 * that lets somebody believe otherwise is the one thing this page must not do. */
.status-pill {
  display: inline-flex; align-items: center; gap: .55rem;
  font-size: .82rem; color: var(--muted);
  border: 1px solid var(--line); background: #ffffff06;
  padding: .5rem .85rem; border-radius: 99px;
}
.dot { width: .52rem; height: .52rem; border-radius: 50%; background: var(--amber); flex: none; }
.dot.live { background: var(--green); }
.dot.pulse { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  50%      { box-shadow: 0 0 0 5px transparent; opacity: .55; }
}

/* ---------------------------------------------------------------- hero art */
.shot {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--ink-lift);
  box-shadow: 0 40px 80px -40px #000c, 0 0 0 1px #ffffff08 inset;
}
.shot img { display: block; width: 100%; height: auto; }
.shot figcaption {
  position: absolute; inset-inline: 0; bottom: 0;
  padding: 1.6rem .9rem .7rem;
  font-size: .78rem; color: #c3cad3;
  background: linear-gradient(to top, #000000d9, transparent);
}
.shot .badge {
  position: absolute; top: .7rem; left: .7rem;
  font: 400 .64rem/1 'Kenney Future', system-ui, sans-serif;
  letter-spacing: .14em; text-transform: uppercase;
  background: #000000b3; color: #cbd3dc; padding: .42rem .6rem; border-radius: 6px;
  border: 1px solid #ffffff1a;
}

/* ---------------------------------------------------------------- sections */
section { padding: clamp(3rem, 8vh, 5.5rem) 0; }
section + section { border-top: 1px solid var(--line); }

.eyebrow {
  font: 400 .7rem/1 'Kenney Future', system-ui, sans-serif;
  letter-spacing: .2em; text-transform: uppercase; color: var(--red-lit);
}
h2 {
  font: 400 clamp(1.5rem, 3.4vw, 2.3rem)/1.15 'Kenney Blocks', system-ui, sans-serif;
  margin: .6rem 0 .8rem; letter-spacing: .01em; text-wrap: balance;
}
h3 { font-size: 1.05rem; margin: 0 0 .35rem; font-weight: 700; letter-spacing: .01em; }
p { max-width: var(--measure); }
.sub { color: var(--muted); max-width: 62ch; }

/* ---------------------------------------------------------------- cards */
.cards {
  display: grid; gap: 1rem; margin-top: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(248px, 1fr));
}
.card {
  position: relative; padding: 1.4rem 1.3rem;
  background: linear-gradient(180deg, #ffffff09, #ffffff03);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform .25s var(--ease), border-color .25s, background .25s;
}
.card:hover { transform: translateY(-4px); border-color: #39414c; }
.card p { color: var(--muted); margin: 0; font-size: .93rem; }
/* An inline SVG isometric cube, not a CSS shape.
 *
 * The first attempt built it from two clipped linear-gradients and rendered as a red CHEVRON —
 * the clip-path hexagon and the gradient stops did not line up into three readable faces at
 * 34 px. Three explicit polygons is the honest way to draw three faces, and it costs no extra
 * request because the SVG is inline in the markup. */
.card .ico { width: 32px; height: 32px; margin-bottom: .85rem; display: block; }
.card .ico .top  { fill: var(--red-lit); }
.card .ico .left { fill: var(--red); }
.card .ico .rght { fill: #8c201d; }
.card:hover .ico { animation: nudge .5s var(--ease); }
@keyframes nudge {
  40% { transform: translateY(-3px); }
  100% { transform: none; }
}

/* ---------------------------------------------------------------- how to play */
.steps { counter-reset: step; display: grid; gap: 1rem; margin-top: 2rem; }
.step {
  display: grid; grid-template-columns: 3rem 1fr; gap: 1.1rem; align-items: start;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #ffffff05;
  transition: border-color .25s, background .25s;
}
.step:hover { border-color: #39414c; background: #ffffff09; }
.step::before {
  counter-increment: step; content: counter(step, decimal-leading-zero);
  font: 400 1.25rem/1 'Kenney Blocks', system-ui, sans-serif;
  color: var(--red-lit); padding-top: .1rem;
}
.step p { margin: 0; color: var(--muted); font-size: .94rem; }

/* ---------------------------------------------------------------- gallery */
.gallery {
  display: grid; gap: .9rem; margin-top: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.gallery figure { margin: 0; }
.gallery button.tile {
  display: block; width: 100%; padding: 0; cursor: zoom-in;
  background: none; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  transition: transform .28s var(--ease), border-color .25s, box-shadow .28s;
}
.gallery button.tile:hover,
.gallery button.tile:focus-visible {
  transform: translateY(-3px) scale(1.006);
  border-color: #414a56; box-shadow: 0 26px 50px -30px #000e;
}
.gallery img { display: block; width: 100%; height: auto; }
.gallery figcaption { font-size: .8rem; color: var(--muted); padding: .55rem .2rem 0; }

/* Lightbox. A <dialog> so Esc, focus trapping and the backdrop are the platform's job. */
dialog.lb {
  border: none; padding: 0; background: transparent; max-width: 96vw; max-height: 94vh;
  color: var(--paper);
}
dialog.lb::backdrop { background: #05070ae8; backdrop-filter: blur(6px); }
dialog.lb img {
  display: block; max-width: 96vw; max-height: 84vh; width: auto; height: auto;
  border-radius: 10px; border: 1px solid var(--line);
}
dialog.lb figcaption { padding: .7rem .2rem 0; font-size: .85rem; color: var(--muted); }
dialog.lb .close {
  position: absolute; top: -.2rem; right: -.2rem; transform: translate(40%, -40%);
  width: 2.3rem; height: 2.3rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--ink-card); color: var(--paper);
  font-size: 1.1rem; cursor: pointer; line-height: 1;
}
dialog.lb .close:hover { border-color: var(--red); color: var(--red-lit); }

/* ---------------------------------------------------------------- servers strip */
.servers { display: grid; gap: .5rem; margin-top: 1.6rem; }
.srv {
  display: grid; grid-template-columns: 1.2rem 1fr auto auto; gap: .85rem;
  align-items: center; padding: .75rem 1rem;
  border: 1px solid var(--line); border-radius: 10px; background: #ffffff05;
  font-size: .92rem;
}
.srv .name { font-weight: 600; }
.srv .country { color: var(--muted); font-weight: 400; }
.srv .state { font: 400 .78rem/1 'Kenney Future', system-ui, sans-serif; letter-spacing: .1em; }
.srv .state.up { color: var(--green); }
.srv .state.down { color: #f85149; }
.srv .state.unknown { color: var(--muted); }
.srv .players { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; }
.srv .lock { color: var(--muted); font-size: .95rem; text-align: center; }

/* ---------------------------------------------------------------- facts */
.facts {
  display: grid; gap: 1px; margin-top: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.fact { background: var(--ink); padding: 1.2rem 1.1rem; }
.fact b {
  display: block;
  font: 400 clamp(1.5rem, 3vw, 2rem)/1 'Kenney Blocks', system-ui, sans-serif;
  color: var(--paper); font-variant-numeric: tabular-nums;
}
.fact span { font-size: .8rem; color: var(--muted); }

/* ---------------------------------------------------------------- footer */
footer {
  border-top: 1px solid var(--line); padding: 2.5rem 0 3.5rem;
  color: var(--muted); font-size: .88rem;
}
footer .cols { display: flex; flex-wrap: wrap; gap: 2.5rem; justify-content: space-between; }
footer a { color: #9fb2c9; }
footer a:hover { color: var(--paper); }
footer .legal { margin-top: 1.8rem; font-size: .8rem; color: #6e7681; max-width: 70ch; }

/* ---------------------------------------------------------------- reveal on scroll */
/* Default state is VISIBLE. JS adds `.reveal` only when it is going to animate, so a browser
 * with JS blocked or an error in site.js still shows every section instead of a blank page. */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.in {
  opacity: 1; transform: none;
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}

/* ---------------------------------------------------------------- a11y / motion */
:focus-visible { outline: 2px solid var(--red-lit); outline-offset: 3px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  #bg { display: none; }
}

/* ---------------------------------------------------------------- server row glyphs */
/* The padlock is an SVG rather than 🔓/🔒: at this size the two emoji are almost identical, and
 * saying WHICH state it is is the glyph's entire job (D-039). */
.srv .lock svg { width: 15px; height: 15px; display: block; margin-inline: auto; }
.srv .lock { color: var(--muted); }

/* Visually hidden but read aloud. The padlock's meaning must not be colour- or shape-only. */
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- narrow screens */
/* MEASURED at 390x844: the nav overflowed the viewport, and because `body` has
 * `overflow-x: hidden` the overflow did not produce a scrollbar — it silently CLIPPED the hero
 * copy mid-word. That is the worst failure mode of the two, so it is worth saying why it
 * happened: `.nav .wrap` is a non-wrapping flex row, so the brand and the five nav links were
 * forced onto one line whose min-content width exceeded 390 px, widening the whole layout.
 *
 * Two fixes, and both are needed: let the nav wrap onto its own line, and give every grid/flex
 * child `min-width: 0` so a long word can never push a column wider than its track. */
.hero-grid > *, .cards > *, .steps > *, .gallery > *, .srv > * { min-width: 0; }

@media (max-width: 760px) {
  .nav .wrap { flex-wrap: wrap; gap: .45rem 1rem; }
  .nav nav {
    margin-left: 0; width: 100%;
    justify-content: flex-start; gap: .1rem;
  }
  .nav nav a { padding: .38rem .5rem; font-size: .82rem; }
  .kicker { align-items: flex-start; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .step { grid-template-columns: 2.2rem 1fr; gap: .8rem; padding: 1rem 1rem; }
  .cta-row .btn { flex: 1 1 auto; justify-content: center; }
}

/* The wordmark is a display face with wide letter-spacing; below this it no longer fits two
 * words per line and would clip rather than wrap. */
@media (max-width: 420px) {
  .brand b { font-size: .86rem; }
  h1.title { font-size: clamp(1.75rem, 10vw, 2.4rem); }
}

/* THE ACTUAL CAUSE of the 390 px clipping, found after the wrap/min-width pass above was not
 * enough: `.nav` is a flex container and `.nav .wrap` is therefore a flex ITEM, whose default
 * `min-width: auto` refuses to shrink below its own min-content. With the brand and five links
 * in a nowrap row that min-content was wider than the phone, so the ITEM stayed wide, widened
 * the document, and `overflow-x: hidden` on body then clipped every section to the viewport —
 * which is why text in the hero was cut mid-word even though the hero itself was innocent.
 *
 * `min-width: 0` lets the item shrink. The nav then scrolls horizontally rather than wrapping
 * into an uneven two-line block: five short links are easier to swipe than to read stacked. */
.nav > .wrap { min-width: 0; }

@media (max-width: 760px) {
  .nav > .wrap { flex-wrap: nowrap; }
  .nav nav {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    margin-left: auto; width: auto;
    /* Fades the right edge so a cut-off link reads as "scroll me", not as a broken layout. */
    mask-image: linear-gradient(to right, #000 0, #000 88%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 88%, transparent 100%);
  }
  .nav nav::-webkit-scrollbar { display: none; }
  .nav nav a { white-space: nowrap; }
}

/* Long unbroken strings (a URL, a build id) must never be the reason a column overflows. */
body { overflow-wrap: break-word; }
