/* ==========================================================================
   Spark of Chaos — site.css
   Order: fonts → tokens → reset → base → components (appended by later tasks).
   Never hardcode a colour below the token block.
   ========================================================================== */

/* --- Fonts ---------------------------------------------------------------- */
@font-face {
  font-family: 'Exo 2';
  src: url('../fonts/exo-2-variable.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Bruno Ace SC';
  src: url('../fonts/bruno-ace-sc-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* --- Tokens --------------------------------------------------------------- */
:root {
  /* Canvas */
  --ink-950: #06070c;
  --ink-900: #0b0e16;
  --ink-800: #121724;
  --ink-700: #1b2233;
  --line: rgba(255, 255, 255, .09);
  --shade: #000;   /* pure black, for color-mix darkening */
  --crt-glass: #fff;    /* physical white of a CRT screen's glass (Kabonk CRT chrome) */
  --crt-bezel: #cdcdcd; /* physical grey of a CRT bezel (Kabonk CRT chrome) */

  /* Text */
  --text: #e9edf6;
  --text-dim: #98a2b8;
  --text-bright: #fff;   /* emphasis; brighter than --text */

  /* Spark ramp — the original ember particle colours */
  --spark-1: #0f4170;
  --spark-2: #214846;
  --spark-3: #a9c464;
  --spark-4: #f8322b;
  --spark-5: #f28c33;
  --spark-6: #fac453;
  --spark-7: #f4f3be;
  --spark-gradient: linear-gradient(135deg,
    var(--spark-1), var(--spark-2), var(--spark-3), var(--spark-4),
    var(--spark-5), var(--spark-6), var(--spark-7));

  /* Accent */
  --accent: #f38f55;
  --accent-2: #f0ba4c;

  /* Per-game palette defaults — overridden by scope classes below */
  --game-accent: var(--accent);
  --game-accent-2: var(--accent-2);
  --game-bg: var(--ink-900);

  /* Space — 4px base */
  --space-1: .25rem;  --space-2: .5rem;   --space-3: .75rem;
  --space-4: 1rem;    --space-5: 1.5rem;  --space-6: 2rem;
  --space-8: 3rem;    --space-10: 4rem;   --space-12: 6rem;

  /* Radius */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 16px;

  /* Elevation */
  --shadow: 0 2px 12px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  --glow: 0 0 32px color-mix(in srgb, var(--game-accent) 45%, transparent);

  /* Type */
  --font-display: 'Bruno Ace SC', ui-serif, Georgia, serif;
  --font-body: 'Exo 2', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --step--1: clamp(.833rem, .79rem + .2vw, .938rem);
  --step-0:  clamp(1rem, .95rem + .25vw, 1.125rem);
  --step-1:  clamp(1.25rem, 1.15rem + .5vw, 1.5rem);
  --step-2:  clamp(1.6rem, 1.4rem + 1vw, 2.25rem);
  --step-3:  clamp(2rem, 1.6rem + 2vw, 3.25rem);
  --step-4:  clamp(2.75rem, 2rem + 3.75vw, 5.5rem);

  /* Layout */
  --measure: 68ch;
  --container: 72rem;
  --container-narrow: 52rem;

  /* Motion */
  --ease: cubic-bezier(.2, .6, .3, 1);
  --dur: 200ms;
}

/* Per-game palettes (§5.2) */
.kabonk  { --game-accent: #ff00ff; --game-accent-2: #a3e0fc; --game-bg: #14030f; }
.fernweh { --game-accent: #f0a45a; --game-accent-2: #7fb98a; --game-bg: #0b120e; }
.dyneria { --game-accent: #ffc334; --game-accent-2: #c2d24b; --game-bg: #0d1226; }

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  min-height: 100svh;
  background: var(--ink-950);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 300;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
img, video { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
p, h1, h2, h3, h4 { overflow-wrap: break-word; }

/* --- Base elements -------------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -.01em;
}
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--accent-2); }

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

hr { border: 0; height: 1px; background: var(--line); }

::selection { background: var(--accent); color: var(--ink-950); }

/* --- Layout helpers ------------------------------------------------------- */
.container { width: min(100% - var(--space-8), var(--container)); margin-inline: auto; }
.container--narrow { width: min(100% - var(--space-8), var(--container-narrow)); margin-inline: auto; }

.section { padding-block: var(--space-12); }
.section--alt { background: var(--ink-900); }

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--ink-950);
  border-radius: var(--radius);
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* --- Motion preference ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* --- Navigation ----------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--ink-950) 78%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-block: var(--space-3);
}
.nav__brand { display: flex; align-items: center; gap: var(--space-2); margin-right: auto; }
.nav__brand img { width: 32px; height: 32px; }
.nav__brand span {
  font-family: var(--font-display);
  font-size: var(--step-0);
  color: var(--text);
}
.nav__panel { display: flex; align-items: center; gap: var(--space-2); }
.nav__link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav__link:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent-2);
}
.nav__icon { display: flex; padding: var(--space-2); color: var(--text); }
.nav__icon:hover { color: var(--accent); }
.nav__icon svg { width: 22px; height: 22px; fill: currentColor; }

/* The toggle only exists for JS users; without JS the panel simply stays open. */
.nav__toggle { display: none; }

@media (max-width: 48rem) {
  [data-js] .nav__toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
  }
  [data-js] .nav__toggle svg { width: 20px; height: 20px; fill: currentColor; }
  [data-js] .nav__panel {
    position: absolute;
    inset-inline: 0;
    top: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--space-3);
    background: var(--ink-900);
    border-bottom: 1px solid var(--line);
  }
  [data-js] .nav__panel[data-open] { display: flex; }
  .nav__panel { flex-wrap: wrap; }
}

/* --- Footer --------------------------------------------------------------- */
.site-footer {
  padding-block: var(--space-8);
  background: var(--ink-900);
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--text-dim);
  font-size: var(--step--1);
}
.site-footer__made { display: flex; align-items: center; justify-content: center; gap: var(--space-2); }
.site-footer__brand {
  background: var(--spark-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
/* Raised out of flow so the flame's base rests on the text rather than
   straddling it; the canvas keeps its 64px slot so the footer height holds. */
#fire { width: 32px; height: 64px; position: relative; top: -5px; }
.fire-fallback { font-size: 1.25rem; line-height: 1; }
[data-js] .fire-fallback { display: none; }
@media (prefers-reduced-motion: reduce) {
  #fire { display: none; }
  [data-js] .fire-fallback { display: block; }
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn svg { width: 20px; height: 20px; fill: currentColor; }

.btn--primary {
  background: var(--game-accent);
  color: var(--ink-950);
  box-shadow: var(--shadow);
}
.btn--primary:hover {
  background: var(--game-accent-2);
  color: var(--ink-950);
  box-shadow: var(--glow);
}

.btn--ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}
.btn--ghost:hover {
  border-color: var(--game-accent);
  color: var(--game-accent);
}

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* --- Chip ----------------------------------------------------------------- */
.chip {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border: 1px solid color-mix(in srgb, var(--game-accent) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--game-accent) 12%, transparent);
  color: var(--game-accent);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* --- Grid ----------------------------------------------------------------- */
.grid { display: grid; gap: var(--space-6); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }

/* --- Card ----------------------------------------------------------------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { border-color: color-mix(in srgb, var(--game-accent) 50%, transparent); transform: translateY(-2px); }
.card__media { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.card__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.card__meta { color: var(--text-dim); font-size: var(--step--1); }
.card h3 { font-size: var(--step-1); }
.card a { text-decoration: none; }
/* Stretch the title link across the whole card so the entire card is clickable. */
.card a::after { content: ''; position: absolute; inset: 0; }

/* --- Team card ------------------------------------------------------------ */
.team-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6);
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
}
.team-card img {
  width: 128px; height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
}
.team-card__links { display: flex; gap: var(--space-3); }
.team-card__links a { display: flex; color: var(--text-dim); }
.team-card__links a:hover { color: var(--accent); }
.team-card__links svg { width: 18px; height: 18px; fill: currentColor; }

/* --- Prose ---------------------------------------------------------------- */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: var(--space-8); }
.prose h3 { margin-top: var(--space-6); }
.prose ul, .prose ol { padding-left: var(--space-5); }
.prose li + li { margin-top: var(--space-2); }
.prose strong { font-weight: 700; color: var(--text-bright); }
.prose blockquote {
  padding-left: var(--space-5);
  border-left: 3px solid var(--game-accent);
  color: var(--text-dim);
  font-size: var(--step-1);
}

/* --- Feature row ---------------------------------------------------------- */
.feature { display: grid; gap: var(--space-6); align-items: center; }
@media (min-width: 48rem) {
  .feature { grid-template-columns: 1fr 1fr; }
  .feature--flip .feature__media { order: 2; }
}
.feature + .feature { margin-top: var(--space-10); padding-top: var(--space-10); border-top: 1px solid var(--line); }

/* --- Hero ----------------------------------------------------------------- */
.hero {
  position: relative;
  display: grid;
  place-items: center;
  gap: var(--space-5);
  padding-block: var(--space-12);
  text-align: center;
  overflow: hidden;
}
.hero > * { position: relative; z-index: 1; }
.hero__bloom {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(44rem 30rem at 50% 42%, color-mix(in srgb, var(--spark-5) 26%, transparent), transparent 70%),
    radial-gradient(26rem 20rem at 38% 55%, color-mix(in srgb, var(--spark-4) 18%, transparent), transparent 72%),
    radial-gradient(24rem 18rem at 62% 34%, color-mix(in srgb, var(--spark-6) 20%, transparent), transparent 72%);
}
/* Fine noise so the gradients cannot band on wide gamut displays. */
.hero__bloom::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: .08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hero__logo { width: min(38vw, 15rem); height: auto; }
.hero__wordmark {
  font-family: var(--font-display);
  font-size: var(--step-4);
  line-height: 1;
  background: var(--spark-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__tagline { max-width: 40ch; color: var(--text-dim); font-size: var(--step-1); }

/* --- Game strip ----------------------------------------------------------- */
.game-strip {
  position: relative;
  padding-block: var(--space-12);
  background-color: var(--game-bg);
  background-size: cover;
  background-position: center;
  isolation: isolate;
}
.game-strip::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--ink-950) 82%, transparent),
    color-mix(in srgb, var(--ink-950) 62%, transparent));
}
.game-strip__inner { display: grid; gap: var(--space-6); align-items: center; }
@media (min-width: 52rem) {
  .game-strip__inner { grid-template-columns: 1fr 1fr; }
  .game-strip--flip .game-strip__media { order: 2; }
}
.game-strip__logo { max-width: 22rem; height: auto; }
.game-strip__title { font-size: var(--step-3); color: var(--game-accent); }
.game-strip__body { display: flex; flex-direction: column; gap: var(--space-4); align-items: flex-start; }

/* --- Retro CRT screen (Kabonk! scope only) -------------------------------- */
.kabonk .shot {
  position: relative;
  box-sizing: content-box;
  background: var(--crt-glass);
  border-top: 3px solid var(--crt-bezel);
  border-bottom: 3px solid var(--crt-bezel);
  border-radius: 50% / 10%;
  filter: grayscale(.8) contrast(1.2) brightness(1.1);
  transform: scale(.94);
  transition: filter var(--dur) var(--ease), border-radius var(--dur) var(--ease),
              transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.kabonk .shot:hover,
.kabonk a:focus-visible .shot {
  filter: none;
  border-radius: var(--radius);
  border-color: var(--game-accent);
  box-shadow: var(--glow);
  transform: scale(1);
}

/* --- Dyneria world art (Dyneria scope only) -------------------------------
   The hero is the game's key art in two layers: the island plate as the
   background, and the transparent gold logo on top as an .hero__logo. Keeping
   them separate is why the logo lands in the sky above the volcano at any
   viewport — `cover` crops the plate's sides, not its middle.
   Both layers are shown as-is. There is no scrim over the plate and no shadow
   or border on the logo: the art carries the hero by itself.
   Screenshots take the standard image radius, the logo takes none: Dyneria gets
   no CRT treatment either, that gimmick belongs to Kabonk!.
   -------------------------------------------------------------------------- */
.dyneria .hero { background: url('/assets/img/dyneria/hero.jpg') center/cover; }
.dyneria .hero__tagline { color: var(--text); }
/* The chip is the one thing the bare art defeats: its gold text lands on the
   sunlit farmland, which is nearly the same hue, measuring 2.7:1. Filling the
   pill itself — rather than scrimming the art — takes it back over 8:1 and
   covers nothing. The tagline and ghost button clear AA on the art unaided. */
.dyneria .hero .chip { background: color-mix(in srgb, var(--shade) 62%, transparent); }
/* .hero has no inline padding — it never needed any, because Kabonk's hero holds
   a single button and Fernweh's holds none. Dyneria's holds a .btn-row, which
   overflows a phone viewport without it. */
.dyneria .hero { padding-inline: var(--space-5); }
.dyneria .hero .btn-row { justify-content: center; }
/* Rectangular screenshots only. The logo is a transparent PNG and is shown bare
   — a border or radius would draw a box around empty space, and it carries its
   own dark backing plate in the artwork. */
.dyneria .feature__media img,
.dyneria .grid a img {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* --- Lightbox ------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: color-mix(in srgb, var(--shade) 90%, transparent);
}
.lightbox img {
  max-width: 92vw;
  max-height: 86vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.lightbox__close, .lightbox__nav {
  position: absolute;
  padding: var(--space-3);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-bright);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox__close { top: var(--space-5); right: var(--space-5); }
.lightbox__nav--prev { left: var(--space-4); }
.lightbox__nav--next { right: var(--space-4); }

/* --- Social row ----------------------------------------------------------- */
.social-row { display: flex; flex-wrap: wrap; gap: var(--space-6); justify-content: center; }
.social-row a { display: flex; color: var(--text); transition: color var(--dur) var(--ease); }
.social-row a:hover { color: var(--accent); }
.social-row svg { width: 32px; height: 32px; fill: currentColor; }

/* --- Fernweh dusk scene ---------------------------------------------------
   Stands in for artwork that does not exist yet (spec §11). To replace with a
   real image later, override exactly one declaration:
     .fernweh .dusk { background: url('/assets/img/fernweh/hero.jpg') center/cover; }
   -------------------------------------------------------------------------- */
.dusk {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    /* campfire glow */
    radial-gradient(18rem 12rem at 50% 78%, color-mix(in srgb, var(--game-accent) 42%, transparent), transparent 68%),
    /* treeline */
    conic-gradient(from 200deg at 12% 100%, transparent 0 38%, color-mix(in srgb, var(--game-accent-2) 26%, var(--shade)) 38% 44%, transparent 44%),
    conic-gradient(from 200deg at 28% 100%, transparent 0 39%, color-mix(in srgb, var(--game-accent-2) 20%, var(--shade)) 39% 45%, transparent 45%),
    conic-gradient(from 160deg at 76% 100%, transparent 0 38%, color-mix(in srgb, var(--game-accent-2) 24%, var(--shade)) 38% 44%, transparent 44%),
    conic-gradient(from 160deg at 90% 100%, transparent 0 39%, color-mix(in srgb, var(--game-accent-2) 18%, var(--shade)) 39% 45%, transparent 45%),
    /* dusk sky */
    linear-gradient(to bottom,
      var(--game-bg) 0%,
      color-mix(in srgb, var(--game-accent) 14%, var(--game-bg)) 52%,
      color-mix(in srgb, var(--game-accent) 30%, var(--game-bg)) 78%,
      var(--game-bg) 100%);
}
.dusk::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: .22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.definition {
  font-family: var(--font-body);
  color: var(--text-dim);
}
.definition strong { color: var(--game-accent); }
.definition .ipa { font-style: normal; letter-spacing: .02em; }
