/* ============================================================
   Apogeo — landing page
   Same design language as the game and the legal pages: SpaceMono,
   the game's void palette, hairline panels. Every
   piece of the game on the page (stars, pickups, ships, trails) is a
   canvas drawn by site/game-art.js, the renderer's own drawings; the
   CSS only lays them out. With "reduce motion" everything holds still
   and stays readable.
   ============================================================ */

@font-face {
  font-family: "SpaceMono";
  src: url("/fonts/SpaceMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "SpaceMono";
  src: url("/fonts/SpaceMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --void-0: #07040f;
  --void-1: #160e30;
  --bg-top: #0a0620;
  --bg-mid: #0b0718;
  --star: #ffc46b;
  --star-core: #fff7e6;
  --ship: #8ff7ff;
  --ghost: #c77dff;
  --ink: #e9e4ff;
  --muted: #8b82b8;
  --boost: #ff8a4d;
  --magnet: #ff5ed0;
  --cold: #6a7392;

  --line: rgba(143, 247, 255, 0.14);
  --line-strong: rgba(143, 247, 255, 0.3);
  --panel: rgba(16, 11, 36, 0.55);

  --mono: "SpaceMono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: max(20px, env(safe-area-inset-left), env(safe-area-inset-right));
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Both languages live in the markup; <html lang> picks one before paint. */
:root[lang="it"] [lang="en"],
:root[lang="en"] [lang="it"] { display: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--void-0) 100%) fixed;
  overflow-x: hidden;
}

/* A slow violet nebula drifting behind everything (the game's own). */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 30% 30%, rgba(90, 50, 160, 0.16), transparent 70%),
    radial-gradient(35% 30% at 75% 70%, rgba(60, 40, 130, 0.12), transparent 70%);
  animation: nebula 70s ease-in-out infinite alternate;
}
@keyframes nebula {
  to { transform: translate3d(8%, -6%, 0) scale(1.08); }
}

.sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

a { color: var(--ship); }
:focus-visible { outline: 2px solid var(--ship); outline-offset: 4px; border-radius: 6px; }

/* ---------- header ---------- */

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) var(--gutter) 14px;
  transition: background 0.4s ease, border-color 0.4s ease;
  border-bottom: 1px solid transparent;
}
.top.scrolled {
  background: rgba(7, 4, 15, 0.62);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.32em;
}
.brand img { border-radius: 8px; display: block; }
.lang {
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--muted);
  background: rgba(16, 11, 36, 0.5);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color 0.25s ease;
}
.lang:hover { border-color: var(--line-strong); }
.lang .sep { margin: 0 6px; opacity: 0.5; }
:root[lang="it"] .lang [data-code="it"],
:root[lang="en"] .lang [data-code="en"] { color: var(--ink); font-weight: 700; }

main, .foot { position: relative; z-index: 1; }

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 110px var(--gutter) 120px;
  overflow: hidden;
}
.orrery {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.8s ease;
}
.orrery.on { opacity: 1; }
/* The scene and its scrim fade out at the bottom of the hero, so the page
   flows on instead of ending in a hard edge. */
.orrery,
.hero::after {
  -webkit-mask-image: linear-gradient(180deg, #000 74%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 74%, transparent 100%);
}
/* Keeps the copy readable while the ships fly behind it. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(7, 4, 15, 0.88) 0%, rgba(7, 4, 15, 0.62) 30%, rgba(7, 4, 15, 0) 56%);
}
.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 36rem;
  margin-left: max(0px, calc((100vw - 1180px) / 2));
}
.kicker {
  margin: 0 0 18px;
  color: var(--star);
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}
.title {
  margin: 0;
  font-size: clamp(3.4rem, 10.5vw, 7.6rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0.16em;
  text-shadow: 0 0 34px rgba(143, 247, 255, 0.22), 0 0 2px rgba(233, 228, 255, 0.4);
}
.tagline {
  margin: 18px 0 0;
  color: var(--ship);
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  letter-spacing: 0.06em;
}
.lede {
  margin: 18px 0 34px;
  max-width: 31rem;
  color: rgba(233, 228, 255, 0.78);
  font-size: 15px;
}

/* Entrance: copy settles in once, top to bottom. */
.js .hero-copy > * {
  opacity: 0;
  transform: translateY(14px);
  animation: settle 1.1s var(--ease-out) forwards;
}
.js .hero-copy > :nth-child(2) { animation-delay: 0.12s; }
.js .hero-copy > :nth-child(3) { animation-delay: 0.3s; }
.js .hero-copy > :nth-child(4) { animation-delay: 0.42s; }
.js .hero-copy > :nth-child(5) { animation-delay: 0.56s; }
@keyframes settle { to { opacity: 1; transform: none; } }

/* Official store badges: Apple's and Google's guidelines forbid recolouring
   or restyling them, so they get size, spacing and a focus ring — nothing
   else. A store that isn't open yet is plain text, never a dimmed badge. */
.stores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}
.store { display: block; border-radius: 9px; }
.store[hidden] { display: none; }
.store img { display: block; height: 46px; width: auto; }
.soon {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.soon[hidden] { display: none; }

.scroll-cue {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.scroll-cue i {
  position: relative;
  width: 1px;
  height: 38px;
  background: linear-gradient(180deg, rgba(143, 247, 255, 0.5), rgba(143, 247, 255, 0));
}
.scroll-cue i::after {
  content: "";
  position: absolute;
  left: -0.5px;
  top: 0;
  width: 2px;
  height: 12px;
  border-radius: 1px;
  background: linear-gradient(180deg, rgba(143, 247, 255, 0), #dffaff);
  animation: cue 2.4s cubic-bezier(0.5, 0, 0.3, 1) infinite;
}
@keyframes cue {
  0% { transform: translateY(-12px); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(38px); opacity: 0; }
}

/* ---------- sections ---------- */

.section {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(72px, 11vw, 140px) var(--gutter) 0;
}
.section-head { max-width: 46rem; margin-bottom: clamp(32px, 5vw, 56px); }
.section-sub { margin-top: 14px; color: rgba(233, 228, 255, 0.72); }
.eyebrow {
  margin: 0 0 12px;
  color: var(--star);
  font-size: 11.5px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}
h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2.05rem);
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-wrap: balance;
}
h3 { margin: 0 0 8px; font-size: 1.05rem; letter-spacing: 0.04em; }
h4 { margin: 0 0 6px; font-size: 0.95rem; letter-spacing: 0.03em; }
p { margin: 0; }

.step,
.daily,
.duel,
.kit {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* Canvases take their size from the layout; the script matches the pixels. */
canvas.art,
canvas.kit-art { display: block; width: 100%; }
.art { aspect-ratio: 4 / 3; }

/* how it plays */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.step { padding: 14px 18px 28px; transition: border-color 0.4s ease, transform 0.4s var(--ease-out); }
.step:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.step > :not(.art) { margin-left: 6px; margin-right: 6px; }
.step p { color: rgba(233, 228, 255, 0.72); }
.step-n {
  display: block;
  margin: 8px 0 6px;
  color: var(--star);
  font-size: 12px;
  letter-spacing: 0.3em;
}

/* the constellation of the day: copy beside a wide sky */
.daily {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.3fr);
  align-items: center;
  gap: clamp(20px, 3vw, 44px);
  padding: clamp(14px, 1.6vw, 18px);
  overflow: hidden;
}
.daily-copy { padding: clamp(14px, 2.6vw, 34px); }
.daily-copy h2 { margin-bottom: 16px; }
.daily-copy p:last-child { color: rgba(233, 228, 255, 0.74); }
canvas.daily-art {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 11;
  border-radius: 16px;
}
@media (max-width: 860px) {
  .daily { grid-template-columns: 1fr; }
  .daily-copy { order: 2; padding: 6px 10px 18px; }
  canvas.daily-art { aspect-ratio: 4 / 3; }
}

/* in flight: ships and power-ups in one strip */
.kit {
  margin-top: 18px;
  padding: clamp(22px, 3.4vw, 40px) clamp(22px, 3.4vw, 40px) clamp(16px, 2.4vw, 26px);
}
.kit-copy { max-width: 40rem; }
.kit-copy h2 { margin-bottom: 10px; }
.kit-copy p:last-child { color: rgba(233, 228, 255, 0.72); }
canvas.kit-art { margin-top: clamp(14px, 2.4vw, 26px); aspect-ratio: 7.7 / 1; }
@media (max-width: 640px) {
  canvas.kit-art { aspect-ratio: 1 / 0.95; }
}

/* ---------- challenges ---------- */

.duel {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.4fr);
  align-items: center;
  gap: clamp(22px, 3.5vw, 52px);
  padding: clamp(26px, 4vw, 44px);
}
.duel-copy h2 { margin-bottom: 16px; }
.duel-copy > p { color: rgba(233, 228, 255, 0.74); }
.duel-rules {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.duel-rules li {
  position: relative;
  padding-left: 22px;
  color: rgba(233, 228, 255, 0.66);
  font-size: 13.5px;
  line-height: 1.6;
}
.duel-rules li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--star);
}

.duel-stage { position: relative; }
.phones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
/* A phone on its side: the game is landscape-only. */
.phone { margin: 0; }
.screen {
  position: relative;
  aspect-ratio: 19.5 / 9;
  border-radius: 16px;
  border: 5px solid #120c24;
  box-shadow: 0 0 0 1px rgba(143, 247, 255, 0.16), 0 18px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  background: #07040f;
}
canvas.screen-art { display: block; width: 100%; height: 100%; }
.veil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  text-align: center;
  background: rgba(7, 4, 15, 0.72);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.phone[data-state="idle"] .veil { opacity: 1; background: rgba(7, 4, 15, 0.86); }
.phone[data-state="idle"] .veil > * { visibility: hidden; }
.phone[data-state="sent"] .veil { opacity: 1; }
.veil p { margin: 0; }
.veil-kicker { color: var(--star); font-size: 9.5px; letter-spacing: 0.36em; padding-left: 0.36em; }
.veil-score { color: var(--ship); font-size: clamp(20px, 2.4vw, 28px); font-weight: 700; line-height: 1.2; margin-top: 4px !important; }
.veil-unit { color: var(--muted); font-size: 8px; letter-spacing: 0.24em; padding-left: 0.24em; }
.veil-wait { color: var(--muted); font-size: 10.5px; line-height: 1.45; margin-top: 8px !important; max-width: 22em; }
.phone:not([data-wait]) .veil-wait { display: none; }
.phone figcaption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--muted);
}
.phone figcaption b { color: var(--ink); font-weight: 700; letter-spacing: 0.06em; }
.phone[data-side="me"] figcaption b { color: var(--ship); }
.phone[data-side="them"] figcaption b { color: var(--ghost); }
.clock { font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }

/* The result, as the app shows it: waiting while a run is missing (your
   friend's score a question mark), then the outcome. */
.verdict {
  margin: 18px auto 0;
  max-width: 360px;
  padding: 16px 22px 14px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(7, 4, 15, 0.55);
  transition: border-color 0.7s ease, box-shadow 0.7s ease;
}
.verdict[data-state="done"] {
  border-color: rgba(255, 196, 107, 0.45);
  box-shadow: 0 0 28px rgba(255, 196, 107, 0.12);
}
.verdict p { margin: 0; }
.verdict-title { font-size: 12px; font-weight: 700; letter-spacing: 0.24em; padding-left: 0.24em; color: var(--muted); }
.verdict[data-state="done"] .verdict-title { color: var(--star); font-size: 17px; letter-spacing: 0.16em; padding-left: 0.16em; }
.verdict[data-state="wait"] .when-done,
.verdict[data-state="done"] .when-wait { display: none; }
.verdict-scores {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  margin: 10px 0 6px !important;
}
.verdict-scores .side { display: flex; flex-direction: column; align-items: center; min-width: 76px; }
.verdict-scores b { font-size: 26px; line-height: 1.15; }
.verdict-scores .side span { font-size: 10px; letter-spacing: 0.1em; color: var(--muted); }
.verdict-scores .me b { color: var(--ship); }
.verdict-scores .them b { color: var(--ghost); }
.verdict-scores .vs { color: var(--muted); font-size: 12px; margin-top: 9px !important; }
.verdict-scores b { transition: color 0.5s ease; }
.verdict[data-state="wait"] .them b { color: var(--muted); }
.verdict-margin { color: var(--muted); font-size: 12.5px; transition: opacity 0.6s ease; }
.verdict[data-state="wait"] .verdict-margin { opacity: 0; }
.verdict-margin b { color: var(--ink); }

@media (max-width: 860px) {
  .duel { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .phones { grid-template-columns: 1fr; gap: 14px; }
}

/* ---------- call to action ---------- */

.cta {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(110px, 16vw, 190px) var(--gutter);
  text-align: center;
  overflow: hidden;
}
/* Three ships going round the call to action. */
.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cta h2 { position: relative; font-size: clamp(1.6rem, 4.4vw, 2.8rem); }
.cta-sub { position: relative; margin: 16px 0 34px; color: var(--muted); }
.cta .stores { position: relative; justify-content: center; }

/* ---------- footer ---------- */

.foot {
  border-top: 1px solid var(--line);
  padding: 34px var(--gutter) calc(34px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 26px; margin-bottom: 14px; }
.foot-links a { color: rgba(233, 228, 255, 0.85); text-decoration: none; }
.foot-links a:hover { color: var(--ship); }
.support { margin-bottom: 6px; }
.support a { color: rgba(233, 228, 255, 0.85); }
.copy { letter-spacing: 0.12em; }

/* ---------- reveal on scroll ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s ease, transform 0.9s var(--ease-out);
}
.js .reveal.in { opacity: 1; transform: none; }
.js .steps .reveal:nth-child(2) { transition-delay: 0.12s; }
.js .steps .reveal:nth-child(3) { transition-delay: 0.24s; }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .hero {
    align-items: flex-start;
    padding-top: calc(118px + env(safe-area-inset-top));
    text-align: center;
  }
  .hero::after {
    background: linear-gradient(180deg, rgba(7, 4, 15, 0.8) 0%, rgba(7, 4, 15, 0.55) 45%, rgba(7, 4, 15, 0) 66%);
  }
  .orrery,
  .hero::after {
    -webkit-mask-image: linear-gradient(180deg, #000 88%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 88%, transparent 100%);
  }
  .cta { padding-top: 250px; }
  .hero-copy { margin: 0 auto; }
  .title { padding-left: 0.16em; } /* letter-spacing trails the last letter */
  .lede { margin-left: auto; margin-right: auto; }
  .stores { justify-content: center; }
  .scroll-cue { display: none; }
}

/* ---------- reduced motion: still, and fully visible ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .js .reveal, .js .hero-copy > * { opacity: 1; transform: none; }
  /* The canvases draw a single still frame themselves. */
  .orrery { opacity: 1; }
}
