/* Layout: a full-bleed 3D lab with glass HUD panels pinned to the corners —
   title and camber math on the left, controls on the right, instruments along
   the bottom. On phones the scene pins to the top and panels stack below. */
:root {
  --bg: #060b16;
  --glass: rgba(8, 15, 29, 0.74);
  --glass-hi: rgba(20, 34, 60, 0.75);
  --line: rgba(150, 190, 255, 0.14);
  --ink: #e8f1ff;
  --muted: #8ea3bf;
  --dim: #5b6f8c;
  --cyan: #5fe1ff;
  --amber: #ffb547;
  --lift: #3ee6a0;
  --drag: #ff6a5c;
  --warn: #ffcc4d;
  --slat: #f39a3d;
  --flap: #3fbf74;
  --aileron: #f2c94c;
  --spoiler: #9b7bff;
  --display: "Chakra Petch", "Arial Narrow", system-ui, sans-serif;
  --ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--ui); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

#view { position: absolute; inset: 0; }
/* soft vignette so the HUD text reads over the lab */
#view::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 60% 45%, transparent 55%, rgba(4, 8, 18, 0.55) 100%), linear-gradient(90deg, rgba(4, 8, 18, 0.6), transparent 32%); }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
body.shot #intro, body.shot #camber, body.shot #controls, body.shot #deck, body.shot #foot, body.shot #labels { display: none; }

.glass {
  position: absolute;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h2 {
  font: 500 10.5px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim);
  margin: 14px 0 8px; display: flex; align-items: center; gap: 8px;
}
h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
h2:first-child { margin-top: 0; }

/* ---- title block ---- */
#intro { position: absolute; top: 18px; left: 20px; width: 330px; pointer-events: none; }
#intro > * { pointer-events: auto; }
.brand {
  display: inline-flex; align-items: center; gap: 7px; color: var(--ink); text-decoration: none;
  font: 700 15px/1 var(--display); letter-spacing: 0.06em;
}
.brand .ic { color: var(--cyan); }
.brand span { font: 500 11px var(--mono); color: var(--muted); letter-spacing: 0.08em; }
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--cyan); margin: 18px 0 6px; }
h1 {
  font: 700 46px/0.92 var(--display); text-transform: uppercase; margin: 0; letter-spacing: 0.01em; text-wrap: balance;
  background: linear-gradient(180deg, #ffffff 10%, var(--cyan) 110%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 14px rgba(95, 225, 255, 0.25));
}
.lede { color: var(--muted); font-size: 13px; margin: 8px 0 12px; max-width: 300px; }
.chips { display: flex; gap: 6px; margin-bottom: 8px; }
.chip { background: var(--glass); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 88px; backdrop-filter: blur(10px); }
.chip span { display: block; font: 500 9.5px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.chip b { font: 600 17px/1 var(--mono); color: var(--cyan); font-variant-numeric: tabular-nums; }
#explain {
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font-size: 13px; color: #c9d6e8; backdrop-filter: blur(10px);
}
#explain p { margin: 0; }
#explain b { color: var(--ink); font-weight: 600; }
#explain .tag { font: 600 10.5px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--cyan); display: block; margin-bottom: 6px; }
#explain.stall { border-color: rgba(255, 106, 92, 0.6); }
#explain.stall .tag { color: var(--drag); }

/* ---- camber panel ---- */
#camber { left: 20px; bottom: 20px; width: 400px; padding: 10px; }
#camber-canvas { width: 100%; height: auto; display: block; border-radius: 7px; }
.calc { margin: 8px 2px 0; display: grid; gap: 4px; }
.calc div[hidden] { display: none; }
.calc div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.calc dt { font: 500 10px/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
.calc dt { min-width: 7.5em; }
.calc dd { margin: 0; font: 500 12.5px/1.4 var(--mono); color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.calc dd small { color: var(--muted); font-size: 11px; }
.calc .eq dd { color: #cfe9ff; }
#c-camber, #c-boost { color: var(--cyan); }
#c-tunnel { color: var(--lift); }

/* ---- controls ---- */
#controls { top: 18px; right: 20px; width: 290px; padding: 14px 16px; max-height: calc(100% - 132px); overflow-y: auto; }
.ctl { display: grid; grid-template-columns: 1fr auto; align-items: center; margin-bottom: 7px; }
.ctl label { font-weight: 500; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.ctl label small { color: var(--dim); font-weight: 400; font-size: 11px; }
.ctl output { font: 500 12.5px var(--mono); color: var(--cyan); font-variant-numeric: tabular-nums; }
.sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.sw.slat { background: var(--slat); } .sw.flap { background: var(--flap); } .sw.aileron { background: var(--aileron); } .sw.spoiler { background: var(--spoiler); }
input[type="range"] { grid-column: 1 / -1; -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--cyan) var(--p, 50%), rgba(150, 190, 255, 0.18) var(--p, 50%)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(150, 190, 255, 0.18); }
input[type="range"]::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--cyan); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%;
  background: #eaffff; border: 0; box-shadow: 0 0 0 4px rgba(95, 225, 255, 0.22), 0 0 12px rgba(95, 225, 255, 0.7);
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #eaffff; border: 0; box-shadow: 0 0 0 4px rgba(95, 225, 255, 0.22), 0 0 12px rgba(95, 225, 255, 0.7); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.presets button, .seg button, .tog, .key {
  border: 1px solid var(--line); background: rgba(150, 190, 255, 0.05); border-radius: 7px; padding: 6px 4px;
  font: 500 11px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: #c9d6e8;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.presets button:hover, .seg button:hover, .tog:hover, .key:hover { border-color: rgba(95, 225, 255, 0.55); color: var(--ink); }
.presets button.on { border-color: var(--cyan); color: var(--cyan); background: rgba(95, 225, 255, 0.1); }
.seg { display: flex; gap: 4px; margin-bottom: 6px; }
.seg button { flex: 1; }
.seg button.on { background: var(--ink); color: #07101f; border-color: var(--ink); }
.toggles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.tog { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 2px 5px; font-size: 9.5px; color: var(--dim); }
.tog.on { color: var(--cyan); border-color: rgba(95, 225, 255, 0.45); background: rgba(95, 225, 255, 0.08); }

/* ---- instrument deck ---- */
#deck {
  left: 440px; right: 20px; bottom: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px 10px 16px;
}
.meter { width: 150px; }
.meter-head { display: flex; justify-content: space-between; font: 500 10.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.meter-head b { color: var(--ink); font-size: 13px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 6px; margin: 6px 0 5px; border-radius: 3px; background: rgba(150, 190, 255, 0.14); overflow: hidden; }
.fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; transition: width 0.15s linear; }
.fill.lift { background: var(--lift); box-shadow: 0 0 10px var(--lift); }
.fill.lift.short { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.fill.drag { background: var(--drag); box-shadow: 0 0 10px var(--drag); }
.need { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.meter-foot { font-size: 10.5px; color: var(--dim); line-height: 1.3; min-height: 2.6em; }
.light {
  font: 700 12px/1 var(--display); letter-spacing: 0.16em; text-transform: uppercase; padding: 9px 11px; border-radius: 7px;
  border: 1px solid var(--line); color: var(--dim);
}
.light.warn { color: #231a00; background: var(--warn); border-color: var(--warn); }
.light.on { color: #fff; background: var(--drag); border-color: var(--drag); box-shadow: 0 0 18px rgba(255, 106, 92, 0.7); animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.roll { display: flex; flex-direction: column; align-items: center; width: 100px; }
#roll-plane { width: 88px; height: 40px; overflow: visible; }
#roll-g { transition: transform 0.3s ease-out; }
.plane { fill: var(--ink); opacity: 0.85; }
.ail { fill: var(--aileron); }
#roll-text { font: 500 9.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); text-align: center; }
.transport { display: flex; gap: 5px; padding-left: 14px; border-left: 1px solid var(--line); }
.key { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 38px; height: 38px; padding: 0 10px; }
.key.on { color: var(--cyan); border-color: var(--cyan); }
.key.mono { font-size: 12px; letter-spacing: 0; }
.key.accent { background: var(--cyan); color: #04121a; border-color: var(--cyan); box-shadow: 0 0 16px rgba(95, 225, 255, 0.45); }
.key.accent:hover { color: #04121a; }

#foot { position: absolute; right: 24px; bottom: 94px; display: flex; gap: 14px; font: 500 10.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
#foot a { color: var(--muted); text-decoration: none; }
#foot a:hover { color: var(--cyan); }

/* ---- 3D part labels ---- */
.tag3d {
  font: 500 10.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink);
  padding: 4px 7px; border-radius: 5px; background: rgba(6, 11, 22, 0.78); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 6px; white-space: nowrap; transform: translateY(-14px);
}
.tag3d::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 6px var(--c, #fff); }

/* ---- mid-size screens: tighten ---- */
@media (max-width: 1280px) {
  h1 { font-size: 38px; }
  #intro { width: 300px; }
  #camber { width: 340px; }
  #deck { left: 376px; }
  .meter { width: 120px; }
  .roll { display: none; }
}

/* ---- phones and small tablets: scene on top, panels below ---- */
@media (max-width: 900px) {
  body { overflow: auto; }
  #stage { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 20px; }
  #view { position: sticky; top: 0; height: 50vh; margin: 0 -16px; z-index: 1; order: 1; }
  #intro { position: static; width: auto; order: 0; padding-top: 14px; }
  h1 { font-size: 34px; }
  .glass { position: static; width: auto; transform: none; max-height: none; }
  #deck { order: 2; flex-wrap: wrap; justify-content: space-between; }
  .meter { flex: 1 1 130px; width: auto; }
  .roll { display: flex; }
  .transport { border-left: 0; padding-left: 0; width: 100%; }
  .transport .key { flex: 1; }
  #camber { order: 3; }
  #controls { order: 4; }
  #foot { position: static; order: 5; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  .light.on { animation: none; }
  #roll-g, .fill { transition: none; }
}
