/*
 * CartoRealm teaser. Tokens mirror the Road Collection design system (the "Night ride"
 * palette in apps/mobile/src/theme/palettes.ts, plus the four brand swatches). Rules below
 * read colours, type, space and shadows only through these variables, never as literals.
 */

@font-face { font-family: "Big Shoulders Display"; src: url("/fonts/BigShouldersDisplay-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("/fonts/BarlowCondensed-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("/fonts/BarlowCondensed-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/fonts/Barlow-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/fonts/Barlow-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  color-scheme: dark;

  /* Brand */
  --fog: #eaefef;
  --mist: #bfc9d1;
  --asphalt: #25343f;
  --signal: #ff9b51;

  /* Night ride */
  --surface: #18232b;
  --surface-raised: #25343f;
  --surface-overlay: #2f3f4b;
  --surface-sunken: #121b21;
  --line: #3a4b57;
  --line-strong: #7a8a96;
  --ink: #eaefef;
  --ink-muted: #a9b6bf;
  --signal-ink: #ff9b51;
  --on-signal: #18232b;
  --signal-deep: #c96a26;
  --danger: #ff7a6b;
  --success: #7ad6a8;
  --focus: #ff9b51;
  --lane-yellow: #f5c518;
  --stud-off: #3a4b57;
  --panel: rgba(18, 27, 33, 0.84);
  --vignette: rgba(18, 27, 33, 0.85);

  /* Type */
  --font-display: "Big Shoulders Display", "Barlow Condensed", system-ui, sans-serif;
  --font-sign: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-sans: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Space, radius, depth */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px;
  --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --radius-xs: 4px; --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-pill: 999px;
  --perspective-card: 900px;
  --key-travel: 4px;

  /* Shadows (Night ride) */
  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.4), 0 14px 30px -10px rgba(0, 0, 0, 0.8);
  --shadow-card-lift: 0 2px 0 rgba(0, 0, 0, 0.4), 0 32px 56px -14px rgba(0, 0, 0, 0.9);
  --shadow-key-signal: 0 4px 0 var(--signal-deep);
  --shadow-float: 0 6px 16px -4px rgba(0, 0, 0, 0.7);
  --shadow-slot: inset 0 2px 6px rgba(0, 0, 0, 0.6);

  /* Motion */
  --dur-press: 90ms; --dur-quick: 160ms; --dur-base: 260ms;
  --ease-press: cubic-bezier(0.3, 0, 0.6, 1);
  --ease-settle: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fog-drift: 60s;
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-press: 0ms; --dur-quick: 0ms; --dur-base: 0ms; }
}

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

/* The page listens for touches on the whole window (the tile map), which makes Android
 * browsers flash their tap highlight over everything. Controls show their own :active. */
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--asphalt);
  color: var(--ink);
  font: 400 17px/1.55 var(--font-sans);
  overflow-x: hidden;
}

a { color: var(--signal-ink); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── Background: the tile map, its fog, and a vignette for the copy ─────────────────── */

.map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }

.fog { position: fixed; inset: -20%; pointer-events: none; overflow: hidden; }
.fog i {
  /* White wisps on transparency, drawn with plain alpha: no blend mode, which some phone
   * GPUs composite wrongly once the canvas below repaints (the fog turned bright on a tap). */
  position: absolute; inset: 0;
  background-size: 512px 512px;
  will-change: transform;
}
.fog-a { background-image: url("/img/fog-a.webp"); opacity: 0.16; animation: drift-a var(--fog-drift) linear infinite alternate; }
.fog-b { background-image: url("/img/fog-b.webp"); opacity: 0.12; animation: drift-b calc(var(--fog-drift) * 1.4) linear infinite alternate; }
@keyframes drift-a { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-8%, 3%, 0); } }
@keyframes drift-b { from { transform: translate3d(-4%, 2%, 0); } to { transform: translate3d(5%, -3%, 0); } }
@media (prefers-reduced-motion: reduce) { .fog i { animation: none; } }

.vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 70% 60% at 50% 48%, var(--vignette), transparent 75%);
}

/* ── Header ──────────────────────────────────────────────────────────────────────── */

.top, .hero, .foot, .hint { position: relative; }

.top { padding: var(--space-5) var(--space-4) 0; display: flex; justify-content: center; }
.brand { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--fog); }
.brand-mark { width: 40px; height: 40px; border-radius: var(--radius-sm); box-shadow: var(--shadow-float); }
.brand-word { font: 800 26px/1 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; }

/* ── Hero ────────────────────────────────────────────────────────────────────────── */

.hero {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  pointer-events: none;
}
.hero > * { pointer-events: auto; }

.copy {
  width: 100%;
  max-width: 520px;
  padding: var(--space-6) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-float);
}

.eyebrow {
  margin: 0 0 var(--space-2);
  font: 700 14px/18px var(--font-sign);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--signal-ink);
}

h1 {
  margin: 0 0 var(--space-3);
  font: 700 clamp(40px, 9vw, 64px)/0.98 var(--font-sign);
  letter-spacing: -0.005em;
  color: var(--fog);
}

.lede { margin: 0 0 var(--space-6); color: var(--ink-muted); font-size: 18px; max-width: 34em; }

/* ── Waitlist form ───────────────────────────────────────────────────────────────── */

.field-label { display: block; margin-bottom: var(--space-2); font: 600 15px/20px var(--font-sans); color: var(--ink); }

.join-row { display: flex; flex-direction: column; gap: var(--space-3); }

.field-input {
  width: 100%; height: 52px; padding: 0 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-sunken); color: var(--ink); box-shadow: var(--shadow-slot);
  font: 400 17px/22px var(--font-sans);
}
.field-input::placeholder { color: var(--ink-muted); opacity: 0.8; }
.field-input:focus { outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--focus); }
.join.is-error .field-input { border-color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 52px; padding: 0 24px; margin-bottom: var(--key-travel);
  border: 0; border-radius: var(--radius-pill); cursor: pointer;
  font: 700 18px/1 var(--font-sign); letter-spacing: 0.02em; white-space: nowrap;
  transform: translateY(0);
  transition: transform var(--dur-press) var(--ease-press), box-shadow var(--dur-press) var(--ease-press);
}
.btn-primary { background: var(--signal); color: var(--on-signal); box-shadow: var(--shadow-key-signal), inset 0 2px 0 rgba(255, 255, 255, 0.35); }
.btn-primary:not(:disabled):active { transform: translateY(var(--key-travel)); box-shadow: 0 0 0 var(--signal-deep), inset 0 2px 0 rgba(255, 255, 255, 0.35); }
.btn:disabled { cursor: progress; opacity: 0.85; }
.btn-spinner {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
.btn.is-busy .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.platform { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0 0; padding: 0; border: 0; }
.platform-legend { float: left; margin-right: var(--space-2); font: 600 14px/32px var(--font-sign); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px;
  border-radius: var(--radius-pill); border: 1.5px solid var(--line-strong);
  font: 600 15px/1 var(--font-sign); letter-spacing: 0.02em; color: var(--ink);
  transition: background-color var(--dur-quick), border-color var(--dur-quick);
}
.chip input:checked + span { background: var(--fog); border-color: var(--fog); color: var(--asphalt); }

.field-msg { margin: var(--space-3) 0 0; font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.join.is-error .field-msg { color: var(--danger); font-weight: 500; }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.join-done { padding: var(--space-4); border-radius: var(--radius-md); background: var(--surface-sunken); box-shadow: var(--shadow-slot); }
.join-done:focus { outline: none; }
.join-done p { margin: 0; color: var(--ink-muted); }
.join-done-title { font: 700 24px/1.2 var(--font-sign); color: var(--fog) !important; margin-bottom: var(--space-1) !important; }

/* ── The face-down card ──────────────────────────────────────────────────────────── */

.card-spot { zoom: 0.5; flex: none; }
.card-scene { width: 240px; height: 336px; perspective: var(--perspective-card); }
.card {
  --rx: 0deg; --ry: 0deg; --gx: 50%; --gy: 30%; --go: 0;
  position: relative; width: 100%; height: 100%; border-radius: var(--radius-lg);
  transform-style: preserve-3d;
  transform: rotateZ(-4deg) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform var(--dur-base) var(--ease-settle);
  box-shadow: var(--shadow-card);
}
.card.is-tilting { transition: transform 70ms linear; box-shadow: var(--shadow-card-lift); }

.cardback {
  position: absolute; inset: 0; overflow: hidden; border-radius: inherit;
  background: var(--asphalt); color: var(--fog);
  box-shadow: inset 0 0 0 8px var(--mist), inset 0 0 0 9.5px rgba(37, 52, 63, 0.5), inset 0 0 0 1.5px rgba(37, 52, 63, 0.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.topo { position: absolute; inset: 0; width: 100%; height: 100%; }
.topo path { fill: none; stroke: rgba(234, 239, 239, 0.13); stroke-width: 1.2; }
.cardback-rail { position: absolute; left: 28px; right: 28px; height: 4px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--lane-yellow) 0 14px, transparent 14px 24px); }
.cardback-rail-top { top: 30px; }
.cardback-rail-bottom { bottom: 30px; }
.cardback-center { position: relative; width: 104px; height: 114px; display: grid; place-items: center; }
.cardback-shield { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45)); }
.shield-outer { fill: var(--fog); }
.shield-inner { fill: var(--signal); }
.cardback-mark { position: relative; margin-top: -6px; color: var(--asphalt); font: 900 64px/1 var(--font-display); }
.cardback-caption { position: relative; margin: 14px 0 0; font: 700 14px/18px var(--font-sign); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fog); }
.cardback-word { position: absolute; bottom: 42px; margin: 0; font: 800 11px/1 var(--font-display); letter-spacing: 0.3em; text-transform: uppercase; color: var(--mist); }
.card-glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.15) 30%, rgba(255, 255, 255, 0) 60%);
  mix-blend-mode: soft-light; opacity: var(--go); transition: opacity var(--dur-base);
}

/* ── Hint and footer ─────────────────────────────────────────────────────────────── */

.hint {
  margin: 0; padding: 0 var(--space-4) var(--space-3); text-align: center; pointer-events: none;
  font: 600 14px/18px var(--font-sign); letter-spacing: 0.1em; text-transform: uppercase; color: var(--mist);
}
.hint-count { color: var(--fog); }

.foot {
  display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-5);
  padding: var(--space-3) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
  font: 400 14px/20px var(--font-sans); color: var(--ink-muted);
  background: linear-gradient(to top, var(--vignette), transparent);
}
.foot p { margin: 0; }
.foot a { color: var(--ink); }

/* ── Simple pages (thanks, confirmed, 404) ───────────────────────────────────────── */

.page-simple .hero { flex-direction: column; }
.page-simple .copy { text-align: left; }
.page-simple .lede { margin-bottom: var(--space-4); }
.back { font: 700 16px/1 var(--font-sign); letter-spacing: 0.02em; }

/* ── Wider screens ───────────────────────────────────────────────────────────────── */

@media (min-width: 560px) {
  .join-row { flex-direction: row; }
  .join-row .field-input { flex: 1; min-width: 0; }
  .copy { padding: var(--space-8); }
}

@media (min-width: 900px) {
  .top { justify-content: flex-start; padding: var(--space-6) var(--space-10) 0; }
  .hero { flex-direction: row; justify-content: space-between; gap: var(--space-10); padding: var(--space-8) var(--space-10); }
  .copy { max-width: 560px; }
  .card-spot { zoom: 1; margin-right: var(--space-8); }
  .vignette { background: radial-gradient(ellipse 60% 70% at 35% 50%, var(--vignette), transparent 75%); }
}

@media (max-height: 700px) and (max-width: 899px) {
  .card-spot { display: none; }
}
