﻿/* =========================
   Vars
   ========================= */
.locations {
    --brand: #0d6efd;
    --ink: #1b1f23;
    --muted: #6c757d;
    --bg: #fff;
    --soft: #f6f8fb;
    --radius: 10px;
    --shadow: 0 8px 20px rgba(0,0,0,.10);
}

/* =========================
   Header
   ========================= */
.locations__header {
    padding-block: .75rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: .75rem;
}

.locations__title {
    margin: 0;
    font-weight: 800;
    letter-spacing: .2px;
    font-size: clamp(1.25rem, 1.1vw + 1rem, 1.75rem);
}

/* Segmented view toggle */
.view-toggle {
    display: none;
    border-radius: 999px;
    background: #e9ecef;
    padding: 2px;
    gap: 2px;
}

.view-toggle__btn {
    border: 0;
    background: transparent;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

    .view-toggle__btn.is-active {
        background: #fff;
        color: var(--brand);
        box-shadow: 0 2px 8px rgba(0,0,0,.08);
    }

    .view-toggle__btn:focus-visible {
        outline: 2px solid var(--brand);
        outline-offset: 2px;
    }

/* =========================
   Layout (desktop-first)
   ========================= */
.locations__wrap {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    background: var(--soft);
    border-top: 1px solid rgba(0,0,0,.06);
    min-height: clamp(520px, 62vh, 780px);
    height: auto;
    contain: content;
    position: relative;
}

.locations__panel {
    width: 30%;
    max-width: 420px;
    background: var(--bg);
    border-right: 1px solid rgba(0,0,0,.08);
    overflow-y: auto;
    overflow-x: hidden; /* PATCH */
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(0,0,0,.06);
    overscroll-behavior: contain;
    scrollbar-gutter: stable both-edges;
}

@media (min-width: 992px) {
    .locations__header {
        display: none;
    }
    /* Desktop: sticky sidebar */
    .locations__panel {
        position: sticky;
        top: calc(var(--header-h, 140px) + 12px);
        max-height: calc(100vh - var(--header-h, 140px) - 24px);
        box-shadow: 0 10px 28px rgba(0,0,0,.08);
        border-radius: var(--radius);
    }
}

.panel__list {
    list-style: none;
    margin: 0;
    padding: 10px 18px 10px 12px; /* PATCH — extra right padding */
    display: grid;
    gap: 12px;
}

/* =========================
   Cards
   ========================= */
.location-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 130px; /* text | thumb */
    gap: 10px 16px;
    align-items: center;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    cursor: pointer;
    box-sizing: border-box; /* PATCH */
}

    .location-card:hover {
        box-shadow: var(--shadow);
        transform: translateY(-1px);
        border-color: rgba(0,0,0,.12);
    }

    .location-card.active {
        border-color: var(--brand);
        box-shadow: 0 16px 34px -18px rgba(13,110,253,.35);
    }

.location-card__title {
    grid-column: 1;
    margin: 0 0 4px;
    font-weight: 800;
    color: var(--ink);
}

.location-card__meta {
    grid-column: 1;
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.location-card__phone {
    color: var(--brand);
    text-decoration: none;
    font-weight: 700;
}

    .location-card__phone:hover {
        text-decoration: underline;
    }

/* Thumb */
.location-card__img {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 130px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
}

/* =========================
   Map
   ========================= */
.locations__mapwrap {
    flex: 1;
    position: relative;
    min-height: 520px;
    height: auto;
    border-radius: var(--radius);
    overflow: clip;
    box-shadow: 0 10px 28px rgba(0,0,0,.06);
}

.locations__map,
#map {
    height: 100%;
    width: 100%;
    min-height: 520px;
    background: #e9ecef;
}

/* Noscript badge */
.noscript {
    position: absolute;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    background: #fff;
    padding: .5rem .75rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* =========================
   Mobile / Tablet
   ========================= */
@media (max-width: 991.98px) {

    .locations__wrap {
        flex-direction: column;
        gap: .75rem;
    }

    .locations__panel {
        width: 100%;
        max-width: none;
        position: static;
        box-shadow: 0 6px 18px rgba(0,0,0,.06);
    }

    .locations__mapwrap {
        width: 100%;
        min-height: 320px;
        height: calc(var(--vh, 1vh) * 60);
    }

    @supports (height: 100dvh) {
        .locations__mapwrap {
            height: calc(100dvh - var(--header-h, 120px) - 120px);
        }
    }

    /* On mobile, show either LIST or MAP, not both */
    .locations--view-list .locations__panel {
        display: block;
    }

    .locations--view-list .locations__mapwrap {
        display: none;
    }

    .locations--view-map .locations__panel {
        display: none;
    }

    .locations--view-map .locations__mapwrap {
        display: block;
    }

    /* Cards full-width */
    .location-card {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .location-card__img {
        grid-column: 1;
        grid-row: auto;
        width: 100%;
        height: 140px;
    }

    .location-card__meta {
        font-size: .95rem;
    }

    .panel__list {
        padding: 12px 12px max(12px, env(safe-area-inset-bottom));
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .location-card.active {
        box-shadow: 0 16px 34px -18px rgba(13,110,253,.28);
        transform: translateY(-1px);
    }

    .view-toggle {
        display: inline-flex;
    }

    .locations__header {
        align-items: center;
    }
}

/* Ultra-small */
@media (max-width: 375px) {
    .location-card {
        padding: 8px;
    }

    .location-card__img {
        height: 120px;
    }
}

/* =========================
   A11y / motion
   ========================= */
@media (prefers-reduced-motion: reduce) {
    .location-card,
    .view-toggle__btn {
        transition: none !important;
    }
}
