/* ============================================
   Stockist locator — shared styles
   Used by both /pages/stockists-v4.html (test) and
   /pages/where-to-buy.html (live). Edit here, not in the pages.
   ============================================ */

/* ─── Layout ──────────────────────────────────────── */
.st-locator {
    display: grid;
    grid-template-columns: minmax(320px, 380px) 1fr;
    grid-template-areas:
        "side map"
        "list map";
    column-gap: 24px;
    row-gap: 0;
    min-height: 600px;
}
@media (max-width: 900px) {
    .st-locator {
        grid-template-columns: 1fr;
        grid-template-areas:
            "side"
            "map"
            "list";
    }
}

/* ─── Mobile stacked locator ───────────────────────── */
@media (max-width: 600px) {
    .st-locator {
        display: flex;
        flex-direction: column;
        gap: 12px;
        min-height: 0;
    }
    #stockistMap {
        order: 2;
        position: relative;
        width: 100%;
        height: 310px;
        min-height: 310px;
    }
    .st-side {
        order: 1;
    }
    .st-list-panel { order: 3; }
    .st-search-box { margin-bottom: 0; }
    .st-geo-btn {
        margin: -4px 0 2px;
        padding-bottom: 0;
    }
    .st-filter {
        margin: 2px 0 0;
    }
    .st-refine {
        margin-bottom: 0;
    }
}

.st-side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.st-list-panel {
    grid-area: list;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.st-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    margin-bottom: 12px;
}
.st-search-box svg { color: var(--color-text-muted); flex-shrink: 0; }
.st-search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 0.9rem;
}
.st-search-box .btn {
    flex-shrink: 0;
    background: #1d3a5f !important;
    border-color: #1d3a5f !important;
    color: #fff !important;
    /* Site .btn uses Alesand (all-caps display face); switch to body
       font here so the button reads as normal "Search" casing. */
    font-family: 'Inter', -apple-system, system-ui, sans-serif !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}
.st-search-box .btn:hover {
    background: #14283f !important;
    border-color: #14283f !important;
}

/* "Use my location" link button */
.st-geo-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 6px 0 10px;
    margin: 0 0 4px;
    color: var(--color-accent);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s;
}
.st-geo-btn:hover { color: #14283f; }
.st-geo-btn svg { flex-shrink: 0; }
.st-geo-btn:disabled {
    opacity: 0.5;
    cursor: progress;
}

/* Segmented filter pill */
.st-filter {
    display: flex;
    background: #f0eeea;
    border-radius: 999px;
    padding: 3px;
    margin-bottom: 12px;
}
.st-filter-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 7px 12px;
    border-radius: 999px;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.st-filter-btn:hover { color: var(--color-text); }
.st-filter-btn.is-active {
    background: #1d3a5f;
    color: #fff;
    font-weight: 600;
}

.st-count {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.st-count-sub {
    text-transform: none;
    letter-spacing: 0;
    color: var(--color-text-secondary);
    font-weight: 400;
    font-size: 0.78rem;
    margin-left: 6px;
}

/* Refine — count row + small pill button */
.st-refine { margin-bottom: 12px; }
.st-count-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 0;
}
.st-count-row .st-count { margin-bottom: 0; }
.st-refine-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 34px;
    padding: 0 12px;
    border: none;
    border-radius: 999px;
    background: #1d3a5f;
    color: #fff;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.st-refine-pill:hover { background: #14283f; }
.st-refine-chev { transition: transform 0.2s; }
.st-refine.is-open .st-refine-chev { transform: rotate(180deg); }

/* Active filter badge — small cream dot on the pill when refine has a value */
.st-refine.is-active .st-refine-pill::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f0e2c5;
    margin-left: 2px;
    flex-shrink: 0;
}

/* The text input — hidden by default, slides down when refine is open */
.st-list-filter {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    margin-top: 6px;
    background: #fff;
}
.st-refine.is-open .st-list-filter { display: flex; }
.st-list-filter svg { color: var(--color-text-muted); flex-shrink: 0; }
.st-list-filter input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 0.82rem;
}

/* State group headers */
.st-state-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #1d3a5f;
    padding: 14px 0 6px;
    border-bottom: 1px solid var(--color-border-light);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.st-state-header:first-child { padding-top: 4px; }
.st-state-header-count {
    font-size: 0.68rem;
    color: var(--color-text-muted);
    font-weight: 500;
    letter-spacing: 0.04em;
}

.st-results {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 600px;
    padding-right: 4px;
}

@media (max-width: 600px) {
    #stockistMap {
        height: 310px;
        min-height: 310px;
    }
    .st-results {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }
    .stockist-result-addr {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
    }
    .stockist-result-actions {
        margin-bottom: 0;
    }
}

.st-result {
    padding: 14px 16px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #fff;
}
.st-result:hover {
    border-color: var(--color-accent);
    background: var(--color-bg);
}
.stockist-result-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 4px;
}
.stockist-result-head h4 {
    font-size: 0.95rem;
    font-weight: 500;
    margin: 0;
}
.stockist-distance {
    font-size: 0.75rem;
    color: var(--color-accent);
    font-weight: 600;
    white-space: nowrap;
}
.stockist-result-addr {
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    margin: 0 0 8px;
}
.stockist-result-actions {
    display: flex;
    gap: 14px;
    margin-bottom: 6px;
}
.stockist-link {
    font-size: 0.78rem;
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}
.stockist-link:hover { text-decoration: underline; }
.stockist-pill {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 999px;
    background: #f0e2c5; /* cream */
    color: #1d3a5f;      /* navy */
    margin-top: 4px;
}
.stockist-empty {
    padding: 18px 14px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}
.stockist-empty h4 {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text);
    margin: 0 0 6px;
}
.stockist-empty p { margin: 0; font-size: 0.82rem; }

/* ─── Map + markers ──────────────────────────────── */
#stockistMap {
    grid-area: map;
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 600px;
    z-index: 1;
    border: 1px solid var(--color-border-light);
}
@media (max-width: 900px) {
    #stockistMap { min-height: 420px; }
}

.stockist-marker-inner {
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: #1d3a5f;            /* navy */
    border: 3px solid #f0e2c5;      /* cream ring */
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
    transition: transform 0.15s ease;
}
.stockist-marker:hover .stockist-marker-inner {
    transform: rotate(-45deg) scale(1.12);
}

.stockist-cluster {
    background: transparent;
}
.stockist-cluster-inner {
    box-sizing: border-box;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1d3a5f;
    color: #f0e2c5;
    border: 3px solid #f0e2c5;
    border-radius: 50%;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1;             /* avoid baseline drift on different glyph heights */
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

.stockist-user-dot {
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(59,130,246,0.5);
}

/* ─── Hover tooltip (mini-card preview before click) ─── */
.leaflet-tooltip.stockist-tooltip {
    background: #1d3a5f;
    color: #fff;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(29, 58, 95, 0.35);
    padding: 9px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    line-height: 1.3;
    white-space: normal;
    max-width: 220px;
    pointer-events: none;
}
.leaflet-tooltip.stockist-tooltip::before {
    border-top-color: #1d3a5f !important;
}
.stockist-tooltip-name {
    font-weight: 600;
    font-size: 0.83rem;
    color: #fff;
    margin-bottom: 2px;
}
.stockist-tooltip-loc {
    color: rgba(240, 226, 197, 0.9);
    font-size: 0.74rem;
    font-weight: 400;
}
.stockist-tooltip-badge {
    display: inline-block;
    margin-top: 5px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #f0e2c5;
    color: #1d3a5f;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Popup ──────────────────────────────────────── */
.leaflet-popup-content-wrapper {
    border-radius: 10px;
    padding: 20px 22px !important;          /* padding here, NOT margin on content (margins would collapse out) */
    box-shadow: 0 6px 20px rgba(29, 58, 95, 0.18);
}
.leaflet-popup-content {
    margin: 0 !important;                   /* override Leaflet defaults so wrapper padding rules */
    width: 280px !important;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
}
.stockist-popup {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}
.stockist-popup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding-right: 20px; /* clear close button */
}
.stockist-popup-name {
    font-size: 0.98rem;
    font-weight: 600;
    color: #1d3a5f;
    line-height: 1.25;
    word-wrap: break-word;
}
.stockist-popup .stockist-pill {
    flex-shrink: 0;
    padding: 3px 9px;
    font-size: 0.6rem;
    margin: 1px 0 0;
}
.stockist-popup-addr {
    font-size: 0.83rem;
    color: #5b6470;
    margin: 0;
    line-height: 1.4;
}
.stockist-popup-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 0.8rem;
}
.stockist-popup-link {
    color: var(--color-accent);
    text-decoration: none;
    white-space: nowrap;
}
.stockist-popup-link:hover { text-decoration: underline; }
.stockist-popup-link--email,
.stockist-popup-link--site {
    white-space: normal;
    word-break: break-word;
}
.stockist-popup-cta {
    display: block;
    margin: 4px 0 0;
    padding: 9px 14px;
    background: #1d3a5f;
    color: #fff !important;
    text-align: center;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}
.stockist-popup-cta:hover { background: #14283f; }
.stockist-popup-cta:active { transform: translateY(1px); }

/* Close button — cream circle with navy X (matches brand) */
.leaflet-popup-close-button {
    top: 6px !important;
    right: 6px !important;
    width: 22px !important;
    height: 22px !important;
    line-height: 20px !important;
    text-align: center !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    color: #1d3a5f !important;
    background: #f0e2c5 !important;
    border-radius: 50% !important;
    padding: 0 !important;
    transition: background 0.15s, color 0.15s;
}
.leaflet-popup-close-button:hover {
    background: #1d3a5f !important;
    color: #fff !important;
}
.leaflet-popup-tip {
    box-shadow: 0 4px 16px rgba(29, 58, 95, 0.18);
}

/* ─── Snapshot-fallback banner ────────────────────────
   Shown only when the live Sheet is unreachable and
   we fell back to vendor/stockists-snapshot.csv.
*/
.st-snapshot-banner {
    display: none;
    background: #fff8e0;
    border: 1px solid #f0d97a;
    color: #6b4f00;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    margin-bottom: 12px;
    line-height: 1.4;
}
.st-snapshot-banner.is-shown { display: block; }

/* ─── Debug overlay (?debug=1) ─────────────────── */
.st-debug {
    display: none;
    position: fixed;
    top: 80px;
    right: 16px;
    width: 320px;
    max-height: 60vh;
    overflow-y: auto;
    background: #1a1a1a;
    color: #f0e2c5;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 0.72rem;
    line-height: 1.45;
    z-index: 9999;
    padding: 12px 14px 14px;
}
.st-debug.is-shown { display: block; }
.st-debug-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(240,226,197,0.18);
}
.st-debug-title {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    color: #f0e2c5;
}
.st-debug-close {
    background: none;
    border: none;
    color: #f0e2c5;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.st-debug-close:hover { opacity: 1; }
.st-debug-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 0;
}
.st-debug-row span:first-child { color: rgba(240,226,197,0.65); }
.st-debug-skipped {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(240,226,197,0.18);
}
.st-debug-skipped-item {
    padding: 4px 0;
    color: #ffb4a8;
}
.st-debug-skipped-item code {
    color: #f0e2c5;
    font-weight: 600;
    margin-right: 6px;
}

/* ─── A11y — visible focus on interactive cards ─── */
.st-result {
    outline: none; /* default removed; replaced with focus-visible rule below */
}
.st-result:focus-visible {
    outline: 2px solid #1d3a5f;
    outline-offset: 2px;
    border-color: #1d3a5f;
}
.st-refine-pill:focus-visible,
.st-filter-btn:focus-visible,
.st-geo-btn:focus-visible {
    outline: 2px solid #1d3a5f;
    outline-offset: 2px;
}
/* Visually hidden but available to screen readers */
.st-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
