/* ==========================================================================

*   CAPK map.css

*   Home page: map, search, filters, results and popups.

*   Mobile first. Desktop starts at 769px to match MOBILE_BREAKPOINT in map.js.

*   ========================================================================== */





/* ==========================================================================

*   Page shell

*   ========================================================================== */



body {

    display: flex;

    flex-direction: column;

    height: 100vh;

    height: 100dvh;

    overflow: hidden;

}



.map-section {

    --results-w: clamp(20rem, 34vw, 26rem);

    --sheet-peek: 112px;

    --map-edge: var(--space-3);

    --control-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));



    position: relative;

    flex: 1 1 auto;

    min-height: 0;

    overflow: hidden;

    isolation: isolate;

    background: #eef2f3;

}



#map {

    position: absolute;

    inset: 0;

    z-index: 1;

    width: 100%;

    height: 100%;

    transition: left 220ms ease, width 220ms ease;

}





/* ==========================================================================

*   Leaflet controls

*   ========================================================================== */



.leaflet-container {

    font-family: var(--font-body);

}



.leaflet-bottom.leaflet-right {

    right: var(--map-edge);

    bottom: var(--control-bottom);

    transition: bottom 260ms ease;

}



.leaflet-control-zoom.leaflet-bar {

    overflow: hidden;

    border: 1px solid var(--gray-300);

    border-radius: var(--radius-lg);

    box-shadow: var(--shadow-md);

}



.leaflet-control-zoom.leaflet-bar a {

    width: var(--tap);

    height: var(--tap);

    border-bottom-color: var(--gray-300);

    color: var(--gray-900);

    font-size: 1.375rem;

    line-height: var(--tap);

}



.leaflet-interactive[stroke="#1d6f7a"] {

    pointer-events: none;

}





/* ==========================================================================
 *  Markers
 *
 *  Program type shows as color and a letter.
 *  The SVG point ends exactly at the Leaflet anchor, so the visible pin and
 *  stored coordinate stay aligned at every zoom level.
 *  ========================================================================== */

.map-marker {
    --marker-color: #475467;

    position: relative;
    display: block;
    width: 30px;
    height: 44px;
    overflow: visible;
    transform-origin: 50% 100%;
    transition: transform 160ms ease;
}

.map-marker__svg {
    position: absolute;
    inset: 0;
    display: block;
    width: 30px;
    height: 44px;
    overflow: visible;
    filter: drop-shadow(0 3px 4px rgba(17, 24, 39, 0.26));
    pointer-events: none;
}

.map-marker__halo {
    fill: none;
    stroke: transparent;
    stroke-width: 0;
    stroke-linejoin: round;
    opacity: 0;
    transition: opacity 160ms ease;
}

.map-marker__shape {
    fill: var(--marker-color);
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linejoin: round;
}

.map-marker--pantry {
    --marker-color: #1d6f7a;
}

.map-marker--commodity {
    --marker-color: #b54708;
}

.map-marker--market {
    --marker-color: #3b7d23;
}

.map-marker--other {
    --marker-color: #475467;
}

/*
 * Selection should not change the silhouette of the pin. A small scale and
 * stronger shadow make the active result obvious without the thick double
 * outline that made the marker look distorted.
 */
.map-marker--active {
    transform: scale(1.08);
}

.map-marker--active .map-marker__svg {
    filter:
        drop-shadow(0 3px 5px rgba(17, 24, 39, 0.34))
        drop-shadow(0 0 3px rgba(29, 111, 122, 0.42));
}

.leaflet-marker-icon:has(.map-marker--active) {
    z-index: 1000 !important;
}

.map-marker__glyph {
    fill: #fff;
    stroke: none;
    font-family: var(--font-head, "Montserrat", sans-serif);
    font-size: 11px;
    font-weight: 800;
    text-anchor: middle;
    dominant-baseline: middle;
    paint-order: stroke fill;
    pointer-events: none;
    user-select: none;
}


/* ==========================================================================
 *  Clusters (Leaflet.markercluster)
 *
 *  The Leaflet icon keeps a minimum 44px hit area. The visible bubble is
 *  smaller so clusters no longer overpower individual program pins.
 *  ========================================================================== */

.map-cluster-icon {
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.map-cluster-icon:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
}

.map-cluster {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 38px;
    height: 38px;

    border: 2.5px solid #fff;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;

    box-shadow: 0 2px 7px rgba(17, 24, 39, 0.26);

    font-family: var(--font-head);
    font-size: 0.875rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;

    transition:
        transform 160ms ease,
        background-color 160ms ease,
        box-shadow 160ms ease;
}

.map-cluster--large {
    width: 42px;
    height: 42px;
    font-size: 0.8125rem;
}

.map-cluster--same-spot {
    box-shadow:
        0 0 0 2px rgba(30, 58, 95, 0.35),
        0 2px 7px rgba(17, 24, 39, 0.26);
}

.map-cluster--active {
    background: var(--teal-dark);
    box-shadow:
        0 0 0 2px var(--gray-900),
        0 3px 9px rgba(17, 24, 39, 0.28);
    transform: scale(1.08);
}

/* From the plugin's MarkerCluster.css: split, merge and fan-out animation */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}

.leaflet-cluster-spider-leg {
    transition: stroke-dashoffset 0.3s ease-out, stroke-opacity 0.3s ease-in;
}


/* ==========================================================================

*   Search bar

*   ========================================================================== */



.map-search {

    position: absolute;

    top: max(var(--map-edge), env(safe-area-inset-top));

    right: var(--map-edge);

    left: var(--map-edge);

    z-index: 1000;

}



.map-search__main {

    display: flex;

    align-items: center;

    gap: var(--space-1);

    min-height: 3.5rem;

    padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4);

    border: 1px solid var(--gray-300);

    border-radius: var(--radius-xl);

    background: #fff;

    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.14);

}



.map-search__main:focus-within {

    border-color: var(--teal);

    box-shadow:

        0 0 0 2px var(--teal),

        0 8px 28px rgba(17, 24, 39, 0.14);

}



/* Ring the bar only while typing; the buttons have their own focus ring */

.map-search__main:focus-within:not(:has(.map-search__input:focus)) {

    border-color: var(--gray-300);

    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.14);

}



.map-search__icon {

    flex: 0 0 auto;

    width: 20px;

    height: 20px;

    color: var(--gray-500);

}



.map-search__input {

    flex: 1 1 auto;

    min-width: 0;

    height: var(--tap);

    padding: 0 var(--space-2);

    border: 0;

    outline: 0;

    background: transparent;

    color: var(--gray-900);

    font-family: var(--font-body);

    font-size: 1.0625rem;

    text-overflow: ellipsis;

}



.map-search__input::placeholder {

    color: var(--gray-500);

    opacity: 1;

}



.map-search__input::-webkit-search-cancel-button {

    display: none;

}



.map-search__action,

.map-search__clear,

.map-search__submit {

    position: relative;

    display: inline-flex;

    flex: 0 0 auto;

    align-items: center;

    justify-content: center;

    width: var(--tap);

    height: var(--tap);

    border-radius: var(--radius-lg);

    -webkit-tap-highlight-color: transparent;

}



.map-search__action,

.map-search__clear {

    color: var(--gray-700);

}



.map-search__action:active,

.map-search__clear:active,

.map-search__filter-toggle[aria-expanded="true"] {

    background: var(--gray-100);

    color: var(--gray-900);

}



.map-search__clear {

    font-size: 1.5rem;

    line-height: 1;

}



.map-search__submit {

    margin-left: var(--space-1);

    background: var(--crimson);

    color: #fff;

}



.map-search__filter-count {

    position: absolute;

    top: 2px;

    right: 2px;

    display: inline-flex;

    align-items: center;

    justify-content: center;

    min-width: 1.25rem;

    height: 1.25rem;

    padding: 0 var(--space-1);

    border: 2px solid #fff;

    border-radius: var(--radius-pill);

    background: var(--teal);

    color: #fff;

    font-family: var(--font-head);

    font-size: 0.6875rem;

    font-weight: 800;

    line-height: 1;

}





/* ==========================================================================

*   Filters panel

*   ========================================================================== */



.map-search__filters {

    max-height: calc(100vh - 13rem);

    max-height: calc(100dvh - 13rem);

    margin-top: var(--space-2);

    padding: var(--space-5);

    overflow-y: auto;

    overscroll-behavior: contain;

    border: 1px solid var(--gray-300);

    border-radius: var(--radius-xl);

    background: #fff;

    box-shadow: 0 12px 34px rgba(17, 24, 39, 0.16);

}



.map-filter-group {

    min-width: 0;

    border: 0;

}



.map-filter-group + .map-filter-group {

    margin-top: var(--space-5);

    padding-top: var(--space-5);

    border-top: 1px solid var(--gray-200);

}



.map-filter-group__heading {

    margin-bottom: var(--space-3);

}



.map-filter-group__label {

    color: var(--gray-900);

    font-family: var(--font-head);

    font-size: var(--text-md);

    font-weight: 700;

}



.map-filter-options {

    display: flex;

    flex-wrap: wrap;

    gap: var(--space-2);

}



.map-filter-chip {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    gap: var(--space-2);

    min-height: var(--tap);

    padding: 0 var(--space-4);

    border: 1px solid var(--gray-400);

    border-radius: var(--radius-pill);

    background: #fff;

    color: var(--gray-900);

    font-family: var(--font-body);

    font-size: var(--text-md);

    font-weight: 600;

    line-height: 1.2;

    -webkit-tap-highlight-color: transparent;

}



.map-filter-chip.is-active,

.map-filter-chip[aria-pressed="true"] {

    border-color: var(--teal);

    background: var(--teal);

    color: #fff;

}



.map-filter-chip.is-active::before,

.map-filter-chip[aria-pressed="true"]::before {

    content: "";

    width: 0.375rem;

    height: 0.75rem;

    margin: -0.2rem 0.125rem 0 0;

    border: solid currentColor;

    border-width: 0 2px 2px 0;

    transform: rotate(45deg);

}



.map-filter-chip:disabled {

    opacity: 0.5;

    cursor: not-allowed;

}



.filter-type-symbol {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    width: 1.375rem;

    height: 1.375rem;

    border-radius: var(--radius-pill);

    background: var(--type-color, #475467);

    color: #fff;

    font-family: var(--font-head);

    font-size: 0.6875rem;

    font-weight: 800;

}



.map-filter-chip--pantry {

    --type-color: #1d6f7a;

}



.map-filter-chip--commodity {

    --type-color: #b54708;

}



.map-filter-chip--market {

    --type-color: #3b7d23;

}





.map-filter-chip.is-active .filter-type-symbol,

.map-filter-chip[aria-pressed="true"] .filter-type-symbol {

    background: rgba(255, 255, 255, 0.2);

    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);

}



.map-filter-help {

    color: var(--gray-700);

    font-size: var(--text-md);

    line-height: 1.45;

}



.map-filter-actions {

    display: flex;

    justify-content: flex-end;

    margin-top: var(--space-4);

}



.map-filter-reset {

    min-height: var(--tap);

    padding: 0 var(--space-3);

    border-radius: var(--radius);

    color: var(--teal-dark);

    font-family: var(--font-head);

    font-size: var(--text-md);

    font-weight: 700;

    text-decoration: underline;

    text-underline-offset: 3px;

}





/* ==========================================================================

*   Distance filter

*   ========================================================================== */



.radius-filter__prompt {

    display: flex;

    flex-wrap: wrap;

    align-items: center;

    gap: var(--space-3) var(--space-4);

}



.radius-filter__prompt .map-filter-help {

    flex: 1 1 14rem;

}



.radius-locate-button {

    display: inline-flex;

    align-items: center;

    gap: var(--space-2);

    min-height: var(--tap);

    padding: 0 var(--space-4);

    border: 1px solid var(--teal);

    border-radius: var(--radius-pill);

    background: #fff;

    color: var(--teal-dark);

    font-family: var(--font-body);

    font-size: var(--text-md);

    font-weight: 700;

}



.radius-locate-button[aria-busy="true"] {

    cursor: progress;

    opacity: 0.7;

}



.radius-filter__controls {

    display: grid;

    gap: var(--space-2);

}



.radius-select {

    width: 100%;

    max-width: 20rem;

    min-height: var(--tap);

    padding: 0 2.75rem 0 var(--space-4);

    border: 1px solid var(--gray-400);

    border-radius: var(--radius);

    background-color: #fff;

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5260' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    background-position: right var(--space-4) center;

    background-repeat: no-repeat;

    color: var(--gray-900);

    font-family: var(--font-body);

    font-size: var(--text-base);

    font-weight: 600;

    cursor: pointer;

    appearance: none;

    -webkit-appearance: none;

}



.radius-select:focus-visible {

    border-color: var(--teal);

}





/* ==========================================================================

*   Map key

*   ========================================================================== */



.map-legend {

    position: absolute;

    bottom: var(--control-bottom);

    left: var(--map-edge);

    z-index: 750;

    transition: bottom 260ms ease;

}



.map-legend__toggle {

    min-height: var(--tap);

    padding: 0 var(--space-4);

    border: 1px solid var(--gray-300);

    border-radius: var(--radius-lg);

    background: #fff;

    color: var(--gray-900);

    box-shadow: var(--shadow-md);

    font-family: var(--font-head);

    font-size: var(--text-md);

    font-weight: 700;

}



.map-legend__toggle[aria-expanded="true"] {

    background: var(--gray-100);

}



.map-legend__panel {

    width: 16rem;

    margin-top: var(--space-2);

    padding: var(--space-4);

    border: 1px solid var(--gray-300);

    border-radius: var(--radius-lg);

    background: #fff;

    box-shadow: var(--shadow-md);

}



.map-legend__title {

    display: block;

    margin-bottom: var(--space-3);

    color: var(--gray-900);

    font-family: var(--font-head);

    font-size: var(--text-md);

}



.map-legend__items {

    display: grid;

    gap: var(--space-3);

}



.map-legend__item {

    display: flex;

    align-items: center;

    gap: var(--space-3);

    color: var(--gray-900);

    font-size: var(--text-md);

}



.map-legend__pin {

    --type-color: #475467;



    display: inline-flex;

    flex: 0 0 1.75rem;

    align-items: center;

    justify-content: center;

    width: 1.75rem;

    height: 1.75rem;

    border: 2px solid #fff;

    border-radius: var(--radius-pill);

    background: var(--type-color);

    color: #fff;

    box-shadow: 0 1px 5px rgba(17, 24, 39, 0.22);

    font-family: var(--font-head);

    font-size: 0.75rem;

    font-weight: 800;

}



.map-legend__pin--pantry {

    --type-color: #1d6f7a;

}



.map-legend__pin--commodity {

    --type-color: #b54708;

}



.map-legend__pin--market {

    --type-color: #3b7d23;

}





.map-legend__note {

    margin-top: var(--space-3);

    color: var(--gray-700);

    font-size: var(--text-sm);

    line-height: 1.45;

}





/* ==========================================================================

*   Results panel (desktop) and shared results parts

*   ========================================================================== */



.results-panel {

    display: none;

}



.results-panel__close {

    display: inline-flex;

    flex: 0 0 auto;

    align-items: center;

    justify-content: center;

    width: var(--tap);

    height: var(--tap);

    border-radius: var(--radius-lg);

    color: var(--gray-700);

}



.results-panel__close:active {

    background: var(--gray-100);

    color: var(--gray-900);

}



.results-note {

    padding: var(--space-4) var(--space-5);

    border-top: 1px solid var(--gray-200);

    background: var(--gray-100);

    color: var(--gray-700);

    font-size: var(--text-md);

    line-height: 1.45;

}



.results-panel__empty {

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    gap: var(--space-3);

    min-height: 12rem;

    padding: var(--space-8) var(--space-6);

    color: var(--gray-700);

    text-align: center;

}



.results-panel__empty p {

    font-size: var(--text-base);

    line-height: 1.5;

}



.results-panel__show-all {

    min-height: var(--tap);

    padding: 0 var(--space-2);

    color: var(--teal-dark);

    font-family: var(--font-head);

    font-size: var(--text-md);

    font-weight: 700;

    text-decoration: underline;

    text-underline-offset: 3px;

}



.skeleton {

    border-radius: var(--radius);

    background: linear-gradient(

        90deg,

        var(--gray-200) 25%,

        var(--gray-100) 50%,

        var(--gray-200) 75%

    );

    background-size: 200% 100%;

    animation: map-shimmer 1.4s infinite;

}



.skeleton-card {

    height: 7.5rem;

    margin: var(--space-3) var(--space-4);

    border-radius: var(--radius-lg);

}



@keyframes map-shimmer {

    from {

        background-position: 200% 0;

    }



    to {

        background-position: -200% 0;

    }

}





/* ==========================================================================

*   Result cards

*   ========================================================================== */



.result-card {

    display: block;

    padding: var(--space-5);

    border-bottom: 1px solid var(--gray-200);

    background: #fff;

    color: inherit;

    cursor: pointer;

    -webkit-tap-highlight-color: transparent;

    transition: background-color 150ms ease, box-shadow 150ms ease;

}



.result-card:active {

    background: var(--gray-100);

}



.result-card:focus-visible {

    outline-offset: -3px;

}



.result-card.highlighted {

    background: var(--teal-light);

    box-shadow: inset 4px 0 0 var(--teal);

}



.result-card.highlighted .result-card__dist {

    background: #fff;

}



.result-card__type-row {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: var(--space-3);

    margin-bottom: var(--space-3);

}



.result-card__header {

    margin-bottom: var(--space-3);

}



.result-card__header-text {

    min-width: 0;

}



.result-card__availability {

    margin-bottom: var(--space-1);

    color: var(--teal-dark);

    font-size: var(--text-md);

    font-weight: 700;

}



.result-card__status--opens_later,

.result-card__status--scheduled,

.result-card__status--call_for_hours {

    color: var(--gray-700);

}



.result-card__status--paused {

    color: var(--crimson-dark);

}



.result-card__name {

    color: var(--gray-900);

    font-family: var(--font-head);

    font-size: var(--text-lg);

    font-weight: 700;

    line-height: 1.35;

}



.result-card__verified {

    display: inline-block;

    margin-left: var(--space-1);

    color: var(--teal);

    vertical-align: -0.15em;

}



.result-card__agency {

    margin-top: var(--space-1);

    color: var(--teal-dark);

    font-size: var(--text-md);

    font-weight: 600;

}



.result-card__dist {

    flex: 0 0 auto;

    padding: var(--space-1) var(--space-3);

    border-radius: var(--radius-pill);

    background: var(--teal-light);

    color: var(--teal-dark);

    font-size: var(--text-sm);

    font-weight: 700;

    white-space: nowrap;

}



.result-card__meta {

    display: grid;

    gap: var(--space-2);

}



.result-card__meta-item {

    display: flex;

    align-items: flex-start;

    gap: var(--space-2);

    min-width: 0;

    color: var(--gray-700);

    font-size: var(--text-md);

    line-height: 1.45;

}



.result-card__meta-item svg {

    flex: 0 0 auto;

    margin-top: 0.2em;

    color: var(--gray-500);

}



.result-card__cta {

    display: inline-flex;

    align-items: center;

    gap: var(--space-1);

    margin-top: var(--space-4);

    color: var(--teal-dark);

    font-family: var(--font-head);

    font-size: var(--text-md);

    font-weight: 700;

    text-decoration: underline;

    text-underline-offset: 3px;

}





/* ==========================================================================

*   Program type badges

*   ========================================================================== */



.program-type-badge {

    --type-color: #475467;



    display: inline-flex;

    align-items: center;

    gap: var(--space-2);

    width: fit-content;

    min-height: 1.875rem;

    padding: 0.125rem var(--space-3) 0.125rem var(--space-1);

    border: 1px solid var(--gray-300);

    border-radius: var(--radius-pill);

    background: var(--gray-100);

    color: var(--gray-900);

    font-family: var(--font-head);

    font-size: var(--text-sm);

    font-weight: 700;

}



.program-type-badge__symbol {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    width: 1.375rem;

    height: 1.375rem;

    border-radius: var(--radius-pill);

    background: var(--type-color);

    color: #fff;

    font-size: 0.6875rem;

    font-weight: 800;

}



.program-type-badge--pantry {

    --type-color: #1d6f7a;

}



.program-type-badge--commodity {

    --type-color: #b54708;

}



.program-type-badge--market {

    --type-color: #3b7d23;

}





@supports (background: color-mix(in srgb, #000 10%, #fff)) {

    .program-type-badge {

        border-color: color-mix(in srgb, var(--type-color) 30%, white);

        background: color-mix(in srgb, var(--type-color) 9%, white);

    }

}





/* ==========================================================================

*   Bottom sheet (mobile results)

*   ========================================================================== */



.bottom-sheet {

    position: absolute;

    right: 0;

    bottom: 0;

    left: 0;

    z-index: 900;

    display: flex;

    flex-direction: column;

    height: min(68vh, 620px, calc(100% - var(--search-card-bottom, 0px) - 72px));

    height: min(68dvh, 620px, calc(100% - var(--search-card-bottom, 0px) - 72px));

    padding-bottom: env(safe-area-inset-bottom);

    border-radius: 20px 20px 0 0;

    background: #fff;

    box-shadow: 0 -8px 28px rgba(17, 24, 39, 0.18);

    transform: translateY(100%);

    transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1);

}



/* --sheet-peek must match SHEET_PEEK_PX in map.js */

.bottom-sheet.peek {

    transform: translateY(calc(100% - var(--sheet-peek) - env(safe-area-inset-bottom)));

}



.bottom-sheet.expanded {

    transform: translateY(0);

}



.bottom-sheet.dragging {

    transition: none;

    user-select: none;

}



.map-section:has(.map-search__filters:not([hidden])) .bottom-sheet {

    transform: translateY(100%);

}



.bottom-sheet__handle {

    display: flex;

    flex: 0 0 auto;

    justify-content: center;

    padding: var(--space-3) 0 var(--space-2);

}



.bottom-sheet__handle,

.bottom-sheet__header {

    cursor: grab;

    touch-action: none;

}



.bottom-sheet.dragging .bottom-sheet__handle,

.bottom-sheet.dragging .bottom-sheet__header {

    cursor: grabbing;

}



.bottom-sheet__handle:focus-visible {

    outline-offset: -3px;

}



.bottom-sheet__handle::after {

    content: "";

    width: 2.75rem;

    height: 5px;

    border-radius: var(--radius-pill);

    background: var(--gray-400);

}



.bottom-sheet__header {

    display: flex;

    flex: 0 0 auto;

    align-items: center;

    justify-content: space-between;

    gap: var(--space-3);

    min-height: 3.25rem;

    padding: 0 var(--space-3) var(--space-2) var(--space-5);

    border-bottom: 1px solid var(--gray-200);

}



.bottom-sheet__title {

    min-width: 0;

    color: var(--gray-900);

    font-family: var(--font-head);

    font-size: 1.0625rem;

    font-weight: 700;

}



.bottom-sheet__list {

    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;

    overscroll-behavior: contain;

    -webkit-overflow-scrolling: touch;

}



.bottom-sheet.peek .bottom-sheet__list {

    overflow: hidden;

}





/* ==========================================================================

*   Popups

*   ========================================================================== */



.leaflet-popup-content-wrapper {

    overflow: hidden;

    padding: 0;

    border-radius: var(--radius-lg);

    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.18);

}



.leaflet-popup-content {

    margin: 0;

}



.leaflet-container a.leaflet-popup-close-button {

    top: var(--space-1);

    right: var(--space-1);

    width: 2.25rem;

    height: 2.25rem;

    border-radius: var(--radius);

    color: var(--gray-700);

    font: 1.5rem/2.25rem var(--font-body);

}



.leaflet-popup-content .map-popup {

    width: min(17.5rem, calc(100vw - 4rem));

}



.map-popup {

    padding: var(--space-4) var(--space-5) var(--space-3);

}



.map-popup > .program-type-badge {

    margin-bottom: var(--space-3);

}



.map-popup__availability {

    margin-bottom: var(--space-1);

    color: var(--teal-dark);

    font-size: var(--text-sm);

    font-weight: 700;

}



.map-popup__agency {

    margin-bottom: var(--space-1);

    color: var(--teal-dark);

    font-size: var(--text-sm);

    font-weight: 600;

}



.map-popup__name {

    margin-bottom: var(--space-2);

    color: var(--gray-900);

    font-family: var(--font-head);

    font-size: 1.0625rem;

    font-weight: 700;

    line-height: 1.3;

}



.map-popup__address {

    margin-bottom: var(--space-1);

    color: var(--gray-700);

    font-size: var(--text-sm);

    line-height: 1.45;

}



/* The address as a directions link: it reads like the plain grey address
   (same size, normal weight) with the pin icon, and underlines on hover and
   keyboard focus. Lighter than .map-popup__link ("View details"). */
.leaflet-container .map-popup__directions {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 24px;
    color: var(--gray-700);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 400;
    line-height: 1.45;
    text-decoration: none;
    text-underline-offset: 3px;
}

.leaflet-container .map-popup__directions svg {
    flex-shrink: 0;
}

.leaflet-container .map-popup__directions:hover,
.leaflet-container .map-popup__directions:focus-visible {
    color: var(--gray-900);
    text-decoration: underline;
}

.leaflet-container .map-popup__directions:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
    border-radius: 2px;
}



.leaflet-container .map-popup__link {

    display: inline-flex;

    align-items: center;

    gap: var(--space-1);

    min-height: var(--tap);

    color: var(--crimson-dark);

    font-family: var(--font-head);

    font-size: var(--text-md);

    font-weight: 700;

    text-decoration: underline;

    text-underline-offset: 3px;

}



.leaflet-popup-content .popup-here {

    display: flex;

    align-items: center;

    gap: var(--space-1);

    padding: var(--space-2) var(--space-3);

    color: var(--gray-900);

    font-family: var(--font-body);

    font-size: var(--text-md);

    font-weight: 600;

    white-space: nowrap;

}



.popup-here-wrapper .leaflet-popup-content {

    width: auto !important;

}





/* ==========================================================================

*   Phones and small tablets

*   Map key and zoom buttons sit at the bottom, and rise above the results

*   list while it is open.

*   ========================================================================== */



@media (max-width: 768px) {

    .map-section.results-open {

        --control-bottom: calc(var(--sheet-peek) + var(--space-6) + env(safe-area-inset-bottom));

    }

}


/* ==========================================================================
 *   Filters as a bottom sheet (phones and small tablets)
 *
 *   The panel leaves the search card and sits on the bottom edge, as tall as
 *   its content up to 85% of the screen, over a dimmed page. It scrolls only
 *   when the content is taller than that, so no scrollbar otherwise (the old
 *   dropdown was capped short, and the scrollbar it then needed narrowed it,
 *   wrapped the chips onto more rows and made it taller still). The sheet's
 *   title bar (title and close button) stays in view while it scrolls.
 *   map.js moves focus in and out and closes it on Esc and backdrop taps.
 * ========================================================================== */

.map-filters__head,
.map-filters-backdrop {
    display: none;
}

@media (max-width: 768px) {

    /* Above the map's own controls (Leaflet's are z-index 1000) */
    .map-search:has(.map-search__filters:not([hidden])) {
        z-index: 1200;
    }

    /* The site header sits above the map section (which isolates its own
       stacking), so it gets a matching dim of its own; a tap on it closes
       the sheet like a tap on the backdrop (map.js: outside the search) */
    body:has(.map-search__filters:not([hidden])) .site-header::after {
        content: "";
        position: absolute;
        inset: 0;
        background: rgba(17, 24, 39, 0.5);
    }

    .map-filters-backdrop:not([hidden]) {
        position: fixed;
        inset: 0;
        z-index: 1;
        display: block;
        background: rgba(17, 24, 39, 0.5);
        -webkit-tap-highlight-color: transparent;
    }

    .map-search__filters {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 2;

        max-height: 85vh;
        max-height: 85dvh;
        margin: 0;
        padding:
            0
            max(var(--space-4), env(safe-area-inset-right))
            calc(var(--space-4) + env(safe-area-inset-bottom))
            max(var(--space-4), env(safe-area-inset-left));

        overflow-y: auto;
        overscroll-behavior: contain;

        border: 0;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 30px rgba(17, 24, 39, 0.22);
    }

    .map-filters__head {
        position: sticky;
        top: 0;
        z-index: 1;

        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;

        margin: 0 calc(-1 * max(var(--space-4), env(safe-area-inset-left))) var(--space-3);
        padding:
            var(--space-4)
            max(var(--space-2), env(safe-area-inset-right))
            var(--space-2)
            max(var(--space-4), env(safe-area-inset-left));

        border-bottom: 1px solid var(--gray-200);
        background: #fff;
    }

    .map-filters__grabber {
        position: absolute;
        top: var(--space-2);
        left: 50%;
        width: 2.5rem;
        height: 0.25rem;
        border-radius: var(--radius-pill);
        background: var(--gray-300);
        transform: translateX(-50%);
    }

    .map-filters__title {
        margin: 0;
        color: var(--gray-900);
        font-family: var(--font-head);
        font-size: var(--text-lg);
        font-weight: 700;
    }

    .map-filters__title:focus {
        outline: none;
    }

    .map-filters__title:focus-visible {
        outline: 3px solid var(--teal);
        outline-offset: 2px;
    }

    .map-filters__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: var(--tap);
        height: var(--tap);
        padding: 0;
        border: 0;
        border-radius: var(--radius-pill);
        background: transparent;
        color: var(--gray-700);
        cursor: pointer;
    }

    .map-filters__close:hover {
        background: var(--gray-100, #f2f4f7);
    }

    .map-filters__close:focus-visible {
        outline: 3px solid var(--teal);
        outline-offset: 2px;
    }
}





/* ==========================================================================

*   Small phones

*   ========================================================================== */



@media (max-width: 400px) {

    .map-section {

        --map-edge: var(--space-2);

    }



    .map-search__main {

        padding-left: var(--space-2);

    }



    .map-search__icon {

        display: none;

    }



    /* The filters sheet keeps its own padding ("Filters as a bottom sheet") */

}





/* ==========================================================================

*   Desktop and tablet

*   ========================================================================== */



@media (min-width: 769px) {

    .map-section {

        --map-edge: var(--space-5);

        --control-bottom: var(--space-5);

    }



    .map-search {

        top: var(--space-5);

        right: auto;

        left: 50%;

        width: min(42.5rem, calc(100% - 3rem));

        transform: translateX(-50%);

    }



    .map-search__main {

        min-height: 3.75rem;

        border-radius: 18px;

    }



    .map-search__filters {

        width: min(40rem, 100%);

        margin-right: auto;

        margin-left: auto;

        padding: var(--space-6);

    }



    .map-filter-chip {

        min-height: 2.5rem;

    }



    .results-panel {

        position: absolute;

        top: 0;

        bottom: 0;

        left: 0;

        z-index: 800;

        display: flex;

        flex-direction: column;

        width: var(--results-w);

        border-right: 1px solid var(--gray-300);

        background: #fff;

        box-shadow: 8px 0 28px rgba(17, 24, 39, 0.08);

    }



    .results-panel__header {

        display: flex;

        flex: 0 0 auto;

        align-items: center;

        justify-content: space-between;

        gap: var(--space-3);

        padding: var(--space-4) var(--space-3) var(--space-4) var(--space-5);

        border-bottom: 1px solid var(--gray-200);

    }



    .results-panel__title {

        color: var(--gray-900);

        font-family: var(--font-head);

        font-size: var(--text-lg);

        font-weight: 700;

    }



    .results-panel__count {

        margin-top: 0.125rem;

        color: var(--gray-500);

        font-size: var(--text-md);

    }



    .results-panel__list {

        flex: 1 1 auto;

        min-height: 0;

        overflow-y: auto;

    }



    .bottom-sheet {

        display: none;

    }



    .map-section.results-open #map {

        left: var(--results-w);

        width: auto;

    }



    .map-section.results-open .map-search {

        left: calc(var(--results-w) + (100% - var(--results-w)) / 2);

        width: min(42.5rem, calc(100% - var(--results-w) - 3rem));

    }



    .map-section.results-open .map-legend {

        left: calc(var(--results-w) + var(--map-edge));

    }

}





/* ==========================================================================

*   Hover

*   Mouse and trackpad only, so taps on phones do not leave a stuck hover color.

*   ========================================================================== */



@media (hover: hover) {

    .leaflet-control-zoom.leaflet-bar a:hover,

    .map-search__action:hover,

    .map-search__clear:hover,

    .map-legend__toggle:hover,

    .results-panel__close:hover,

    .leaflet-container a.leaflet-popup-close-button:hover {

        background: var(--gray-100);

        color: var(--gray-900);

    }



    .map-search__submit:hover {

        background: var(--crimson-dark);

    }



    .map-filter-chip:hover:not(:disabled),

    .radius-select:hover {

        border-color: var(--teal);

        background-color: var(--teal-xlt);

    }



    .map-filter-chip.is-active:hover,

    .map-filter-chip[aria-pressed="true"]:hover {

        background: var(--teal-dark);

    }



    .radius-locate-button:hover {

        background: var(--teal-xlt);

    }



    .map-filter-reset:hover,

    .result-card:hover {

        background: var(--teal-xlt);

    }



    .result-card.highlighted:hover {

        background: var(--teal-light);

    }



    .leaflet-container .map-popup__link:hover {

        color: var(--crimson);

    }

}


/* ==========================================================================
 * Results pagination
 *
 * One shared pager moves with #results-list between the desktop sidebar and
 * the mobile bottom sheet. Each page is loaded from the server on its own;
 * the map shows that page's pins.
 *
 * Desktop:  summary .............. per-page
 *           [<- Previous]  Page 1 of 6  [Next ->]
 * Phone:    Showing 1–25 of 79   [25 v] per page   [<-] [->]
 *           one line, 44px tap targets; below ~340px it wraps to two
 *
 * The DOM order is summary, per-page, buttons (map.js), the same as the
 * visual order at both widths. Public map page only: map.css is not
 * loaded by the portals.
 * ========================================================================== */

.results-pagination {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "summary size"
        "nav     nav";
    align-items: center;
    gap: var(--space-3) var(--space-4);

    padding: var(--space-4) var(--space-5);

    border-top: 1px solid var(--gray-200);
    background: #fff;

    color: var(--gray-500);
    font-family: var(--font-body);
    font-size: var(--text-sm);
}

.results-pagination[hidden] {
    display: none !important;
}

.results-pagination__summary {
    grid-area: summary;
    margin: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.results-pagination__size {
    grid-area: size;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    white-space: nowrap;
}

/* Same look as the Area and radius selects (.radius-select), smaller text */
.results-pagination__select {
    min-height: var(--tap);
    padding: 0 2.25rem 0 var(--space-3);

    border: 1px solid var(--gray-400);
    border-radius: var(--radius);

    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5260' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-position: right var(--space-3) center;
    background-repeat: no-repeat;

    color: var(--gray-900);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;

    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.results-pagination__nav {
    grid-area: nav;
    display: grid;
    /* Both buttons the same width, the page text centred between them */
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-3);
}

.results-pagination__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);

    width: 100%;
    max-width: 10rem;
    min-height: var(--tap);
    padding: 0 var(--space-4);

    border: 2px solid var(--teal);
    border-radius: var(--radius);

    background: #fff;
    color: var(--teal);

    font-family: var(--font-head);
    font-size: var(--text-sm);
    font-weight: 700;
    white-space: nowrap;

    cursor: pointer;
    transition: background-color var(--transition), color var(--transition);
}

.results-pagination__button--prev {
    justify-self: start;
}

.results-pagination__button--next {
    justify-self: end;
}

/* Disabled: the same outline button, faded, not a grey box */
.results-pagination__button:disabled,
.results-pagination__button[aria-disabled="true"] {
    background: #fff;
    color: var(--teal);
    opacity: 0.4;
    cursor: not-allowed;
}

.results-pagination__button:focus-visible,
.results-pagination__select:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
}

.results-pagination__select:focus-visible {
    border-color: var(--teal);
}

.results-pagination__page {
    color: var(--gray-700);
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

@media (hover: hover) {
    .results-pagination__button:hover:not(:disabled) {
        background: var(--teal);
        color: #fff;
    }

    .results-pagination__select:hover {
        border-color: var(--teal);
        background-color: var(--teal-xlt);
    }
}

/* Phone: the bottom sheet (same breakpoint as MOBILE_BREAKPOINT in map.js).
   One wrapping flex line: summary, per-page, then the two arrow buttons at
   the right edge. "Showing 1–25 of 93" is about 305px of content, so it fits
   a 375px phone with room to spare and only wraps below ~320px (a little
   earlier for four-digit totals). */
@media (max-width: 768px) {
    .results-pagination {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-2);

        /* The sheet has no side padding of its own; keep clear of the
           edges and of a notch (the sheet pads the bottom itself) */
        padding:
            var(--space-2)
            max(var(--space-2), env(safe-area-inset-right))
            var(--space-2)
            max(var(--space-2), env(safe-area-inset-left));

        font-size: 0.75rem;
    }

    .results-pagination__summary {
        flex: 1 1 auto;
    }

    .results-pagination__size {
        gap: var(--space-1);
    }

    /* The select's own label is "Results per page"; "[25] per page" reads
       the same on screen without the leading "Show" */
    .results-pagination__size-show {
        display: none;
    }

    .results-pagination__select {
        padding: 0 1.5rem 0 var(--space-2);
        background-position: right 0.375rem center;
        background-size: 14px 14px;
        font-size: 0.8125rem;
    }

    .results-pagination__nav {
        display: flex;
        gap: var(--space-1);
        margin-left: auto;
    }

    /* Arrow-only squares; the aria-label names them */
    .results-pagination__button {
        width: var(--tap);
        min-width: var(--tap);
        max-width: none;
        padding: 0;
        font-size: var(--text-md);
    }

    .results-pagination__label,
    .results-pagination__page {
        display: none;
    }
}
