/* ============================================================================
   Lothal — activation terminal
   ----------------------------------------------------------------------------
   Palette is lifted from the app itself (src/ui, src/lab) so the page and the
   product read as one object: slate-blue chrome, a single cyan accent that
   means "live", amber for the pilot's own marks, red for a halt.
   ========================================================================= */

:root {
  --bg-0:  #0E1013;
  --bg-1:  #14171C;
  --bg-2:  #1A1E25;
  --bg-3:  #21262F;

  --line:      #272C36;
  --line-soft: #1E232B;

  --text:  #E0E6F0;
  --dim:   #8591A8;
  --dimmer:#5D6879;

  --cyan:  #66D1F5;
  --cyan-d:#2E9BC4;
  --amber: #FFB840;
  --red:   #FF5C4D;
  --green: #7CE0A8;

  --shell: min(1080px, 100% - 3rem);

  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out-expo: cubic-bezier(.16, 1, .3, 1);
}

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

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

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  color: var(--text);
  font-family: "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(15px, 0.55vw + 13px, 17px);
  line-height: 1.6;
  overflow-x: hidden;
}

::selection { background: var(--cyan); color: #06202B; }

/* ── Atmosphere ─────────────────────────────────────────────────────────── */

.atmos { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

/* Survey grid. Two hairline sets, the coarser one brighter. */
.atmos--grid {
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px),
    linear-gradient(rgba(102,209,245,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102,209,245,.045) 1px, transparent 1px);
  background-size: 28px 28px, 28px 28px, 140px 140px, 140px 140px;
  mask-image: radial-gradient(120% 90% at 50% 8%, #000 20%, transparent 78%);
  transform: translate3d(var(--par-x, 0px), var(--par-y, 0px), 0);
  transition: transform .8s var(--ease);
}

.atmos--glow {
  background:
    radial-gradient(58% 42% at 50% -6%, rgba(102,209,245,.16), transparent 70%),
    radial-gradient(40% 40% at 88% 108%, rgba(255,184,64,.07), transparent 70%);
}

/* Slow scan sweep. The one moving thing on an otherwise still page. */
.atmos--scan {
  background: linear-gradient(180deg, transparent, rgba(102,209,245,.055) 42%, transparent 84%);
  height: 46vh;
  inset: -46vh 0 auto 0;
  animation: sweep 11s linear infinite;
}
@keyframes sweep { to { transform: translateY(160vh); } }

.atmos--grain {
  opacity: .5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
}

.atmos--vignette {
  background: radial-gradient(120% 100% at 50% 50%, transparent 52%, rgba(0,0,0,.62) 100%);
}

/* ── OSD corner brackets ────────────────────────────────────────────────── */

.bracket {
  position: fixed;
  width: 26px; height: 26px;
  border: 1.5px solid var(--cyan);
  opacity: .5;
  z-index: 3;
  pointer-events: none;
  animation: bracket-in .9s var(--ease-out-expo) both;
}
.bracket--tl { top: 18px; left: 18px;  border-right: 0; border-bottom: 0; }
.bracket--tr { top: 18px; right: 18px; border-left: 0;  border-bottom: 0; animation-delay: .06s; }
.bracket--bl { bottom: 18px; left: 18px;  border-right: 0; border-top: 0; animation-delay: .12s; }
.bracket--br { bottom: 18px; right: 18px; border-left: 0;  border-top: 0; animation-delay: .18s; }

@keyframes bracket-in {
  from { opacity: 0; transform: scale(2.4); }
  to   { opacity: .5; transform: scale(1); }
}

/* ── HUD header ─────────────────────────────────────────────────────────── */

.hud {
  position: relative;
  z-index: 4;
  width: var(--shell);
  margin: 0 auto;
  padding: 2.6rem 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  animation: fade-up .8s var(--ease-out-expo) .1s both;
}

.mark {
  display: inline-flex; align-items: center; gap: .6rem;
  color: var(--text); text-decoration: none;
}
/* Arms take currentColor so the front-right stays the only cyan member —
   colouring the whole glyph cyan would erase the forward marking. */
.mark__glyph { width: 26px; height: 26px; color: var(--text); }
.mark__word {
  font-weight: 700; font-size: .95rem;
  letter-spacing: .34em; text-indent: .34em;
}
.mark:hover .mark__glyph { color: var(--cyan); transition: color .25s; }

/* ── 3D Reference Quadcopter Viewport ───────────────────────────────────────
   Full 3D WebGL viewport on wide screens, adaptive tactical card on medium/mobile.
   Features real-time lighting on 3K twill carbon fiber, CNC motor bells,
   tri-blade aerodynamic propellers, dynamic downwash, and avionics telemetry.   */

.rig3d { display: none; }

@media (min-width: 1080px) {
  .rig3d {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    right: clamp(2rem, 5vw, 6rem);
    transform: translateY(-50%);
    width: clamp(420px, 36vw, 600px);
    z-index: 3;
    pointer-events: auto;
    animation: rig-in 1.1s var(--ease-out-expo) .2s both;
  }

  .horizon { display: none; }
}

@keyframes rig-in {
  from { opacity: 0; transform: translateY(-47%) scale(.95); }
  to   { opacity: 1; transform: translateY(-50%) scale(1); }
}

/* Floating top control bar */
.rig3d__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 0 .25rem .5rem;
}

.rig3d__tag {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .22em;
  color: var(--cyan);
  background: rgba(102, 209, 245, 0.08);
  border: 1px solid rgba(102, 209, 245, 0.22);
  padding: .25rem .65rem;
  border-radius: 4px;
}

.rig3d__modes {
  display: flex;
  align-items: center;
  gap: .3rem;
  background: rgba(20, 23, 28, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.rig3d__mode {
  background: transparent;
  border: 0;
  color: var(--dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .64rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: .28rem .75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all .2s var(--ease);
}

.rig3d__mode:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.rig3d__mode.is-active {
  background: var(--cyan);
  color: #061922;
  font-weight: 600;
  box-shadow: 0 0 14px rgba(102, 209, 245, 0.4);
}

/* 3D Viewport canvas container — open, atmospheric, borderless */
.rig3d__viewport {
  position: relative;
  width: 100%;
  height: clamp(360px, 46vh, 520px);
  margin: .25rem 0;
  overflow: visible;
}

.quad3d-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
  cursor: grab;
}

.quad3d-canvas:active {
  cursor: grabbing;
}

.rig3d__hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 16, 19, 0.75);
  border: 1px solid var(--line);
  padding: .22rem .75rem;
  border-radius: 20px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .58rem;
  letter-spacing: .14em;
  color: var(--dim);
  text-transform: uppercase;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: .35rem;
  backdrop-filter: blur(8px);
  transition: opacity .4s ease;
}
.rig3d__hint-icon { color: var(--cyan); font-size: .75rem; }

.rig__caption {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  margin: .25rem 0 0;
  padding: .6rem .25rem 0;
  border-top: 1px solid var(--line-soft);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .58rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dim);
}
.rig__caption-dim { color: var(--dimmer); letter-spacing: .12em; }

.hud__meta { display: flex; align-items: center; gap: .6rem; }

.tag {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .66rem; letter-spacing: .2em;
  color: var(--dim); text-transform: uppercase;
}
.tag--dim { color: var(--dimmer); font-variant-numeric: tabular-nums; }
.sep { color: var(--line); }

/* ── Artificial horizon ─────────────────────────────────────────────────── */

.horizon {
  position: fixed;
  right: 46px; bottom: 62px;
  width: 92px; height: 92px;
  z-index: 3;
  opacity: .8;
  animation: fade-up 1s var(--ease-out-expo) .5s both;
}
.horizon svg { width: 100%; height: 100%; display: block; }
#hz-ball { transition: transform .45s var(--ease); transform-origin: 60px 60px; }

/* ── Stage / screens ────────────────────────────────────────────────────── */

.stage {
  position: relative;
  z-index: 4;
  flex: 1;
  width: var(--shell);
  margin: 0 auto;
  display: grid;
  /* Top-aligned, not centred. The screens differ a lot in height, and centring
     a screen taller than the viewport pushes its heading off the top edge
     where nothing can scroll it back into view. */
  place-items: start start;
  padding: clamp(2rem, 6vh, 5rem) 0 3rem;
}

.screen {
  grid-area: 1 / 1;
  max-width: 46rem;
  visibility: hidden;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .45s var(--ease), transform .45s var(--ease), visibility .45s;
}
.screen.is-active {
  visibility: visible;
  opacity: 1;
  transform: none;
}

/* Children stagger in when their screen becomes active. */
.screen.is-active > * { animation: fade-up .7s var(--ease-out-expo) both; }
.screen.is-active > *:nth-child(1) { animation-delay: .04s; }
.screen.is-active > *:nth-child(2) { animation-delay: .10s; }
.screen.is-active > *:nth-child(3) { animation-delay: .16s; }
.screen.is-active > *:nth-child(4) { animation-delay: .22s; }
.screen.is-active > *:nth-child(5) { animation-delay: .28s; }
.screen.is-active > *:nth-child(6) { animation-delay: .34s; }
.screen.is-active > *:nth-child(7) { animation-delay: .40s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ── Type ───────────────────────────────────────────────────────────────── */

.eyebrow {
  display: flex; align-items: center; gap: .55rem;
  margin: 0 0 1.4rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .7rem; letter-spacing: .24em; text-transform: uppercase;
  color: var(--cyan);
}
.eyebrow--bad { color: var(--red); }

.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 4px rgba(102,209,245,.14);
}
.dot--live { animation: pulse 1.3s ease-in-out infinite; }
.dot--ok  { background: var(--green); box-shadow: 0 0 0 4px rgba(124,224,168,.14); }
.dot--bad { background: var(--red);   box-shadow: 0 0 0 4px rgba(255,92,77,.14); }

@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 4px rgba(102,209,245,.14); }
  50%     { opacity: .45; box-shadow: 0 0 0 9px rgba(102,209,245,0); }
}

.display {
  margin: 0 0 1.3rem;
  font-size: clamp(3rem, 8.5vw, 5.6rem);
  font-weight: 700;
  line-height: .94;
  letter-spacing: -.025em;
  text-transform: uppercase;
}
.display--sm { font-size: clamp(2.1rem, 5vw, 3.2rem); }
.display__accent {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--cyan);
  text-shadow: 0 0 42px rgba(102,209,245,.35);
}

.lede {
  margin: 0 0 1.1rem;
  max-width: 34rem;
  font-size: 1.12rem;
  color: var(--text);
}
.body {
  margin: 0 0 1.9rem;
  max-width: 34rem;
  color: var(--dim);
}

.fineprint {
  margin: 1.1rem 0 0;
  max-width: 32rem;
  font-size: .82rem;
  line-height: 1.65;
  color: var(--dimmer);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.actions { margin: 0; }
.actions--row { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 1.8rem; }

.btn {
  --btn-bd: var(--line);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .7rem;
  padding: .85rem 1.5rem;
  border: 1px solid var(--btn-bd);
  border-radius: 2px;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: .02em;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .22s, background .22s, transform .12s, color .22s;
}
.btn::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 42%, rgba(255,255,255,.10) 50%, transparent 58%);
  transform: translateX(-120%);
  transition: transform .6s var(--ease);
}
.btn:hover { --btn-bd: var(--cyan-d); background: var(--bg-3); }
.btn:hover::after { transform: translateX(120%); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn--primary {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #06202B;
}
.btn--primary:hover { background: #7FDCFA; border-color: #7FDCFA; }

.btn--google { padding: .95rem 1.7rem; font-size: 1rem; }
.btn__g { width: 18px; height: 18px; flex: none; }

.linkish {
  margin-top: 1.6rem;
  padding: 0;
  border: 0; background: none;
  color: var(--dimmer);
  font: inherit; font-size: .85rem;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.linkish:hover { color: var(--text); }
.linkish:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* ── Spec strip ─────────────────────────────────────────────────────────── */

.specs {
  display: flex; flex-wrap: wrap; gap: 0;
  margin: 2.6rem 0 0; padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.specs li {
  flex: 1 1 11rem;
  padding: .95rem 1.2rem .95rem 0;
  border-right: 1px solid var(--line-soft);
}
.specs li:last-child { border-right: 0; }
.specs__k {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .62rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--dimmer);
  margin-bottom: .3rem;
}
.specs__v { color: var(--text); font-size: .92rem; font-weight: 500; }

/* ── Loader ─────────────────────────────────────────────────────────────── */

.loader { display: flex; gap: 5px; margin: 0 0 1.6rem; }
.loader span {
  width: 3px; height: 26px;
  background: var(--cyan);
  opacity: .25;
  animation: bars 1.05s ease-in-out infinite;
}
.loader span:nth-child(2) { animation-delay: .12s; }
.loader span:nth-child(3) { animation-delay: .24s; }
.loader span:nth-child(4) { animation-delay: .36s; }
.loader span:nth-child(5) { animation-delay: .48s; }
@keyframes bars {
  0%,100% { opacity: .2; transform: scaleY(.4); }
  50%     { opacity: 1;  transform: scaleY(1); }
}

/* ── Issued-to + key box ────────────────────────────────────────────────── */

.issued-to {
  display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap;
  margin: 0 0 1.5rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}
.issued-to__k {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .62rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--dimmer);
}
.issued-to__v {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 1.02rem;
  color: var(--amber);
  word-break: break-all;
}

.keybox {
  margin: 0 0 1.5rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  overflow: hidden;
}
.keybox__bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-2);
}
.keybox__label, .keybox__len {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .62rem; letter-spacing: .2em; text-transform: uppercase;
}
.keybox__label { color: var(--cyan); }
.keybox__len { color: var(--dimmer); font-variant-numeric: tabular-nums; }

.keybox__body {
  margin: 0;
  padding: 1rem .9rem;
  max-height: 9.5rem;
  overflow: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .74rem;
  line-height: 1.75;
  color: var(--dim);
  white-space: pre-wrap;
  word-break: break-all;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}
.keybox__body:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.keybox__body::-webkit-scrollbar { width: 8px; }
.keybox__body::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }

/* ── Steps ──────────────────────────────────────────────────────────────── */

.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: .55rem; }
.steps li { display: flex; align-items: baseline; gap: .8rem; color: var(--dim); font-size: .95rem; }
.steps__n {
  flex: none;
  width: 1.4rem; height: 1.4rem;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .66rem;
  color: var(--cyan);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.foot {
  position: relative; z-index: 4;
  width: var(--shell);
  margin: 0 auto;
  padding: 1.6rem 0 2.4rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .7rem;
  border-top: 1px solid var(--line-soft);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .68rem; letter-spacing: .1em;
  color: var(--dimmer);
}
.foot a { color: var(--dim); text-decoration: none; }
.foot a:hover { color: var(--cyan); }
.foot a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%; bottom: 2.2rem;
  /* Hidden by opacity/visibility, not by transform alone: a percentage
     translate is relative to the element's own height, so an empty toast moves
     only ~34px and would sit on the page as a bare rectangle. */
  transform: translate(-50%, 1.5rem);
  opacity: 0;
  visibility: hidden;
  z-index: 20;
  padding: .7rem 1.2rem;
  border: 1px solid var(--cyan-d);
  border-radius: 2px;
  background: var(--bg-2);
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .74rem; letter-spacing: .12em; text-transform: uppercase;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
  transition: transform .4s var(--ease-out-expo), opacity .3s var(--ease), visibility .4s;
}
.toast.is-up {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  :root { --shell: calc(100% - 2.2rem); }
  .horizon { display: none; }
  .hud { padding-top: 2rem; }
  /* Hide the label and its separator together — dropping only the label
     leaves an orphaned slash floating next to the clock. */
  .hud__meta .tag:not(.tag--dim),
  .hud__meta .sep { display: none; }
  .stage { padding: 2rem 0; }
  .specs li { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .specs li:last-child { border-bottom: 0; }
  .bracket { width: 18px; height: 18px; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .atmos--scan { display: none; }
  .screen { transform: none; }
}
