/* Aircraft digital twin. Glass chrome over a full-bleed model, the same
   arrangement as the iOS viewer: the canvas is the screen, the panel floats. */

:root {
  --bg: #0b0e12;
  --accent: #00645a;
  --ink: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.62);
  --faint: rgba(255, 255, 255, 0.42);
  --line: rgba(255, 255, 255, 0.16);
  --glass: rgba(18, 22, 28, 0.55);
  --radius-chip: 11px;
  --radius-card: 16px;
  --panel: 360px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

.stage { position: fixed; inset: 0; }
.backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 46% 28%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 68%),
    var(--bg);
}
#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#view:active { cursor: grabbing; }
#view[data-pan="armed"],
#view[data-pan="armed"]:active { cursor: move; }

.top, .dock, .panel, .status {
  position: absolute;
  z-index: 2;
}

.top {
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  padding: 8px 12px 8px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.brand svg { width: 18px; height: 18px; }
.brand strong { font-weight: 650; letter-spacing: -0.02em; }
.brand span { color: var(--muted); font-size: 13px; font-weight: 500; }

.modes {
  display: flex;
  max-width: 100%;
  overflow-x: auto;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.modes button {
  appearance: none;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 13px/1 var(--font);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.modes button[aria-selected="true"] {
  background: var(--accent);
  color: white;
}

.picks {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.picks label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 6px 10px 7px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.picks select {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 600 13px/1.2 var(--font);
  letter-spacing: 0;
  text-transform: none;
  padding: 0 16px 0 0;
  max-width: 180px;
}
.app-link {
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.dock {
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: min(420px, calc(100% - 32px));
  pointer-events: none;
}
.dock > * { pointer-events: auto; }
.hint {
  margin: 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.hint[hidden] { display: none; }
.dock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}
.presets {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.presets button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 12px/1 var(--font);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.presets button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.14);
  color: white;
}
.details-toggle, .panel-dismiss {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--ink);
  font: 600 12px/1 var(--font);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.panel-dismiss {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  backdrop-filter: none;
}
.panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: -4px 0 4px;
}
#panel-picks:empty { display: none; }

/* The time control. The current scene is named in text (`#time-label`), not by
   colour alone, so it is readable by someone who cannot distinguish the pressed
   state's tint from the unpressed one. The buttons are a real toolbar and the
   slider is a real range input, so the whole control is keyboard reachable
   without a key handler of its own. */
.time {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 8px 10px 10px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.time-label {
  font: 600 12px/1.2 var(--font);
  color: white;
  letter-spacing: 0.01em;
}
.time-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.time-buttons button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 11px/1 var(--font);
  padding: 6px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.time-buttons button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.14);
  color: white;
}
.time-buttons button:focus-visible,
.time-slider input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.time-slider { display: block; }
.time-slider input {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.panel {
  top: 76px;
  right: 16px;
  bottom: 16px;
  width: var(--panel);
  overflow: auto;
  padding: 16px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
}
.panel h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
  font-weight: 680;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.lede {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}
.stat {
  padding: 10px 12px;
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.stat b {
  display: block;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat b small { font-size: 12px; margin-left: 2px; font-weight: 650; }
.stat span {
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-label {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 650;
}
.chips, .modules { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button, .modules button, .text-button, .toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: 600 12px/1 var(--font);
  padding: 8px 10px;
  border-radius: var(--radius-chip);
  cursor: pointer;
}
.chips button[aria-pressed="true"], .modules button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 80%, black);
  border-color: transparent;
}
.slider {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  font-size: 12px;
  color: var(--muted);
}
.slider input { width: 100%; accent-color: var(--accent); }
.slider b { font-variant-numeric: tabular-nums; color: var(--ink); min-width: 42px; text-align: right; }

.readouts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 4px;
}
.readout {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
}
.readout b {
  display: block;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.readout span { color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; }
/* Cargo load readout: computed weight/CG checks. Good = within limits,
   bad = over limit. Tint the value and edge, keep the engine grid style. */
.readout-good b { color: #6fcf8e; }
.readout-good { box-shadow: inset 0 0 0 1px rgba(111, 207, 142, 0.35); }
.readout-bad b { color: #ff7a6b; }
.readout-bad { box-shadow: inset 0 0 0 1px rgba(255, 122, 107, 0.45); }

.chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 177, 90, 0.16);
  color: #ffb15a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}
.phase {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card {
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.card h2 { margin: 0 0 4px; font-size: 16px; letter-spacing: -0.02em; }
.card p { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.meta { color: var(--faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

.map-wrap { margin-top: 8px; }
#seat-map {
  width: 100%;
  height: 280px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  display: block;
  cursor: crosshair;
}
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
}
.legend span { font-size: 11px; color: var(--muted); }

.sources { margin-top: 14px; color: var(--faint); font-size: 12px; }
.sources summary { cursor: pointer; color: var(--muted); }
.sources a { color: var(--ink); }
.note { margin: 14px 0 0; color: var(--faint); font-size: 11.5px; line-height: 1.4; }

.status {
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 14, 0.35);
  z-index: 3;
}
.status[hidden] { display: none; }
.status-card {
  width: min(360px, calc(100% - 48px));
  padding: 18px;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.status-card p { margin: 10px 0 0; font-size: 14px; }
.progress {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.progress div {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 120ms linear;
}

button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.sheet-grip { display: none; }

@media (min-width: 861px) {
  .details-toggle { display: none; }
  body[data-panel="closed"] .details-toggle {
    display: inline-flex;
    position: fixed;
    z-index: 4;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
  }
  .panel.is-closed { pointer-events: none; }
}

@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 8px; }
  .modes {
    flex: 1 0 100%;
    order: 2;
    min-width: 0;
  }
  .modes button { padding: 8px 10px; font-size: 12px; }
  .picks { margin-left: 0; width: 100%; }
  .picks label { flex: 1; }
  .app-link { display: none; }
  .panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    height: auto;
    max-height: min(72vh, 680px);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    transform: translateY(calc(100% + 24px));
    pointer-events: none;
  }
  .panel.is-open { pointer-events: auto; }
  .panel-tools {
    position: relative;
    justify-content: center;
    margin: 0;
    min-height: 44px;
  }
  .sheet-grip {
    display: flex;
    flex: 1;
    height: 44px;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    border: 0;
    background: transparent;
    padding: 0;
  }
  .sheet-grip:active { cursor: grabbing; }
  .sheet-grip span {
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.55);
  }
  .panel-dismiss {
    position: absolute;
    right: 4px;
    top: 4px;
  }
  #panel-picks { padding: 0 12px; }
  #panel-picks .picks { width: 100%; }
  #panel-picks .picks label {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
  }
  #panel-body {
    overflow: auto;
    flex: 1 1 auto;
    min-height: auto;
    max-height: calc(min(72vh, 680px) - 132px);
    padding: 0 16px 16px;
    overscroll-behavior: contain;
  }
  .dock {
    left: 8px;
    right: 8px;
    bottom: 12px;
    max-width: none;
  }
  body[data-panel="open"] .dock {
    opacity: 0;
    pointer-events: none;
  }
  .presets { min-width: 0; overflow-x: auto; }
  .brand span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}
