/* ==========================================================================
   FLIGHT MAP (template-parts/modules/flight-map.php + js/flight-map.js)
   Light map on the page canvas, gold states, beacons, one flight route with a
   drone. Phones: mini map that flies to each state + swipeable tour cards.
   ========================================================================== */

.fm-section {
    background: transparent;
}
.fm {
    margin-top: 28px;
}
/* Jeremy 10/6: less space above and below the map. The map itself always stays full size. */
@media (min-width: 768px) {
    .fm-section {
        padding-top: 56px !important;
        padding-bottom: 56px !important;
    }
    .fm {
        margin-top: 52px;
    }
}
/* The paragraph + button sit level with the top of the heading's letters (the heading's line box starts ~12px above them) */
@media (min-width: 1024px) {
    #map-locations.fm-section .container > div:first-child > div:last-child {
        padding-top: 12px;
    }
}
/* Desktop layout B (Deann 10/14): everything but the map sits in one column on the left (heading, intro, button,
   legend, counter, hint), so the heading and the full-size map, Alaska/Hawaii included, show together on a
   laptop screen. Stacked below 1024px. */
@media (min-width: 1024px) {
    #map-locations.fm-section {
        padding-top: 28px !important;
        padding-bottom: 20px !important;
    }
    #map-locations.fm-section > .container {
        display: grid;
        grid-template-columns: 330px minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        column-gap: 24px;
        align-items: start;
    }
    /* .fm drops out of the layout so its children join the grid */
    #map-locations.fm-section .fm {
        display: contents;
    }
    #map-locations.fm-section > .container > div:first-child {
        grid-column: 1;
        grid-row: 1;
        align-self: end;
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }
    #map-locations.fm-section > .container > div:first-child h2 {
        font-size: 44px;
        line-height: 1.08;
    }
    #map-locations.fm-section > .container > div:first-child > div:last-child {
        padding-top: 0;
        gap: 20px;
        max-width: none;
        width: 100%;
    }
    #map-locations.fm-section > .container > div:first-child > div:last-child > div {
        font-size: 17px;
    }
    #map-locations.fm-section > .container > div:first-child > div:last-child a {
        width: 100%;
        max-width: none;
        height: 48px;
    }
    #map-locations.fm-section .fm-stage {
        grid-column: 2;
        grid-row: 1 / span 3;
        align-self: center;
        margin: 0;
    }
    #map-locations.fm-section .fm-top {
        grid-column: 1;
        grid-row: 2;
        align-self: start;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 14px;
        margin-top: 26px;
    }
    #map-locations.fm-section .fm-legend {
        flex-wrap: nowrap;
        gap: 18px;
        font-size: 15px;
    }
    #map-locations.fm-section .fm-legend li {
        gap: 8px;
        white-space: nowrap;
    }
    #map-locations.fm-section .fm-hint {
        grid-column: 1;
        grid-row: 3;
        align-self: start;
        margin: 14px 0 0;
        text-align: left;
    }
}
/* 1024-1199px: a slimmer left column so the map keeps as much width as it can */
@media (min-width: 1024px) and (max-width: 1199px) {
    #map-locations.fm-section > .container {
        grid-template-columns: 290px minmax(0, 1fr);
        column-gap: 20px;
    }
    #map-locations.fm-section > .container > div:first-child h2 {
        font-size: 38px;
    }
    #map-locations.fm-section > .container > div:first-child > div:last-child > div {
        font-size: 16px;
    }
    #map-locations.fm-section .fm-legend {
        font-size: 14px;
        gap: 14px;
    }
    #map-locations.fm-section .fm-count {
        font-size: 15px;
    }
    #map-locations.fm-section .fm-count [data-count] {
        font-size: 26px;
    }
}
.fm-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
}
.fm-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    min-height: 18px;
    gap: 10px 28px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 16px;
    line-height: 1;
    color: #4b5563;
}
.fm-legend li {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.fm-swatch {
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 5px;
}
.fm-swatch--done { background: linear-gradient(135deg, #e2c36d, #be9141); }
.fm-swatch--next { background: #e4e9f2; border: 1px solid #d5dce8; }
.fm-count {
    margin: 0;
    white-space: nowrap;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    color: #02225a;
    font-size: 17px;
    font-weight: 500;
}
.fm-count [data-count] {
    color: #a67c1e;
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
}

/* ---- Map ---- */
.fm-stage {
    position: relative;
    margin-top: 18px;
}
.fm-map {
    display: block;
    width: 100%;
    max-width: 960px;
    height: auto;
    margin: 0 auto;
    overflow: visible;
    filter: drop-shadow(0 22px 28px rgba(2, 34, 90, 0.09));
}
/* Alaska + Hawaii sit outside the frame in this SVG: hidden until js/flight-map.js moves them
   into insets (bottom left) and shows them */
.fm-map #US-AK,
.fm-map #US-HI {
    display: none;
}
.fm-map .state.is-inset {
    vector-effect: non-scaling-stroke;
}
.fm-inset-frame {
    fill: none;
    stroke: #d5dce8;
    stroke-width: 1;
    stroke-dasharray: 3 3;
    vector-effect: non-scaling-stroke;
}
.fm-map .state {
    fill: #e4e9f2;
    stroke: #ffffff;
    stroke-width: 0.9;
    transition: fill 0.3s ease, filter 0.3s ease;
}
.fm-map .state.is-done {
    fill: #d4b25a; /* the script sets the gradient inline */
    cursor: pointer;
    outline: none;
}
.fm-map .state.is-done:hover,
.fm-map .state.is-done:focus-visible,
.fm-map .state.is-selected {
    fill: #c9963b !important;
    filter: drop-shadow(0 2px 6px rgba(190, 145, 65, 0.55));
}

/* Beacons */
.fm-beacon {
    cursor: pointer;
}
.fm-beacon__hit {
    fill: transparent;
}
.fm-beacon__ring {
    fill: none;
    stroke: #d4af37;
    stroke-width: 2;
    transform-box: fill-box;
    transform-origin: center;
    opacity: 0;
}
.fm-beacon__core {
    fill: #ffffff;
    stroke: #be9141;
    stroke-width: 2.4;
}
.fm-beacon.is-selected .fm-beacon__core {
    fill: #02225a;
    stroke: #ffffff;
}
.fm-beacon__badge circle {
    fill: #02225a;
    stroke: #ffffff;
    stroke-width: 1.5;
}
.fm-beacon__badge text {
    fill: #ffffff;
    font: 700 9.5px/1 "Work Sans", ui-sans-serif, system-ui, sans-serif;
    text-anchor: middle;
}
@media (prefers-reduced-motion: no-preference) {
    .fm.is-visible .fm-beacon__ring {
        animation: fm-ping 2.6s ease-out var(--fm-d, 0s) infinite;
    }
}
@keyframes fm-ping {
    0% { opacity: 0.9; scale: 1; }
    100% { opacity: 0; scale: 2.6; }
}

/* Flight route draws in, then the drone flies it */
.fm-route__line {
    fill: none;
    stroke: #be9141;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-dasharray: 1 6;
    vector-effect: non-scaling-stroke;
    opacity: 0;
    transition: opacity 1.2s ease 0.3s;
}
.fm.is-drawn .fm-route__line {
    opacity: 0.85;
}
.fm-drone {
    pointer-events: none;
    filter: drop-shadow(0 2px 2px rgba(2, 34, 90, 0.3));
}
.fm-rotor {
    transform-box: fill-box;
    transform-origin: center;
}
@media (prefers-reduced-motion: no-preference) {
    .fm.is-visible .fm-rotor {
        animation: mx-rotor 0.16s linear infinite;
    }
}

/* Desktop hover card */
.fm-card {
    position: absolute;
    z-index: 5;
    width: 264px;
    overflow: hidden;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 18px 44px rgba(2, 34, 90, 0.2);
    opacity: 0;
    translate: 0 8px;
    transition: opacity 0.2s ease, translate 0.25s ease;
}
.fm-card.is-on {
    opacity: 1;
    translate: 0 0;
}
.fm-card__media {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #0f172a;
    cursor: pointer;
}
.fm-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.fm-card__play,
.fm-tile__play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='16' viewBox='0 0 16 18'%3E%3Cpath d='M1 1.7v14.6a1 1 0 001.5.87l12.5-7.3a1 1 0 000-1.74L2.5.83A1 1 0 001 1.7z' fill='%23012159'/%3E%3C/svg%3E") 56% 50% no-repeat;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.fm-card__body {
    padding: 14px 16px 16px;
}
.fm-card__logo {
    display: block;
    max-width: 120px;
    max-height: 34px;
    margin-bottom: 8px;
    object-fit: contain;
}
.fm-card__logo[hidden] {
    display: none;
}
.fm-card__state,
.fm-tile__state,
.fm-player__state {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8c6a21;
}
.fm-card__name {
    margin: 3px 0 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.25;
    color: #02225a;
}
.fm-card__city {
    margin: 2px 0 0;
    font-size: 14px;
    color: #4b5563;
}
.fm-card__more {
    margin: 6px 0 0;
    font-size: 13px;
    color: #8c6a21;
}
.fm-card__more:empty {
    display: none;
}
.fm-card__watch,
.fm-tile__watch {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    background: #02225a;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s ease;
}
.fm-card__watch:hover,
.fm-tile__watch:hover {
    background: #be9141;
}
.fm-card__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 14px;
    margin-top: 12px;
}
.fm-card__actions .fm-card__watch {
    margin-top: 0;
}
.fm-card__case {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 14px;
    font-weight: 600;
    color: #8c6a21;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}
.fm-card__case:hover {
    color: #02225a;
}
.fm-card__case[hidden] {
    display: none;
}
.fm-hint {
    margin: 14px 0 0;
    text-align: center;
    font-size: 15px;
    color: #555555;
}

/* Phone-only parts are hidden on bigger screens */
.fm-tap,
.fm-rail,
.fm-dots,
.fm-swipe,
.fm-player__grab {
    display: none;
}

/* ==========================================================================
   Phones
   ========================================================================== */
@media (max-width: 767px) {
    .fm {
        margin-top: 28px;
    }
    .fm-top {
        gap: 10px;
    }
    .fm-legend {
        font-size: 15px;
        gap: 8px 18px;
    }
    .fm-count {
        font-size: 15px;
    }
    .fm-count [data-count] {
        font-size: 24px;
    }
    .fm-stage {
        margin: 14px -4px 0;
        border-radius: 22px;
        background: linear-gradient(180deg, #f6f8fc, #ffffff);
        overflow: hidden;
        box-shadow: inset 0 0 0 1px #e8edf5;
    }
    .fm-map {
        overflow: hidden;
        filter: none;
        aspect-ratio: 593.38 / 318.29;
    }
    .fm-card,
    .fm-hint {
        display: none !important;
    }
    .fm-tap {
        display: block;
        margin: 14px 0 0;
        text-align: center;
        font-size: 15px;
        font-weight: 600;
        color: #02225a;
    }
    .fm-swipe {
        display: block;
        margin: 6px 0 0;
        text-align: center;
        font-size: 13px;
        color: #6b7280;
    }
    .fm-rail {
        display: flex;
        gap: 14px;
        margin: 12px -16px 0;
        padding: 6px 16px 14px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 16px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .fm-rail::-webkit-scrollbar {
        display: none;
    }
    .fm-tile {
        flex: 0 0 82%;
        scroll-snap-align: center;
        overflow: hidden;
        border-radius: 20px;
        background: #ffffff;
        box-shadow: 0 10px 26px rgba(2, 34, 90, 0.12), 0 0 0 1px #edf1f7;
        transition: transform 0.35s ease;
    }
    .fm-tile__media {
        position: relative;
        display: block;
        width: 100%;
        aspect-ratio: 16 / 9;
        padding: 0;
        border: 0;
        background: #0f172a;
    }
    .fm-tile__media img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    .fm-tile__body {
        padding: 14px 16px 16px;
    }
    .fm-tile__name {
        margin: 3px 0 0;
        font-size: 18px;
        font-weight: 600;
        line-height: 1.25;
        color: #02225a;
    }
    .fm-tile__city {
        margin: 3px 0 0;
        font-size: 14px;
        color: #4b5563;
    }
    .fm-tile__more {
        display: inline-block;
        margin-left: 6px;
        padding: 2px 8px;
        border-radius: 999px;
        background: #f6efdc;
        color: #8c6a21;
        font-size: 12px;
        font-weight: 600;
    }
    .fm-tile__actions {
        display: flex;
        align-items: center;
        gap: 14px;
        margin-top: 4px;
    }
    .fm-tile__link {
        margin-top: 12px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        font-size: 14px;
        font-weight: 600;
        color: #8c6a21;
        text-decoration: underline;
        text-underline-offset: 3px;
    }
    .fm-tile--all {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 8px;
        padding: 24px;
        background: #02225a;
        color: #ffffff;
        text-decoration: none;
    }
    .fm-tile__all-num {
        font-size: 44px;
        font-weight: 700;
        line-height: 1;
        color: #e2c36d;
    }
    .fm-tile__all-text {
        font-size: 18px;
        font-weight: 600;
        line-height: 1.3;
    }
    .fm-tile__all-arrow {
        font-size: 24px;
        color: #e2c36d;
    }
    .fm-dots {
        display: flex;
        justify-content: center;
        gap: 6px;
        margin-top: 4px;
    }
    .fm-dots span {
        width: 6px;
        height: 6px;
        border-radius: 999px;
        background: #d5dce8;
        transition: width 0.3s ease, background 0.3s ease;
    }
    .fm-dots span.is-on {
        width: 20px;
        background: #be9141;
    }
}

/* ==========================================================================
   Tour player: centered dialog on desktop, full-screen sheet on phones
   ========================================================================== */
body.fm-lock {
    overflow: hidden;
}
.fm-player {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 18, 39, 0.72);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.fm-player[hidden] {
    display: none;
}
.fm-player.is-open {
    opacity: 1;
}
.fm-player__sheet {
    position: relative;
    width: 100%;
    max-width: 880px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 26px 26px 22px;
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s ease;
}
.fm-player__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #02225a;
    font-size: 26px;
    line-height: 1;
}
.fm-player__close:hover {
    background: #be9141;
    color: #ffffff;
}
.fm-player__name {
    margin: 4px 52px 0 0;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
    color: #02225a;
}
.fm-player__city {
    margin: 2px 0 0;
    color: #4b5563;
}
.fm-player__video {
    position: relative;
    margin-top: 16px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 16px;
    background: #0f172a;
}
.fm-player__video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.fm-player__more[hidden] {
    display: none;
}
.fm-player__more-title {
    margin: 18px 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: #02225a;
}
.fm-player__chips {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
}
.fm-player__chip {
    flex: 0 0 168px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: #333333;
    cursor: pointer;
}
.fm-player__chip img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 10px;
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition: outline-color 0.2s ease;
}
.fm-player__chip.is-on img,
.fm-player__chip:hover img {
    outline-color: #be9141;
}
.fm-player__case {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 10px;
    font-weight: 600;
    color: #8c6a21;
}
.fm-player__case[hidden] {
    display: none;
}

@media (max-width: 767px) {
    .fm-player {
        align-items: flex-end;
        padding: 0;
    }
    .fm-player__sheet {
        max-width: none;
        max-height: 100%;
        height: 100%;
        padding: 18px 16px 28px;
        border-radius: 0;
        translate: 0 40px;
        transition: transform 0.25s ease, translate 0.3s ease;
    }
    .fm-player.is-open .fm-player__sheet {
        translate: 0 0;
    }
    .fm-player__grab {
        display: block;
        width: 44px;
        height: 5px;
        margin: 0 auto 14px;
        border-radius: 999px;
        background: #d5dce8;
    }
    .fm-player__close {
        top: 10px;
        right: 10px;
    }
    .fm-player__name {
        font-size: 21px;
    }
    .fm-player__video {
        margin-left: -16px;
        margin-right: -16px;
        border-radius: 0;
    }
    .fm-player__chip {
        flex-basis: 140px;
    }
}
