/* GNS 430 Simulator — base styles. Dark cockpit theme by default. */

:root {
  --bg: #0c0e12;
  --panel: #161a20;
  --faceplate: #2a2d33;
  --faceplate-edge: #4a505a;
  /* Real unit TFT is deep navy, not pure black */
  --display-bg: #061018;
  --display-green: #3fd67a;
  --display-cyan: #5ec8e0;
  --display-dim: #2d6a52;
  --text: #e8e6e0;
  --text-dim: #9a978f;
  --accent: #d7a94f;
  --radius: 10px;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* App shell — Trainer | Learn | About */
.app-shell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--faceplate-edge);
  background: #141820;
  position: sticky;
  top: 0;
  z-index: 20;
}
.shell-brand { display: flex; flex-direction: column; gap: 2px; min-width: 8rem; }
.shell-title {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
}
.shell-title:hover { color: var(--display-cyan); }
.shell-sub { font-size: 0.75rem; color: var(--text-dim); }
.shell-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.shell-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 8px;
  font: 600 0.92rem/1 inherit;
  text-decoration: none;
  cursor: pointer;
}
.shell-tab:hover { color: var(--text); background: rgba(255,255,255,0.04); text-decoration: none; }
.shell-tab.active {
  color: var(--display-cyan);
  border-color: rgba(94, 200, 224, 0.35);
  background: rgba(94, 200, 224, 0.1);
}

.site-header {
  padding: 40px 20px 8px;
  text-align: center;
}

.site-header h1 {
  margin: 0 0 6px;
  font-size: 1.9rem;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0;
  color: var(--text-dim);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* Situation map (external overview) */
.situation-wrap {
  margin: 0 auto 28px;
  max-width: 920px;
  background: var(--panel);
  border: 1px solid var(--faceplate-edge);
  border-radius: var(--radius);
  overflow: hidden;
}
.situation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--faceplate-edge);
}
.situation-head h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent);
}
.map-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.situation-body { padding: 0; }
.situation-map {
  display: block;
  width: 100%;
  height: min(42vw, 320px);
  min-height: 220px;
  background: #0a121c;
}
.situation-hint {
  margin: 0;
  padding: 8px 14px 12px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.about-page {
  max-width: 820px;
  margin: 0 auto 24px;
}
.about-card { margin-top: 0; }

/* Device stage — real unit PHOTO with transparent hit overlays. */
.device-stage { margin-bottom: 40px; }

.faceplate {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.55));
}

.faceplate.photo-face {
  /* Match stock photo aspect 806×375 */
  aspect-ratio: 806 / 375;
  width: 100%;
  background: #0a0c10;
  border-radius: 4px;
  overflow: hidden;
}

.face-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Transparent hit targets over the photo */
.hit-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.hit {
  position: absolute;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}
.hit.key:focus { outline: none; }
.hit.key:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 4px;
}
.hit.key:hover {
  background: rgba(255, 255, 255, 0.06);
}
.hit.key.pressed,
.hit.key:active {
  background: rgba(0, 0, 0, 0.22);
}
.hit-round { border-radius: 50%; }
.hit-rect { border-radius: 4px; }
.hit-pill { border-radius: 8px; }

.hit.knob {
  border-radius: 50%;
  cursor: pointer;
}
.hit.knob:focus { outline: none; }

/* Active-dial affordance. A soft radial GLOW centred on the knob — not a hard
   ring — so the knob simply "lights up". Soft edges keep it reading as centred
   even when the hit box is a few px off the physical knob. Single volume knobs
   get one glow; the concentric tuning knobs get two zones (see .knob-ring). */
.hit.knob.vol::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  height: 118%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
    rgba(215, 169, 79, 0.5) 0%,
    rgba(215, 169, 79, 0.28) 42%,
    rgba(215, 169, 79, 0) 68%);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.hit.knob.vol:hover::before,
.hit.knob.vol:focus-visible::before { opacity: 1; }

/* Little "how to use the knobs" diagram under the unit. */
.dial-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 0;
  padding: 8px 12px;
  border: 1px solid rgba(215, 169, 79, 0.35);
  border-radius: 10px;
  background: rgba(215, 169, 79, 0.06);
}
.dial-hint svg { flex: 0 0 auto; width: 84px; height: 52px; }
.dial-hint .dh-knob { fill: none; stroke: var(--accent, #d7a94f); stroke-width: 2.5; }
.dial-hint .dh-knob-inner { fill: var(--accent, #d7a94f); opacity: 0.5; }
.dial-hint .dh-arrow { stroke: var(--accent, #d7a94f); stroke-width: 2.5; }
.dial-hint .dh-arrow-head { fill: var(--accent, #d7a94f); }
.dial-hint .dh-mouse { fill: none; stroke: var(--text, #e8e6e0); stroke-width: 2; }
.dial-hint .dh-wheel { fill: var(--accent, #d7a94f); }
.dial-hint figcaption {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-dim, #b9c0cc);
}
.dial-hint figcaption b { color: var(--text, #e8e6e0); font-weight: 600; }
@media (max-width: 520px) {
  .dial-hint { flex-direction: column; text-align: center; }
}
/* The .knob-ring spans stay INVISIBLE — they are only the scroll/click hit
   zones (outer annulus = large, inner disc = small, boundary ~65% radius). */
.knob-ring {
  position: absolute;
  border-radius: 50%;
  box-sizing: border-box;
}
.knob-ring.large { inset: 2%; }
.knob-ring.small { inset: 17%; }

/* Concentric-knob touch-zone highlight (per the user's guide). The visible fill
   is drawn on pseudo-elements sized with aspect-ratio:1 and centred on the knob
   — so they are always TRUE CIRCLES, concentric, regardless of the hit box's
   rendered aspect (the span-based fill came out as an off-centre oval). Green
   bounds the knob's OUTER edge; yellow is the concentric inner circle. Shown
   only while the matching zone is hovered (:has), never persistent. */
.hit.knob:not(.vol)::before,
.hit.knob:not(.vol)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
/* green — fills the outer ring zone, bounding the knob edge */
.hit.knob:not(.vol)::before {
  height: 100%;
  background: radial-gradient(circle at 50% 50%,
    rgba(51, 214, 74, 0) 56%, rgba(51, 214, 74, 0.45) 80%, rgba(51, 214, 74, 0.30) 100%);
}
/* yellow — fills the inner disc zone */
.hit.knob:not(.vol)::after {
  height: 66%;
  background: radial-gradient(circle at 50% 50%,
    rgba(243, 236, 25, 0.44) 0%, rgba(243, 236, 25, 0.30) 62%, rgba(243, 236, 25, 0) 100%);
}
.hit.knob:not(.vol):has(.knob-ring.large:hover)::before { opacity: 1; }
.hit.knob:not(.vol):has(.knob-ring.small:hover)::after { opacity: 1; }
/* keyboard focus (no pointer to pick a zone) shows both faintly, focus-only */
.hit.knob:not(.vol):focus-visible::before,
.hit.knob:not(.vol):focus-visible::after { opacity: 0.62; }

/* Optional debug: outline hit areas — enable with ?debugHits=1 (see index.html
   inline script, which toggles .debug-hits on .faceplate). Keys and knobs get
   distinct colors; each hit target is labeled with its data-key / data-knob. */
.faceplate.debug-hits .hit.key {
  background: rgba(255, 0, 80, 0.22) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 80, 120, 0.85);
}
.faceplate.debug-hits .hit.knob {
  background: rgba(0, 140, 255, 0.18) !important;
  box-shadow: inset 0 0 0 1px rgba(80, 170, 255, 0.85);
}
.faceplate.debug-hits .hit[data-key]::after,
.faceplate.debug-hits .hit[data-knob]::after {
  content: attr(data-key) attr(data-knob);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2px;
  overflow: hidden;
  font: 700 8px/1.1 var(--mono);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.95);
  pointer-events: none;
}
.faceplate.debug-hits .display-cutout {
  outline: 2px solid lime;
}

/* Glass cutout — calibrated to unit-faceplate.png LCD (806×375) */
.display-cutout {
  position: absolute;
  left: 26.43%;
  top: 20.27%;
  width: 49.63%;
  height: 56.8%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--display-bg);
  border-radius: 2px;
  overflow: hidden;
  z-index: 1;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.75),
    inset 0 1px 4px rgba(0, 0, 0, 0.45);
}

.screen-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--display-bg);
}

.display-fallback {
  margin: 0;
  padding: 12px;
  color: var(--display-dim);
  font-family: var(--mono);
  font-size: 0.85rem;
  text-align: center;
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.shortcuts {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--faceplate-edge);
  border-radius: var(--radius);
  padding: 20px 24px;
  max-width: 480px;
}
.shortcuts::backdrop { background: rgba(0, 0, 0, 0.6); }
.shortcuts h3 { margin: 0 0 12px; color: var(--accent); }
.shortcuts table { border-collapse: collapse; }
.shortcuts td { padding: 4px 12px 4px 0; font-size: 0.9rem; }
.shortcuts kbd {
  background: #22252b;
  border: 1px solid #4a4e55;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.shortcuts form { margin: 14px 0 0; text-align: right; }
.shortcuts button {
  background: #22252b;
  color: var(--text);
  border: 1px solid #4a4e55;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}

.stage-note {
  margin: 18px auto 0;
  max-width: 560px;
  color: var(--text-dim);
  font-size: 0.95rem;
  text-align: center;
}

.about {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.about h2 { margin-top: 0; font-size: 1.15rem; color: var(--accent); }
.about ul { margin: 0; padding-left: 20px; }
.about li { margin-bottom: 8px; }

.fine-print {
  margin: 14px 0 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.site-footer {
  text-align: center;
  padding: 0 0 40px;
}

.site-footer a {
  color: var(--text-dim);
  text-decoration: none;
}

.site-footer a:hover { color: var(--text); }

/* Aircraft side panel (Milestone A) */
.cockpit {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 20px auto 0;
  max-width: 820px;
  padding: 0 16px 32px;
}
@media (min-width: 720px) {
  .cockpit { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
}
.panel {
  background: var(--panel, #1a1d23);
  border-radius: 10px;
  padding: 18px 20px;
  border: 1px solid var(--faceplate-edge, #45494f);
}
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; color: var(--accent, #d7a94f); }
.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.panel-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-dim, #9a978f);
}
.panel-grid input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--faceplate-edge, #45494f);
  background: var(--bg, #101216);
  color: var(--text, #e8e6e0);
  font: 600 0.95rem ui-monospace, Menlo, monospace;
}
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.panel-actions .btn,
.panel .btn {
  appearance: none;
  border: 1px solid var(--faceplate-edge, #45494f);
  background: var(--bg, #101216);
  color: var(--text, #e8e6e0);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.panel-actions .btn:hover { border-color: var(--accent, #d7a94f); color: var(--accent, #d7a94f); text-decoration: none; }
.site-header a { color: var(--accent, #d7a94f); }
.readouts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 16px 0 0;
}
.readouts div {
  background: var(--bg, #101216);
  border-radius: 8px;
  padding: 8px 10px;
}
.readouts dt { margin: 0; font-size: 0.7rem; color: var(--text-dim, #9a978f); letter-spacing: 0.06em; }
.readouts dd {
  margin: 2px 0 0;
  font: 600 0.95rem ui-monospace, Menlo, monospace;
  color: var(--display-green, #58d18a);
}
.panel-hint { margin: 14px 0 0; font-size: 0.85rem; color: var(--text-dim, #9a978f); line-height: 1.45; }
.cockpit .about {
  background: var(--panel, #1a1d23);
  border-radius: 10px;
  padding: 20px 24px;
}

.lesson-status {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg, #101216);
  font: 0.85rem/1.4 ui-monospace, Menlo, monospace;
  color: var(--display-cyan, #6fd7e3);
}

/* Graded-scenario debrief (#1124). */
.debrief h4 { margin: 0 0 6px; color: var(--display-cyan, #6fd7e3); }
.debrief-score { margin: 0 0 8px; color: #e8e6e0; }
.debrief-score b { color: #69bd45; }
.debrief-steps { list-style: none; margin: 0 0 8px; padding: 0; }
.debrief-steps li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.debrief-steps li.ok { color: #cfeecf; }
.debrief-steps li.ok::before { content: "✓ "; color: #69bd45; }
.debrief-steps li.miss { color: #c8a45c; }
.debrief-steps li.miss::before { content: "· "; }
.debrief-errors { margin: 6px 0; border-left: 3px solid #c8a45c; padding-left: 8px; }
.debrief-errors p { margin: 0 0 4px; color: #e0b24a; }
.debrief-errors ul { margin: 0; padding-left: 16px; color: #d6cf9a; }
.debrief-clean { color: #69bd45; margin: 6px 0; }
.debrief button[data-retry] {
  margin-top: 6px; padding: 6px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--display-cyan, #6fd7e3); background: transparent;
  color: var(--display-cyan, #6fd7e3); font: inherit;
}
.debrief button[data-retry]:hover { background: rgba(111, 215, 227, 0.15); }

/* How-to section: controls reference + guided flights. */
.howto {
  background: var(--panel, #1a1d23);
  border-radius: var(--radius, 10px);
  padding: 20px 24px;
  margin-top: 24px;
}
.howto h2 { margin-top: 0; font-size: 1.15rem; color: var(--accent, #d7a94f); }
.howto h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--text, #e8e6e0); }
.howto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.howto ul, .howto ol { margin: 0; padding-left: 20px; }
.howto li { margin-bottom: 10px; font-size: 0.92rem; line-height: 1.5; }
.howto p { font-size: 0.92rem; color: var(--text-dim, #9a978f); line-height: 1.5; }
@media (max-width: 720px) {
  .howto-grid { grid-template-columns: 1fr; }
}

/* Scenario-link copy confirmation (#1052). Empty by default; briefly shows
   "Copied scenario link!" (or the raw link, if clipboard access failed). */
.scenario-status {
  min-height: 1.1em;
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--display-green, #58d18a);
  word-break: break-all;
}

/* Instructor mode (#1053) — collapsed by default, clearly training-only. */
.instructor-panel {
  margin-top: 16px;
  border: 1px solid var(--faceplate-edge, #45494f);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg, #101216);
}
.instructor-panel summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent, #d7a94f);
}
.instructor-panel summary::marker { color: var(--text-dim, #9a978f); }
.instructor-panel .panel-actions { margin-top: 10px; }
.instructor-panel .panel-hint { margin-top: 10px; }
