/* Nav Radio Trainer — cockpit-dark page, paper chart. */

:root {
    --nt-bg: #17181c;
    --nt-bg-2: #202227;
    --nt-bg-3: #2a2d33;
    --nt-line: #34373e;
    --nt-text: #e8e9ec;
    --nt-muted: #9aa0ab;
    --nt-accent: #f59e0b;        /* heading-bug orange */
    --nt-lcd: #7cf0a4;           /* radio display green */
    --nt-lcd-dim: #3f7a56;

    /* Chart ("sectional") tokens */
    --ch-low: #dde8c6;
    --ch-t1: #ece3bf;
    --ch-t2: #e2cf9f;
    --ch-t3: #d4b687;
    --ch-water: #b7d6ea;
    --ch-water-line: #5f95c3;
    --ch-city: #f4dc83;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(1200px 600px at 50% -10%, #23262d 0%, var(--nt-bg) 60%);
    color: var(--nt-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.45;
}

button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ── Header ─────────────────────────────────────────────── */
.nt-header { padding: 1rem clamp(0.75rem, 3vw, 2rem) 0.25rem; }
.nt-titlebar {
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.nt-logo {
    margin: 0;
    font-size: clamp(1.45rem, 3.4vw, 2.1rem);
    font-weight: 800;
    letter-spacing: -0.02em;
}
.nt-logo span { color: var(--nt-accent); }
.nt-sub { margin: 0.1rem 0 0; color: var(--nt-muted); font-size: 0.9rem; }

.nt-modes {
    display: flex;
    gap: 0.3rem;
    background: var(--nt-bg-2);
    padding: 0.3rem;
    border-radius: 999px;
    border: 1px solid var(--nt-line);
}
.nt-mode {
    border: 0;
    background: transparent;
    color: var(--nt-muted);
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
}
.nt-mode:hover { color: var(--nt-text); }
.nt-mode.is-active { background: var(--nt-accent); color: #1b1305; }

/* ── Layout ─────────────────────────────────────────────── */
.nt-main {
    width: 100%;
    margin: 0 auto;
    padding: 0.75rem clamp(0.75rem, 3vw, 2rem) 1.5rem;
    display: grid;
    /* Chart column: as big as fits the screen height (the chart is 100 × 70),
       the instrument panel takes whatever width is left. */
    --chart-max: calc((100vh - 12.5rem) * 100 / 70);
    grid-template-columns: minmax(0, max(34rem, var(--chart-max))) minmax(360px, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "chart panel" "coach panel";
    gap: 1rem 1.25rem;
    align-items: start;
    flex: 1;
}
.nt-chart-col { grid-area: chart; }
.nt-coach { grid-area: coach; min-width: 0; }
.nt-panel { grid-area: panel; }
/* Ultrawide: the gauges fit in one row, so the explanations move up beside
   the chart instead of hiding below the fold. */
@media (min-aspect-ratio: 21/10) and (min-width: 1600px) {
    .nt-main { grid-template-rows: auto 1fr; grid-template-areas: "chart panel" "chart coach"; }
    .nt-panel { position: static; }
}
@media (max-width: 1000px) {
    .nt-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "chart" "panel" "coach"; }
}

.nt-chart-col { min-width: 0; display: flex; flex-direction: column; gap: 0.6rem; }

/* ── Toolbar ────────────────────────────────────────────── */
.nt-toolbar, .nt-quizbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}
.nt-quizbar {
    background: #3a2a0d;
    border: 1px solid #6b4c12;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    color: #fde7b4;
}
.nt-quizbar span { flex: 1 1 14rem; }
.nt-turns { display: inline-flex; gap: 0.25rem; flex-wrap: wrap; }

.nt-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--nt-line);
    background: var(--nt-bg-3);
    border-radius: 8px;
    padding: 0.38rem 0.7rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}
.nt-btn:hover { border-color: #50545d; }
.nt-fly[aria-pressed="true"] { background: var(--nt-accent); color: #1b1305; border-color: var(--nt-accent); }
.nt-quiet { background: transparent; color: var(--nt-muted); }
body.is-quiz .nt-toolbar { opacity: 0.45; pointer-events: none; }

.nt-field, .nt-check {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--nt-muted);
    font-size: 0.9rem;
}
.nt-field select {
    background: var(--nt-bg-3);
    border: 1px solid var(--nt-line);
    border-radius: 8px;
    padding: 0.32rem 0.4rem;
}
.nt-check { color: var(--nt-text); cursor: pointer; font-weight: 600; }
.nt-check input { accent-color: var(--nt-accent); width: 1.05rem; height: 1.05rem; }

/* ── Chart ──────────────────────────────────────────────── */
.nt-chart-scroll {
    overflow: auto;
    border-radius: 12px;
    border: 1px solid #0b0c0e;
    box-shadow: 0 10px 30px #0006;
    background: var(--ch-low);
}
nav-chart { display: block; min-width: 680px; }
.chart {
    display: block;
    width: 100%;
    height: auto;
    font-family: "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}
.nt-hint { margin: 0; color: var(--nt-muted); font-size: 0.85rem; }
.nt-orange { color: #fb923c; }
body.is-quiz .nt-hint { visibility: hidden; }

.ch-water-lbl { font-size: 0.9px; fill: #2f6ea3; font-style: italic; letter-spacing: 0.05px; }
.ch-city-lbl { font-size: 1.05px; fill: #3b3b3b; font-weight: 700; letter-spacing: 0.08px; }
.ch-peak { font-size: 0.95px; fill: #3b2f25; font-weight: 700; }
.ch-peak-name { font-size: 0.8px; fill: #3b2f25; }
.ch-airway { font-size: 1.1px; fill: #1f5fa8; font-weight: 800; }
.ch-radial { font-size: 1.05px; fill: #1f5fa8; font-weight: 700; }
.ch-rose circle { stroke: #1f5fa8; stroke-width: 0.1; }
.ch-rose-ticks line { stroke: #1f5fa8; stroke-width: 0.08; }
.ch-rose-nums text { font-size: 0.9px; fill: #1f5fa8; font-weight: 600; }
.ch-apt { font-size: 1.1px; font-weight: 800; letter-spacing: 0.04px; }
.ch-apt-sub { font-size: 0.9px; font-weight: 600; }
.ch-box-name { font-size: 1.05px; font-weight: 800; letter-spacing: 0.04px; }
.ch-box-freq { font-size: 1.35px; font-weight: 800; }
.ch-box-tag { font-size: 0.75px; font-weight: 700; opacity: 0.8; }
.ch-box-morse { font-size: 1.45px; font-weight: 900; letter-spacing: 0.05px; }
.ch-title-a { font-size: 1.35px; font-weight: 800; fill: #222; letter-spacing: 0.1px; }
.ch-title-b { font-size: 0.8px; font-weight: 700; fill: #9c2f78; letter-spacing: 0.06px; }
.ch-scale text { font-size: 0.9px; fill: #222; font-weight: 600; }
.ch-scale-t { font-size: 0.7px !important; letter-spacing: 0.08px; }
.ch-ov-lbl { font-size: 1.05px; fill: #fff; font-weight: 800; letter-spacing: 0.03px; }

.ch-plane-body { cursor: grab; touch-action: none; }
.ch-handle { cursor: alias; touch-action: none; }
nav-chart.is-dragging .ch-plane-body { cursor: grabbing; }
.ch-plane.is-locked .ch-handle, .ch-plane.is-locked .ch-hdg-line { display: none; }
.ch-plane.is-locked .ch-plane-body { cursor: default; }
.ch-plane-body:focus, .ch-plane:focus { outline: none; }

/* ── Coach ──────────────────────────────────────────────── */
.nt-coach-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.6rem; }
.co-card {
    background: var(--nt-bg-2);
    border: 1px solid var(--nt-line);
    border-left: 4px solid var(--co, var(--nt-accent));
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
}
.co-card h3 {
    margin: 0 0 0.35rem;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--co, var(--nt-accent));
    filter: brightness(1.6);
}
.co-card p { margin: 0.3rem 0; }
.co-card ol { margin: 0.3rem 0; padding-left: 1.2rem; }
.co-card li { margin: 0.2rem 0; }
.co-quiz { grid-column: 1 / -1; --co: #f59e0b; }
.co-warn { color: #fcd38d; }
.co-tip { color: #a5d8c0; }
.co-math {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    background: #15161a;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    display: inline-block;
}
.co-hidden { grid-column: 1 / -1; color: var(--nt-muted); margin: 0; }
.co-flash { grid-column: 1 / -1; margin: 0; }

/* ── Panel ──────────────────────────────────────────────── */
.nt-panel {
    background: linear-gradient(180deg, #2b2d32, #232428);
    border: 1px solid #0e0f11;
    border-radius: 16px;
    padding: 0.8rem;
    box-shadow: inset 0 1px 0 #ffffff10, 0 12px 30px #0007;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    position: sticky;
    top: 0.75rem;
}
@media (max-width: 1000px) { .nt-panel { position: static; } }

.nt-stack {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
    gap: 0.4rem 0.6rem;
    align-items: start;
}

.nt-gauges {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}
.nt-gauges figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.nt-gauges figcaption { font-size: 0.72rem; color: var(--nt-muted); letter-spacing: 0.08em; text-transform: uppercase; }
nav-cdi, nav-adf, nav-hdg, nav-hsi { display: block; width: 100%; max-width: 320px; }
.nt-gauges .g-hsi { grid-column: 1 / -1; }
nav-hsi { max-width: 380px; }

.nt-instr { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; container: nt-instr / inline-size; }
/* Wide panel: all the gauges in one row (the HSI takes two slots). */
@container nt-instr (min-width: 880px) {
    .nt-gauges { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .nt-gauges .g-hsi { grid-column: span 2; }
}
.nt-disp { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem; font-size: 0.8rem; color: var(--nt-muted); }
.nt-disp span { margin-right: 0.2rem; }
.nt-disp button {
    border: 1px solid #44474f;
    background: #2a2c32;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    color: var(--nt-muted);
}
.nt-disp button[aria-pressed="true"] { background: #4a3a0e; border-color: #7a5f16; color: #ffd66b; }
@media (max-width: 1000px) and (min-width: 640px) {
    .nt-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .nt-howto { grid-column: 1 / -1; }
}

.gauge { display: block; width: 100%; height: auto; font-family: system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
.gauge .rot { transform-origin: 100px 100px; transform-box: view-box; transition: transform 0.4s cubic-bezier(.3, .7, .3, 1); }
.gauge .needle { transition: transform 0.4s cubic-bezier(.3, .7, .3, 1); }
nav-hdg .gauge .rot { transition-duration: 0.15s; }
.gauge .tf, .gauge .flag, .gauge .nosig { transition: opacity 0.25s; }
.gauge .knob { cursor: ew-resize; touch-action: none; outline: none; }
.gauge .knob:focus-visible circle:nth-of-type(2) { stroke: var(--nt-accent); stroke-width: 2.5; }
@media (prefers-reduced-motion: reduce) {
    .gauge .rot, .gauge .needle { transition: none; }
}

/* Radios */
.rad {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "head win" "head knobs" "morse morse";
    align-items: center;
    gap: 0.25rem 0.6rem;
    background: #1a1b1f;
    border: 1px solid #0c0d0f;
    border-radius: 10px;
    padding: 0.45rem 0.6rem;
}
.rad-head { grid-area: head; display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; min-width: 3.3rem; }
.rad-name { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; color: var(--nt-muted); }
.rad-id {
    border: 1px solid #44474f;
    background: #2a2c32;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.12rem 0.45rem;
    cursor: pointer;
}
.rad-id:hover { border-color: var(--nt-lcd-dim); color: var(--nt-lcd); }
.rad-win {
    grid-area: win;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: #0a0f0c;
    border-radius: 6px;
    padding: 0.2rem 0.45rem;
    box-shadow: inset 0 0 0 1px #0f2418;
    justify-self: start;
}
.rad-slot { display: flex; flex-direction: column; flex-shrink: 0; }
.rad-tag { font-size: 0.55rem; letter-spacing: 0.12em; color: var(--nt-lcd-dim); font-weight: 700; }
.rad-freq {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--nt-lcd);
    background: transparent;
    border: 0;
    padding: 0;
    width: 4.3em;
}
.rad-adf .rad-freq { width: 3.2em; }
.rad-sby { color: #b5e9c9; opacity: 0.85; border-bottom: 1px dashed #2d5a3f; border-radius: 0; }
.rad-sby:focus { outline: none; opacity: 1; border-bottom-color: var(--nt-lcd); }
.rad-swap {
    border: 1px solid #25402f;
    background: #102017;
    color: var(--nt-lcd);
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
}
.rad-swap:hover { background: #17301f; }
.rad-knobs { grid-area: knobs; display: flex; gap: 0.3rem 0.6rem; flex-wrap: wrap; }
.rad-step {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    font-size: 0.62rem;
    color: var(--nt-muted);
    font-weight: 700;
}
.rad-step button {
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 50%;
    border: 1px solid #0c0d0f;
    background: radial-gradient(circle at 40% 35%, #4a4d55, #26282d);
    font-weight: 800;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.rad-step button:active { transform: scale(0.94); }
.rad-morse { grid-area: morse; display: flex; flex-wrap: wrap; gap: 0.6rem; font-size: 0.8rem; color: var(--nt-muted); min-height: 0; }
.rad-morse:empty { display: none; }
.rad-morse span { font-family: ui-monospace, Consolas, monospace; transition: color 0.1s; }
.rad-morse span b { font-family: system-ui, sans-serif; }
.rad-morse span.on { color: var(--nt-lcd); }
.rad-static { color: #d88 !important; font-style: italic; }


/* DME */
.dme {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    background: #1a1b1f;
    border: 1px solid #0c0d0f;
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
}
.dme-name { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; color: var(--nt-muted); min-width: 2.6rem; }
.dme-src { display: inline-flex; border: 1px solid #44474f; border-radius: 6px; overflow: hidden; }
.dme-src button { border: 0; background: #2a2c32; font-size: 0.7rem; font-weight: 800; padding: 0.15rem 0.45rem; cursor: pointer; color: var(--nt-muted); }
.dme-src button[aria-pressed="true"] { background: #4a3410; color: #ffc46b; }
.dme-cell { display: inline-flex; align-items: baseline; gap: 0.2rem; background: #140d05; padding: 0.1rem 0.45rem; border-radius: 5px; }
.dme-cell output {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffb347;
    min-width: 2.2em;
    text-align: right;
}
.dme-cell span { font-size: 0.58rem; color: #9b6b2a; font-weight: 700; letter-spacing: 0.08em; }

/* How-to */
.nt-howto { font-size: 0.86rem; color: var(--nt-muted); }
.nt-howto summary { cursor: pointer; font-weight: 700; color: var(--nt-text); }
.nt-howto ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.nt-howto li { margin: 0.3rem 0; }
.nt-howto b { color: var(--nt-text); }

/* ── Footer ─────────────────────────────────────────────── */
.nt-footer {
    width: 100%;
    margin: 0 auto;
    padding: 0.75rem clamp(0.75rem, 3vw, 2rem) 1.25rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    color: var(--nt-muted);
    font-size: 0.85rem;
}
.nt-footer a { color: var(--nt-accent); text-decoration: none; }
