/* New Orleans ATC — radar console styles. Always dark (it's a radar scope). */
:root {
  --bg: #030c0b;
  --panel: #071615;
  --panel-2: #0b1f1e;
  --line: rgba(120, 220, 190, 0.18);
  --line-strong: rgba(120, 220, 190, 0.35);
  --fg: #d7ece5;
  --muted: #8aa9a0;
  --accent: #6ee7b7;
  --approach: #7cc8ff;
  --caution: #f0e442;
  --warn: #ffb000;
  --danger: #ff6b4a;
  --mono: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hud-h: 52px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 var(--sans);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: var(--mono); color: var(--accent); }

.app {
  display: grid;
  height: 100vh;
  height: 100dvh;
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-rows: var(--hud-h) minmax(0, 1fr);
  grid-template-areas: "hud hud" "scope panel";
}

/* ── HUD ─────────────────────────────────────────────────────────────── */
.hud {
  grid-area: hud;
  display: flex; align-items: center; gap: 16px;
  padding: 0 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  background: linear-gradient(#081a18, #051110);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-title { font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 15px; color: var(--accent); white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.stats { display: flex; gap: 18px; margin: 0 auto; min-width: 0; }
.stat { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.stat dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat dd { margin: 0; font: 17px/1.1 var(--mono); color: var(--fg); }
.hud-buttons { display: flex; gap: 6px; }

.hbtn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  color: var(--fg);
  cursor: pointer;
  touch-action: manipulation;
}
.hbtn svg { width: 16px; height: 16px; fill: currentColor; }
.hbtn-text { font: 16px var(--mono); }
.hbtn:hover { border-color: var(--accent); }
.hbtn:focus-visible, .step:focus-visible, .act:focus-visible, .strip:focus-visible, .primary:focus-visible, .secondary:focus-visible, .diff-opt:focus-visible, input:focus-visible {
  outline: 2px solid var(--approach); outline-offset: 2px;
}
.hbtn.on { background: #123b33; border-color: var(--accent); color: var(--accent); }
.hbtn.muted .snd-wave { display: none; }
.hbtn.muted { color: var(--muted); }

/* ── Scope ───────────────────────────────────────────────────────────── */
.scope { grid-area: scope; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#radar { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.zoom { position: absolute; left: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.toasts {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  display: flex; flex-direction: column; gap: 4px; pointer-events: none;
}
.toast {
  font: 12.5px/1.3 var(--mono);
  background: rgba(4, 16, 15, 0.86);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  padding: 5px 9px; border-radius: 6px;
  transition: opacity 0.5s;
}
.toast b { float: right; margin-left: 8px; }
.toast-good { border-left-color: var(--approach); }
.toast-good b { color: var(--approach); }
.toast-warn { border-left-color: var(--warn); }
.toast-warn b { color: var(--warn); }
.toast-bad { border-left-color: var(--danger); background: rgba(40, 10, 6, 0.9); }
.toast-bad b { color: var(--danger); }
.toast.fade { opacity: 0; }
.paused-banner {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  font: 15px var(--mono); letter-spacing: 0.3em; color: var(--caution);
  border: 1px solid var(--caution); padding: 4px 14px; border-radius: 6px; background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* ── Panel ───────────────────────────────────────────────────────────── */
.panel {
  grid-area: panel;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0; overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.strips {
  display: flex; flex-direction: column; gap: 3px;
  padding: 8px; border-bottom: 1px solid var(--line);
  max-height: 40%; overflow-y: auto; flex: none;
}
.strips:empty::before { content: "No traffic yet"; color: var(--muted); font-size: 12px; padding: 4px; }
.strip {
  display: grid; grid-template-columns: 1fr auto auto 72px; gap: 8px; align-items: center;
  text-align: left; padding: 5px 8px; min-height: 32px;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 5px; font: 13px var(--mono); cursor: pointer; touch-action: manipulation;
}
.strip .s-dest, .strip .s-alt { color: var(--muted); }
.strip .s-tag { font-size: 11px; text-align: right; }
.strip[data-state="app"] { border-left-color: var(--approach); }
.strip[data-state="app"] .s-tag { color: var(--approach); }
.strip[data-state="caution"] { border-left-color: var(--caution); }
.strip[data-state="caution"] .s-tag { color: var(--caution); }
.strip[data-state="warn"] { border-left-color: var(--warn); }
.strip[data-state="warn"] .s-tag { color: var(--warn); }
.strip[data-state="danger"] { border-left-color: var(--danger); }
.strip[data-state="danger"] .s-tag { color: var(--danger); }
.strip.sel { background: #16302c; border-color: #fff; border-left-width: 4px; }

.ctl-empty { color: var(--muted); padding: 14px; margin: 0; font-size: 13px; }
.ctl { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 9px; }
.ctl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ctl-callsign { font: 22px/1 var(--mono); color: #fff; }
.ctl-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ctl-close { width: 32px; height: 32px; }
.ctl-now { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; font: 11px var(--mono); color: var(--muted); }
.ctl-now span { display: flex; flex-direction: column; }
.ctl-now b { font-size: 15px; color: var(--fg); font-weight: 400; }

.appr {
  border: 1px solid var(--line-strong); border-left: 5px solid var(--muted);
  border-radius: 6px; padding: 6px 9px; background: var(--panel-2);
  display: flex; flex-direction: column; gap: 1px;
}
.appr-text { font: 14px var(--mono); letter-spacing: 0.04em; }
.appr-text::before { content: "○ "; }
.appr-detail { font-size: 12px; color: var(--muted); }
.appr[data-code="GOOD"], .appr[data-code="LANDING"] { border-left-color: var(--approach); }
.appr[data-code="GOOD"] .appr-text, .appr[data-code="LANDING"] .appr-text { color: var(--approach); }
.appr[data-code="GOOD"] .appr-text::before, .appr[data-code="LANDING"] .appr-text::before { content: "✓ "; }
.appr[data-code="HIGH"], .appr[data-code="LOW"], .appr[data-code="FAST"], .appr[data-code="OCCUPIED"] { border-left-color: var(--warn); }
.appr[data-code="HIGH"] .appr-text, .appr[data-code="LOW"] .appr-text, .appr[data-code="FAST"] .appr-text, .appr[data-code="OCCUPIED"] .appr-text { color: var(--warn); }
.appr[data-code="HIGH"] .appr-text::before { content: "▲ "; }
.appr[data-code="LOW"] .appr-text::before { content: "▼ "; }
.appr[data-code="FAST"] .appr-text::before { content: "» "; }
.appr[data-code="OCCUPIED"] .appr-text::before { content: "■ "; }
.appr[data-code="OFFCOURSE"], .appr[data-code="WRONGEND"] { border-left-color: var(--danger); }
.appr[data-code="OFFCOURSE"] .appr-text, .appr[data-code="WRONGEND"] .appr-text { color: var(--danger); }
.appr[data-code="OFFCOURSE"] .appr-text::before, .appr[data-code="WRONGEND"] .appr-text::before { content: "✕ "; }

.row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 6px; border-radius: 6px; }
.row label { font-size: 12px; color: var(--muted); }
.row .unit { font-family: var(--mono); }
.row-ctl { display: grid; grid-template-columns: 1fr 1fr 1.35fr 1fr 1fr; gap: 4px; }
.step {
  height: 40px; padding: 0; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  font: 13px var(--mono); cursor: pointer; touch-action: manipulation;
}
.step:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.step:active:not(:disabled) { background: #16302c; }
.row input {
  width: 100%; min-width: 0; height: 40px; text-align: center;
  background: #020807; color: #fff; border: 1px solid var(--line-strong); border-radius: 6px;
  font: 17px var(--mono);
}
button:disabled, input:disabled { opacity: 0.4; cursor: default; }
.row.sent { animation: sent 0.6s ease-out; }
.row.sent input { border-color: var(--accent); color: var(--accent); }
@keyframes sent { from { background: rgba(110, 231, 183, 0.22); } to { background: transparent; } }

.ctl-actions { display: grid; grid-template-columns: 1.6fr 1fr; gap: 6px; }
.act {
  min-height: 42px; border-radius: 7px; padding: 4px 8px;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  font: 13px var(--mono); cursor: pointer; touch-action: manipulation;
}
.act[data-mode="armed"] { border-color: var(--approach); color: var(--approach); }
.act[data-mode="established"], .act[data-mode="landing"] { border-color: var(--approach); background: #0d2a3a; color: var(--approach); }
.act[data-mode="off"] { color: var(--muted); border-style: dashed; }
.act-ga:not(:disabled) { border-color: var(--warn); color: var(--warn); }
.kbd-hint { margin: 0; font-size: 11px; color: var(--muted); }

/* ── Overlays ────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 16px;
  background: rgba(1, 6, 6, 0.72);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}
.card {
  position: relative;
  width: min(520px, 100%);
  background: linear-gradient(#0a1d1b, #061211);
  border: 1px solid var(--line-strong); border-radius: 14px;
  padding: 26px 24px 20px;
  box-shadow: 0 0 0 1px rgba(110, 231, 183, 0.05), 0 20px 60px rgba(0, 0, 0, 0.6);
}
.card-wide { width: min(940px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; }
.card h1 { margin: 0; font: 700 34px/1.05 var(--sans); letter-spacing: 0.03em; color: var(--accent); text-transform: uppercase; }
.card h2 { margin: 0 0 10px; font: 700 22px var(--sans); color: var(--accent); }
.card h3 { margin: 0 0 6px; font: 600 15px var(--sans); color: var(--approach); }
.tagline { margin: 4px 0 14px; color: var(--muted); font-size: 15px; letter-spacing: 0.04em; }
.card p { margin: 0 0 10px; }
.card ul { margin: 0 0 10px; padding-left: 18px; }
.card li { margin-bottom: 4px; }
.card-close { position: absolute; top: 12px; right: 12px; }
.diff { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.diff-opt {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 10px; border-radius: 9px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line-strong);
}
.diff-opt b { font-size: 14px; }
.diff-opt span { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.diff-opt[aria-checked="true"] { border-color: var(--accent); background: #12302a; box-shadow: inset 0 0 0 1px var(--accent); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.primary, .secondary {
  min-height: 44px; padding: 0 18px; border-radius: 9px; cursor: pointer; font-weight: 600;
}
.primary { background: var(--accent); color: #032018; border: 0; }
.primary:hover { filter: brightness(1.08); }
.secondary { background: transparent; border: 1px solid var(--line-strong); }
.secondary:hover { border-color: var(--accent); }
.fine { font-size: 12px; color: var(--muted); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 26px; font-size: 13.5px; }
.score-table { border-collapse: collapse; width: 100%; font-size: 13px; margin-bottom: 8px; }
.score-table td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.score-table td:last-child { text-align: right; font-family: var(--mono); }
.noscript { padding: 20px; }

/* ── Narrow / portrait: scope on top, controls as a bottom sheet ─────── */
@media (max-width: 820px) {
  :root { --hud-h: 48px; }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--hud-h) minmax(0, 1fr) auto;
    grid-template-areas: "hud" "scope" "panel";
  }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: 47vh; max-height: 47dvh; }
  .strips { flex-direction: row; overflow-x: auto; overflow-y: hidden; max-height: none; padding: 6px 8px; scrollbar-width: none; }
  .strip { grid-template-columns: auto auto; grid-template-rows: auto auto; gap: 0 6px; min-width: 104px; flex: none; padding: 3px 7px; font-size: 12px; }
  .strip .s-tag { grid-column: 1 / -1; text-align: left; min-height: 13px; font-size: 10px; }
  .strip .s-alt { display: none; }
  .ctl { padding: 8px 10px 10px; gap: 7px; }
  .ctl-callsign { font-size: 19px; }
  .row { grid-template-columns: 52px 1fr; gap: 4px; }
  .row label { font-size: 11px; line-height: 1.15; }
  .step, .row input { height: 38px; }
  .row-ctl { gap: 3px; }
  .ctl-head { align-items: center; }
  .ctl-meta { font-size: 11px; }
  .appr { padding: 4px 8px; }
  .appr-detail { font-size: 11px; }
  .act { min-height: 38px; }
  .toast { font-size: 11px; padding: 3px 7px; background: rgba(4, 16, 15, 0.78); }
  .toast:nth-child(n+3) { display: none; }
  .zoom .hbtn { width: 32px; height: 32px; }
  .kbd-hint, .ctl-empty { display: none; }
  .ctl-empty { display: block; padding: 8px 12px; }
  .brand-sub, .stat-clock { display: none; }
  .brand-title { font-size: 12px; }
  .stats { gap: 10px; }
  .stat dd { font-size: 15px; }
  .hbtn { width: 34px; height: 34px; }
  .hud-buttons { gap: 4px; }
  .hud { gap: 8px; padding: 0 8px; }
  .help-grid { grid-template-columns: 1fr; }
  .card { padding: 20px 16px 16px; }
  .card h1 { font-size: 26px; }
  .diff { grid-template-columns: 1fr; }
  .diff-opt { flex-direction: row; align-items: baseline; gap: 8px; }
}
@media (max-width: 420px) {
  .brand { display: none; }
  .stats { margin-left: 0; }
}
@media (max-width: 820px) and (max-height: 700px) {
  .ctl-now { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .row.sent { animation: none; }
  .toast { transition: none; }
}
