/* ORIGISOFT — FLIGHT MODE (v2) */

:root {
  --bg: #0A0A0A;
  --bg-panel: rgba(18,18,18,0.92);
  --fg: #EAEAEA;
  --fg-dim: #8A8A8A;
  --accent: #FF2A2A;
  --green: #4AF626;
  --line: #2A2A2A;
  --mono: 'JetBrains Mono', 'IBM Plex Mono', 'Courier New', monospace;
  --sans: 'Archivo Black', 'Inter', -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.hud-accent { color: var(--accent); }
.status-ok { color: var(--green); }

#scanlines {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,0.15) 2px, rgba(0,0,0,0.15) 4px
  );
  mix-blend-mode: multiply;
}

#noise {
  position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* vignette to sell the cockpit glass */
#vignette {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.75) 100%);
}

#canvas-wrap { position: fixed; inset: 0; z-index: 0; }
#scene { display: block; width: 100%; height: 100%; }

/* ---------- fixed cockpit HUD ---------- */
.hud {
  position: fixed; inset: 0; z-index: 30;
  pointer-events: none;
  padding: clamp(0.8rem, 2.5vw, 2rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-row { display: flex; justify-content: space-between; align-items: flex-start; }
.hud-block { display: flex; flex-direction: column; gap: 0.2em; }
.hud-block.hud-right { align-items: flex-end; text-align: right; }
.hud-center-title { align-items: center; }
.hud-callsign { font-size: 0.75rem; letter-spacing: 0.15em; }
.hud-label { font-size: 0.62rem; letter-spacing: 0.1em; color: var(--fg-dim); text-transform: uppercase; }
.hud-value { font-size: 0.72rem; letter-spacing: 0.08em; }

.hud-reticle {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 34px; height: 34px;
  z-index: 30; pointer-events: none;
  opacity: 0.75;
}
.hud-reticle::before, .hud-reticle::after {
  content: ''; position: absolute; background: var(--fg-dim);
}
.hud-reticle::before { top: 50%; left: 0; width: 100%; height: 1px; }
.hud-reticle::after { left: 50%; top: 0; height: 100%; width: 1px; }
.hud-reticle .dot {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 4px; height: 4px; background: var(--accent); border-radius: 50%;
}

.hud-bottom { align-items: flex-end; }
.hud-gauge { display: flex; flex-direction: column; gap: 0.15em; min-width: 7rem; }
.hud-gauge-right { align-items: flex-end; text-align: right; }
.hud-gauge-center { align-items: center; text-align: center; }
.hud-big { font-size: clamp(1.1rem, 2.4vw, 1.8rem); font-weight: 700; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.hud-unit { font-size: 0.58rem; letter-spacing: 0.1em; color: var(--fg-dim); }

.hud-bar {
  margin-top: 0.4rem;
  width: 100%;
  height: 4px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.hud-bar-right { align-self: flex-end; }
.hud-bar-fill {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 0%;
  background: var(--fg);
  transition: width 0.12s linear, background-color 0.2s ease;
}
.hud-bar-fill.hud-bar-danger { background: var(--accent); }
.hud-bar-fill-alt { background: var(--green); }
.hud-bar-fill-alt.hud-bar-danger { background: var(--accent); }

/* compass strip */
.compass {
  position: fixed; top: clamp(0.8rem, 2.5vw, 2rem);
  left: 50%; transform: translateX(-50%);
  z-index: 31; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  margin-top: 2.4rem;
}
.compass-track {
  width: min(60vw, 420px); height: 1px; background: var(--line);
  position: relative;
}
.compass-target {
  position: absolute; top: -4px; width: 2px; height: 9px; background: var(--accent);
  transform: translateX(-50%);
}
.compass-label {
  font-size: 0.6rem; letter-spacing: 0.12em; color: var(--fg-dim);
}

/* nearest-gate direction arrow */
#gate-arrow {
  position: fixed; z-index: 32; pointer-events: none;
  font-size: 1.4rem; color: var(--accent);
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease;
}

/* ---------- intro / controls overlay ---------- */
#intro {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10,10,10,0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.intro-box {
  max-width: 34rem;
  border: 1px solid var(--line);
  padding: clamp(1.5rem, 4vw, 3rem);
  background: var(--bg-panel);
}
.intro-tag { font-size: 0.7rem; letter-spacing: 0.15em; color: var(--fg-dim); }
.intro-title {
  font-family: var(--sans); font-weight: 900; text-transform: uppercase;
  font-size: clamp(1.8rem, 6vw, 3rem); letter-spacing: -0.03em; line-height: 0.92;
  margin: 0.8rem 0 1.4rem;
}
.intro-controls {
  display: flex; flex-direction: column; gap: 0.5rem;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 1rem 0; margin-bottom: 1.4rem;
  font-size: 0.75rem;
}
.intro-controls div { display: flex; justify-content: space-between; gap: 1rem; }
.intro-controls kbd {
  font-family: var(--mono); border: 1px solid var(--fg-dim); padding: 0.1em 0.5em;
  color: var(--fg);
}
#start-btn {
  font-family: var(--mono); background: var(--accent); color: #0A0A0A;
  border: none; padding: 0.9rem 1.4rem; font-size: 0.85rem; letter-spacing: 0.08em;
  text-transform: uppercase; cursor: pointer; width: 100%;
}
#start-btn:hover { opacity: 0.85; }
.intro-note { margin-top: 0.8rem; font-size: 0.62rem; color: var(--fg-dim); text-align: center; }

/* ---------- data pad panels (triggered by gates) ---------- */
#datapad {
  position: fixed; z-index: 35;
  top: 50%; right: clamp(0.8rem, 4vw, 3rem);
  transform: translateY(-50%) translateX(20px);
  width: min(92vw, 26rem);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: clamp(1.2rem, 3vw, 2rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
#datapad.active {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}
.pad-tag { font-size: 0.65rem; letter-spacing: 0.15em; color: var(--fg-dim); }
.pad-title {
  font-family: var(--sans); font-weight: 900; text-transform: uppercase;
  font-size: clamp(1.3rem, 3.5vw, 1.9rem); letter-spacing: -0.02em; margin: 0.5rem 0 1rem;
}
.pad-body { font-size: 0.8rem; line-height: 1.55; color: var(--fg-dim); margin-bottom: 1.2rem; }
.pad-body strong { color: var(--fg); }

.pad-grid { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 1rem; }
.pad-cell { background: var(--bg); padding: 0.8rem 1rem; }
.pad-cell h4 { font-family: var(--sans); font-size: 0.85rem; text-transform: uppercase; margin-bottom: 0.3rem; }
.pad-cell p { font-size: 0.72rem; color: var(--fg-dim); line-height: 1.4; }

.pad-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 1rem; }
.pad-stat { background: var(--bg); padding: 0.9rem; text-align: center; }
.pad-stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pad-stat-label { font-size: 0.6rem; color: var(--fg-dim); letter-spacing: 0.08em; margin-top: 0.2rem; }

.pad-cta {
  display: inline-block; color: var(--accent); text-decoration: none;
  font-size: 0.85rem; border-bottom: 1px solid var(--accent); padding-bottom: 0.2em;
}
.pad-close {
  position: absolute; top: 0.8rem; right: 0.8rem;
  background: none; border: 1px solid var(--line); color: var(--fg-dim);
  width: 1.6rem; height: 1.6rem; cursor: pointer; font-family: var(--mono);
}
#datapad { position: fixed; }

/* ---------- gate labels ---------- */
.gate-label {
  position: absolute; z-index: 20; pointer-events: none;
  font-size: 0.65rem; letter-spacing: 0.12em; color: var(--fg);
  background: rgba(10,10,10,0.6);
  border: 1px solid var(--line);
  padding: 0.25em 0.6em;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}
.gate-label.visited { color: var(--fg-dim); border-color: var(--line); }
.gate-label.near { color: var(--accent); border-color: var(--accent); }

/* ---------- crash / KO screen ---------- */
#crash {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10,10,10,0.95);
  display: none;
  align-items: center; justify-content: center;
  padding: 1.5rem;
}
#crash.active { display: flex; }
#crash::before {
  content: '';
  position: fixed; inset: 0;
  background: var(--accent);
  opacity: 0;
  animation: crash-flash 0.5s ease-out;
  pointer-events: none;
}
@keyframes crash-flash {
  0% { opacity: 0.6; }
  100% { opacity: 0; }
}
.crash-box {
  max-width: 32rem;
  border: 1px solid var(--accent);
  padding: clamp(1.5rem, 4vw, 3rem);
  background: var(--bg-panel);
  text-align: center;
}
.crash-tag { font-size: 0.7rem; letter-spacing: 0.15em; color: var(--accent); }
.crash-title {
  font-family: var(--sans); font-weight: 900; text-transform: uppercase;
  color: var(--accent);
  font-size: clamp(2rem, 7vw, 3.4rem); letter-spacing: -0.03em; line-height: 0.92;
  margin: 0.8rem 0 1.6rem;
}
.crash-stats {
  display: flex; flex-direction: column; gap: 0.6rem;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 1rem 0; margin-bottom: 1.6rem;
}
.crash-stats div { display: flex; justify-content: space-between; font-size: 0.75rem; }
.crash-stats dt { color: var(--fg-dim); letter-spacing: 0.05em; }
#restart-btn {
  font-family: var(--mono); background: var(--accent); color: #0A0A0A;
  border: none; padding: 0.9rem 1.4rem; font-size: 0.85rem; letter-spacing: 0.08em;
  text-transform: uppercase; cursor: pointer; width: 100%;
}
#restart-btn:hover { opacity: 0.85; }

/* ---------- mobile touch controls ---------- */
#touch-controls {
  position: fixed; inset: 0; z-index: 25; display: none;
}
#touch-controls.active { display: block; }
.touch-pad {
  position: absolute; bottom: 1.5rem; width: 40vw; max-width: 11rem; height: 40vw; max-height: 11rem;
  border: 1px solid var(--line); background: rgba(18,18,18,0.4);
}
#touch-look { left: 1.5rem; }
#touch-throttle { right: 1.5rem; display: flex; align-items: center; justify-content: center; }
.touch-hint { font-size: 0.6rem; color: var(--fg-dim); text-align: center; }

/* mobile toggle for controls hint */
.mobile-only { display: none; }
@media (max-width: 720px), (pointer: coarse) {
  .mobile-only { display: block; }
  .desktop-only { display: none; }
  #datapad { top: auto; bottom: 5.5rem; right: 0.8rem; left: 0.8rem; width: auto; transform: translateY(20px); }
  #datapad.active { transform: translateY(0); }
}
