/* Spitefall — one stylesheet, no build step.
 *
 * The colours are the game's own, copied out of data/tuning/palette.json, and
 * tools/check_site.py fails the deploy if they drift apart. The site and the game should look
 * like one thing; matching them by eye is how they stop matching six months later.
 *
 * The layout rule that matters: the header is the tightest thing on any page. A wordmark plus
 * four links is around 500px that cannot break, which is wider than a phone, so below 680px it
 * becomes two rows. Test at 375px and check scrollWidth, not appearance.
 */

/* The typefaces are hosted here, not fetched from Google: a visitor's browser contacts no one but
 * this site. Both are variable fonts in the Latin subset, so one file per family covers every
 * weight the site uses. Licences are in /fonts/LICENSE.txt. `swap` shows the fallback at once
 * instead of hiding the text while the file loads. */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/space-grotesk-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("/fonts/source-serif-4-latin.woff2") format("woff2");
}

:root {
  --ink: #16102E;
  --field: #8A83C0;
  --accent: #57F2DE;
  --hazard: #FF5A44;
  --player: #FFC93F;
  --exit: #8CEA6B;
  --text: #F5F0E4;
  /* The warm gold of the app icon's torchlight. Not the player's amber (#FFC93F means "you" in the
     game) and not a game colour at all: it is the site's own accent, for links and the glow. */
  --ember: #D9993A;
  --ember-soft: rgba(217, 153, 58, 0.18);

  --dim: #B9B2D6;
  --rule: rgba(245, 240, 228, 0.16);
  --panel: rgba(245, 240, 228, 0.04);

  --s1: 0.5rem;
  --s2: 1rem;
  --s3: 1.75rem;
  --s4: 3rem;
  --s5: 5rem;
  --wide: 1080px;

  --sans: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
  scrollbar-color: var(--field) var(--ink);
  scrollbar-width: thin;
}

/* The parts the browser draws by default belong to no design. Text selection is the player's
   amber, the colour that means "you", and keyboard focus is the same amber, so a keyboard user
   can always see where they are. */
/* Bypass link: first thing a keyboard or screen-reader user reaches, invisible until focused. */
.skip { position: absolute; left: var(--s2); top: -4rem; background: var(--player); color: var(--ink); font-family: var(--sans); padding: 0.6rem 1rem; z-index: 10; text-decoration: none; }
.skip:focus { top: var(--s1); }

::selection { background: var(--player); color: var(--ink); }
:focus-visible { outline: 2px solid var(--player); outline-offset: 3px; border-radius: 2px; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
}

.wrap {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--s3);
}

a { color: var(--ember); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--text); }
a, nav a { transition: color 160ms ease-out; }
@media (prefers-reduced-motion: reduce) { a, nav a { transition: none; } }

h1, h2, h3, nav, .btn { font-family: var(--sans); }
h1 { font-size: clamp(2.4rem, 7vw, 4rem); line-height: 1.05; margin: 0 0 var(--s2); text-wrap: balance; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); line-height: 1.15; margin: 0 0 var(--s2); text-wrap: balance; }
h3 { font-size: 1.1rem; margin: 0 0 var(--s1); }

p { margin: 0 0 var(--s2); max-width: 68ch; text-wrap: pretty; }

/* --- header --- */

header {
  border-bottom: 1px solid var(--rule);
  padding: var(--s2) 0;
}
.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
}
.mark {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
/* The app icon at the size a home screen draws it: the corner radius is iOS's, 22.37%. */
.mark img { display: block; width: 28px; height: 28px; border-radius: 22.37%; }
nav { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }
/* Padding, not margin: the link itself is the 44 px target, which is what a thumb finds. */
nav a { color: var(--dim); text-decoration: none; font-size: 0.95rem; display: inline-block; padding: 0.7rem 0; min-height: 44px; }
nav a:hover, nav a[aria-current="page"] { color: var(--text); }

@media (max-width: 680px) {
  .bar { flex-direction: column; align-items: flex-start; gap: 0; }
  nav { gap: var(--s2); }
}

/* --- sections --- */

section { padding: var(--s5) 0; border-bottom: 1px solid var(--rule); }
section:last-of-type { border-bottom: 0; }

.hero { padding-top: var(--s3); padding-bottom: var(--s4); background: radial-gradient(70% 55% at 50% 100%, var(--ember-soft), transparent 72%); }
.hero-head { display: flex; gap: var(--s4); align-items: center; }
.hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.8rem); margin-bottom: 0; }
.app-icon { flex: none; width: clamp(88px, 10.5vw, 136px); height: auto; aspect-ratio: 1; border-radius: 22.37%; box-shadow: 0 18px 50px -12px rgba(217, 153, 58, 0.55), 0 0 0 1px rgba(245, 240, 228, 0.1); }
.hero-text { padding-top: var(--s3); }
.hero-text .lede { margin-top: 0; }
.status { color: var(--dim); font-family: var(--sans); font-size: 0.95rem; margin: var(--s1) 0 0; }
@media (max-width: 700px) { .hero-head { flex-direction: column; align-items: flex-start; gap: var(--s3); } }

/* The stage: the game, nearly the width of the screen. */
.stage { margin: var(--s3) auto 0; max-width: 1480px; }
.stage-video { display: block; width: 100%; height: auto; background: var(--ink); border-top: 1px solid rgba(217, 153, 58, 0.45); border-bottom: 1px solid rgba(217, 153, 58, 0.45); }
.stage-bar { display: flex; gap: var(--s3); align-items: flex-start; justify-content: space-between; max-width: var(--wide); margin: var(--s2) auto 0; padding: 0 var(--s3); }
.stage-bar figcaption { margin-top: 0; }
.stage-toggle { flex: none; font-family: var(--sans); font-size: 0.92rem; color: var(--text); background: transparent; border: 1px solid var(--rule); border-radius: 4px; padding: 0.65rem 1.1rem; min-height: 44px; cursor: pointer; transition: border-color 160ms ease-out, color 160ms ease-out; }
.stage-toggle:hover { border-color: var(--ember); color: var(--ember); }
@media (max-width: 700px) { .stage-bar { flex-direction: column; } }

/* Six worlds. */
.worlds { list-style: none; padding: 0; margin: var(--s3) 0 0; max-width: none; display: grid; grid-template-columns: 1fr; gap: var(--s3); }
.worlds li { margin: 0; }
.worlds figure { margin: 0; }
.worlds figcaption strong { display: block; color: var(--text); font-family: var(--sans); font-weight: 500; }
@media (min-width: 640px) { .worlds { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .worlds { grid-template-columns: repeat(3, 1fr); } }
}
.lede { font-size: clamp(1.15rem, 2.2vw, 1.4rem); color: var(--text); max-width: 58ch; }

/* The colours the game teaches, as a legend: the swatch is the thing being explained, so it is
 * big enough to be looked at, and there is no box around it. */
.legend { list-style: none; padding: 0; max-width: 68ch; margin: 0; }
.legend li { display: grid; grid-template-columns: 2.25rem 1fr; gap: var(--s2); align-items: start; padding: var(--s2) 0; border-top: 1px solid var(--rule); margin: 0; }
.legend li:last-child { border-bottom: 1px solid var(--rule); }
.legend .swatch { width: 2.25rem; height: 2.25rem; margin: 0.15rem 0 0; }
.legend h3 { margin: 0 0 0.25rem; }
.legend p { margin: 0; }

/* The four colours the game teaches. Used here so the site says the same thing the screen
 * does, and so anyone reading /tells can check them against a screenshot. */
.swatch {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.4em;
  vertical-align: -0.05em;
  border: 1px solid var(--ink);
}
.sw-hazard { background: var(--hazard); }
.sw-edge { background: var(--text); }
.sw-player { background: var(--player); }
.sw-exit { background: var(--exit); }

table { border-collapse: collapse; width: 100%; font-size: 0.97rem; }
th, td { text-align: left; padding: var(--s1) var(--s2) var(--s1) 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); font-weight: 500; }

.wide-scroll { overflow-x: auto; }

figure { margin: 0 0 var(--s3); }
figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  /* Pixel art scaled up by the browser has to stay pixels. Smoothing a 32 px tile at three
     times its size is exactly the grey smear the game spends its whole art pipeline avoiding,
     and it would be the first thing anyone sees. */
  image-rendering: pixelated;
}
figcaption { color: var(--dim); font-size: 0.92rem; margin-top: var(--s1); max-width: 68ch; }

code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--panel);
  padding: 0.1em 0.35em;
  border: 1px solid var(--rule);
}

.note {
  border-top: 1px solid var(--rule);
  padding-top: var(--s2);
  color: var(--dim);
}

ul { max-width: 68ch; padding-left: 1.2em; }
li { margin-bottom: var(--s1); }

footer {
  border-top: 1px solid var(--rule);
  padding: var(--s3) 0 var(--s4);
  color: var(--dim);
  font-size: 0.92rem;
}
footer nav { gap: var(--s2); }
