/* Interactive flight map widget */
.flightmap {
    --fm-ink: #222;
    --fm-muted: #666;
    --fm-panel: rgba(255, 255, 255, 0.94);
    --fm-border: rgba(0, 0, 0, 0.15);
    position: relative;
    height: min(72vh, 680px);
    min-height: 380px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    font-family: "Source Sans Pro", Helvetica, sans-serif;
    background: #cfe3ef;
}
.flightmap .leaflet-container { font: inherit; }

/* Route lines */
.flightmap .fm-leg { transition: opacity 150ms, stroke-width 150ms; }
.flightmap .fm-hit { cursor: pointer; }

/* Airport dots, like the waypoint dots on SkyVector */
.flightmap .fm-airport { cursor: pointer; }

/* Photo pins: small camera dots (single photos and groups alike). The photo itself is in the popup. */
.flightmap .fm-poi-icon { background: none; border: 0; }
.flightmap .fm-poi {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    box-sizing: border-box; border-radius: 50%;
    background: #2b2f36; color: #fff; border: 1.5px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    transition: transform 120ms, background 120ms;
}
.flightmap .fm-poi:hover { transform: scale(1.2); background: #000; }
.flightmap .fm-poi svg { display: block; }

/* Zoomed in: rounded photo thumbnails; groups look like a small stack with a count */
.flightmap .fm-thumb { position: relative; display: block; width: 100%; height: 100%; }
.flightmap .fm-thumb img {
    width: 100%; height: 100%; object-fit: cover; display: block; box-sizing: border-box;
    border: 2px solid #fff; border-radius: 8px; background: #ccc;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    transition: transform 120ms;
}
.flightmap .fm-thumb:hover img { transform: scale(1.12); }
.flightmap .fm-thumb-stack img { box-shadow: 3px 3px 0 -1px #fff, 3px 3px 0 0 rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.45); }
.flightmap .fm-thumb-stack b {
    position: absolute; top: -7px; right: -9px; min-width: 20px; height: 20px; padding: 0 5px;
    box-sizing: border-box; border-radius: 10px; background: #2b2f36; color: #fff; border: 1.5px solid #fff;
    font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.flightmap .fm-photo-popup .leaflet-popup-content { width: 300px !important; }
.fm-pop-photo { aspect-ratio: auto; max-height: 240px; }
.fm-pop-leg { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--fm-border); }
.fm-pop-leg .fm-pop-link { margin-top: 2px; }

/* Trip list panel */
.fm-panel {
    background: var(--fm-panel);
    border: 1px solid var(--fm-border);
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    color: var(--fm-ink);
    font-size: 14px;
    line-height: 1.3;
    width: 240px;
    max-height: calc(100% - 20px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.fm-panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 10px; border-bottom: 1px solid var(--fm-border);
}
.fm-panel-head strong { font-size: 15px; }
.fm-totals { font-size: 12px; color: var(--fm-muted); }
.fm-toggle {
    border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px;
    color: var(--fm-muted); padding: 2px 4px;
}
.fm-trips { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; }
.fm-panel.collapsed .fm-trips, .fm-panel.collapsed .fm-showall { display: none; }
.fm-trips li {
    display: flex; gap: 8px; align-items: flex-start;
    padding: 5px 10px; cursor: pointer;
}
.fm-trips li:hover { background: rgba(0, 0, 0, 0.05); }
.fm-trips li.active { background: rgba(0, 0, 0, 0.09); }
.fm-swatch { flex: none; width: 14px; height: 4px; border-radius: 2px; margin-top: 7px; }
.fm-trip-title { font-weight: 600; }
.fm-trip-meta { font-size: 12px; color: var(--fm-muted); }
.fm-showall {
    margin: 4px 10px 8px; padding: 4px 8px; font: inherit; font-size: 13px; cursor: pointer;
    border: 1px solid var(--fm-border); border-radius: 4px; background: #fff;
}
.fm-showall[hidden] { display: none; }

/* Popups */
.flightmap .leaflet-popup-content-wrapper { border-radius: 6px; }
.flightmap .leaflet-popup-content { margin: 0; width: 260px !important; font-size: 14px; line-height: 1.35; }
.fm-pop-img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px 6px 0 0; background: #ddd; }
.fm-pop-body { padding: 8px 12px 10px; }
.fm-pop-trip { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.fm-pop-title { font-weight: 700; font-size: 15px; margin: 2px 0; }
.fm-pop-date { color: var(--fm-muted); font-size: 13px; }
.fm-pop-stats { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 6px 0 0; font-size: 13px; color: var(--fm-muted); }
.fm-pop-link { display: inline-block; margin-top: 8px; font-weight: 600; }
.fm-pager {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 8px; border-top: 1px solid var(--fm-border);
    font-size: 12px; color: var(--fm-muted);
}
.fm-pager button {
    width: 28px; height: 28px; border: 1px solid var(--fm-border); border-radius: 4px;
    background: #fff; font-size: 18px; line-height: 1; cursor: pointer; color: var(--fm-ink);
}
.fm-pager button:hover { background: #f1f1f1; }
.fm-pop-list { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; max-height: 180px; overflow-y: auto; }
.fm-pop-list li { padding: 2px 0; }
.fm-pop-list .fm-swatch { display: inline-block; vertical-align: middle; margin: 0 6px 0 0; }

@media (max-width: 600px) {
    .flightmap { height: 75vh; }
    .fm-panel { width: 200px; }
    .flightmap .leaflet-control-scale { display: none; }
}

/* Canadian airports at close zoom: sectional-style symbol with a chart-style label beneath */
.fm-apt { background: none; border: 0; }
.fm-apt-sym svg { display: block; filter: drop-shadow(0 0 1px #fff); }
.fm-apt-label {
    position: absolute; top: 25px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center;
    white-space: nowrap; pointer-events: none;
    font: 600 12.5px/1.15 "Source Sans Pro", Helvetica, sans-serif; color: #9c2a73;
    text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
}
.fm-apt-label span + span { font-weight: 400; }

/* Safari: route and airspace lines (SVG) and photo markers each get 3D transforms, and Safari can
   stack those above layers with a higher z-index (routes drawn over thumbnails). Giving every map
   layer its own compositing layer makes Safari follow the z-index order. */
.flightmap .leaflet-map-pane > .leaflet-pane { transform: translateZ(0); }
/* ...and the photo markers too: otherwise Safari paints them into a shared layer that can end up
   below the routes, and their hover zoom (which briefly gives them a layer of their own) flips the
   order back and forth. With a permanent layer each, the order holds. */
.flightmap .fm-poi-icon, .flightmap .fm-thumb, .flightmap .fm-thumb img, .flightmap .fm-poi { will-change: transform; }

/* Narrow screens (phones): the credits line would wrap over a fifth of the map, so show one line
   and the rest on tap/hover */
@media (max-width: 600px) {
    .flightmap .leaflet-control-attribution {
        max-width: calc(100vw - 80px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        font-size: 10px; cursor: pointer;
    }
    .flightmap .leaflet-control-attribution:hover,
    .flightmap .leaflet-control-attribution:focus-within { white-space: normal; }
}

/* With the trip list collapsed, the chosen trip is named in its header */
.fm-current { display: none; align-items: center; gap: 6px; margin-top: 3px; font-size: 13px; font-weight: 600; }
.fm-current .fm-swatch { margin-top: 0; }
.fm-panel.collapsed .fm-current:not([hidden]) { display: flex; }

/* Phones: until the map is tapped, one-finger drags scroll the page; this says so */
.flightmap .fm-hint {
    margin-bottom: 26px !important; padding: 4px 9px; border-radius: 12px;
    background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 12px; pointer-events: none;
}
