/* =========================================================================
   YambaCode v4 "Bridge"
   Tokens and principles: docs/v4-plan.md
   ========================================================================= */

:root {
  --void: #050816;          /* event horizon: page background */
  --hull: #0b1226;          /* panels */
  --hull-a: rgba(11, 18, 38, 0.66);
  --hull-b: rgba(14, 24, 52, 0.82);
  --ion: #5cf2ff;           /* primary light */
  --ion-rgb: 92, 242, 255;
  --plasma: #9b7bff;        /* brand violet */
  --plasma-rgb: 155, 123, 255;
  --pulsar: #ff5cc8;        /* rare highlight */
  --solar: #ffb547;         /* in development */
  --live: #6cf5b0;          /* aurora: live status */
  --star: #e8eeff;          /* body text */
  --dust: #8d97be;          /* secondary text */
  --line: rgba(92, 242, 255, 0.16);
  --line-strong: rgba(92, 242, 255, 0.34);

  --display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --hud-h: 68px;
  --rail-w: 0px;
  --r-panel: 16px;
  --r-ctl: 10px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  color-scheme: dark;
}

@media (min-width: 1180px) {
  :root { --rail-w: 88px; }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--hud-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--void);
  color: var(--star);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, video, svg, canvas { display: block; max-width: 100%; }
a { color: var(--ion); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #fff; }
button { font: inherit; color: inherit; }
p { margin: 0 0 1em; }
h1, h2, h3 { margin: 0; font-weight: 600; }

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

::selection { background: rgba(var(--plasma-rgb), .45); color: #fff; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; left: 16px; top: -60px; z-index: 100;
  background: var(--ion); color: var(--void); padding: 10px 14px; border-radius: var(--r-ctl);
  font-weight: 600; text-decoration: none; transition: top .2s;
}
.skip-link:focus { top: 12px; }

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + var(--gutter) * 2);
  margin: 0 auto;
  padding-left: max(var(--gutter), var(--rail-w));
  padding-right: var(--gutter);
}

/* ---------- Space: WebGL canvas and its CSS fallback ---------- */

#space {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh;
  z-index: 0; pointer-events: none;
}

.space-fallback {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 40vmax at 78% 30%, rgba(var(--plasma-rgb), .22), transparent 60%),
    radial-gradient(50vmax 35vmax at 10% 80%, rgba(var(--ion-rgb), .12), transparent 60%),
    radial-gradient(40vmax 30vmax at 90% 90%, rgba(255, 92, 200, .08), transparent 60%),
    var(--void);
}
.has-webgl .space-fallback { display: none; }

main, .footer, .hud, .rail { position: relative; z-index: 2; }

/* ---------- Viewport frame ---------- */

.frame { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.frame__corner {
  position: absolute; width: 26px; height: 26px; border-color: rgba(var(--ion-rgb), .38);
  border-style: solid; border-width: 0;
}
.frame__corner--tl { top: calc(var(--hud-h) + 10px); left: 12px; border-top-width: 1px; border-left-width: 1px; }
.frame__corner--tr { top: calc(var(--hud-h) + 10px); right: 12px; border-top-width: 1px; border-right-width: 1px; }
.frame__corner--bl { bottom: 12px; left: 12px; border-bottom-width: 1px; border-left-width: 1px; }
.frame__corner--br { bottom: 12px; right: 12px; border-bottom-width: 1px; border-right-width: 1px; }
.frame__readout {
  position: absolute; right: 48px; bottom: 14px; margin: 0;
  display: flex; gap: 14px;
  font: 300 10px/1 var(--mono); letter-spacing: .04em; color: rgba(var(--ion-rgb), .6);
}
@media (max-width: 900px) { .frame { display: none; } }

/* ---------- Buttons, pills, chips ---------- */

.btn {
  --bg: transparent; --fg: var(--star); --bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 46px; padding: 0 20px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--bd); border-radius: var(--r-ctl);
  font: 600 .95rem/1 var(--sans); letter-spacing: .01em; text-decoration: none; cursor: pointer;
  transition: background .25s, box-shadow .25s, color .25s, border-color .25s, transform .25s var(--ease-out);
}
.btn:hover { transform: translateY(-1px); }
.btn--primary {
  --bg: var(--ion); --fg: #03121a; --bd: var(--ion);
  box-shadow: 0 0 0 0 rgba(var(--ion-rgb), 0), 0 8px 30px -10px rgba(var(--ion-rgb), .7);
}
.btn--primary:hover { --bg: #9ef7ff; color: #03121a; box-shadow: 0 0 0 4px rgba(var(--ion-rgb), .14), 0 10px 40px -8px rgba(var(--ion-rgb), .9); }
.btn--ghost { --bg: rgba(11, 18, 38, .5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn--ghost:hover { --bd: var(--ion); color: #fff; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: .85rem; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  font: 400 .72rem/1.4 var(--mono); color: var(--dust); white-space: nowrap;
}
.pill--live { color: var(--live); border-color: rgba(108, 245, 176, .35); }
.pill--live::before, .pill--dev::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.pill--dev { color: var(--solar); border-color: rgba(255, 181, 71, .35); }
.pill--domain { color: var(--plasma); border-color: rgba(var(--plasma-rgb), .4); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot--live { background: var(--live); box-shadow: 0 0 10px var(--live); }
.dot--domain { background: var(--plasma); box-shadow: 0 0 10px var(--plasma); }
.dot--dev { background: var(--solar); box-shadow: 0 0 10px var(--solar); }

kbd {
  font: 400 .7rem/1 var(--mono); padding: 4px 6px; border-radius: 5px;
  border: 1px solid var(--line-strong); color: var(--dust); background: rgba(5, 8, 22, .6);
}

/* ---------- HUD bar ---------- */

.hud {
  position: fixed; top: 0; left: 0; right: 0; height: var(--hud-h); z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 var(--gutter);
  background: linear-gradient(to bottom, rgba(5, 8, 22, .88), rgba(5, 8, 22, .55));
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(var(--ion-rgb), .1);
}
.hud::after { /* scan glint along the bottom edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--ion-rgb), .8), transparent);
  background-size: 30% 100%; background-repeat: no-repeat;
  animation: glint 9s linear infinite;
}
@keyframes glint { from { background-position: -30% 0; } to { background-position: 130% 0; } }

.hud__brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--star); flex: none; }
.hud__mark { width: 34px; height: 34px; filter: drop-shadow(0 0 6px rgba(var(--ion-rgb), .55)); }
.hud__brand:hover .hud__mark { animation: spin-in 1.2s var(--ease-out); }
@keyframes spin-in { from { transform: rotate(-90deg); } to { transform: rotate(0); } }
.wordmark { font: 600 1.05rem/1 var(--display); letter-spacing: -.01em; }
.wordmark b { font-weight: 600; color: var(--plasma); }

.hud__nav { display: flex; gap: 4px; margin-left: auto; }
.hud__nav a {
  position: relative; padding: 8px 12px; border-radius: 8px;
  font-size: .9rem; font-weight: 500; color: var(--dust); text-decoration: none;
  transition: color .2s, background .2s;
}
.hud__nav a:hover { color: var(--star); background: rgba(var(--ion-rgb), .06); }
.hud__nav a[aria-current="true"] { color: var(--star); }
.hud__nav a[aria-current="true"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 2px; border-radius: 2px;
  background: var(--ion); box-shadow: 0 0 10px var(--ion);
}

.hud__tools { display: flex; align-items: center; gap: 8px; }

.tool {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px;
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: rgba(5, 8, 22, .4);
  color: var(--dust); cursor: pointer; transition: border-color .2s, color .2s, background .2s;
}
.tool:hover { color: var(--star); border-color: var(--line-strong); }
.tool svg { width: 16px; height: 16px; }
.tool__label { font-size: .85rem; font-weight: 500; }

/* sound equaliser: flat when off, dancing when on */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { width: 3px; height: 4px; border-radius: 1px; background: currentColor; opacity: .55; transition: height .3s; }
.eq i:nth-child(2) { height: 8px; } .eq i:nth-child(3) { height: 5px; } .eq i:nth-child(4) { height: 10px; }
.tool--sound[aria-pressed="true"] .eq i { opacity: 1; }
.tool--sound[aria-pressed="true"] { color: var(--ion); border-color: rgba(var(--ion-rgb), .5); background: rgba(var(--ion-rgb), .08); }
.tool--sound[aria-pressed="true"] .eq i { animation: eq 1.1s ease-in-out infinite; }
.tool--sound[aria-pressed="true"] .eq i:nth-child(2) { animation-delay: -.4s; }
.tool--sound[aria-pressed="true"] .eq i:nth-child(3) { animation-delay: -.7s; }
.tool--sound[aria-pressed="true"] .eq i:nth-child(4) { animation-delay: -.2s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 14px; } }

.tool--menu { display: none; width: 42px; justify-content: center; }
.tool--menu span, .tool--menu span::before, .tool--menu span::after {
  display: block; width: 18px; height: 1.5px; background: currentColor; border-radius: 2px; position: relative;
  transition: transform .3s var(--ease-out), opacity .2s;
}
.tool--menu span::before, .tool--menu span::after { content: ""; position: absolute; left: 0; }
.tool--menu span::before { top: -6px; }
.tool--menu span::after { top: 6px; }
.tool--menu[aria-expanded="true"] span { background: transparent; }
.tool--menu[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.tool--menu[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

.mobile-menu {
  position: fixed; top: var(--hud-h); left: 0; right: 0; z-index: 19;
  display: grid; gap: 4px; padding: 16px var(--gutter) 24px;
  background: rgba(5, 8, 22, .96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.mobile-menu a:not(.btn) {
  padding: 14px 4px; border-bottom: 1px solid rgba(var(--ion-rgb), .08);
  font: 500 1.15rem/1 var(--display); color: var(--star); text-decoration: none;
}
.mobile-menu .btn { margin-top: 14px; }
.mobile-menu[hidden] { display: none; }

@media (max-width: 1060px) {
  .hud__nav { display: none; }
  .hud__tools { margin-left: auto; }
  .tool--menu { display: inline-flex; }
}
@media (max-width: 640px) {
  .hud { gap: 12px; }
  .hud__cta, .tool__label, .tool--palette { display: none; }
  .wordmark { font-size: .95rem; }
}

/* ---------- Deck rail ---------- */

.rail {
  position: fixed; left: 22px; top: 50%; transform: translateY(-50%); z-index: 15;
  display: none;
}
@media (min-width: 1180px) { .rail { display: block; } }
.rail ol { list-style: none; margin: 0; padding: 0 0 0 14px; display: grid; gap: 14px; }
.rail a {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--dust);
  font: 400 .68rem/1 var(--mono);
}
.rail b {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); font-weight: 400; transition: all .3s var(--ease-out);
}
.rail span { opacity: 0; transform: translateX(-6px); transition: all .3s var(--ease-out); white-space: nowrap; color: var(--star); }
.rail a:hover span, .rail a:focus-visible span, .rail a[aria-current="true"] span { opacity: 1; transform: none; }
.rail a[aria-current="true"] b { border-color: var(--ion); color: var(--void); background: var(--ion); box-shadow: 0 0 14px rgba(var(--ion-rgb), .7); }
.rail__track { position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--line); }
.rail__fill { position: absolute; left: 0; top: 0; width: 1px; height: 100%; background: var(--ion); transform-origin: top; transform: scaleY(0); box-shadow: 0 0 8px var(--ion); }

/* ---------- Decks (sections) ---------- */

.deck { position: relative; padding: clamp(80px, 12vw, 150px) 0; }
.deck__head { max-width: 720px; margin-bottom: clamp(32px, 5vw, 56px); }
.deck__head h2, .mission h2, .comms h2 {
  position: relative; display: inline-block;
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.75rem, 3.6vw, 2.9rem); line-height: 1.08; letter-spacing: -.02em;
  margin-bottom: .55em; text-wrap: balance;
}
.deck__head p { color: var(--dust); font-size: 1.1rem; max-width: 62ch; }

/* docking: brackets lock onto a deck title the first time it comes into view */
.js .deck h2::before, .js .deck h2::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 0 solid var(--ion);
  opacity: 0; transition: opacity .3s, transform .7s var(--ease-out);
}
.js .deck h2::before { left: -18px; top: -12px; border-top-width: 1px; border-left-width: 1px; transform: translate(-20px, -20px); }
.js .deck h2::after { right: -18px; bottom: -6px; border-bottom-width: 1px; border-right-width: 1px; transform: translate(20px, 20px); }
.js .deck.is-docked h2::before, .js .deck.is-docked h2::after { opacity: .9; transform: none; }
@media (max-width: 640px) { .js .deck h2::before, .js .deck h2::after { display: none; } }

/* ---------- 1 Bridge ---------- */

.deck--bridge {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--hud-h) + 40px) 0 40px;
}
.bridge { position: relative; }
.bridge > * { max-width: 640px; }
.bridge__kicker { color: var(--dust); font-size: .95rem; margin-bottom: 22px; }
.bridge__title {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(2.3rem, 5.4vw, 4.6rem); line-height: 1.02; letter-spacing: -.035em;
  margin-bottom: 26px; max-width: 13ch;
  text-shadow: 0 0 40px rgba(var(--ion-rgb), .25);
}
.scramble { display: block; }
.scramble .g { color: var(--ion); opacity: .85; }
.bridge__lede { font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: #c3cbea; max-width: 46ch; margin-bottom: 34px; }
.bridge__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.bridge__hint { margin-top: 26px; font: 300 .72rem/1.5 var(--mono); color: rgba(var(--ion-rgb), .55); }
.no-webgl .bridge__hint { display: none; }
.hint-touch { display: none; }
@media (hover: none) { .hint-fine { display: none; } .hint-touch { display: inline; } }

.telemetry {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
  margin-top: clamp(48px, 8vh, 90px); margin-bottom: 0;
}
.telemetry > div {
  padding: 14px 18px; border-top: 1px solid var(--line);
  background: linear-gradient(to bottom, rgba(var(--ion-rgb), .045), transparent);
}
.telemetry > div + div { border-left: 1px solid rgba(var(--ion-rgb), .08); }
.telemetry dt { font-size: .78rem; color: var(--dust); margin-bottom: 6px; }
.telemetry dd { margin: 0; font: 400 .8rem/1.4 var(--mono); color: var(--star); }
.telemetry a { color: var(--ion); text-decoration: none; }
@media (max-width: 820px) {
  .telemetry { grid-template-columns: 1fr 1fr; }
  .telemetry > div:nth-child(3) { border-left: 0; }
}

@media (max-width: 760px) {
  .bridge__title { max-width: none; }
  .bridge > * { max-width: none; }
}

/* ---------- 2 Viewscreen ---------- */

.screen { margin: 0; position: relative; max-width: min(100%, calc(74vh * 16 / 9)); }
.screen__glass {
  position: relative; overflow: hidden; border-radius: 18px;
  aspect-ratio: 16 / 9; background: #02040c;
  border: 1px solid rgba(var(--ion-rgb), .3);
  box-shadow:
    0 0 0 6px rgba(5, 8, 22, .65),
    0 0 0 7px rgba(var(--ion-rgb), .12),
    0 40px 120px -30px rgba(var(--ion-rgb), .45),
    0 0 80px -20px rgba(var(--plasma-rgb), .5);
}
.screen__video { width: 100%; height: 100%; object-fit: cover; }
.screen__scan {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .03) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}
.screen__scan::after { /* slow refresh bar */
  content: ""; position: absolute; left: 0; right: 0; height: 22%;
  background: linear-gradient(to bottom, transparent, rgba(var(--ion-rgb), .07), transparent);
  animation: refresh 6s linear infinite;
}
@keyframes refresh { from { top: -25%; } to { top: 105%; } }
.screen__hud {
  position: absolute; inset: 0; padding: 14px 16px; pointer-events: none;
  display: flex; justify-content: space-between; align-items: flex-start;
  font: 300 .7rem/1 var(--mono); color: rgba(232, 238, 255, .85);
}
.screen__tag, .screen__tc { background: rgba(2, 4, 12, .55); padding: 7px 9px; border-radius: 6px; backdrop-filter: blur(4px); }
.screen__tag { display: inline-flex; align-items: center; gap: 8px; }
.rec { width: 7px; height: 7px; border-radius: 50%; background: var(--pulsar); box-shadow: 0 0 10px var(--pulsar); animation: blink 1.6s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: .2; } }
.screen__bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 18px; color: var(--dust); font-size: .92rem;
}
.screen__bar span { flex: 1 1 260px; }
.screen__bar a { font-weight: 500; }
[data-screen-toggle] .ico-play { display: none; }
[data-screen-toggle][aria-pressed="false"] .ico-play { display: block; }
[data-screen-toggle][aria-pressed="false"] .ico-pause { display: none; }

.portals {
  list-style: none; padding: 0; margin: 48px 0 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
}
.portal {
  position: relative; display: grid; gap: 6px; height: 100%;
  padding: 22px 22px 24px; border-radius: var(--r-panel);
  background: var(--hull-a); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--dust); text-decoration: none; overflow: hidden;
  transition: border-color .3s, transform .4s var(--ease-out);
}
.portal::before { /* event horizon glow that follows the pointer */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--ion-rgb), .16), transparent 70%);
}
.portal:hover { border-color: var(--line-strong); transform: translateY(-3px); color: #c3cbea; }
.portal:hover::before { opacity: 1; }
.portal__kind { font: 300 .7rem/1 var(--mono); color: var(--ion); }
.portal strong { font: 600 1.15rem/1.2 var(--display); color: var(--star); letter-spacing: -.01em; }
@media (max-width: 860px) { .portals { grid-template-columns: 1fr; } }

/* Teaser card: an image, no link. The role line appears on hover or focus. */
.portal--teaser { min-height: 212px; align-content: end; cursor: default; isolation: isolate; }
.portal--teaser > :not(svg) { position: relative; z-index: 1; }
.portal--teaser:focus-visible { outline: 2px solid var(--ion); outline-offset: 3px; }
.teaser__art {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0;
  opacity: .78; transition: opacity .6s var(--ease-out), transform 1.2s var(--ease-out);
}
.portal--teaser::after { /* keeps the words readable over the image */
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 30%, rgba(5, 8, 22, .82) 100%);
}
.teaser__sun { opacity: .7; transform-origin: 72% 38%; transition: opacity .8s, transform 1.4s var(--ease-out); }
.teaser__dust { opacity: .35; transition: opacity .8s; }
.teaser__rungs { opacity: .32; }
.teaser__note {
  max-height: 0; opacity: 0; transform: translateY(6px); overflow: hidden;
  font-size: .92rem; line-height: 1.45; color: #c3cbea;
  transition: max-height .6s var(--ease-out), opacity .5s, transform .6s var(--ease-out);
}
.portal--teaser:hover .teaser__art, .portal--teaser:focus-visible .teaser__art { opacity: 1; transform: scale(1.04); }
.portal--teaser:hover .teaser__sun, .portal--teaser:focus-visible .teaser__sun { opacity: 1; transform: scale(1.12); }
.portal--teaser:hover .teaser__dust, .portal--teaser:focus-visible .teaser__dust { opacity: .8; }
.portal--teaser:hover .teaser__helix, .portal--teaser:focus-visible .teaser__helix { animation: helix-drift 9s linear infinite; }
.portal--teaser:hover .teaser__note, .portal--teaser:focus-visible .teaser__note { max-height: 5em; opacity: 1; transform: none; }
@keyframes helix-drift { to { transform: translateX(-120px); } }
@media (hover: none) { .teaser__note { max-height: 5em; opacity: 1; transform: none; } }

/* ---------- 3 Mission ---------- */

.mission { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: clamp(32px, 6vw, 80px); align-items: start; }
.crew { position: sticky; top: calc(var(--hud-h) + 30px); }
.crew__portrait { position: relative; width: min(100%, 300px); aspect-ratio: 1; margin: 0 auto 28px; }
.crew__portrait img {
  position: absolute; inset: 14%; width: 72%; height: 72%; border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(var(--ion-rgb), .5), 0 0 50px -6px rgba(var(--plasma-rgb), .7);
}
.crew__orbit { position: absolute; inset: 0; width: 100%; height: 100%; animation: orbit 60s linear infinite; }
.crew__orbit text { font: 300 7.4px var(--mono); fill: rgba(var(--ion-rgb), .75); letter-spacing: 1.2px; }
@keyframes orbit { to { transform: rotate(360deg); } }
.crew__card {
  margin: 0; padding: 6px 18px; border-radius: var(--r-panel);
  background: var(--hull-a); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.crew__card > div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; font-size: .9rem; }
.crew__card > div + div { border-top: 1px solid rgba(var(--ion-rgb), .08); }
.crew__card dt { color: var(--dust); }
.crew__card dd { margin: 0; text-align: right; }
.mission h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
.mission__lead { font-size: clamp(1.15rem, 1.8vw, 1.4rem); line-height: 1.5; color: var(--star); }
.mission__body > p:not(.mission__lead) { color: #b9c2e4; max-width: 64ch; }
.chips { list-style: none; padding: 0; margin: 30px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  padding: 6px 12px; border-radius: 999px; font-size: .82rem; color: #c3cbea;
  border: 1px solid var(--line); background: rgba(5, 8, 22, .45);
}
.mission__links { display: flex; gap: 20px; }
@media (max-width: 860px) {
  .mission { grid-template-columns: 1fr; }
  .crew { position: static; max-width: 420px; }
}

/* ---------- 4 Systems console ---------- */

.console {
  display: grid; grid-template-columns: 280px 1fr; gap: 0;
  border-radius: 20px; overflow: hidden;
  background: var(--hull-b); border: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 30px 90px -40px rgba(var(--plasma-rgb), .6);
}
.console__tabs { display: grid; align-content: start; padding: 14px; gap: 4px; border-right: 1px solid var(--line); background: rgba(5, 8, 22, .35); }
.console__tabs button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 14px; border: 1px solid transparent; border-radius: 12px; background: none;
  font-size: .98rem; font-weight: 500; color: var(--dust); cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.console__tabs button i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px rgba(255, 255, 255, .04); flex: none; transition: box-shadow .3s; }
.console__tabs button:hover { color: var(--star); background: rgba(var(--ion-rgb), .05); }
.console__tabs button[aria-selected="true"] { color: var(--star); background: rgba(var(--ion-rgb), .08); border-color: rgba(var(--ion-rgb), .25); }
.console__tabs button[aria-selected="true"] i { box-shadow: 0 0 12px var(--c), 0 0 0 3px rgba(255, 255, 255, .06); }

.console__screen { position: relative; display: grid; grid-template-columns: 1fr 1fr; min-height: 420px; }
.console__canvas { grid-column: 2; grid-row: 1; width: 100%; height: 100%; min-height: 320px; }
.console__panel { grid-column: 1; grid-row: 1; padding: 34px 32px; }
.console__panel h3 { font: 600 1.35rem/1.25 var(--display); letter-spacing: -.01em; margin-bottom: 12px; }
.console__panel p { color: #b9c2e4; }
.console__panel ul { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 10px; }
.console__panel li { position: relative; padding-left: 22px; font-size: .97rem; }
.console__panel li::before {
  content: ""; position: absolute; left: 2px; top: .55em; width: 8px; height: 8px;
  border: 1px solid var(--ion); transform: rotate(45deg);
}
.console__panel a { font-weight: 500; }
.console__panel:not([hidden]) { animation: panel-in .5s var(--ease-out); }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 980px) {
  .console { grid-template-columns: 1fr; }
  .console__tabs { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .console__tabs::-webkit-scrollbar { display: none; }
  .console__tabs button { padding: 10px 14px; }
  .console__screen { grid-template-columns: 1fr; }
  .console__canvas { grid-column: 1; grid-row: 1; min-height: 200px; height: 220px; }
  .console__panel { grid-column: 1; grid-row: 2; padding: 22px 22px 28px; }
}

/* ---------- 5 Star map (orrery) ---------- */

.deck--starmap .deck__head { max-width: 760px; }
.legend { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 18px; font-size: .88rem; color: var(--dust); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }

.orrery { position: relative; }
.bodies { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.bodies a {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: var(--hull-a); border: 1px solid var(--line); color: var(--star); text-decoration: none; font-weight: 500;
}
.bodies li[data-status="live"] i { background: var(--live); box-shadow: 0 0 12px var(--live); }
.bodies li[data-status="domain"] i { background: var(--plasma); box-shadow: 0 0 12px var(--plasma); }
.bodies li[data-status="dev"] i { background: var(--solar); box-shadow: 0 0 12px var(--solar); }
.bodies i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.orrery__sky { display: none; }
.probe { display: none; }

/* orbital mode, switched on by JS */
.orrery__field { position: relative; }
.orrery.is-orbiting { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: center; }
.is-orbiting .orrery__field { aspect-ratio: 1000 / 540; min-height: 340px; max-height: 620px; }
.is-orbiting .orrery__sky { display: block; position: absolute; inset: 0; }
.is-orbiting .orrery__rings { width: 100%; height: 100%; overflow: visible; }
.is-orbiting .ring { fill: none; stroke: rgba(var(--ion-rgb), .16); stroke-width: 1; stroke-dasharray: 2 6; vector-effect: non-scaling-stroke; }
.is-orbiting .ring--2 { stroke: rgba(var(--plasma-rgb), .2); }
.is-orbiting .ring--3 { stroke: rgba(255, 181, 71, .14); }
.is-orbiting .orrery__core {
  position: absolute; left: 50%; top: 50%; width: 84px; height: 84px; transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 18px rgba(var(--ion-rgb), .8)) drop-shadow(0 0 40px rgba(var(--plasma-rgb), .6));
  animation: core 6s ease-in-out infinite;
}
@keyframes core { 50% { transform: translate(-50%, -50%) scale(1.06); } }
.is-orbiting .bodies { display: block; position: absolute; inset: 0; }
.is-orbiting .bodies li { position: absolute; left: 0; top: 0; will-change: transform; }
.is-orbiting .bodies a {
  padding: 0; background: none; border: 0; gap: 8px; transform: translate(-50%, -50%);
  font-size: .82rem; white-space: nowrap; position: relative;
}
.is-orbiting .bodies a i { width: 12px; height: 12px; transition: transform .3s var(--ease-out); }
.is-orbiting .bodies li[data-orbit="2"] a i { width: 10px; height: 10px; }
.is-orbiting .bodies li[data-orbit="3"] a i { width: 8px; height: 8px; }
.is-orbiting .bodies a span {
  padding: 4px 8px; border-radius: 6px; background: rgba(5, 8, 22, .55); border: 1px solid transparent;
  transition: border-color .2s, background .2s, color .2s; color: #c3cbea;
}
.is-orbiting .bodies a:hover span, .is-orbiting .bodies a:focus-visible span, .is-orbiting .bodies a.is-active span {
  border-color: var(--line-strong); background: rgba(11, 18, 38, .9); color: #fff;
}
.is-orbiting .bodies a:hover i, .is-orbiting .bodies a.is-active i { transform: scale(1.6); }
.is-orbiting .probe {
  display: block; position: relative;
  padding: 22px 22px 24px; border-radius: var(--r-panel);
  background: var(--hull-b); border: 1px solid var(--line-strong);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .8);
}
.is-orbiting .probe::before, .is-orbiting .probe::after { /* targeting brackets */
  content: ""; position: absolute; width: 12px; height: 12px; border: 0 solid var(--ion);
}
.is-orbiting .probe::before { left: -6px; top: -6px; border-top-width: 1px; border-left-width: 1px; }
.is-orbiting .probe::after { right: -6px; bottom: -6px; border-bottom-width: 1px; border-right-width: 1px; }
.probe__status { margin-bottom: 10px; }
.probe h3 { font: 600 1.2rem/1.2 var(--display); margin-bottom: 8px; }
.probe p { color: #b9c2e4; font-size: .92rem; }
@media (max-width: 980px) {
  .orrery.is-orbiting { grid-template-columns: 1fr; gap: 16px; }
  .is-orbiting .orrery__field { aspect-ratio: 1000 / 620; }
}
@media (max-width: 640px) {
  .is-orbiting .orrery__field { aspect-ratio: auto; height: 340px; }
  .is-orbiting .bodies a span { display: none; }
  .is-orbiting .bodies a.is-active span { display: inline; }
  .is-orbiting .orrery__core { width: 56px; height: 56px; }
}

/* ---------- 6 Signals ---------- */

.signals { list-style: none; padding: 0; margin: 0; position: relative; max-width: 900px; }
.signals::before { /* the carrier wave the signals hang on */
  content: ""; position: absolute; left: 130px; top: 6px; bottom: 6px; width: 1px;
  background: linear-gradient(to bottom, var(--ion), rgba(var(--plasma-rgb), .5), transparent);
}
.signal { display: grid; grid-template-columns: 130px 1fr; gap: 0 40px; padding: 0 0 44px; position: relative; }
.signal::before {
  content: ""; position: absolute; left: 125px; top: 6px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--void); border: 1px solid var(--ion); box-shadow: 0 0 12px rgba(var(--ion-rgb), .7);
}
.signal:first-child::before { background: var(--ion); }
.signal time { font: 400 .78rem/1.8 var(--mono); color: var(--dust); padding-top: 1px; }
.signal__tags { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.signal h3 { font: 600 1.2rem/1.3 var(--display); letter-spacing: -.01em; margin-bottom: 8px; }
.signal p { color: #b9c2e4; max-width: 64ch; }
.signal__links { display: flex; flex-wrap: wrap; gap: 18px; font-weight: 500; }
.signals__more { margin: 8px 0 0 170px; }
@media (max-width: 700px) {
  .signals::before { left: 5px; }
  .signal { grid-template-columns: 1fr; padding-left: 30px; }
  .signal::before { left: 0; }
  .signal time { margin-bottom: 6px; }
  .signals__more { margin-left: 30px; }
}

/* ---------- 7 Comms ---------- */

.comms { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 80px); align-items: start; }
.comms__intro > p { color: var(--dust); font-size: 1.1rem; max-width: 46ch; }
.channels { list-style: none; padding: 0; margin: 28px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.channels a {
  display: grid; gap: 2px; padding: 16px 18px; border-radius: 14px; text-decoration: none;
  background: var(--hull-a); border: 1px solid var(--line); transition: border-color .2s, transform .3s var(--ease-out);
}
.channels a:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.channels strong { color: var(--star); font-weight: 600; }
.channels span { color: var(--dust); font-size: .85rem; }
.comms__direct { color: var(--dust); }

.transmitter {
  position: relative; padding: 30px; border-radius: 20px;
  background: var(--hull-b); border: 1px solid var(--line-strong);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 30px 90px -40px rgba(var(--ion-rgb), .5);
}
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-size: .88rem; color: var(--dust); font-weight: 500; }
.field input, .field textarea {
  width: 100%; padding: 13px 14px; border-radius: var(--r-ctl);
  background: rgba(2, 4, 12, .6); border: 1px solid var(--line); color: var(--star);
  font: 400 1rem/1.4 var(--sans); transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 130px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ion); box-shadow: 0 0 0 3px rgba(var(--ion-rgb), .15); }
.field ::placeholder { color: #58618a; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.transmitter .btn { width: 100%; }
.transmitter__status { margin: 14px 0 0; min-height: 1.4em; font-size: .92rem; color: var(--dust); }
.transmitter__status.is-ok { color: var(--live); }
.transmitter__status.is-err { color: var(--solar); }
@media (max-width: 860px) {
  .comms { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .channels { grid-template-columns: 1fr; }
  .transmitter { padding: 22px; }
}

/* ---------- Footer ---------- */

.footer { padding: 70px 0 40px; border-top: 1px solid var(--line); background: linear-gradient(to bottom, rgba(5, 8, 22, .3), rgba(5, 8, 22, .9)); }
.footer__grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.footer__brand p { color: var(--dust); font-size: .92rem; margin-top: 14px; max-width: 30ch; }
.footer__status { display: inline-flex; align-items: center; gap: 8px; font: 300 .75rem/1 var(--mono); }
.footer h3 { font: 600 .82rem/1 var(--display); color: var(--star); margin-bottom: 14px; }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer nav a { color: var(--dust); text-decoration: none; font-size: .92rem; }
.footer nav a:hover { color: var(--ion); }
.footer__base { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 48px; padding-top: 22px; border-top: 1px solid rgba(var(--ion-rgb), .08); font-size: .82rem; color: var(--dust); }
.footer__base p { margin: 0; }
@media (max-width: 760px) { .footer__grid { grid-template-columns: 1fr 1fr; } .footer__brand { grid-column: 1 / -1; } }

/* ---------- Boot overlay ---------- */

main, .footer, .hud, .rail, .frame { transition: opacity 1.1s ease .15s, filter 1.1s ease .15s; }
.is-booting main, .is-booting .footer, .is-booting .hud, .is-booting .rail, .is-booting .frame { opacity: 0; filter: blur(6px); }

.boot {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, rgba(8, 14, 34, .5), rgba(2, 3, 10, .88) 75%);
  transition: opacity .7s ease, visibility .7s;
}
.boot[hidden] { display: none; }
.boot.is-leaving { opacity: 0; visibility: hidden; }
.boot__panel { width: min(560px, calc(100vw - 32px)); display: grid; justify-items: start; gap: 22px; }
.boot__mark { width: 64px; height: 64px; filter: drop-shadow(0 0 16px rgba(var(--ion-rgb), .8)); animation: boot-mark 2.2s ease-in-out infinite; }
@keyframes boot-mark { 50% { filter: drop-shadow(0 0 28px rgba(var(--ion-rgb), 1)); } }
.boot__log {
  margin: 0; min-height: 9.6em; width: 100%;
  font: 300 .82rem/1.6 var(--mono); color: #b9f9ff; white-space: pre-wrap;
}
.boot__log .ok { color: var(--live); }
.boot__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.boot__actions[hidden] { display: none; }
.boot__skip { position: fixed; right: 20px; bottom: 20px; background: none; border: 0; color: var(--dust); font-size: .85rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Command palette ---------- */

.palette {
  width: min(620px, calc(100vw - 24px)); max-height: 70vh; margin: 12vh auto auto; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 18px; color: var(--star);
  background: rgba(8, 13, 30, .96); box-shadow: 0 40px 120px -20px rgba(0, 0, 0, .9), 0 0 60px -20px rgba(var(--ion-rgb), .5);
}
.palette::backdrop { background: rgba(2, 3, 10, .6); backdrop-filter: blur(4px); }
.palette[open] { animation: pal-in .35s var(--ease-out); }
@keyframes pal-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
.palette__box { display: grid; grid-template-rows: auto 1fr auto; max-height: 70vh; }
.palette input {
  width: 100%; padding: 20px 22px; border: 0; border-bottom: 1px solid var(--line); background: transparent;
  color: var(--star); font: 400 1.1rem/1.2 var(--sans); outline: none;
}
.palette ul { list-style: none; margin: 0; padding: 8px; overflow: auto; }
.palette li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border-radius: 10px; cursor: pointer; color: #c3cbea;
}
.palette li small { font: 300 .7rem/1 var(--mono); color: var(--dust); }
.palette li[aria-selected="true"] { background: rgba(var(--ion-rgb), .1); color: #fff; box-shadow: inset 2px 0 0 var(--ion); }
.palette li.empty { cursor: default; color: var(--dust); }
.palette__foot { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--dust); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* Video player inside a signal (The Last Bowl) */
.signal__player { position: relative; aspect-ratio: 16 / 9; margin: 6px 0 14px; max-width: 64ch; border-radius: 12px; overflow: hidden; background: #02040c; border: 1px solid rgba(var(--ion-rgb), .3); box-shadow: 0 0 40px -16px rgba(var(--ion-rgb), .45); }
.signal__player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
