/* droids.wtf — the beacon. Night mission-control stripped to a single instrument.
   Ground #0b0922 · one coral #ff3b3f · Bricolage display · DM Mono telemetry.
   The pitch is gone; the machinery hums in the dark. Motion is one orchestrated
   system, gated on .js and fully parked under prefers-reduced-motion. */

/* ---------- fonts ---------- */
@font-face { font-family: 'Bricolage'; src: url('fonts/Bricolage-500Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('fonts/Bricolage-600SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('fonts/Bricolage-700Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('fonts/Bricolage-800ExtraBold.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'DM Mono'; src: url('fonts/DMMono-400Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'DM Mono'; src: url('fonts/DMMono-500Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }

/* ---------- tokens ---------- */
:root {
  --bg: #0b0922;
  --surface: #151133;
  --surface-2: #1a1540;
  --border: #2e2866;
  --hairline: #1e1946;
  --text: #ececef;
  --body: #b9bac6;
  --muted: #8d8f9c;
  --faint: #5c5e6a;
  --accent: #ff3b3f;
  --accent-soft: #ff7276;
  --accent-tint: #ffa8aa;
  --accent-glow: rgba(255, 59, 63, .30);
  --ok: #4ade80;
  --grad-btn: linear-gradient(180deg, #ff5a5e, #e62f34);
  --r-ctrl: 9px;
  --r-pill: 999px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --display: 'Bricolage', system-ui, sans-serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Inter, Roboto, sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --r1: min(30rem, 92vmin);
  --r2: min(41rem, 118vmin);
  --r3: min(52rem, 144vmin);
}

/* ---------- ground ---------- */
* { box-sizing: border-box; margin: 0; }
html { height: 100%; overflow: hidden; }
body {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 600px at 85% -8%, rgba(255, 59, 63, .07), transparent 60%),
    radial-gradient(800px 560px at 4% -6%, rgba(96, 165, 250, .05), transparent 60%),
    var(--bg);
  color: var(--body);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
::selection { background: rgba(255, 59, 63, .38); color: #fff; }
:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; border-radius: 4px; }

.mono { font-family: var(--mono); letter-spacing: .04em; }
.num { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- atmosphere: breathing wash · scanlines · grain ---------- */
.atmo {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(640px 420px at 50% 58%, rgba(255, 59, 63, .055), transparent 70%);
  animation: breathe-wash 9s ease-in-out infinite;
}
@keyframes breathe-wash { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

body::before { /* scanlines */
  content: ""; position: fixed; inset: 0; z-index: 30; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .014) 0 1px, transparent 1px 3px);
}
body::after { /* grain */
  content: ""; position: fixed; inset: 0; z-index: 31; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

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

.spotlight {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(560px 560px at var(--mx, 50%) var(--my, 42%), rgba(255, 114, 118, .06), transparent 70%);
  mix-blend-mode: screen;
}

/* ---------- boot sequence ---------- */
.boot { position: fixed; inset: 0; z-index: 90; display: none; background: var(--bg); overflow: hidden; }
.js .boot {
  display: flex; align-items: center; justify-content: center;
  /* failsafe: if main.js never runs, the overlay removes itself */
  animation: boot-fail .5s ease 6s forwards;
}
.boot.done {
  opacity: 0; visibility: hidden; transform: scale(1.03);
  transition: opacity .55s ease, transform .55s var(--ease), visibility 0s .6s;
  animation: none;
}
@keyframes boot-fail { to { opacity: 0; visibility: hidden; } }
.boot-log {
  width: min(30rem, 84vw);
  font-size: .74rem; letter-spacing: .14em;
  color: var(--muted); display: grid; gap: .6rem;
}
.boot-line { display: flex; align-items: baseline; gap: .7rem; opacity: 0; animation: boot-line-in .3s var(--ease) forwards; }
@keyframes boot-line-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.boot-line .bk { color: var(--accent-soft); }
.boot-line .bfill { flex: 1; border-bottom: 1px dotted var(--hairline); transform: translateY(-.25em); }
.boot-line .bv { color: var(--text); }
.boot-line.typing .bv::after {
  content: ""; display: inline-block; width: .55em; height: 1em;
  background: var(--accent); margin-left: .15em; transform: translateY(.15em);
}
.boot-scan {
  position: absolute; left: 0; right: 0; top: -2px; height: 2px; opacity: .5;
  background: linear-gradient(90deg, transparent, var(--accent-glow) 30%, var(--accent) 50%, var(--accent-glow) 70%, transparent);
  animation: boot-scan 1.6s linear infinite;
}
@keyframes boot-scan { from { top: -2px; } to { top: 100%; } }

/* ---------- the beacon ---------- */
.beacon {
  position: relative; z-index: 10; flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
}

.radar-wrap { position: absolute; left: 50%; top: 41%; z-index: 0; pointer-events: none; will-change: transform; }
.radar { position: absolute; left: 0; top: 0; scale: 1; opacity: 1; transition: opacity 1.2s ease .15s, scale 1.2s var(--ease) .15s; }
.js .radar { opacity: 0; scale: .94; }
body.booted .radar { opacity: 1; scale: 1; }
/* failsafe: if main.js never runs, the radar still appears */
.js body:not(.booted) .radar { animation: radar-fallback .9s var(--ease) 5.4s forwards; }
@keyframes radar-fallback { to { opacity: 1; scale: 1; } }

.ring, .sweep, .orbit, .heartring, .ring-dashed {
  position: absolute; left: 0; top: 0; translate: -50% -50%; border-radius: 50%;
}
.ring { border: 1px solid var(--hairline); }
.ring-1 { width: var(--r1); height: var(--r1); box-shadow: inset 0 0 60px rgba(255, 59, 63, .045); }
.ring-2 { width: var(--r2); height: var(--r2); opacity: .85; }
.ring-dashed { width: var(--r3); height: var(--r3); overflow: visible; animation: spin 90s linear infinite reverse; }
.ring-dashed circle { fill: none; stroke: var(--border); stroke-width: .35; stroke-dasharray: .8 2.6; opacity: .8; }

.sweep {
  width: var(--r2); height: var(--r2); opacity: .55;
  background: conic-gradient(from 0deg, rgba(255, 59, 63, .13), rgba(255, 59, 63, .04) 14%, transparent 24%);
  animation: spin 7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.orbit-1 { width: var(--r1); height: var(--r1); animation: spin 22s linear infinite; }
.orbit-2 { width: var(--r2); height: var(--r2); animation: spin 34s linear infinite reverse; }
.orbit-3 { width: var(--r3); height: var(--r3); animation: spin 47s linear infinite; }
.orbit i {
  position: absolute; left: 50%; top: 0; translate: -50% -50%;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent-glow), 0 0 5px var(--accent);
}
.orbit-2 i { width: 5px; height: 5px; background: var(--muted); box-shadow: none; opacity: .8; }
.orbit-3 i { width: 6px; height: 6px; }

.heartring {
  width: 13rem; height: 13rem; opacity: 0;
  border: 2px solid var(--accent);
  animation: heart 2.6s cubic-bezier(.2, .6, .35, 1) infinite;
}
@keyframes heart {
  0% { transform: scale(.22); opacity: .5; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ---------- the stack ---------- */
.stack {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: clamp(1.1rem, 3.2vh, 1.9rem);
  will-change: transform;
}

.wordmark {
  position: relative;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(3.4rem, 13vw, 8.75rem);
  line-height: .95; letter-spacing: -.03em;
  color: var(--text);
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  text-shadow: 0 0 90px rgba(255, 59, 63, .16);
}
.wm-wtf { color: var(--accent); animation: wtf-breathe 2.6s ease-in-out infinite; }
@keyframes wtf-breathe {
  0%, 100% { text-shadow: 0 0 26px var(--accent-glow); }
  14% { text-shadow: 0 0 60px rgba(255, 59, 63, .55), 0 0 26px var(--accent-glow); }
}

/* glitch: two ghost copies sliced by clip-path, one coral, one white */
.wordmark::before, .wordmark::after {
  content: attr(data-text);
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
}
.wordmark.glitch { animation: jitter .26s steps(4) both; }
.wordmark.glitch::before {
  color: var(--accent); opacity: .55; text-shadow: none;
  animation: glitch-a .26s steps(3) both;
}
.wordmark.glitch::after {
  color: #fff; opacity: .32; text-shadow: none;
  animation: glitch-b .26s steps(3) both;
}
@keyframes jitter {
  0% { transform: translate(0, 0); }
  25% { transform: translate(2px, -1px); }
  50% { transform: translate(-2px, 1px); }
  75% { transform: translate(1px, 1px); }
  100% { transform: translate(0, 0); }
}
@keyframes glitch-a {
  0% { clip-path: inset(8% 0 66% 0); transform: translate(-5px, 2px); }
  33% { clip-path: inset(52% 0 24% 0); transform: translate(4px, -2px); }
  66% { clip-path: inset(74% 0 4% 0); transform: translate(-4px, 1px); }
  100% { clip-path: inset(30% 0 48% 0); transform: translate(3px, 2px); }
}
@keyframes glitch-b {
  0% { clip-path: inset(62% 0 12% 0); transform: translate(5px, -2px); }
  33% { clip-path: inset(18% 0 58% 0); transform: translate(-4px, 2px); }
  66% { clip-path: inset(40% 0 36% 0); transform: translate(4px, -1px); }
  100% { clip-path: inset(70% 0 8% 0); transform: translate(-3px, -2px); }
}

.cipher { min-height: 1.6em; }
.cipher-line {
  display: inline-flex; align-items: center; gap: .12em;
  font-size: clamp(.72rem, 2.2vw, .95rem);
  letter-spacing: .16em; color: var(--body); white-space: nowrap;
}
.cipher-text i { font-style: normal; color: var(--accent-soft); opacity: .75; }
.caret {
  display: inline-block; width: .55em; height: 1.05em;
  background: var(--accent); animation: blink 1.05s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--display); font-weight: 700; font-size: 1.02rem;
  padding: .84rem 1.7rem; border-radius: var(--r-pill);
  text-decoration: none; border: 0; cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), filter .16s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--grad-btn); color: #fff;
  box-shadow: 0 8px 24px -8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 16px 40px -10px var(--accent-glow); }

.btn-summon { position: relative; will-change: transform; }
.btn-summon::after { /* hover emission ring */
  content: ""; position: absolute; inset: -2px; border-radius: inherit;
  border: 2px solid var(--accent-soft); opacity: 0; pointer-events: none;
}
.btn-summon:hover::after { animation: emit 0.7s var(--ease); }
@keyframes emit {
  0% { opacity: .7; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.45); }
}

.reach { font-size: .76rem; letter-spacing: .12em; color: var(--muted); }
.reach-mail {
  color: var(--text); text-decoration: none;
  border-bottom: 1px solid rgba(236, 236, 239, .3);
  transition: border-color .16s ease, color .16s ease;
  padding-bottom: .1em;
}
.reach-mail:hover { color: #fff; border-color: var(--accent-soft); }

/* ---------- entrance cascade ---------- */
.js .rise { opacity: 0; transform: translateY(18px); }
body.booted .rise {
  opacity: 1; transform: none;
  transition: opacity .8s var(--ease), transform .8s var(--ease);
}
body.booted .wordmark { transition-delay: .05s; }
body.booted .cipher { transition-delay: .24s; }
body.booted .actions { transition-delay: .4s; }
body.booted .reach { transition-delay: .52s; }
/* failsafe: if main.js never runs, everything rises on its own */
.js body:not(.booted) .rise { animation: rise-fallback .7s var(--ease) 5.4s forwards; }
@keyframes rise-fallback { to { opacity: 1; transform: none; } }

/* ---------- telemetry chips ---------- */
.tele { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.chip {
  position: absolute;
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem .85rem; border-radius: 10px;
  background: rgba(21, 17, 51, .55); border: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-size: .62rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted); white-space: nowrap;
}
.chip b { font-weight: 500; color: var(--accent-soft); }
.chip-tl { top: clamp(1rem, 3vh, 1.7rem); left: clamp(1rem, 3vw, 2.2rem); }
.chip-tr { top: clamp(1rem, 3vh, 1.7rem); right: clamp(1rem, 3vw, 2.2rem); }
.chip-bl { bottom: 4.6rem; left: clamp(1rem, 3vw, 2.2rem); }
.chip-br { bottom: 4.6rem; right: clamp(1rem, 3vw, 2.2rem); }

.pdot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); color: var(--ok); box-shadow: 0 0 8px currentColor;
  animation: pdot-pulse 2.2s ease-in-out infinite;
}
@keyframes pdot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.redact {
  background: var(--faint); color: transparent; border-radius: 2px;
  padding: 0 .12em; user-select: all;
  animation: redact-flicker 3.7s steps(1) infinite;
}
.redact.r2 { animation-delay: 1.9s; }
@keyframes redact-flicker {
  0%, 100% { opacity: .85; }
  46% { opacity: .85; } 48% { opacity: .45; } 50% { opacity: .85; }
  87% { opacity: .85; } 89% { opacity: .55; } 91% { opacity: .85; }
}

.js .chip { opacity: 0; translate: 0 10px; transition: opacity .7s var(--ease), translate .7s var(--ease); }
body.booted .chip { opacity: 1; translate: 0 0; }
body.booted .chip-tl { transition-delay: .7s; }
body.booted .chip-tr { transition-delay: .82s; }
body.booted .chip-bl { transition-delay: .94s; }
body.booted .chip-br { transition-delay: 1.06s; }
.js body:not(.booted) .chip { animation: chip-fallback .7s var(--ease) 5.6s forwards; }
@keyframes chip-fallback { to { opacity: 1; translate: 0 0; } }
body.booted .chip-tl { animation: bob 5.2s ease-in-out 1.8s infinite; }
body.booted .chip-tr { animation: bob 6.1s ease-in-out 2.2s infinite; }
body.booted .chip-bl { animation: bob 5.7s ease-in-out 2s infinite; }
body.booted .chip-br { animation: bob 6.6s ease-in-out 2.5s infinite; }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }

/* ---------- footer ---------- */
.foot {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: .35rem .6rem; padding: .95rem clamp(1rem, 3vw, 2rem);
  border-top: 1px solid var(--hairline);
  font-size: .64rem; text-transform: uppercase; letter-spacing: .13em;
  color: var(--muted);
}
.foot a { color: var(--body); text-decoration: none; border-bottom: 1px solid transparent; transition: color .16s ease, border-color .16s ease; }
.foot a:hover { color: var(--text); border-color: var(--accent-soft); }
.fs { color: var(--hairline); }
.foot-freeze {
  font-size: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--muted); background: transparent; border: 1px solid var(--hairline);
  border-radius: var(--r-pill); padding: .2rem .7rem; cursor: pointer;
  transition: color .16s ease, border-color .16s ease;
}
.foot-freeze:hover { color: var(--text); border-color: var(--accent-soft); }
html:not(.js) .foot-freeze { display: none; } /* nothing for it to control without JS */

/* ---------- small screens ---------- */
@media (max-width: 680px) {
  .chip-bl, .chip-br { display: none; }
  .cipher-line { letter-spacing: .1em; }
  .foot { gap: .3rem .5rem; font-size: .56rem; }
}
@media (max-width: 420px) {
  .chip-tl, .chip-tr { display: none; }
}
/* short viewports: shrink the theater, allow scroll as a last resort */
@media (max-height: 600px) {
  .wordmark { font-size: clamp(2.6rem, 9vh, 5rem); }
  .stack { gap: .9rem; }
  .chip { display: none; }
}
@media (max-height: 460px) {
  html { overflow: auto; }
  body { height: auto; min-height: 100svh; overflow: visible; }
}

/* ---------- reduced motion: nothing moves, nothing is missing ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .boot { display: none !important; }
  .js .rise, body.booted .rise { opacity: 1 !important; transform: none !important; }
  .js .radar { opacity: 1 !important; scale: 1 !important; }
  .js .chip { opacity: 1 !important; translate: 0 0 !important; }
  .caret { opacity: 1; }
  .spotlight { display: none; }
  /* park the orbit dots scattered, not stacked at 12 o'clock */
  .orbit-1 { transform: rotate(50deg); }
  .orbit-2 { transform: rotate(170deg); }
  .orbit-3 { transform: rotate(300deg); }
  .foot-freeze { display: none; } /* the OS setting already governs */
}

/* ---------- frozen (footer control): same contract as reduced motion ---------- */
html.frozen *, html.frozen *::before, html.frozen *::after { animation: none !important; transition: none !important; }
html.frozen .boot { display: none !important; }
html.frozen .rise { opacity: 1 !important; transform: none !important; }
html.frozen .radar { opacity: 1 !important; scale: 1 !important; }
html.frozen .chip { opacity: 1 !important; translate: 0 0 !important; }
html.frozen .caret { opacity: 1; }
html.frozen .spotlight { display: none; }
html.frozen .orbit-1 { transform: rotate(50deg); }
html.frozen .orbit-2 { transform: rotate(170deg); }
html.frozen .orbit-3 { transform: rotate(300deg); }
