/* HeliTool Flight Deck 2.0 - map page UI. Scoped to html.fd (set by maps.html).
   Tokens: design-tokens.css. Icons, site navigation and base theme: site-shell.css. */

/* ── Shell ───────────────────────────────────────────────────────────────── */
.fd-root { display: none; }
html.fd .fd-root { display: block; }
.fd-root [hidden] { display: none !important; }

/* ── Page chrome replaced by the Flight Deck ─────────────────────────────── */
html.fd .main-footer,
html.fd .leaflet-control-layers,
html.fd .leaflet-control-fullscreen,
html.fd .heli-edit-toggle {
    display: none !important;
}

html.fd body {
    height: 100dvh;
    overflow: hidden;
    background: var(--fd-navy-900);
}
html.fd main.container-fluid { padding: 0; }

/* The map takes all remaining viewport space */
html.fd #map {
    position: fixed;
    top: var(--fd-nav-h);
    left: 0;
    right: 0;
    bottom: 0;
    width: auto !important;
    height: auto !important;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Leaflet's own top-left controls (draw/measure/undo) sit right of the toolbar */
html.fd .leaflet-top.leaflet-left { left: 56px; }

html.fd #toast-container { top: calc(var(--fd-nav-h) + 12px) !important; }


/* ── Top navigation ──────────────────────────────────────────────────────── */
.fd-nav {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--fd-nav-h);
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 0 14px;
    background: var(--fd-navy-800);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    font-family: var(--fd-font);
    font-size: 13px;
}
.fd-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: .01em;
    margin-right: 6px;
}
.fd-brand img { height: 32px; width: auto; display: block; }
.fd-brand:hover { color: #fff; }

.fd-tabs { display: flex; gap: 2px; min-width: 0; }
.fd-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: var(--fd-nav-h);
    padding: 0 14px;
    border: 0;
    background: none;
    color: #c4cfdd;
    font: 600 12px/1 var(--fd-font);
    letter-spacing: .07em;
    text-transform: uppercase;
    cursor: pointer;
}
.fd-tab:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.fd-tab[aria-expanded="true"] { color: #fff; }
.fd-tab[aria-expanded="true"]::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--fd-active);
}
.fd-nav-right { margin-left: auto; display: flex; align-items: center; gap: 2px; }

.fd-iconbtn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--fd-radius);
    background: transparent;
    color: #dbe4ef;
    cursor: pointer;
}
.fd-iconbtn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.fd-nav .fd-iconbtn[aria-expanded="true"] { background: rgba(255, 255, 255, .16); color: #fff; }
.fd-iconbtn-dark { color: var(--fd-text-2); }
.fd-iconbtn-dark:hover { background: #eaeff6; color: var(--fd-text); }

.fd-tab:focus-visible,
.fd-iconbtn:focus-visible,
.fd-tool:focus-visible,
.fd-btn:focus-visible,
.fd-cat-row:focus-visible,
.fd-linkbtn:focus-visible,
.fd-exit:focus-visible {
    outline: 2px solid var(--fd-active);
    outline-offset: -2px;
}

/* ── Bottom navigation (phones) ──────────────────────────────────────────── */
.fd-bottomnav {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1200;
    height: calc(var(--fd-bn-h) + var(--fd-safe-b));
    padding-bottom: var(--fd-safe-b);
    background: var(--fd-navy-800);
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.fd-bottomnav .fd-tab {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    height: var(--fd-bn-h);
    font-size: 10px;
    letter-spacing: .03em;
}
.fd-bottomnav .fd-tab[aria-expanded="true"]::after {
    top: 0;
    bottom: auto;
    border-radius: 0 0 3px 3px;
}

/* ── Left map toolbar ────────────────────────────────────────────────────── */
.fd-toolbar {
    position: fixed;
    top: calc(var(--fd-nav-h) + 8px);
    left: 8px;
    z-index: 1190;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    background: var(--fd-panel);
    border: 1px solid var(--fd-border);
    border-radius: 10px;
    box-shadow: var(--fd-shadow);
}
.fd-tool {
    position: relative;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--fd-radius);
    background: transparent;
    color: var(--fd-text);
    cursor: pointer;
}
.fd-tool:hover { background: #eaeff6; }
.fd-tool.is-active,
.fd-tool[aria-pressed="true"] { background: var(--fd-brand); color: #fff; }
.fd-tool::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--fd-navy-900);
    color: #fff;
    font: 500 12px var(--fd-font);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s;
}
.fd-tool:hover::after,
.fd-tool:focus-visible::after { opacity: 1; }
.fd-tool-sep { height: 1px; margin: 3px 6px; background: var(--fd-border); }

/* ── Contextual panel ────────────────────────────────────────────────────── */
.fd-panel {
    position: fixed;
    top: calc(var(--fd-nav-h) + 8px);
    left: 68px;
    width: 340px;
    max-height: calc(100dvh - var(--fd-nav-h) - 20px);
    z-index: 1195;
    display: flex;
    flex-direction: column;
    background: var(--fd-panel);
    color: var(--fd-text);
    border: 1px solid var(--fd-border);
    border-radius: 12px;
    box-shadow: var(--fd-shadow);
    font: 13px/1.4 var(--fd-font);
}
.fd-panel-grab { display: none; }
.fd-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 6px 6px 16px;
    border-bottom: 1px solid var(--fd-border);
}
.fd-panel-head h2 {
    margin: 0;
    font: 700 12px var(--fd-font);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--fd-navy-800);
}
.fd-panel-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 14px 14px;
}

.fd-sec {
    margin: 14px 0 4px;
    font: 700 11px var(--fd-font);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--fd-text-2);
}
.fd-sec:first-child { margin-top: 2px; }
.fd-muted { color: var(--fd-text-2); font-size: 12px; }
.fd-note { margin: 10px 0 0; font-size: 11px; color: var(--fd-text-2); }
.fd-empty { margin: 14px 0; text-align: center; color: var(--fd-text-2); }

/* Fields and buttons */
.fd-field {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    margin: 0 0 6px;
    padding: 0 10px;
    background: var(--fd-bg);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
    color: var(--fd-text-2);
}
.fd-field:focus-within { border-color: var(--fd-active); box-shadow: 0 0 0 2px rgba(59, 130, 246, .2); }
.fd-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--fd-text);
    font: 14px var(--fd-font);
}
.fd-field-grow { flex: 1; min-width: 0; margin: 0; }
.fd-searchrow { display: flex; align-items: center; gap: 6px; }

.fd-btn {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
    background: #fff;
    color: var(--fd-text);
    font: 600 12px var(--fd-font);
    cursor: pointer;
}
.fd-btn:hover { background: #eaeff6; }
.fd-btn-primary { background: var(--fd-brand); border-color: var(--fd-brand); color: #fff; }
.fd-btn-primary:hover { background: var(--fd-brand-dark); }
.fd-btn-danger { background: var(--fd-danger); border-color: var(--fd-danger); color: #fff; }
.fd-btn-danger:hover { background: #b92d3b; }
.fd-btn-sm { height: 28px; padding: 0 10px; font-size: 11px; }
.fd-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.fd-actions form { margin: 0; }
.fd-linkbtn {
    display: block;
    margin-top: 12px;
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--fd-brand);
    font: 600 12px var(--fd-font);
    text-align: left;
    text-decoration: underline;
    cursor: pointer;
}

/* Toggle rows */
.fd-list { display: flex; flex-direction: column; }
.fd-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 36px;
    padding: 5px 2px;
    border-bottom: 1px solid #edf1f6;
    cursor: pointer;
}
.fd-row:last-child { border-bottom: 0; }
.fd-row:hover { background: var(--fd-bg); }
.fd-row-text { display: flex; flex-direction: column; min-width: 0; }
.fd-row-title { font-weight: 600; color: var(--fd-text); }
.fd-row-note { font-size: 11px; color: var(--fd-text-2); }
.fd-row-child { padding-left: 18px; }
.fd-row-child .fd-row-title { font-weight: 500; font-size: 12px; }
.fd-check { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--fd-brand); cursor: pointer; }

/* Base maps: two-column selectable tiles (radio stays in the DOM for keyboard / screen readers) */
#fd-basemaps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
#fd-basemaps .fd-row {
    position: relative;
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
}
#fd-basemaps .fd-row:last-child { border-bottom: 1px solid var(--fd-border); }
#fd-basemaps .fd-check { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
#fd-basemaps .fd-row:has(.fd-check:checked) { border-color: var(--fd-brand); background: #eaf0fd; box-shadow: inset 0 0 0 1px var(--fd-brand); }
#fd-basemaps .fd-row:has(.fd-check:checked) .fd-row-title { color: var(--fd-brand); }
#fd-basemaps .fd-row:has(.fd-check:focus-visible) { outline: 2px solid var(--fd-active); outline-offset: 1px; }
#fd-basemaps .fd-row-title { font-size: 12px; }
.fd-group-head { margin: 12px 0 2px; font: 700 10px var(--fd-font); letter-spacing: .08em; text-transform: uppercase; color: var(--fd-text-2); }

.fd-slider { margin-top: 12px; padding: 10px 12px; background: var(--fd-bg); border-radius: var(--fd-radius); }
.fd-slider label { display: flex; justify-content: space-between; font-weight: 600; }
.fd-slider input { width: 100%; margin-top: 6px; accent-color: var(--fd-brand); }

/* Categories */
.fd-bar { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 4px; }
.fd-bar-actions { display: inline-flex; gap: 4px; }
.fd-cat-row {
    display: grid;
    grid-template-columns: 1fr auto 42px;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 6px 2px;
    border: 0;
    border-bottom: 1px solid #edf1f6;
    background: none;
    color: var(--fd-text);
    font: 600 13px var(--fd-font);
    text-align: left;
    cursor: pointer;
}
.fd-cat-row:hover { background: var(--fd-bg); }
.fd-cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-cat-count { color: var(--fd-text-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.fd-cat-state {
    justify-self: end;
    min-width: 38px;
    padding: 2px 0;
    border-radius: 999px;
    background: #e3e9f1;
    color: var(--fd-text-2);
    font: 700 10px var(--fd-font);
    letter-spacing: .05em;
    text-align: center;
}
.fd-cat-row[aria-checked="true"] .fd-cat-state { background: var(--fd-brand); color: #fff; }

/* Sub-panels, inline inputs and chips (aerodrome filters, NOTAM station, coordination grid) */
.fd-subpanel { margin-top: 6px; }
.fd-chiplabel { margin: 8px 0 4px; font-size: 11px; font-weight: 600; color: var(--fd-text-2); }
.fd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fd-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--fd-border);
    border-radius: 999px;
    background: #fff;
    color: var(--fd-text);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}
.fd-chip:has(input:checked) { border-color: var(--fd-brand); background: #eaf0fd; color: var(--fd-brand); }
.fd-chip input { margin: 0; accent-color: var(--fd-brand); }
.fd-inline { display: flex; gap: 6px; }
.fd-input {
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
    background: var(--fd-bg);
    color: var(--fd-text);
    font: 13px var(--fd-font);
}
.fd-inline .fd-input { flex: 1; }
.fd-input:focus { outline: 0; border-color: var(--fd-active); box-shadow: 0 0 0 2px rgba(59, 130, 246, .2); }
.fd-input-sm { width: 76px; text-align: center; }
.fd-fields { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.fd-fieldrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; font-weight: 500; }
.fd-slider-flat { margin-top: 0; }
.fd-warn { padding: 6px 10px; border: 1px solid rgba(245, 158, 11, .45); border-radius: var(--fd-radius); background: rgba(245, 158, 11, .12); color: #92580a; }
.fd-results-box { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--fd-border); border-radius: var(--fd-radius); background: var(--fd-bg); font-size: 12px; max-height: 200px; overflow-y: auto; }
.fd-note a { color: var(--fd-brand); font-weight: 600; }

/* Links list */
.fd-links { margin: 0; padding: 0; list-style: none; }
.fd-links a {
    display: block;
    padding: 9px 2px;
    border-bottom: 1px solid #edf1f6;
    color: var(--fd-text);
    font-weight: 500;
    text-decoration: none;
}
.fd-links a:hover { background: var(--fd-bg); color: var(--fd-brand); }

/* Search */
.fd-formats {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--fd-bg);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
    font-size: 12px;
}
.fd-formats ul { margin: 6px 0 0; padding-left: 16px; }
.fd-formats code { padding: 1px 4px; border: 1px solid var(--fd-border); border-radius: 4px; background: #fff; font-size: 11px; }
.fd-result {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 8px 2px;
    border: 0;
    border-bottom: 1px solid #edf1f6;
    background: none;
    color: var(--fd-text);
    font: 600 13px var(--fd-font);
    text-align: left;
    cursor: pointer;
}
.fd-result:hover { background: var(--fd-bg); }
.fd-result small { color: var(--fd-text-2); font-weight: 500; font-size: 11px; }

/* ── Presentation (fullscreen) mode ──────────────────────────────────────── */
.fd-exit {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1200;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 999px;
    background: rgba(11, 31, 56, .82);
    color: #fff;
    font: 600 12px var(--fd-font);
    cursor: pointer;
}
.fd-exit .fd-ic { width: 16px; height: 16px; }
html.fd.fd-present .fd-exit { display: inline-flex; }
html.fd.fd-present .fd-nav,
html.fd.fd-present .fd-bottomnav,
html.fd.fd-present .fd-panel,
html.fd.fd-present .fd-toolbar { display: none !important; }
html.fd.fd-present #map { top: 0; bottom: 0; }
html.fd.fd-present .leaflet-top.leaflet-left { left: 0; }
html.fd.fd-present .leaflet-top.leaflet-right { top: 52px; }
html.fd.fd-present #toast-container { top: 56px !important; }
html.fd.fd-present .cookie-settings-btn { display: none !important; }

/* ── Touch devices ───────────────────────────────────────────────────────── */
@media (pointer: coarse) {
    .fd-tool { width: 44px; height: 44px; }
    .fd-tool::after { display: none; }
    .fd-row, .fd-cat-row { min-height: 46px; }
    .fd-check { width: 22px; height: 22px; }
    .fd-links a { padding: 12px 2px; }
    .fd-btn { height: 40px; }
    .fd-btn-sm { height: 32px; }
}

/* ── iPad / small laptops ────────────────────────────────────────────────── */
@media (max-width: 1023.98px) {
    .fd-brand-text { display: none; }
    .fd-tab { padding: 0 11px; }
    .fd-panel { width: 360px; }
}

/* ── iPhone: compact header, bottom navigation, bottom-sheet panels ──────── */
@media (max-width: 767.98px) {
    :root { --fd-nav-h: 48px; }

    .fd-brand-text { display: inline; font-size: 16px; }
    .fd-tabs { display: none; }
    .fd-bottomnav { display: flex; }
    .fd-nav { padding-left: 12px; }

    html.fd #map { bottom: calc(var(--fd-bn-h) + var(--fd-safe-b)); }
    html.fd.fd-present #map { bottom: 0; }

    .fd-toolbar {
        max-height: calc(100dvh - var(--fd-nav-h) - var(--fd-bn-h) - var(--fd-safe-b) - 20px);
        overflow-y: auto;
    }

    .fd-panel {
        inset: auto 0 calc(var(--fd-bn-h) + var(--fd-safe-b)) 0;
        width: auto;
        max-height: 62dvh;
        border-radius: 16px 16px 0 0;
        border-bottom: 0;
    }
    .fd-panel-grab {
        display: block;
        width: 36px;
        height: 4px;
        margin: 8px auto 0;
        border-radius: 2px;
        background: var(--fd-border);
    }
    .fd-panel-head { padding-top: 2px; }
    .fd-field input { font-size: 16px; }

    html.fd .helitool-utc-bar { bottom: calc(var(--fd-bn-h) + var(--fd-safe-b) + 8px); }
    html.fd #altitude_chart_bar { bottom: calc(var(--fd-bn-h) + var(--fd-safe-b) + 8px) !important; }
    html.fd .cookie-settings-btn { bottom: calc(var(--fd-bn-h) + var(--fd-safe-b) + 36px) !important; }
}

/* ── Terrain overlays (static/js/terrain-layers.js) ──────────────────────── */
.fd-hillshade { mix-blend-mode: multiply; }
#fd-elev-legend {
    position: fixed;
    right: 10px;
    bottom: 62px;
    z-index: 800;
    width: 250px;
    padding: 8px 10px 9px;
    background: rgba(255, 255, 255, .95);
    border: 1px solid var(--fd-border);
    border-radius: 10px;
    box-shadow: var(--fd-shadow);
    color: var(--fd-text);
    font: 11px/1.3 var(--fd-font);
    pointer-events: none;
}
#fd-elev-legend[hidden] { display: none; }
#fd-elev-legend .fd-elev-title { margin-bottom: 5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--fd-text-2); }
#fd-elev-legend .fd-elev-bar { height: 10px; border-radius: 3px; border: 1px solid rgba(11, 31, 56, .25); }
#fd-elev-legend .fd-elev-ticks { position: relative; height: 14px; margin-top: 2px; font-variant-numeric: tabular-nums; color: var(--fd-text-2); }
#fd-elev-legend .fd-elev-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
#fd-elev-legend .fd-elev-ticks span.fd-elev-end { transform: translateX(-100%); }
#fd-elev-legend .fd-elev-readout { margin-top: 4px; padding-top: 5px; border-top: 1px solid var(--fd-border); font-size: 13px; font-weight: 700; color: var(--fd-navy-800); }
html.fd.fd-present #fd-elev-legend { bottom: 16px; }
@media (max-width: 767.98px) {
    #fd-elev-legend { bottom: calc(var(--fd-bn-h) + var(--fd-safe-b) + 40px); width: 220px; }
}
