/* Vesperfall — Nocturne.
   Single stylesheet, mobile-first, no dependencies.
   script.js is progressive enhancement: everything here stays readable and
   usable with JavaScript disabled. */

/* Bodoni Moda 400, latin subset, self-hosted so the site still makes no
   external request. Variable on the optical-size axis, so the hairlines
   thin out on their own at display sizes and thicken back up small.
   unicode-range keeps anything outside latin on Georgia rather than tofu. */
@font-face {
  font-family: "Bodoni Moda";
  src: url("bodoni-moda-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Surfaces. Contrast ratios below are measured on --ink. */
  --ink:        #05070d;   /* page base */
  --surface:    #0b0f19;   /* cards, quoted blocks */
  --surface-2:  #080b13;   /* cards at rest */
  --line:       #141a27;
  --line-2:     #1e2536;
  --line-3:     #26314a;

  /* Text. --dim is the floor: nothing below it ever carries meaning. */
  --display:    #f2f4fa;
  --text:       #e6e9f2;   /* 16.6:1 */
  --lead:       #c8cfdf;
  --starlight:  #c3ccdf;   /* 11.8:1 */
  --muted:      #8d97b0;   /* 6.9:1  — body copy */
  --dim:        #7d87a1;   /* 5.6:1  — dimmest allowed on text */
  --faint:      #6f778c;   /* hairlines and micro-meta only */

  /* Light. Amber is a light, not a text colour: micro-labels, focus rings
     and glow only, never a paragraph. */
  --candle:     #f0b256;   /* 10.7:1 — pool, 2200K */
  --candle-rgb: 240, 178, 86;
  --ember-rgb:  232, 150, 60;
  --core-rgb:   255, 214, 150; /* 2700K core */
  --btn-text:   #f6dcae;
  --btn-lit:    #ffeccb;

  /* Georgia is the fallback the design nominates, and covers the swap window. */
  --serif: "Bodoni Moda", Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 68ch;
  --ease:    cubic-bezier(0.2, 0.7, 0.3, 1);

  /* Written by script.js: scroll progress 0..1. */
  --sy: 0;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
  background-color: var(--ink);
}

body {
  margin: 0;
  background-image: radial-gradient(120% 80% at 50% 0%, #0a0f1d 0%, var(--ink) 62%);
  background-repeat: no-repeat;
  background-size: 100% 1000px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(var(--candle-rgb), 0.26); color: #fff; }

/* ---------------------------------------------------------------- Sky --
   Two layers of fixed stars. The far layer never moves; the near layer
   drifts a little on scroll, which is what makes the far one read as
   distant. No pointer tracking here — the only pointer-driven light on the
   site is the one on the games grid. */

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.stars {
  position: absolute;
  inset: -6%;
  display: block;
}

.stars.far {
  opacity: 0.8;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 14%, var(--starlight), transparent),
    radial-gradient(1px 1px at 27% 7%, #9aa6c0, transparent),
    radial-gradient(1px 1px at 41% 20%, var(--starlight), transparent),
    radial-gradient(1.4px 1.4px at 58% 10%, #dfe6f5, transparent),
    radial-gradient(1px 1px at 71% 25%, #9aa6c0, transparent),
    radial-gradient(1px 1px at 86% 13%, var(--starlight), transparent),
    radial-gradient(1px 1px at 93% 33%, var(--muted), transparent),
    radial-gradient(1px 1px at 7% 38%, var(--muted), transparent);
}

.stars.near {
  background-image:
    radial-gradient(1.2px 1.2px at 34% 44%, var(--starlight), transparent),
    radial-gradient(1px 1px at 64% 40%, #9aa6c0, transparent),
    radial-gradient(1px 1px at 20% 62%, var(--muted), transparent),
    radial-gradient(1px 1px at 80% 56%, #9aa6c0, transparent),
    radial-gradient(1px 1px at 46% 72%, var(--muted), transparent);
  transform: translate3d(0, calc(var(--sy) * 40px), 0);
}

/* ------------------------------------------------------------- Candles --
   Three light sources site-wide, and no more: the hero, the games card
   under the pointer, and the floor of the footer. `.lamp` places the light
   and holds its level; `.pool` is the light itself and breathes on its own,
   so the two never fight over one property. */

.lamp {
  position: absolute;
  display: block;
  width: var(--r, 300px);
  height: var(--rh, var(--r, 300px));
  pointer-events: none;
}

.pool {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 50%;
  filter: blur(2px);
  background-image: radial-gradient(closest-side,
    rgba(var(--candle-rgb), 0.20),
    rgba(var(--ember-rgb), 0.085) 44%,
    rgba(var(--ember-rgb), 0) 74%);
}

/* The core is a third of the radius, warmer, and never animates. */
.pool::after {
  content: "";
  position: absolute;
  inset: 33%;
  border-radius: 50%;
  background-image: radial-gradient(closest-side,
    rgba(var(--core-rgb), 0.16),
    rgba(255, 190, 110, 0) 70%);
}

.lamp.hero-lamp { --r: 300px; right: -90px; bottom: -70px; }

.lamp.floor {
  --r: min(900px, 140%);
  --rh: 440px;
  left: 0;
  right: 0;
  bottom: -260px;
  margin-inline: auto;
}

.lamp.floor .pool {
  background-image: radial-gradient(closest-side,
    rgba(var(--candle-rgb), 0.13),
    rgba(var(--ember-rgb), 0.05) 46%,
    rgba(var(--ember-rgb), 0) 76%);
}

/* ------------------------------------------------------------- Layout -- */

.wrap {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding-inline: 1.75rem;
}

/* --------------------------------------------------------------- Type -- */

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 11vw, 4.875rem);
  line-height: 0.98;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--display);
}

h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 5vw, 2.125rem);
  line-height: 1.1;
  letter-spacing: 0.05em;
  color: var(--text);
}

h3 {
  margin: 0;
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--text);
}

p { margin: 0; text-wrap: pretty; }

.meta {
  font: 500 0.6875rem/1 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

.meta.lit { color: var(--candle); }
.meta.faint { color: var(--faint); }

.lead { color: var(--lead); font-size: 1.125rem; }

/* --------------------------------------------------------------- Moon --
   The only cold source on the site, and the only light that never
   flickers. It is never allowed to share a corner with a candle. */

.moon { display: block; color: var(--starlight); }

.moon.lg {
  width: 3.875rem;
  height: 3.875rem;
  color: #eef2fb;
  filter: drop-shadow(0 0 18px rgba(195, 204, 223, 0.30)) drop-shadow(0 0 48px rgba(150, 170, 210, 0.15));
}

.moon.md {
  width: 1.625rem;
  height: 1.625rem;
  color: #dfe6f5;
  filter: drop-shadow(0 0 8px rgba(195, 204, 223, 0.28));
}

.moon.sm { width: 1rem; height: 1rem; color: var(--muted); }

/* --------------------------------------------------------------- Bars -- */

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-block: 2.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.875rem;
  font-family: var(--serif);
  font-size: 1.0625rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text);
}

.topbar nav {
  display: flex;
  gap: 2.125rem;
  font-size: 0.875rem;
}

/* --------------------------------------------------------------- Hero -- */

.hero {
  position: relative;
  overflow: hidden;
  min-height: 88svh;
  display: flex;
  flex-direction: column;
  padding-block: 5rem 2.5rem;
}

/* Keep .wrap's gutter so the wordmark lines up with the brand in the top
   bar, and cap the line length on the children instead. */
.hero-inner { margin-block: auto 0; }
.hero-inner > * { max-width: 39rem; }

.hero .moon.lg { margin-bottom: 2.375rem; }

.hero-inner .wordmark { margin-top: 0; }

.rule-label {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.125rem;
}

.rule-label .line {
  display: none;
  width: 3.5rem;
  height: 1px;
  flex: none;
  background-image: linear-gradient(90deg, rgba(var(--candle-rgb), 0.7), rgba(var(--candle-rgb), 0));
}

.tagline {
  font: 0.75rem/1 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--candle);
}

.hero .intro { margin-top: 1.625rem; font-size: 1rem; }

.hero-actions {
  margin-top: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* On a narrow screen only the scroll cue survives — the pair of labels is
   wider than 320px once the tracking is counted. */
.hero-foot {
  margin-top: 2.5rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.hero-foot .count { display: none; }

/* ----------------------------------------------------------- Sections -- */

section { padding-block: 4.5rem; }

.section-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 2.25rem;
}

/* -------------------------------------------------------------- Games -- */

.games {
  display: grid;
  /* min() keeps the 280px track from outgrowing a 320px screen. */
  grid-template-columns: repeat(auto-fit, minmax(min(17.5rem, 100%), 1fr));
  gap: 1.75rem;
}

.game {
  position: relative;
  overflow: hidden;
  min-height: 17.5rem;
  padding: 2.125rem 1.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  border: 1px solid var(--line);
  background-color: var(--surface-2);
  transition: border-color 0.35s var(--ease), background-color 0.35s var(--ease);
}

/* Lift the copy above the pool without catching the lamp itself — a bare
   `.game > *` outranks `.lamp`'s own `position: absolute` and drops a 260px
   hole into the top of every card. */
.game > :not(.lamp) { position: relative; }

.game h3 { color: #c8cfdf; transition: color 0.35s var(--ease); }
.game p { color: var(--dim); font-size: 0.9375rem; transition: color 0.35s var(--ease); }
.game .meta { transition: color 0.35s var(--ease); }
.game .spacer { margin-top: auto; }

/* The light follows the pointer and only ever lives on the card that has
   attention, so two cards are never lit at once. */
.game .lamp {
  --r: 260px;
  left: var(--mx, 50%);
  top: var(--my, 116%);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

.game:hover,
.game:focus-within {
  border-color: var(--line-2);
  background-color: var(--surface);
}

.game:hover .lamp,
.game:focus-within .lamp { opacity: 0.8; }

.game:hover h3,
.game:focus-within h3 { color: var(--text); }

.game:hover p,
.game:focus-within p { color: var(--muted); }

.game:hover .meta,
.game:focus-within .meta { color: var(--candle); }

/* The open slot is a promise, not a product: dashed, unlit, no surface. */
.game.slot {
  border-style: dashed;
  border-color: #1a2131;
  background-color: transparent;
}

.game.slot:hover,
.game.slot:focus-within { background-color: transparent; }

/* ------------------------------------------------------------ Contact -- */

.contact-grid {
  display: grid;
  gap: 2.5rem;
  align-items: end;
}

.contact-grid p { margin-top: 1.25rem; font-size: 1.0625rem; }

.contact-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.socials {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ------------------------------------------------------------- Footer -- */

.page-foot { position: relative; overflow: hidden; }

.foot-inner {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  padding-block: 2.125rem 2.5rem;
  border-top: 1px solid var(--line);
}

.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--serif);
  font-size: 0.8125rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem;
  font-size: 0.875rem;
}

.copyright {
  font: 0.6875rem/1 var(--mono);
  letter-spacing: 0.14em;
  color: var(--faint);
}

/* -------------------------------------------------- Links and buttons -- */

a { color: var(--muted); text-decoration: none; transition: color 0.16s ease-out; }
a:hover { color: var(--starlight); }

:focus-visible {
  outline: 2px solid var(--candle);
  outline-offset: 3px;
}

.btn {
  display: inline-block;
  padding: 0.875rem 1.625rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--btn-text);
  border: 1px solid rgba(var(--candle-rgb), 0.32);
  background-color: rgba(var(--candle-rgb), 0.07);
  transition: color 0.16s ease-out, border-color 0.16s ease-out, background-color 0.16s ease-out, box-shadow 0.16s ease-out;
}

.btn:hover,
.btn:focus-visible {
  color: var(--btn-lit);
  border-color: rgba(var(--candle-rgb), 0.55);
  background-color: rgba(var(--candle-rgb), 0.13);
  box-shadow:
    0 0 0 1px rgba(var(--candle-rgb), 0.10),
    0 10px 40px -14px rgba(var(--candle-rgb), 0.55);
}

/* No lift on press — the light does the work, not the geometry. */
.btn:active { background-color: rgba(var(--candle-rgb), 0.18); }

.btn.lit {
  color: var(--btn-lit);
  border-color: rgba(var(--candle-rgb), 0.55);
  background-color: rgba(var(--candle-rgb), 0.13);
  box-shadow: 0 10px 40px -14px rgba(var(--candle-rgb), 0.5);
}

.btn.quiet {
  color: var(--muted);
  border-color: var(--line-2);
  background-color: transparent;
  font-weight: 400;
  font-size: 0.875rem;
  padding: 0.8125rem 1.375rem;
}

.btn.quiet:hover,
.btn.quiet:focus-visible {
  color: #dfe6f5;
  border-color: #313a52;
  background-color: #0d1220;
  box-shadow: none;
}

.link-out {
  align-self: flex-start;
  font-size: 0.875rem;
  color: var(--muted);
  border-bottom: 1px solid #2a3345;
  padding-bottom: 3px;
}

.link-out:hover { color: var(--starlight); border-bottom-color: var(--candle); }

/* ------------------------------------------------------ Legal / long-form --
   No candles on this page: nothing here is an action, so nothing here is
   lit. */

.legal-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-block: 2rem 2rem;
  border-bottom: 1px solid var(--line);
}

.legal-layout { padding-block: 3rem 5rem; }

.toc { display: none; }

.legal article { max-width: var(--measure); }

.legal .updated {
  font: 0.6875rem/1 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

.legal h1 {
  margin: 1.375rem 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 8vw, 2.875rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: var(--display);
}

.legal .lead { margin-top: 1.625rem; line-height: 1.7; }

/* The hairline does the spacing work, so the heading needs no ornament. */
.legal h2 {
  margin-top: 3.5rem;
  padding-top: 1.375rem;
  border-top: 1px solid var(--line);
  font-size: clamp(1.375rem, 5vw, 1.6875rem);
  letter-spacing: 0.02em;
}

/* H3 is system 600, deliberately not serif, so the two levels can never be
   confused. */
.legal h3 {
  margin-top: 2.125rem;
  font-size: 1.1875rem;
  color: #dfe6f5;
}

.legal p { margin-top: 1.125rem; line-height: 1.75; }
.legal h2 + p, .legal h3 + p { margin-top: 0.875rem; }

.legal ul {
  margin: 1.125rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.legal li {
  display: grid;
  grid-template-columns: 1.125rem 1fr;
  gap: 0.75rem;
  line-height: 1.7;
}

.legal li::before {
  content: "\2014";
  color: var(--candle);
  font-size: 0.8125rem;
  line-height: 1.9;
}

.legal strong { color: var(--lead); font-weight: 600; }
.legal em { color: var(--lead); font-style: normal; }

/* Scoped to the prose: the table of contents has its own treatment and must
   not inherit the amber underline. */
.legal article a {
  color: var(--candle);
  border-bottom: 1px solid rgba(var(--candle-rgb), 0.4);
}

.legal article a:hover { color: var(--btn-lit); border-bottom-color: var(--candle); }

.back {
  font-family: var(--serif);
  font-size: 0.875rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------------------------------------------------------- 404 --
   The darkest page on the site. The only warm thing is the exit. */

.lost {
  min-height: 84svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.lost .moon { opacity: 0.5; width: 2.875rem; height: 2.875rem; filter: drop-shadow(0 0 14px rgba(195, 204, 223, 0.2)); }

.lost .numeral {
  margin-top: 2.5rem;
  font-family: var(--serif);
  font-size: clamp(4.5rem, 22vw, 6rem);
  line-height: 1;
  letter-spacing: 0.1em;
  color: #2a3345;
}

.lost h1 {
  margin: 1.75rem 0 0;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--lead);
}

.lost p { margin-top: 1rem; max-width: 44ch; color: var(--dim); }
.lost .btn { margin-top: 2.375rem; }

.lost-sky .stars { opacity: 0.45; }

/* ------------------------------------------------------- Reveal on scroll --
   Only ever hidden under `.js`, which an inline snippet adds before first
   paint — with scripting off nothing is hidden. */

.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
  transition-delay: var(--d, 0s);
}

.js .reveal.in { opacity: 1; transform: none; }

.hero-inner > .reveal:nth-child(2) { --d: 0.08s; }
.hero-inner > .reveal:nth-child(3) { --d: 0.16s; }
.hero-inner > .reveal:nth-child(4) { --d: 0.24s; }
.hero-inner > .reveal:nth-child(5) { --d: 0.32s; }

/* ---------------------------------------------------------- Wide screens -- */

@media (min-width: 45rem) {
  .hero { min-height: 100svh; padding-block: 0 3.25rem; }
  .hero-inner { margin-block: auto; }
  .topbar { display: flex; }
  .wm-break { display: none; }
  .rule-label .line { display: block; }
  .tagline { font-size: 0.8125rem; letter-spacing: 0.24em; }
  .hero .intro { font-size: 1.125rem; max-width: 52ch; }
  .hero-actions { flex-direction: row; align-items: center; gap: 1rem; }
  .hero-foot { justify-content: space-between; }
  .hero-foot .count { display: inline; }
  .hero-actions .btn { padding-inline: 1.875rem; }
  section { padding-block: 6rem; }
  .section-head { margin-bottom: 2.75rem; }
  .contact-grid { grid-template-columns: 1fr auto; gap: 5rem; }
  .legal-layout { padding-block: 3.5rem 6rem; }
}

@media (min-width: 64rem) {
  .lamp.hero-lamp { --r: 560px; right: 6%; bottom: -160px; }

  .legal-layout {
    display: grid;
    grid-template-columns: 14.375rem minmax(0, var(--measure));
    gap: 5rem;
  }

  .toc {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: sticky;
    top: 2.5rem;
    align-self: start;
    max-height: calc(100svh - 5rem);
    overflow-y: auto;
  }

  .toc a {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--dim);
    border-left: 1px solid var(--line-2);
    padding-left: 0.75rem;
  }

  .toc a:hover { color: var(--starlight); border-left-color: var(--line-3); }
}

/* -------------------------------------------------------------- Motion --
   Flicker is ±4% opacity and ±1.4% scale over two desynced periods. It
   breathes, it never blinks: nothing on the site changes faster than 3s.
   Scale rides the `scale` property so it never clobbers the transform a
   lamp uses for positioning. */

@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .stars.near { transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .hero-lamp .pool { animation: flick-a 6.4s ease-in-out infinite; }
  .floor .pool { animation: flick-b 8.1s ease-in-out infinite; }
}

@keyframes flick-a {
  0%, 100% { opacity: 0.94;  scale: 1; }
  27%      { opacity: 1;     scale: 1.014; }
  51%      { opacity: 0.955; scale: 0.998; }
  76%      { opacity: 0.985; scale: 1.007; }
}

@keyframes flick-b {
  0%, 100% { opacity: 0.97;  scale: 1.006; }
  34%      { opacity: 0.93;  scale: 0.996; }
  68%      { opacity: 1;     scale: 1.012; }
}
