/**
 * Microtransit Zones map — [microtransit_map]
 *
 * Ported from the standalone 2026-microtransit-map/microtransit-zones.html.
 * Every rule is scoped under .nt-microtransit and every class carries the
 * nt-mt- prefix, so nothing leaks into the theme and Salient's content
 * styles can't reach in. The original page's global `*` reset and `body`
 * background were dropped outright (they belong to a standalone document,
 * not an embedded widget).
 *
 * The original sized the map with 100vh and pinned the side panel with
 * position:fixed. Here the root is the positioning context: the map takes
 * --nt-mt-height (set per-instance by the shortcode) and the panel, legend
 * and controls are absolute *within the widget*, so nothing overlays the
 * site header or footer.
 */

.nt-microtransit {
    --nt-mt-blue: #00677F;
    --nt-mt-teal: #0CAB9B;
    --nt-mt-rapids: #053747;
    --nt-mt-limestone: #D3D1CB;
    --nt-mt-yellow: #FFE2A1;
    --nt-mt-black: #000014;
    --nt-mt-height: clamp(480px, 70vh, 760px);
    --nt-mt-panel-w: 340px;

    position: relative;
    isolation: isolate;
    overflow: hidden;
    border-radius: 8px;
    background: #F0F0EE;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
}

/* Salient sets box-sizing globally, but don't rely on it. */
.nt-microtransit *,
.nt-microtransit *::before,
.nt-microtransit *::after {
    box-sizing: border-box;
}

/**
 * Every control in this widget is a real <button> — the panel's zone and
 * hub links included, because they move the map rather than navigate. The
 * theme styles bare `button` (background, border, padding, transform), so
 * neutralize it first; the rules further down restyle from a known floor.
 * Kept at single-class specificity so those later rules win on order.
 */
.nt-mt-reset,
.nt-mt-fs,
.nt-mt-panel-close,
.nt-mt-hub-link,
.nt-mt-zone-link,
.nt-mt-back {
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: 0;
    border-radius: 0;
    margin: 0;
    padding: 0;
    width: auto;
    min-width: 0;
    min-height: 0;
    color: inherit;
    font: inherit;
    line-height: inherit;
    letter-spacing: normal;
    text-transform: none;
    text-align: left;
    text-shadow: none;
    box-shadow: none;
    transform: none;
    cursor: pointer;
}

.nt-mt-map {
    width: 100%;
    height: var(--nt-mt-height);
    min-height: 360px;
    background: #F0F0EE;
}

/* Leaflet injects its own font-family; keep the widget consistent. */
.nt-microtransit .leaflet-container {
    font-family: inherit;
    background: #F0F0EE;
}

/* ---------------------------------------------------------------- controls */

/**
 * JS moves this block into Leaflet's top-left control stack, below the
 * zoom buttons, so Leaflet owns its placement — no absolute positioning
 * here. It sits left because the zone panel opens over the right-hand side
 * and would cover anything parked there.
 */
.nt-mt-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.nt-mt-reset {
    background: var(--nt-mt-blue);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.nt-mt-reset:hover {
    background: var(--nt-mt-rapids);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nt-mt-reset:focus-visible,
.nt-mt-fs:focus-visible {
    outline: 3px solid var(--nt-mt-teal);
    outline-offset: 2px;
}

/* Fullscreen is a labelled button matching the reset button beside it. */
.nt-mt-fs {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--nt-mt-blue);
    color: #fff;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.nt-mt-fs:hover {
    background: var(--nt-mt-rapids);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nt-mt-fs svg {
    display: block;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* Icon follows the button's state; label text is swapped by JS. */
.nt-mt-fs .nt-mt-fs-exit,
.nt-mt-fs[data-fs-state="on"] .nt-mt-fs-enter {
    display: none;
}

.nt-mt-fs[data-fs-state="on"] .nt-mt-fs-exit {
    display: block;
}

.nt-mt-hint {
    background: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    color: var(--nt-mt-black);
    max-width: 240px;
    line-height: 1.5;
    text-align: left;
}

.nt-mt-hint h4 {
    color: var(--nt-mt-blue);
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

/* ------------------------------------------------------------------ legend */

.nt-mt-legend {
    position: absolute;
    bottom: 30px;
    left: 10px;
    z-index: 1000;
    background: #fff;
    padding: 14px 18px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    max-width: 210px;
    transition: opacity 0.3s ease;
}

.nt-mt-legend h4 {
    color: var(--nt-mt-blue);
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.nt-mt-legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.nt-mt-legend-item:last-child {
    margin-bottom: 0;
}

.nt-mt-swatch {
    width: 20px;
    height: 14px;
    border-radius: 3px;
    margin-right: 8px;
    flex-shrink: 0;
}

.nt-mt-swatch.is-selected {
    background: var(--nt-mt-teal);
    border: 2px solid var(--nt-mt-teal);
}

.nt-mt-swatch.is-connected {
    background: rgba(0, 103, 127, 0.6);
    border: 2px solid var(--nt-mt-blue);
}

.nt-mt-swatch.is-unconnected {
    background: var(--nt-mt-limestone);
    border: 2px solid #999;
}

.nt-mt-swatch.is-inactive {
    background: #E5E5E5;
    border: 2px dashed #999;
}

.nt-mt-swatch.is-hub {
    background: var(--nt-mt-yellow);
    border: 2px solid #D4A84A;
    border-radius: 50%;
    width: 14px;
    height: 14px;
}

/* ------------------------------------------------------------- side panel */

.nt-mt-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--nt-mt-panel-w);
    max-width: 100%;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
}

.nt-mt-panel.is-open {
    transform: translateX(0);
}

.nt-mt-panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: background 0.2s ease;
}

.nt-mt-panel-close:hover {
    background: #fff;
}

.nt-mt-panel-close:focus-visible {
    outline: 3px solid var(--nt-mt-teal);
    outline-offset: 2px;
}

.nt-mt-panel-close svg {
    stroke: var(--nt-mt-rapids);
    display: block;
}

.nt-mt-panel-content {
    flex: 1;
}

.nt-mt-panel-content .nt-mt-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Drag handle — mobile bottom-sheet affordance only. */
.nt-mt-panel-handle {
    display: none;
}

/* Sticky footer holding the Book a Ride CTA. */
.nt-mt-panel-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 16px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

.nt-mt-book {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #0CAB9B 0%, #089485 100%);
    color: #fff;
    text-align: center;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(12, 171, 155, 0.3);
}

.nt-mt-book:hover,
.nt-mt-book:focus {
    background: linear-gradient(135deg, #089485 0%, #067a6d 100%);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(12, 171, 155, 0.4);
}

.nt-mt-book:focus-visible {
    outline: 3px solid var(--nt-mt-rapids);
    outline-offset: 2px;
}

.nt-mt-book:active {
    transform: translateY(0);
}

/* ------------------------------------------------------------- panel cards */

.nt-mt-card-head {
    background: var(--nt-mt-blue);
    color: #fff;
    padding: 24px;
    padding-right: 50px;
}

.nt-mt-card-head h3 {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 12px;
    color: #fff;
}

.nt-mt-card-head.is-hub {
    background: linear-gradient(135deg, #F5C842 0%, #E0AD20 100%);
    color: var(--nt-mt-black);
}

.nt-mt-card-head.is-hub h3 {
    color: var(--nt-mt-black);
    margin-bottom: 8px;
}

.nt-mt-hub-type {
    font-size: 16px;
    color: #3D2E00;
}

.nt-mt-card-head .nt-mt-hours {
    color: rgba(255, 255, 255, 0.9);
    margin: 8px 0 0;
    font-size: 18px;
}

.nt-mt-card-head .nt-mt-hours svg {
    stroke: rgba(255, 255, 255, 0.9);
}

.nt-mt-card-head .nt-mt-noservice {
    color: rgba(255, 255, 255, 0.9);
    margin: 8px 0 0;
    font-size: 16px;
    font-weight: 500;
}

.nt-mt-card-body {
    padding: 20px 24px;
    flex: 1;
    color: var(--nt-mt-black);
}

.nt-mt-hours {
    display: flex;
    align-items: flex-start;
    margin-bottom: 16px;
    font-size: 16px;
    color: var(--nt-mt-rapids);
}

.nt-mt-hours svg {
    margin-right: 8px;
    margin-top: 2px;
    flex-shrink: 0;
}

.nt-mt-noservice {
    color: #D32F2F;
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

.nt-mt-section {
    margin-bottom: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.nt-mt-section:first-child {
    border-top: none;
    padding-top: 0;
}

.nt-mt-section:last-child {
    margin-bottom: 0;
}

.nt-mt-section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.3;
    color: #4A4A4A;
    margin: 0 0 6px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.nt-mt-section-title:focus-visible {
    outline: 3px solid var(--nt-mt-teal);
    outline-offset: 2px;
}

.nt-mt-chevron svg {
    display: block;
}

.nt-mt-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/**
 * list-style must be killed on the `li`, not just the `ul`: Salient ships
 * `ul li { list-style: disc }` set directly on the item, and a direct rule
 * beats the value inherited from the list. Without this the theme's disc
 * renders alongside this widget's teal ::before dot — two bullets per row.
 */
.nt-mt-list li {
    list-style: none;
    font-size: 16px;
    /* The widget root sets 1.5 for body copy; single-line list rows read
       as double-spaced at that leading, so tighten them here. */
    line-height: 1.35;
    padding: 3px 0 3px 18px;
    position: relative;
    color: var(--nt-mt-black);
    margin: 0;
}

.nt-mt-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--nt-mt-teal);
    border-radius: 50%;
}

.nt-mt-list.is-hubs li::before {
    background: var(--nt-mt-yellow);
    border: 1px solid #D4A84A;
}

.nt-mt-hub-link,
.nt-mt-zone-link {
    color: var(--nt-mt-blue);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.nt-mt-hub-link:hover,
.nt-mt-zone-link:hover {
    color: var(--nt-mt-teal);
    text-decoration: underline;
}

.nt-mt-hub-link:focus-visible,
.nt-mt-zone-link:focus-visible,
.nt-mt-back:focus-visible {
    outline: 3px solid var(--nt-mt-teal);
    outline-offset: 2px;
}

.nt-mt-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--nt-mt-blue);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    transition: color 0.2s ease;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.nt-mt-back:hover {
    color: var(--nt-mt-teal);
}

.nt-mt-back svg {
    flex-shrink: 0;
}

.nt-mt-startdate {
    background: #E8F5E9;
    border: 1px solid #81C784;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 16px;
    font-weight: 600;
    color: #2E7D32;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nt-mt-startdate svg {
    flex-shrink: 0;
}

.nt-mt-notice {
    background: #FFF3CD;
    border: 1px solid var(--nt-mt-yellow);
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 16px;
    color: #5D4800;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.nt-mt-notice-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.nt-mt-notice-icon svg {
    display: block;
}

.nt-mt-routes-text {
    font-size: 18px;
    color: var(--nt-mt-black);
    line-height: 1.8;
    margin: 0;
}

/* -------------------------------------------------- map overlays & a11y */

.nt-mt-hub-label {
    background: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--nt-mt-rapids);
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.nt-mt-tooltip {
    background: var(--nt-mt-rapids);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nt-mt-tooltip::before {
    border-top-color: var(--nt-mt-rapids);
}

/* Zone colour transitions on the SVG paths Leaflet renders. */
.nt-microtransit .leaflet-interactive {
    transition: fill 0.3s ease, fill-opacity 0.3s ease, stroke 0.3s ease, stroke-width 0.2s ease;
}

.nt-microtransit .leaflet-interactive:focus {
    outline: 3px solid var(--nt-mt-teal);
    outline-offset: 2px;
}

.nt-microtransit .leaflet-interactive:focus:not(:focus-visible) {
    outline: none;
}

.nt-microtransit .leaflet-interactive:focus-visible {
    outline: 3px solid var(--nt-mt-teal);
    outline-offset: 2px;
}

.nt-mt-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Shown when data/microtransit-zones.json can't be loaded. */
.nt-mt-notice-block {
    padding: 24px;
    font-size: 16px;
    color: var(--nt-mt-rapids);
}

/* ------------------------------------------------------- scroll/zoom hint */

/**
 * Sits over the map and explains the gesture. pointer-events stays off in
 * every state so it can never intercept a click on a zone, and it renders
 * below the panel, controls and legend (z-index 1000+) so it dims the map
 * without dimming the controls.
 */
.nt-mt-scrollhint {
    position: absolute;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 20, 0.5);
    color: #fff;
    font-size: 19px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.nt-mt-scrollhint.is-visible {
    opacity: 1;
}

@media (max-width: 600px) {
    .nt-mt-scrollhint {
        font-size: 16px;
    }
}

/* ------------------------------------------------------------ fullscreen */

/**
 * One class covers both paths: the native Fullscreen API (where the root is
 * already the fullscreen element and these rules just make it fill the
 * space) and the iOS fallback, where Safari refuses requestFullscreen() on
 * anything but a <video> and the widget pins itself over the viewport
 * instead. JS adds .is-fullscreen in both cases.
 */
.nt-microtransit.is-fullscreen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    z-index: 100000;
    border-radius: 0;
    --nt-mt-height: 100%;
}

.nt-microtransit.is-fullscreen .nt-mt-map {
    height: 100%;
    min-height: 0;
}

/* Locks the page behind the iOS fallback so it can't scroll underneath. */
html.nt-mt-fs-lock,
html.nt-mt-fs-lock body {
    overflow: hidden;
}

/* Native fullscreen letterboxes with black by default. */
.nt-microtransit:fullscreen {
    background: #F0F0EE;
}

.nt-microtransit:-webkit-full-screen {
    background: #F0F0EE;
}

/* ------------------------------------------------------------- collapsing */

/* Sections collapse on small screens only; the chevron is the affordance. */
.nt-mt-chevron {
    display: none;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.nt-mt-section.is-collapsed .nt-mt-chevron {
    transform: rotate(-90deg);
}

/* ------------------------------------------------------------------ small */

@media (max-width: 600px) {
    .nt-microtransit {
        --nt-mt-height: clamp(420px, 65vh, 620px);
    }

    /* Leaflet positions the block now; only the buttons need shrinking. */
    .nt-mt-reset,
    .nt-mt-fs {
        padding: 8px 12px;
        font-size: 13px;
    }

    .nt-mt-hint {
        display: none;
    }

    .nt-mt-legend {
        bottom: 20px;
        left: 8px;
        padding: 10px 12px;
        max-width: 170px;
        font-size: 11px;
    }

    .nt-mt-legend h4 {
        font-size: 12px;
    }

    /* The bottom sheet rises over both; get out of its way. */
    .nt-mt-legend.is-panel-open,
    .nt-mt-controls.is-panel-open {
        opacity: 0;
        pointer-events: none;
    }

    .nt-mt-controls {
        transition: opacity 0.3s ease;
    }

    /* Bottom sheet, anchored to the widget rather than the viewport. */
    .nt-mt-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        max-height: 75%;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }

    .nt-mt-panel.is-open {
        transform: translateY(0);
    }

    .nt-mt-panel-handle {
        display: block;
        width: 36px;
        height: 4px;
        background: var(--nt-mt-limestone);
        border-radius: 2px;
        margin: 10px auto 6px;
    }

    .nt-mt-panel-close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
    }

    .nt-mt-card-head {
        padding: 16px;
        padding-right: 45px;
    }

    .nt-mt-card-head h3 {
        font-size: 18px;
    }

    .nt-mt-card-body {
        padding: 16px;
    }

    .nt-mt-panel-footer {
        padding: 12px 16px;
    }

    .nt-mt-book {
        padding: 14px 20px;
        font-size: 16px;
    }

    .nt-mt-chevron {
        display: inline-flex;
    }

    .nt-mt-section-title {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .nt-mt-section.is-collapsed .nt-mt-list,
    .nt-mt-section.is-collapsed .nt-mt-routes-text {
        display: none;
    }
}

@media (max-width: 480px) {
    .nt-microtransit .leaflet-control-attribution {
        font-size: 9px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nt-mt-panel,
    .nt-mt-legend,
    .nt-mt-reset,
    .nt-mt-fs,
    .nt-mt-book,
    .nt-mt-chevron,
    .nt-mt-scrollhint,
    .nt-microtransit .leaflet-interactive {
        transition: none;
    }
}
