/* ============================================================
   SPW Location — Front-end styles
   v1.1.0 · Splendid Websites

   Colours: all use the Bricks Builder CSS variables defined in
   the site's colour palette. No hex values are hardcoded here
   (except the JS-bridged Google Maps marker colours, which Maps
   requires as literal values — see spw-location.js).

   Variable reference (from Bricks colour palette):
     --primary        Main text / charcoal
     --primary-l-5    Muted text (labels, secondary info)
     --tertiary       Crescent Green / this plugin's accent
                       (tabs, badges, distance figures)
     --tertiary-d-3   Darker green, used for error states only —
                       distinct enough from the active accent
     --secondary-l-10 Palest stone (map placeholder bg)
     --black-l-18     Neutral border colour (fields, dividers)
     --black-l-20     Neutral background fill (hover states)
     --white          #ffffff

   Sizing: font sizes use the --text-* fluid scale; padding/margin/
   gap use the --space-* fluid scale (smallest step is --space-2xs;
   there is no --space-3xs). Fixed pixel values are kept only for
   genuinely structural dimensions — the map's set height, and the
   spinner/number-badge circles, which need an exact diameter rather
   than scaling with the spacing rhythm.
   ============================================================ */

/* ── Widget container ───────────────────────────────────────── */
.spw-location {
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    font-size: var(--text-s);
    color: var(--primary);
    background: var(--white);
    border: 1px solid var(--black-l-18);
    overflow: hidden;
}

/* ── Map ────────────────────────────────────────────────────── */
.spw-location__map {
    width: 100%;
    height: 380px; /* structural — fixed map viewport height */
    display: block;
    background: var(--secondary-l-10);
}

@media (max-width: 640px) {
    .spw-location__map {
        height: 260px;
    }
}

/* Google Maps info window */
.spw-map-info {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: var(--text-xs);
    line-height: 1.5;
    color: var(--primary);
    max-width: 200px;
}

/* ── Tab navigation ─────────────────────────────────────────── */
.spw-location__tabs-wrap {
    border-top: 1px solid var(--black-l-18);
}

.spw-location__tab-nav {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border-bottom: 1px solid var(--black-l-18);
    background: var(--black-l-20);
}

.spw-location__tab-nav::-webkit-scrollbar {
    display: none;
}

.spw-location__tab-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: var(--space-xs) var(--space-s);
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font-family: inherit;
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--primary-l-5);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
    line-height: 1;
    letter-spacing: 0.01em;
}

.spw-location__tab-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.spw-location__tab-btn:hover {
    color: var(--tertiary);
}

.spw-location__tab-btn:hover svg {
    opacity: 1;
}

.spw-location__tab-btn.is-active {
    color: var(--tertiary);
    border-bottom-color: var(--tertiary);
    font-weight: 600;
}

.spw-location__tab-btn.is-active svg {
    opacity: 1;
}

/* ── Tab panels ─────────────────────────────────────────────── */
.spw-location__tab-panel {
    display: none;
    min-height: 220px;
}

.spw-location__tab-panel.is-active {
    display: block;
}

/* ── Loading state ──────────────────────────────────────────── */
.spw-location__loading {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-m) var(--space-s);
    color: var(--primary-l-5);
    font-size: var(--text-xs);
}

.spw-location__spinner {
    width: 20px;  /* structural — fixed spinner diameter */
    height: 20px;
    border: 2px solid var(--black-l-18);
    border-top-color: var(--tertiary);
    border-radius: 50%;
    animation: spw-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes spw-spin {
    to { transform: rotate(360deg); }
}

/* ── Results list ───────────────────────────────────────────── */
.spw-location__results {
    list-style: none;
    margin: 0;
    padding: 0;
}

.spw-location__result-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-s);
    border-bottom: 1px solid var(--black-l-18);
    transition: background 0.12s ease;
}

.spw-location__result-item:last-child {
    border-bottom: none;
}

.spw-location__result-item:hover {
    background: var(--black-l-20);
}

/* Number badge */
.spw-location__result-num {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 26px;  /* structural — fixed badge diameter */
    height: 26px;
    border-radius: 50%;
    background: var(--tertiary);
    color: var(--white);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1;
}

/* Info block */
.spw-location__result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
}

.spw-location__result-name {
    font-weight: 600;
    font-size: var(--text-s);
    color: var(--primary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spw-location__result-address {
    font-size: var(--text-xs);
    color: var(--primary-l-5);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Distance block */
.spw-location__result-dist {
    flex-shrink: 0;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-2xs);
}

.spw-location__dist-badge {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--tertiary);
    letter-spacing: 0.01em;
}

.spw-location__walk-time {
    font-size: var(--text-xs);
    color: var(--primary-l-5);
    white-space: nowrap;
}

/* ── Empty / error states ────────────────────────────────────── */
.spw-location__empty,
.spw-location__error {
    padding: var(--space-m) var(--space-s);
    font-size: var(--text-xs);
    color: var(--primary-l-5);
    margin: 0;
}

.spw-location__error {
    color: var(--tertiary-d-3); /* Darker green — distinct from the lighter --tertiary used as the active accent */
}

/* ── Responsive tweaks ──────────────────────────────────────── */
@media (max-width: 480px) {
    .spw-location__tab-btn {
        padding: var(--space-xs) var(--space-2xs);
    }

    .spw-location__result-item {
        padding: var(--space-2xs) var(--space-xs);
        gap: var(--space-2xs);
    }

    .spw-location__result-name {
        font-size: var(--text-xs);
    }

    .spw-location__walk-time {
        display: none;
    }
}

/* ── Respect reduced motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .spw-location__spinner {
        animation: none;
        border-top-color: var(--tertiary);
        opacity: 0.5;
    }
}
