/* ============================================================
   Dealer Locator Component  —  prefix: .dl
   ACSS tokens used: --h3, --h4, --text-m, --text-s, --text-xs,
                     --text-dark, --text-dark-muted, --primary, --neutral,
                     --space-xl, --space-l, --space-m, --space-s, --space-xs
   ============================================================ */

/* ── Component vars ────────────────────────────────────────── */
.dl {
    --dl-border:       rgba(0, 0, 0, 0.12);
    --dl-speed:        200ms;
    scroll-margin-top: calc(124px + var(--space-m, 1.25rem));
}

/* Override form--light block layout — keep search row as flex */
.dl__search.form--light {
    display:     flex !important;
    align-items: stretch;
    flex-wrap:   nowrap;
    padding:     0 !important;
}

/* ── Controls ──────────────────────────────────────────────── */
.dl__controls {
    display:        flex;
    flex-direction: column;
    gap:            var(--space-s, 0.75rem);
    margin-bottom:  var(--space-l, 2rem);
}

.dl__search-wrap {
    width:    100%;
    position: relative;
}


.dl__search-btn,
.dl__geo-btn {
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         0 var(--space-s, 0.75rem);
    border:          none;
    border-left:     1px solid var(--dl-border);
    background:      transparent;
    cursor:          pointer;
    color:           var(--text-dark, #111);
    transition:      background var(--dl-speed);
    flex-shrink:     0;
    min-height:      44px;
    min-width:       44px;
}

.dl__search-btn {
    background: var(--primary);
    color:      var(--neutral);
}

.dl__search-btn:hover { filter: brightness(0.92); }
.dl__geo-btn:hover    { background: rgba(0,0,0,0.05); }

.dl__geo-btn[aria-busy="true"] {
    opacity:        0.5;
    pointer-events: none;
}

/* ── Filters (fieldset reset) ───────────────────────────────── */
.dl__filters {
    border:          none;
    margin:          0;
    padding:         0;
    min-inline-size: 0;
    display:         flex;
    align-items:     center;
    gap:             var(--space-l, 2rem);
}

.dl__filter-label {
    display:     flex;
    align-items: center;
    gap:         var(--space-xs, 0.5rem);
    cursor:      pointer;
    font-size:   var(--text-m, 1rem);
    font-weight: 600;
    color:       var(--text-dark, #111);
    user-select: none;
}

.dl__filter-label input[type="checkbox"] {
    accent-color: var(--primary);
    width:        1.4rem;
    height:       1.4rem;
    cursor:       pointer;
    flex-shrink:  0;
}

/* ── Autocomplete dropdown ───────────────────────────────────── */
.dl__autocomplete {
    position:         absolute;
    top:              100%;
    left:             0;
    right:            0;
    z-index:          100;
    background:       var(--white, #fff);
    border:           1px solid var(--dl-border);
    border-top:       none;
    list-style:       none;
    margin:           0;
    padding:          0;
    box-shadow:       0 4px 12px rgba(0,0,0,0.1);
}

.dl__autocomplete-item {
    display:     flex;
    align-items: center;
    gap:         var(--space-s, 0.75rem);
    padding:     0.65rem var(--space-s, 0.75rem);
    cursor:      pointer;
    font-size:   var(--text-s, 0.9rem);
    color:       var(--text-dark, #111);
    transition:  background 100ms;
}

.dl__autocomplete-item:hover,
.dl__autocomplete-item.is-active {
    background: rgba(0,0,0,0.05);
}

.dl__ac-flag {
    font-size:   1.2em;
    line-height: 1;
    flex-shrink: 0;
}

.dl__ac-icon {
    display:    flex;
    flex-shrink: 0;
    opacity:    0.5;
}

.dl__ac-text {
    display:        flex;
    flex-direction: column;
    gap:            0.1rem;
    min-width:      0;
}

.dl__ac-label {
    font-weight:  600;
    white-space:  nowrap;
    overflow:     hidden;
    text-overflow: ellipsis;
}

.dl__ac-sub {
    font-size:  var(--text-xs, 0.8rem);
    color:      var(--text-dark-muted, #888);
    white-space: nowrap;
    overflow:   hidden;
    text-overflow: ellipsis;
}

/* ── List wrapper ────────────────────────────────────────────── */
.dl__list {
    width: 100%;
}

/* ── Map ─────────────────────────────────────────────────────── */
.dl__map {
    width:         100%;
    height:        520px;
    min-height:    400px;
    margin-bottom: var(--space-l, 2rem);
    border:        1px solid var(--dl-border);
    position:      relative;
    z-index:       0;
    display:       block;
}

@media (max-width: 767px) {
    .dl__map { height: 360px; }
}

/* Stack cards into a single column on tablets and smaller.
 * Country headings already span the full row via `grid-column: 1 / -1`. */
@media (max-width: 960px) {
    .dl__grid { grid-template-columns: 1fr !important; }

    /* Card name on its own row; type chips drop below */
    .dl-card__top {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Custom map pins ─────────────────────────────────────────── */
.dl-pin {
    display:       block;
    width:         14px;
    height:        14px;
    border-radius: var(--radius-circle, 50vw);
    border:        2px solid var(--white, #fff);
    box-shadow:    0 1px 4px rgba(0,0,0,0.4);
}

/* ── Cluster badge ───────────────────────────────────────────── */
.dl-cluster {
    display:         flex;
    align-items:     center;
    justify-content: center;
    width:           38px;
    height:          38px;
    border-radius:   var(--radius-circle, 50vw);
    background:      var(--primary);
    color:           var(--neutral);
    font-size:       var(--text-xs, 0.8rem);
    font-weight:     700;
    border:          2px solid var(--white, #fff);
    box-shadow:      0 2px 6px rgba(0,0,0,0.3);
}

/* ── Popup ───────────────────────────────────────────────────── */
.dl-popup {
    font-size: var(--text-s, 0.9rem);
    color:     var(--text-dark, #111);
    min-width: 220px;
}

.dl-popup__name {
    display:       block;
    font-size:     var(--text-m, 1rem);
    font-weight:   700;
    margin-bottom: 0.35rem;
}

.dl-popup__types {
    display:       flex;
    gap:           0.3rem;
    margin-bottom: 0.5rem;
    flex-wrap:     wrap;
}

.dl-popup__address {
    margin:      0 0 0.5rem;
    color:       var(--text-dark-muted, #555);
    font-style:  normal;
    font-size:   var(--text-xs, 0.8rem);
    line-height: 1.6;
}

.dl-popup__contacts {
    display:        flex;
    flex-direction: column;
    gap:            0.3rem;
    margin-top:     0.5rem;
}

.dl-popup__contact {
    display:         flex;
    align-items:     center;
    gap:             0.35rem;
    font-size:       var(--text-xs, 0.8rem);
    color:           var(--text-dark, #111);
    text-decoration: none;
    word-break:      break-all;
}

.dl-popup__contact:hover {
    color:           var(--text-dark-muted);
    text-decoration: underline;
}

/* ── Flat grid — country headings span full width ────────────── */
.dl__grid {
    display:               grid;
    grid-template-columns: repeat(2, 1fr);
    gap:                   var(--grid-gap);
    align-items:           stretch;
}

.dl__country-heading {
    grid-column:      1 / -1;
    display:          flex;
    align-items:      center;
    gap:              var(--space-s, 0.75rem);
    font-size:        var(--h3, 1.5rem);
    font-family:      "Saira Semi Condensed", sans-serif;
    font-weight:      700;
    letter-spacing:   0.02em;
    padding-bottom:   0.5rem;
    margin-bottom:    var(--space-s, 0.75rem);
    margin-top:       var(--space-l, 2rem);
    color:            var(--text-dark, #111);
}

.dl__grid > .dl__country-heading:first-child {
    margin-top: 0;
}


/* ── Dealer card ─────────────────────────────────────────────── */
.dl-card {
    background:     var(--white, #fff);
    border:         1px solid var(--dl-border);
    border-left:    4px solid var(--primary);
    padding:        var(--space-m, 1.25rem);
    cursor:         pointer;
    transition:     box-shadow var(--dl-speed);
    position:       relative;
    display:        flex;
    flex-direction: column;
}

.dl-card:hover,
.dl-card:focus-visible {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    outline:    none;
}

/* ── Flag — bottom right of card ─────────────────────────────── */
.dl-card__flag {
    position:       absolute;
    bottom:         var(--space-s, 0.75rem);
    right:          var(--space-s, 0.75rem);
    font-size:      1.6em;
    line-height:    1;
    pointer-events: none;
}

.dl-card--highlight {
    border-color:      var(--neutral);
    border-left-color: var(--neutral);
    border-left-width: 4px;
}

.dl-card__top {
    display:         flex;
    justify-content: space-between;
    align-items:     flex-start;
    gap:             var(--space-s, 0.75rem);
    margin-bottom:   var(--space-xs, 0.5rem);
}

.dl-card__name {
    font-size:      var(--h3, 1.4rem);
    font-weight:    700;
    font-family:    'Saira Semi Condensed', sans-serif;
    text-transform: uppercase;
    color:          var(--text-dark, #111);
    line-height:    1.2;
}

.dl-card__distance {
    font-size:   var(--text-xs, 0.75rem);
    color:       var(--text-dark-muted, #888);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
    align-self:  center;
}

.dl-card__address {
    font-size:   var(--text-m);
    color:       var(--text-dark-muted, #555);
    font-style:  normal;
    line-height: 1.6;
    margin:      0 0 0.5rem;
}

.dl-card__types {
    display:     flex;
    gap:         var(--space-xs, 0.5rem);
    flex-wrap:   wrap;
    flex-shrink: 0;
    align-items: flex-start;
    padding-top: 0.15rem;
}

/* ── Type badges ─────────────────────────────────────────────── */
.dl-card__badge,
.dl-popup__types .dl-card__badge {
    display:        inline-block;
    padding:        0.3em 0.75em;
    font-size:      var(--text-xs, 0.8rem);
    font-weight:    600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dl-card__badge--dealer  { background: var(--primary); color: var(--neutral); }
.dl-card__badge--service { background: var(--neutral); color: #fff; }

/* ── Card contact links ──────────────────────────────────────── */
.dl-card__contacts {
    display:        flex;
    flex-direction: column;
    gap:            0.5rem;
    margin-top:     auto;
    padding-top:    var(--space-s, 0.75rem);
}

.dl-card__contact {
    display:         flex;
    align-items:     center;
    gap:             var(--space-s, 0.75rem);
    font-size:       var(--text-m);
    color:           var(--text-dark-muted, #555);
    text-decoration: none;
    word-break:      break-all;
    pointer-events:  auto;
    position:        relative;
    z-index:         1;
}

.dl-card__contact span {
    min-width: 0;
}

.dl-card__contact:hover {
    color:           var(--text-dark);
    text-decoration: underline;
}

/* ── SVG icons ───────────────────────────────────────────────── */
.dl-icon {
    width:       15px;
    height:      15px;
    flex-shrink: 0;
    opacity:     0.65;
}

/* ── Empty state ─────────────────────────────────────────────── */
.dl__empty {
    padding:    var(--space-l, 2rem);
    text-align: center;
    color:      var(--text-dark-muted, #888);
    font-size:  var(--text-s, 0.9rem);
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .dl__country-heading {
        font-size: var(--h4, 1.25rem);
    }
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .dl-card,
    .dl__search-btn,
    .dl__geo-btn { transition: none; }
}
