/*
 * Rise to Greatness — the site's one stylesheet.
 *
 * The colours are the game's own: the UI theme's surfaces and text (src/ui/ui_theme.gd) and the
 * palette ramps (data/art/palette.tres), so the site and the client read as one product. Body text
 * is the system's UI face and the display face is the game's PixelifySans (OFL, D-032): the game's
 * body face ships as an 876 KB variable font, and no page should pay that to read a paragraph.
 * Contrast is WCAG AA or better for every text colour on every surface it is used on.
 */

@font-face {
  font-family: "Pixelify Sans";
  src: url("/assets/fonts/PixelifySans.9ba86cd010.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --ink: #0a0a0c;        /* UITheme.BG_DEEP */
  --sunken: #0e0e10;     /* UITheme.BG_SUNKEN */
  --plate: #161619;      /* UITheme.BG_PANEL */
  --raised: #202024;     /* UITheme.BG_RAISED */
  --border: #333338;     /* UITheme.BORDER */
  --border-strong: #524f54;
  --text: #f5f0e6;       /* UITheme.TEXT */
  --muted: #b0aca2;      /* UITheme.TEXT_MUTED, 9.3:1 on --ink */
  --faint: #8f8b85;      /* 5.6:1 on --ink, 5.1:1 on --plate */
  --gold: #f0cc8f;       /* UITheme.ACCENT */
  --gold-dim: #9e804d;   /* UITheme.ACCENT_DIM */
  --ember: #ff8c2e;      /* palette ember:4 */
  --sky: #76b6ff;        /* palette sky:5 */
  --verdigris: #5cad57;  /* palette verdigris:4 */
  --void: #b87ef0;       /* palette void:5 */
  --good: #6be094;       /* UITheme.GOOD */
  --bad: #f26b6b;        /* UITheme.BAD */

  --display: "Pixelify Sans", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;

  --step--1: clamp(0.84rem, 0.82rem + 0.1vw, 0.9rem);
  --step-0: clamp(1rem, 0.97rem + 0.15vw, 1.075rem);
  --step-1: clamp(1.17rem, 1.1rem + 0.35vw, 1.35rem);
  --step-2: clamp(1.4rem, 1.25rem + 0.75vw, 1.85rem);
  --step-3: clamp(1.75rem, 1.45rem + 1.5vw, 2.6rem);
  --step-4: clamp(2.2rem, 1.7rem + 2.5vw, 3.6rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: clamp(3.5rem, 2.5rem + 5vw, 6.5rem);

  --radius: 0.375rem;
  --measure: 44rem;
  --wide: 76rem;
  --gutter: clamp(1rem, 0.4rem + 3vw, 2.5rem);
}

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

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; height: auto; }
.pixel { image-rendering: pixelated; }
[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
  margin: 0 0 var(--space-4);
  text-wrap: balance;
}
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--text); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 2px; }

code, pre { font-family: var(--mono); font-size: 0.9em; }
pre {
  margin: 0 0 var(--space-4);
  padding: var(--space-4);
  overflow-x: auto;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.5;
}
:not(pre) > code {
  padding: 0.1em 0.35em;
  background: var(--raised);
  border-radius: 0.25rem;
  overflow-wrap: anywhere;
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  z-index: 20;
  padding: var(--space-2) var(--space-4);
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
  border-radius: var(--radius);
}
.skip-link:focus { top: var(--space-4); }

.container {
  width: 100%;
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---- Buttons --------------------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.9rem;
  padding: 0.6rem 1.35rem;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--ink);
  font: 600 var(--step-0) / 1.2 var(--body);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.button:hover { background: var(--text); border-color: var(--text); color: var(--ink); }
.button:disabled { opacity: 0.6; cursor: progress; }
.button-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.button-ghost:hover { background: var(--raised); color: var(--text); border-color: var(--gold-dim); }
.button-small { min-height: 2.25rem; padding: 0.35rem 0.9rem; font-size: var(--step--1); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); }
.text-link { font-weight: 600; }
.text-link::after { content: " →"; }

/* ---- Masthead and footer ---------------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgb(10 10 12 / 0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  min-height: 3.75rem;
  padding-block: var(--space-2);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-family: var(--display);
  font-size: var(--step-1);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--gold); }
.primary-nav ul, .footer-nav ul { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); margin: 0; padding: 0; list-style: none; }
.primary-nav a, .footer-nav a { color: var(--muted); text-decoration: none; }
.primary-nav a:hover, .footer-nav a:hover, .primary-nav a[aria-current="page"], .footer-nav a[aria-current="page"] { color: var(--text); }
.primary-nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 0.4em; }
.masthead-actions { display: flex; align-items: center; gap: var(--space-4); margin-left: auto; }
.lang-switch { color: var(--muted); font-size: var(--step--1); }

@media (max-width: 52rem) {
  .primary-nav { order: 3; width: 100%; overflow-x: auto; }
  .primary-nav ul { flex-wrap: nowrap; padding-bottom: var(--space-1); }
  .primary-nav a { white-space: nowrap; }
}
@media (max-width: 26rem) {
  .brand span { display: none; }
}

.site-footer {
  margin-top: var(--space-8);
  padding-block: var(--space-7);
  background: var(--sunken);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--step--1);
}
.footer-inner { display: grid; gap: var(--space-6); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); align-items: start; }
.footer-brand img { width: 11rem; margin-bottom: var(--space-3); }
.footer-nav ul { flex-direction: column; gap: var(--space-2); }
.footer-legal { grid-column: 1 / -1; margin: 0; padding-top: var(--space-5); border-top: 1px solid var(--border); color: var(--faint); }

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

.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: min(52rem, 88vh);
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid var(--border);
}
.hero-art {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% 50%;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgb(10 10 12 / 0.35) 0%, rgb(10 10 12 / 0.55) 45%, var(--ink) 100%),
    linear-gradient(90deg, rgb(10 10 12 / 0.85) 0%, rgb(10 10 12 / 0.2) 70%);
}
.hero-content { padding-block: var(--space-8) var(--space-7); }
.hero-logo { margin: 0 0 var(--space-4); }
.hero-logo img { width: min(34rem, 92%); margin-left: -3%; filter: drop-shadow(0 6px 24px rgb(0 0 0 / 0.6)); }
.hero-tagline { font-family: var(--display); font-size: var(--step-2); color: var(--gold); margin-bottom: var(--space-3); }
.hero-lede { max-width: 38rem; font-size: var(--step-1); color: var(--text); }
.hero-note { margin-top: var(--space-5); color: var(--muted); font-size: var(--step--1); }

/* On a narrow screen the cover crop centres on the key art's middle, which is where the capture's
   combat text is (a damage number, an aggro mark, a monster's name): it lands behind the stacked
   wordmark and reads as a glitch. The crop moves left, onto the Emberworks wall and floor, which
   carry no text, and the scrim closes under the wordmark and the headline. */
@media (max-width: 40rem) {
  .hero-art { object-position: 8% 50%; }
  .hero::before {
    background:
      linear-gradient(180deg, rgb(10 10 12 / 0.55) 0%, rgb(10 10 12 / 0.78) 40%, var(--ink) 100%);
  }
}

.eyebrow {
  margin: 0 0 var(--space-3);
  color: var(--gold);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---- Sections and layout ---------------------------------------------------------------- */

.section { padding-block: var(--space-8); }
.section-alt { background: var(--plate); border-block: 1px solid var(--border); }
.section-title { max-width: var(--measure); }
.section-lede { max-width: var(--measure); color: var(--muted); font-size: var(--step-1); margin-bottom: var(--space-6); }
.prose { max-width: var(--measure); }
.prose + .stats, .prose + .biomes, .prose + .strip { margin-top: var(--space-6); }
.meta { color: var(--faint); font-size: var(--step--1); }

.split { display: grid; gap: var(--space-6); align-items: center; }
.two-col { display: grid; gap: var(--space-7); }
@media (min-width: 60rem) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.page-header { padding-block: var(--space-8) var(--space-6); border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--plate), var(--ink)); }
.page-title { font-size: var(--step-4); }
.page-lede { max-width: var(--measure); color: var(--muted); font-size: var(--step-1); }

.toc { margin-top: var(--space-6); }
.toc ul { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.toc a {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: var(--step--1);
  text-decoration: none;
}
.toc a:hover { border-color: var(--gold); color: var(--gold); }
[id] { scroll-margin-top: 5rem; }

/* ---- Cards ----------------------------------------------------------------------------- */

.card-grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); margin-top: var(--space-6); }
.card {
  padding: var(--space-5) var(--space-5) var(--space-6);
  background: var(--plate);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold-dim);
  border-radius: var(--radius);
}
.card p { color: var(--muted); }
.card-accent-ember { border-top-color: var(--ember); }
.card-accent-gold { border-top-color: var(--gold); }
.card-accent-sky { border-top-color: var(--sky); }

/* ---- The acts --------------------------------------------------------------------------- */

.timeline { width: 100%; height: 0.75rem; margin-bottom: var(--space-5); border-radius: 2px; overflow: hidden; }
.timeline .act-descent { fill: var(--sky); }
.timeline .act-contest { fill: var(--gold); }
.timeline .act-collapse { fill: var(--ember); }

.acts { display: grid; gap: var(--space-5); margin: 0 0 var(--space-6); padding: 0; list-style: none; }
@media (min-width: 52rem) { .acts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.act { padding: var(--space-5); background: var(--ink); border: 1px solid var(--border); border-left: 4px solid; border-radius: var(--radius); }
.acts .act-descent { border-left-color: var(--sky); }
.acts .act-contest { border-left-color: var(--gold); }
.acts .act-collapse { border-left-color: var(--ember); }
.act-time { margin-bottom: var(--space-2); color: var(--muted); font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.act p:not(.act-time) { color: var(--muted); }

/* ---- Screens ---------------------------------------------------------------------------- */

.showcase { display: grid; gap: var(--space-5); margin-top: var(--space-6); }
@media (min-width: 52rem) {
  .showcase { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shot-main { grid-column: 1 / -1; }
}
.shot, .strip { margin: 0; }
.shot img, .strip img { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--sunken); }
figcaption { margin-top: var(--space-2); color: var(--faint); font-size: var(--step--1); }
.strip img { background: #2c2f3e; }

/* ---- Rules, stats, biomes ------------------------------------------------------------------ */

.rule-list { display: grid; gap: var(--space-3); max-width: var(--measure); margin: 0; padding: 0; list-style: none; }
.rule-list li { position: relative; padding-left: var(--space-5); color: var(--muted); }
.rule-list li::before { content: ""; position: absolute; left: 0; top: 0.65em; width: 0.5rem; height: 0.5rem; background: var(--gold); }
.rule-list strong { color: var(--text); }

.stats { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); margin: 0; }
.stat { display: flex; flex-direction: column-reverse; padding: var(--space-4); background: var(--plate); border: 1px solid var(--border); border-radius: var(--radius); }
.stat dt { color: var(--muted); font-size: var(--step--1); }
.stat dd { margin: 0; font-family: var(--display); font-size: var(--step-3); color: var(--gold); line-height: 1.1; font-variant-numeric: tabular-nums; }

.biomes { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); margin: 0 0 var(--space-7); padding: 0; list-style: none; }
.biome { padding: var(--space-5); background: var(--plate); border: 1px solid var(--border); border-top: 3px solid var(--border-strong); border-radius: var(--radius); }
.biome p { color: var(--muted); }
.biome-emberworks { border-top-color: var(--ember); }
.biome-hollowfrost { border-top-color: var(--sky); }
.biome-stormvault { border-top-color: var(--void); }
.biome-barrowmere { border-top-color: var(--verdigris); }
.biome-facts { display: grid; gap: var(--space-1); margin: var(--space-4) 0 0; font-size: var(--step--1); }
.biome-facts div { display: flex; justify-content: space-between; gap: var(--space-3); padding-top: var(--space-1); border-top: 1px solid var(--border); }
.biome-facts dt { color: var(--faint); }
.biome-facts dd { margin: 0; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

.boss-list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-6); padding: 0; list-style: none; }
.boss-list li { padding: 0.25rem 0.75rem; border: 1px solid var(--gold-dim); border-radius: 999px; color: var(--gold); font-family: var(--display); }

/* ---- Alpha ----------------------------------------------------------------------------- */

.steps { display: grid; gap: var(--space-4); margin: var(--space-6) 0 0; padding: 0; list-style: none; counter-reset: step; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.step { position: relative; padding: var(--space-5); padding-top: var(--space-7); background: var(--plate); border: 1px solid var(--border); border-radius: var(--radius); counter-increment: step; }
.step::before { content: counter(step); position: absolute; top: var(--space-4); left: var(--space-5); font-family: var(--display); font-size: var(--step-2); color: var(--gold); }
.step p { color: var(--muted); }
.key-sample { display: inline-block; margin-top: var(--space-2); letter-spacing: 0.04em; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.spec-table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.spec-table th, .spec-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.spec-table tr:last-child th, .spec-table tr:last-child td { border-bottom: 0; }
.spec-table thead th { background: var(--raised); color: var(--text); }
.spec-table tbody th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.facts-table tbody th { width: 34%; }

.downloads { max-width: var(--measure); }
.downloads-pending { padding: var(--space-5); background: var(--ink); border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); }
.download-list { display: grid; gap: var(--space-4); margin: var(--space-4) 0; padding: 0; list-style: none; }
.download { padding: var(--space-5); background: var(--ink); border: 1px solid var(--border); border-radius: var(--radius); }
.download-meta { color: var(--muted); font-size: var(--step--1); }
.download-sum code { word-break: break-all; }
.download-extras { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin: 0 0 var(--space-4); padding: 0; list-style: none; }

/* ---- FAQ and press ----------------------------------------------------------------------- */

.faq { display: grid; gap: var(--space-3); max-width: var(--measure); margin: 0; }
.faq-item { padding: var(--space-5); background: var(--plate); border: 1px solid var(--border); border-radius: var(--radius); }
.faq dt { margin-bottom: var(--space-2); font-family: var(--display); font-size: var(--step-1); color: var(--text); }
.faq dd { margin: 0; color: var(--muted); }

.asset-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); margin: 0; padding: 0; list-style: none; }
.asset a { display: flex; flex-direction: column; gap: var(--space-2); height: 100%; padding: var(--space-3); background: var(--plate); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.asset a:hover { border-color: var(--gold-dim); }
.asset img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--sunken); border-radius: 0.25rem; }
.asset .asset-logo, .asset .asset-icon { object-fit: contain; padding: var(--space-3); }
.asset span { font-size: var(--step--1); }

.legal h2 { font-size: var(--step-2); margin-top: var(--space-6); }
.legal h2:first-child { margin-top: 0; }
.legal p { color: var(--muted); }

/* ---- Waitlist and answer pages ------------------------------------------------------------ */

.waitlist-panel {
  display: grid;
  gap: var(--space-6);
  padding: clamp(1.5rem, 1rem + 3vw, 3.5rem);
  background:
    radial-gradient(120% 140% at 0% 0%, rgb(240 204 143 / 0.08), transparent 60%),
    var(--plate);
  border: 1px solid var(--gold-dim);
  border-radius: calc(var(--radius) * 2);
}
@media (min-width: 60rem) { .waitlist-panel { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; } }
.waitlist-copy p { color: var(--muted); }
.steps-inline { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-4) 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps-inline li { counter-increment: step; padding: 0.25rem 0.75rem; background: var(--ink); border: 1px solid var(--border); border-radius: 999px; font-size: var(--step--1); color: var(--text); }
.steps-inline li::before { content: counter(step) ". "; color: var(--gold); }

.field-label { display: block; margin-bottom: var(--space-2); font-weight: 600; }
.field-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.field {
  flex: 1 1 14rem;
  min-width: 0;
  min-height: 2.9rem;
  padding: 0.6rem 0.9rem;
  background: var(--sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
.field::placeholder { color: var(--faint); }
.field:focus { outline: 3px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.field-hint { margin-top: var(--space-2); color: var(--faint); font-size: var(--step--1); }
.consent { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); margin-top: var(--space-4); color: var(--muted); font-size: var(--step--1); line-height: 1.5; }
.consent input { width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; accent-color: var(--gold); }
.waitlist-status { margin-top: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--ink); }
.waitlist-status[data-kind="good"] { border-color: var(--good); color: var(--good); }
.waitlist-status[data-kind="bad"] { border-color: var(--bad); color: var(--bad); }
.waitlist-status[data-kind="info"] { color: var(--muted); }

.result { min-height: 60vh; display: flex; align-items: center; }
.result-panel { max-width: var(--measure); }
.token-form { margin-top: var(--space-5); }

@media print {
  .masthead, .site-footer, .waitlist, .hero-art { display: none; }
  body { background: #fff; color: #000; }
}
