/* ===== Tokens ===== */
:root {
  --ink: #0F1626;        /* campo de noche */
  --dusk: #26365C;       /* cielo de crepúsculo */
  --haze: #9AACCB;       /* texto secundario sobre ink */
  --paper: #EEF1F6;      /* texto principal / fondo claro */
  --gate: #FF3D8B;       /* LED de gate */
  --volt: #FFB627;       /* batería / OSD */
  --morning: #DCE4EC;    /* sección estabilizados */
  --morning-ink: #1B2A3F;

  --f-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --f-body: "Instrument Sans", system-ui, sans-serif;
  --f-osd: "Share Tech Mono", ui-monospace, monospace;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: clamp(2.2rem, 5vw, 3.6rem);
  --step-4: clamp(3rem, 8vw, 6rem);
  --step-5: clamp(4.5rem, 15vw, 13rem);

  --gutter: clamp(16px, 4vw, 48px);
  --max: 1200px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-body);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }
img, canvas { display: block; }

:focus-visible { outline: 3px solid var(--volt); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: fixed; left: 16px; top: -60px; z-index: 100;
  background: var(--volt); color: var(--ink); padding: 10px 14px; font-weight: 600;
}
.skip:focus { top: 16px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* ===== Type ===== */
.display {
  font-family: var(--f-display);
  font-weight: 900;
  font-size: var(--step-5);
  line-height: 0.82;
  letter-spacing: -0.01em;
}
.display--md { font-size: var(--step-4); line-height: 0.9; font-weight: 800; }

.section-title {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: var(--step-3);
  line-height: 0.95;
  max-width: 14ch;
}

.lead { font-size: var(--step-1); line-height: 1.5; max-width: 42ch; color: var(--haze); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px;
  background: var(--gate); color: #fff;
  font: 600 var(--step-0) / 1 var(--f-body);
  text-decoration: none; border: 0; border-radius: 999px; cursor: pointer;
  transition: transform .15s ease, background-color .15s ease;
}
.btn:hover { background: #ff5c9f; }
.btn:active { transform: scale(.97); }
.btn--ghost { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 2px rgba(238,241,246,.5); }
.btn--ghost:hover { background: rgba(238,241,246,.1); }
.btn--small { min-height: 40px; padding: 0 18px; font-size: var(--step--1); }

/* ===== Nav ===== */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 14px var(--gutter);
  background: rgba(15,22,38,.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font: 800 1.6rem/1 var(--f-display); text-decoration: none; letter-spacing: .01em;
}
.brand svg { width: 28px; height: 28px; color: var(--gate); }
.brand__name { display: grid; line-height: 1; }
.brand__name b { font: 800 1.3rem/1 var(--f-display); }
.brand__name small { margin-top: 3px; font: 500 .72rem/1 var(--f-body); color: var(--haze); letter-spacing: .01em; }
@media (max-width: 400px) { .brand__name b { font-size: 1.1rem; } }
.nav nav { margin-left: auto; }
.nav ul { display: flex; gap: 22px; list-style: none; margin: 0; padding: 0; }
.nav nav a { text-decoration: none; font-size: var(--step--1); font-weight: 500; opacity: .85; }
.nav nav a:hover { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 820px) { .nav nav { display: none; } .nav .btn { margin-left: auto; } }

/* ===== Scrolly stages ===== */
.scrolly { position: relative; }
.flight { height: 700vh; }
.goggles { height: 500vh; background: #0b111e; }
.stab { height: 420vh; background: var(--morning); color: var(--morning-ink); }

.stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
}
.stage__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Elements that appear on a scroll range */
[data-range] { transition: opacity .45s ease, transform .45s ease, visibility 0s linear .45s; }
[data-range]:not(.is-on) { opacity: 0; visibility: hidden; transform: translateY(14px); }
[data-range].is-on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

/* ===== Hero / flight ===== */
.flight__intro {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: clamp(32px, 8vh, 80px);
  max-width: 760px;
}
.flight__intro .display { padding-bottom: .1em; }
.flight__intro .lead { margin-top: 20px; color: var(--paper); text-shadow: 0 1px 12px rgba(15,22,38,.6); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hint { margin-top: 28px; font-size: var(--step--1); color: var(--haze); }
.hint::after { content: ""; display: inline-block; width: 1px; height: 22px; margin-left: 10px; vertical-align: middle; background: var(--haze); animation: drop 1.6s ease-in-out infinite; transform-origin: top; }
@keyframes drop { 0%,100% { transform: scaleY(.2); } 50% { transform: scaleY(1); } }

.captions { list-style: none; margin: 0; padding: 0; }
.captions li {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: clamp(72px, 14vh, 140px);
  max-width: 420px;
  padding: 18px 20px 20px;
  border-left: 3px solid var(--gate);
  background: rgba(15,22,38,.62);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.captions h2, .captions h3 { font: 800 var(--step-3)/0.95 var(--f-display); }
.captions p { margin-top: 8px; color: var(--paper); }

/* OSD overlay (Betaflight-style) */
.osd {
  position: absolute; inset: 0; pointer-events: none;
  font: 400 clamp(12px, 1.3vw, 16px)/1 var(--f-osd);
  color: #fff; text-shadow: 0 0 2px #000, 0 0 6px rgba(0,0,0,.6);
  text-transform: uppercase; letter-spacing: .04em;
}
.osd b { font-weight: 400; color: var(--volt); }
.osd > span { position: absolute; }
.osd__tl { top: 84px; left: var(--gutter); }
.osd__tr { top: 84px; right: var(--gutter); }
.osd__bl { bottom: 28px; right: var(--gutter); }
.osd__br { bottom: 52px; right: var(--gutter); }
.osd__cross { left: 50%; top: 50%; width: 28px; height: 28px; transform: translate(-50%,-50%); }
.osd__cross::before, .osd__cross::after { content: ""; position: absolute; background: rgba(255,255,255,.75); }
.osd__cross::before { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; }
.osd__cross::after { top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; }
.flight .osd { opacity: 0; transition: opacity .6s ease; }
.flight.is-flying .osd { opacity: 1; }
@media (max-width: 600px) { .osd__tr { display: none; } .osd__tl, .osd__tr { top: 76px; } }

/* ===== Pillars ===== */
.pillars { padding: clamp(96px, 16vh, 180px) 0; background: var(--ink); }
.pillar-list { list-style: none; margin: 56px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 clamp(24px, 5vw, 80px); }
.pillar-list li { padding: 28px 0 36px; border-top: 2px solid var(--dusk); }
.pillar-list h3 { font: 700 var(--step-2)/1.1 var(--f-display); font-size: clamp(1.8rem, 3vw, 2.4rem); }
.pillar-list p { margin-top: 10px; color: var(--haze); max-width: 46ch; }
@media (max-width: 720px) { .pillar-list { grid-template-columns: 1fr; } }

/* ===== Goggles ===== */
.veil { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.goggles__copy { position: absolute; left: var(--gutter); top: 50%; transform: translateY(-50%); max-width: 520px; }
.goggles__copy.is-on { transform: translateY(-50%); }
.goggles__copy:not(.is-on) { transform: translateY(calc(-50% + 14px)); }
.goggles__copy .lead { margin-top: 20px; }

.steps {
  position: absolute; right: var(--gutter); top: 50%; transform: translateY(-50%);
  width: min(440px, calc(100% - 2 * var(--gutter)));
  list-style: none; margin: 0; padding: 0; display: grid; gap: 18px;
}
.steps.is-on { transform: translateY(-50%); }
.steps:not(.is-on) { transform: translateY(calc(-50% + 14px)); }
.steps li { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; }
.steps__n {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--gate); color: var(--gate);
  font: 800 1.3rem/1 var(--f-display);
}
.steps h3 { font: 700 1.5rem/1.1 var(--f-display); }
.steps p { margin-top: 4px; color: var(--haze); font-size: var(--step--1); }

.goggles__end { position: absolute; left: var(--gutter); bottom: clamp(40px, 10vh, 96px); max-width: 720px; }
.goggles__end .btn { margin-top: 24px; }
.goggles__end p { text-shadow: 0 2px 24px rgba(0,0,0,.5); }
/* Feed OSD: white Betaflight/analog look, laid out inside the goggles' image */
.osd--feed { color: #fff; font-size: clamp(12px, 1.25vw, 17px); text-shadow: 0 0 1px #000, 0 0 2px #000, 0 0 5px rgba(0,0,0,.7); }
.osd--feed b { color: #fff; }
.osd--feed small { font-size: .82em; opacity: .9; }
.fosd__frame { position: absolute; inset: 84px var(--gutter) 28px; }
.fosd__frame > span { position: absolute; line-height: 1.35; white-space: nowrap; }
.fosd__tl { top: 0; left: 0; }
.fosd__tc { top: 0; left: 50%; transform: translateX(-50%); text-align: center; }
.fosd__tr { top: 0; right: 0; text-align: right; }
.fosd__ml { top: 34%; left: 14%; transform: translateY(-50%); text-align: center; }
.fosd__mr { top: 34%; right: 14%; transform: translateY(-50%); text-align: center; }
.fosd__br { bottom: 0; right: 0; text-align: right; }
.fosd__att { top: calc(50% + 46px); left: 50%; transform: translateX(-50%); }
.osd--feed .osd__cross { width: 22px; height: 22px; }
.osd--feed .osd__cross::before, .osd--feed .osd__cross::after { background: #fff; box-shadow: 0 0 2px #000; }
/* battery glyph */
.fosd__bat { display: inline-block; position: relative; width: .7em; height: 1.05em; margin-right: .35em; vertical-align: -.15em; border: 2px solid #fff; border-radius: 2px; box-shadow: 0 0 2px #000; }
.fosd__bat::before { content: ""; position: absolute; left: 50%; top: -5px; width: 40%; height: 3px; transform: translateX(-50%); background: #fff; }
.fosd__bat i { position: absolute; left: 1px; right: 1px; bottom: 1px; height: 80%; background: #fff; }
.fosd__rec { display: inline-block; width: .6em; height: .6em; margin-right: .35em; border-radius: 50%; background: #ff3b3b; box-shadow: 0 0 3px #000; animation: rec 1s steps(1) infinite; }
@keyframes rec { 50% { opacity: 0; } }
.fosd__home { display: inline-block; }
/* artificial horizon: a dashed line that tilts with roll and slides with pitch */
.fosd__horizon { left: 50%; top: 50%; width: min(46vw, 560px); height: 0; margin-left: calc(min(46vw, 560px) / -2); }
.fosd__horizon i { position: absolute; inset: -1px 0; border-top: 2px dashed rgba(255,255,255,.85); filter: drop-shadow(0 0 1px #000); }
.fosd__horizon::before, .fosd__horizon::after { content: ""; position: absolute; top: -1px; width: 18%; border-top: 3px solid #fff; filter: drop-shadow(0 0 1px #000); }
.fosd__horizon::before { left: -2%; }
.fosd__horizon::after { right: -2%; }
/* fixed sidebars framing the center, like Betaflight's horizon sidebars */
.fosd__bars { left: 50%; top: 50%; width: min(34vw, 420px); height: 120px; transform: translate(-50%, -50%); border-left: 2px solid rgba(255,255,255,.7); border-right: 2px solid rgba(255,255,255,.7); }
.fosd__bars::before, .fosd__bars::after { content: ""; position: absolute; top: 50%; width: 10px; border-top: 2px solid #fff; }
.fosd__bars::before { left: 0; }
.fosd__bars::after { right: 0; }
@media (max-width: 720px) {
  .fosd__frame { inset: 76px 14px 20px; }
  .fosd__ml { left: 2%; } .fosd__mr { right: 2%; }
  .fosd__tc small, .fosd__bars { display: none; }
  .fosd__br { bottom: auto; top: calc(50% + 80px); right: 50%; transform: translateX(50%); text-align: center; }
}

@media (max-width: 820px) {
  .goggles__copy { top: auto; bottom: 48px; transform: none; }
  .goggles__copy.is-on, .goggles__copy:not(.is-on) { transform: none; }
  .steps { top: auto; bottom: 32px; transform: none; gap: 12px; padding: 16px; background: rgba(11,17,30,.75); backdrop-filter: blur(8px); }
  .steps.is-on, .steps:not(.is-on) { transform: none; }
  .steps p { display: none; }
}

/* ===== Stabilized ===== */
.stab__head { position: absolute; left: var(--gutter); top: 96px; }
.captions--light li {
  background: rgba(238,241,246,.7);
  border-left-color: var(--morning-ink);
  color: var(--morning-ink);
}
.captions--light p { color: var(--morning-ink); }

.inset {
  position: absolute; right: var(--gutter); bottom: clamp(72px, 14vh, 140px); margin: 0;
  width: min(300px, 40vw);
}
.inset__frame {
  position: relative; aspect-ratio: 16 / 9;
  border: 2px solid var(--morning-ink); border-radius: 6px;
}
.inset__frame::before, .inset__frame::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid #fff;
}
.inset__frame::before { left: 8px; top: 8px; border-right: 0; border-bottom: 0; }
.inset__frame::after { right: 8px; bottom: 8px; border-left: 0; border-top: 0; }
.inset__horizon { position: absolute; left: 10%; right: 10%; top: 50%; height: 0; border-top: 1px dashed rgba(255,255,255,.85); }
.inset figcaption { margin-top: 8px; font-size: var(--step--1); }
.wind {
  position: absolute; right: var(--gutter); top: 96px;
  font: 400 var(--step-0)/1 var(--f-osd);
}
.wind b { font-weight: 400; font-size: 1.6em; }
@media (max-width: 720px) {
  .inset { bottom: auto; top: 150px; width: 46vw; }
  .inset figcaption { display: none; }
  .wind { top: 184px; left: var(--gutter); right: auto; }
  .inset { top: 184px; }
}

/* ===== Legal ===== */
.legal { padding: clamp(96px, 16vh, 180px) 0; background: var(--ink); }
.legal__grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: clamp(32px, 6vw, 96px); align-items: start; }
.legal__grid .lead { margin-top: 20px; }
.legal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 28px; }
.legal-list li { display: grid; grid-template-columns: 9rem 1fr; gap: 16px; padding-bottom: 28px; border-bottom: 1px solid var(--dusk); }
.legal-list h3 { font: 700 1.6rem/1.1 var(--f-display); color: var(--volt); }
.legal-list p { color: var(--haze); }
@media (max-width: 820px) {
  .legal__grid { grid-template-columns: 1fr; }
  .legal-list li { grid-template-columns: 1fr; gap: 6px; }
}

/* ===== Agenda ===== */
.agenda { padding: clamp(80px, 12vh, 140px) 0; background: var(--dusk); }
.agenda__soon { max-width: 760px; }
.agenda__soon .lead { margin-top: 20px; max-width: 58ch; }
.agenda__kinds { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.tag { padding: 6px 12px; border-radius: 999px; font-size: var(--step--1); font-weight: 600; background: rgba(238,241,246,.12); }
.tag--race { background: var(--gate); color: #fff; }
.tag--meet { background: var(--volt); color: var(--ink); }
.btn svg { width: 20px; height: 20px; margin-right: 10px; flex: none; }

/* ===== Join ===== */
.join { padding: clamp(96px, 16vh, 180px) 0; background: var(--ink); }
.join__grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 96px); align-items: start; }
.join .lead { margin-top: 20px; }
.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 6px; font-weight: 500; font-size: var(--step--1); }
.form input, .form select {
  min-height: 48px; padding: 0 14px; border-radius: 10px;
  background: rgba(238,241,246,.06); color: var(--paper);
  border: 1.5px solid rgba(238,241,246,.25); font: inherit; font-size: var(--step-0);
}
.form select option { color: var(--ink); }
.form input:focus-visible, .form select:focus-visible { border-color: var(--volt); outline-offset: 1px; }
.form input[aria-invalid="true"] { border-color: var(--gate); }
.form .btn { justify-self: start; margin-top: 8px; }
.form__msg { min-height: 1.5em; color: var(--volt); }
.form__msg a { color: inherit; }
.form__trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form { position: relative; }
.form .btn[disabled] { opacity: .6; cursor: progress; }
.join__alt { margin-top: 20px; color: var(--haze); }
.join__alt a { color: var(--paper); text-underline-offset: 3px; }
@media (max-width: 820px) { .join__grid { grid-template-columns: 1fr; } }

/* ===== Footer ===== */
.footer { padding: 40px 0; border-top: 1px solid var(--dusk); color: var(--haze); font-size: var(--step--1); }
.footer__row { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; justify-content: space-between; }
.social { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; }
.social a { display: inline-flex; align-items: center; gap: 8px; color: var(--paper); text-decoration: none; min-height: 44px; }
.social a:hover span { text-decoration: underline; text-underline-offset: 3px; }
.social svg { width: 22px; height: 22px; color: var(--gate); }
.brand--static { color: var(--paper); }

/* ===== Fallbacks ===== */
.no-webgl .stage__canvas { display: none; }
.no-webgl .flight .stage { background: radial-gradient(120% 80% at 50% 100%, #c2577a 0%, var(--dusk) 45%, var(--ink) 100%); }
.no-webgl .goggles .stage { background: #0b111e; }

/* Reduced motion: no scroll-scrubbed flight, everything readable in place */
.reduced .flight, .reduced .goggles, .reduced .stab { height: auto; }
.reduced .stage { position: relative; min-height: 100vh; }
.reduced [data-range] { transition: none; }
.reduced .flight .captions, .reduced .flight .osd, .reduced .veil, .reduced .goggles__end, .reduced .osd--feed { display: none; }
.reduced .hint::after { animation: none; }
@media (max-width: 820px) { .reduced .goggles__copy { top: 96px; bottom: auto; } }

/* Debug snapshots (?at=kind:progress) */
.debug-solo main > :not(.is-solo), .debug-solo footer { display: none; }
.debug-solo .is-solo { height: 100vh; }
.debug-static .scrolly { display: none; }
