/* Styles for the dealer finder and the dealer pages. */


/* Finder search, on the photo band
   ========================================================================== */

/* The band is dark in both modes, so the fields and their drop-downs are too. */
.dealer-search {
    color-scheme: dark;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    align-items: end;
    gap: var(--space-3);
    width: 100%;
    max-width: 640px;
    margin-top: var(--space-2);
}

/* A select is drawn shorter than a text box, so both get the same height. */
.dealer-search .field__input {
    height: 52px;
    border-color: var(--color-hero-line);
    background: var(--color-hero-chip);
    color: var(--color-hero-text);
}

.dealer-search .field__input::placeholder {
    color: inherit;
    opacity: 0.7;
}

.dealer-search__atv {
    margin-top: var(--space-2);
}

/* On a phone the photo would push the search below the fold. */
@media (max-width: 899px) {
    .dealer-finder-hero .page-hero__media {
        display: none;
    }
}


/* Finder results bar
   ========================================================================== */

.dealer-bar {
    position: sticky;
    top: var(--header-height);
    z-index: 50;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.dealer-bar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-5);
    min-height: 64px;
    padding-block: var(--space-3);
}

/* On a phone the count wraps beside the List/Map switch rather than above it. */
.dealer-bar__count {
    flex: 1 1 12rem;
    font-size: var(--text-sm);
}

/* The search box shows the same choices, so phones leave these out to keep the bar to one line. */
.dealer-bar__filters {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.dealer-bar__clear {
    font-size: var(--text-sm);
    font-weight: 600;
}

.dealer-bar__view {
    display: inline-flex;
    margin-left: auto;
    overflow: hidden;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-button);
}

.dealer-bar__view button {
    min-height: 40px;
    padding: 0 var(--space-4);
    border: 0;
    background: transparent;
    color: var(--color-text);
    font-family: var(--font-label);
    font-size: var(--text-sm);
    font-weight: var(--button-weight);
    letter-spacing: var(--button-tracking);
    text-transform: var(--button-transform);
    cursor: pointer;
}

.dealer-bar__view button[aria-pressed="true"] {
    background: var(--color-primary);
    color: var(--color-on-primary);
}


/* Finder results and map
   ========================================================================== */

.dealer-finder {
    display: grid;
    gap: var(--space-6);
    padding-block: var(--space-6) var(--space-8);
}

/* Small screens show the list or the map, as the bar's switch says. */
.dealer-finder__map,
.dealer-finder.is-map .dealer-finder__results {
    display: none;
}

.dealer-finder.is-map .dealer-finder__map {
    display: block;
}

.dealer-finder__note {
    margin-top: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.dealer-finder .dealer-map {
    height: 70svh;
    min-height: 360px;
}

.dealer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: var(--space-5);
}


/* Dealer card
   ========================================================================== */

.dealer-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dealer-card:hover {
    border-color: var(--card-hover-border);
    box-shadow: var(--shadow-card-hover);
}

/* Its pin on the map is being pointed at. */
.dealer-card.is-active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary), var(--shadow-card-hover);
}

.dealer-card__media {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--color-footer-bg);
}

.dealer-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Logos are made for white, so this stays white in both modes. */
.dealer-card__media .dealer-card__logo {
    padding: var(--space-6);
    background: var(--color-media);
    object-fit: contain;
}

.dealer-card__tag {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    padding: 2px var(--space-2);
    border-radius: var(--radius-badge);
    background: var(--color-footer-bg);
    color: var(--color-footer-text);
    font-family: var(--font-label);
    font-size: var(--text-sm);
    font-weight: 700;
}

.dealer-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5) var(--space-5);
}

.dealer-card__showroom {
    color: var(--color-accent-text);
    font-family: var(--font-label);
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dealer-card__title {
    font-size: var(--text-lg);
}

.dealer-card__title a {
    color: inherit;
    text-decoration: none;
}

.dealer-card__title a:hover {
    text-decoration: underline;
}

.dealer-card__address {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.dealer-card__facts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.dealer-card__facts li {
    padding: 2px var(--space-2);
    border-radius: var(--radius-badge);
    background: var(--color-surface-raised);
    font-size: var(--text-sm);
    font-weight: 600;
}

.dealer-card__actions {
    display: flex;
    gap: var(--space-2);
    margin-top: auto;
    padding-top: var(--space-3);
}

.dealer-card__actions .btn--primary {
    flex: 1;
}

.dealer-card__icon {
    flex: none;
    width: 40px;
    padding: 0;
}


/* Maps
   ========================================================================== */

.dealer-map {
    height: 400px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface-raised);
}

.dealer-map__failed {
    display: grid;
    place-items: center;
    height: 100%;
    padding: var(--space-5);
    color: var(--color-text-muted);
    text-align: center;
}

/* Mapbox moves each pin by writing a transform on it, so the pin never sets its own. */
.map-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 28px;
    padding: 0 6px;
    border: 2px solid var(--color-on-primary);
    border-radius: var(--radius-button);
    background: var(--color-primary);
    color: var(--color-on-primary);
    box-shadow: 0 3px 8px rgb(0 0 0 / 0.35);
    font-family: var(--font-label);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    cursor: pointer;
}

/* A dealer's second showroom: the same badge, inverted. */
.map-pin--showroom {
    border-color: var(--color-primary);
    background: var(--color-surface);
    color: var(--color-accent-text);
}

.map-pin.is-active {
    z-index: 2;
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.dealer-map .mapboxgl-popup-content {
    padding: var(--space-3) var(--space-6) var(--space-3) var(--space-4);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-card-hover);
    font-family: var(--font-body);
}

.dealer-map .mapboxgl-popup-anchor-top .mapboxgl-popup-tip,
.dealer-map .mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip,
.dealer-map .mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip {
    border-bottom-color: var(--color-surface);
}

.dealer-map .mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip,
.dealer-map .mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip,
.dealer-map .mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip {
    border-top-color: var(--color-surface);
}

.dealer-map .mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
    border-right-color: var(--color-surface);
}

.dealer-map .mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
    border-left-color: var(--color-surface);
}

.dealer-map .mapboxgl-popup-close-button {
    padding: 2px 8px;
    color: var(--color-text);
    font-size: 1.25rem;
}

.map-popup {
    display: grid;
    gap: 2px;
    min-width: 160px;
}

.map-popup b {
    font-family: var(--font-heading);
}

.map-popup span {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.map-popup a {
    margin-top: var(--space-1);
    color: var(--color-accent-text);
    font-size: var(--text-sm);
    font-weight: 700;
}


/* Dealer page
   ========================================================================== */

.page-hero__facts a {
    color: inherit;
}

.dealer-hero__actions {
    margin-top: var(--space-2);
}

/* The dealer's own logo, first in the hero's text. It sits on white in both modes,
   like the brand logos, and keeps its shape whether it is wide or square. */
.dealer-hero__logo {
    order: -1;
    display: inline-flex;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-card);
    background: var(--color-media);
}

.dealer-hero__logo img {
    width: auto;
    max-width: min(220px, 60vw);
    height: auto;
    max-height: 56px;
    object-fit: contain;
}

/* Two to a row on a phone, with the phone number across the top. */
@media (max-width: 639px) {
    .dealer-hero__actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .dealer-hero__actions > :first-child {
        grid-column: 1 / -1;
    }

    .dealer-hero__actions .btn {
        padding-inline: var(--space-3);
    }
}

.btn .icon {
    flex: none;
}

.dealer-main {
    display: grid;
    gap: var(--space-8);
    padding-block: var(--space-7) var(--space-8);
}

/* Keeps a heading clear of the sticky header and section bar. */
.dealer-section {
    min-width: 0;
    scroll-margin-top: calc(var(--header-height) + 64px);
}

.dealer-section__more {
    margin: calc(var(--space-4) * -1) 0 var(--space-5);
    font-weight: 600;
}

[data-type-grid] > [hidden] {
    display: none;
}

/* Above the bike name's link, which covers the card. */
.demo-card__actions {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding-top: var(--space-3);
}

.dealer-visit,
.dealer-visit__info {
    display: grid;
    align-items: start;
    gap: var(--space-5);
}

.dealer-places {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    align-content: start;
    gap: var(--space-4);
}

.dealer-place {
    display: grid;
    align-content: start;
    gap: var(--space-2);
    padding: var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
}

.dealer-place h3 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-lg);
}

.dealer-place > p {
    color: var(--color-text-muted);
}

.dealer-place__links {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-1) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-sm);
}

.dealer-place__links a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.dealer-place__links .icon {
    flex: none;
    color: var(--color-accent-text);
}

.dealer-hours table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.dealer-hours th,
.dealer-hours td {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
    font-weight: 400;
    text-align: left;
}

.dealer-hours td {
    text-align: right;
}

.dealer-hours tr:last-child > * {
    border-bottom: 0;
}

.dealer-hours .is-today > * {
    color: var(--color-text);
    font-weight: 700;
}

.dealer-hours .is-today th {
    box-shadow: inset 3px 0 var(--color-primary);
    padding-left: var(--space-3);
}

/* Beside the showrooms on a wide screen, under them on a phone. */
.dealer-contact {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    scroll-margin-top: calc(var(--header-height) + 64px);
}

.dealer-contact h3 {
    font-size: var(--text-xl);
}

.dealer-contact__sent {
    margin-block: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-left: 4px solid var(--color-success);
    border-radius: var(--radius-card);
    background: var(--color-surface-raised);
    font-weight: 600;
}

.dealer-contact__form {
    display: grid;
    gap: var(--space-4);
    margin-top: var(--space-3);
}

.dealer-contact__message {
    min-height: 140px;
    resize: vertical;
}

.dealer-about {
    display: grid;
    gap: var(--space-6);
}

.dealer-about__text {
    display: grid;
    gap: var(--space-3);
    max-width: 70ch;
}

.dealer-about h3 {
    font-size: var(--text-lg);
}

/* "Visit Us Today!" in the dealer's own text, on a line of its own. */
.dealer-about__visit {
    display: block;
    margin-top: var(--space-2);
}

.dealer-brands {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
}

.dealer-brands li {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-button);
    background: var(--color-surface);
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Logos are made for white, so this stays white in both modes. */
.dealer-brands img {
    width: 36px;
    height: 36px;
    padding: 3px;
    border-radius: var(--radius-field);
    background: var(--color-media);
    object-fit: contain;
}


/* Wider screens
   ========================================================================== */

@media (min-width: 768px) {
    .dealer-bar__count {
        flex: none;
    }

    .dealer-bar__filters {
        display: flex;
    }
}

@media (min-width: 1000px) {
    .dealer-about {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    }
}

@media (min-width: 1100px) {
    .dealer-visit {
        grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    }

    /* Stays in view while the showrooms, hours and map scroll past. */
    .dealer-contact {
        position: sticky;
        top: calc(var(--header-height) + 64px);
    }
}

/* Room for the list and the map side by side, so the switch goes. */
@media (min-width: 1200px) {
    .dealer-bar__view {
        display: none;
    }

    .dealer-finder--map {
        grid-template-columns: minmax(0, 1fr) minmax(380px, 38%);
        align-items: start;
    }

    .dealer-finder.is-map .dealer-finder__results,
    .dealer-finder--map .dealer-finder__map {
        display: block;
    }

    .dealer-finder__map {
        position: sticky;
        top: calc(var(--header-height) + 64px + var(--space-5));
    }

    .dealer-finder .dealer-map {
        height: calc(100vh - var(--header-height) - 64px - var(--space-5) * 2 - 2rem);
        min-height: 420px;
    }
}
