/* Public dealer map. Shown inside an iframe on the company website, so it stays plain and neutral,
   with KHL blue for actions. */

:root {
    color-scheme: light;

    --ink: #1f2a33;
    --ink-muted: #5b6670;
    --bg: #ffffff;
    --panel: #e8eef1;          /* light blue-grey, like the old search bar */
    --line: #d3dbe0;
    --brand: #005b85;          /* KHL blue */
    --brand-hover: #00476a;
    --brand-ink: #ffffff;
    --selected: #e3f0f6;
    --radius: 4px;

    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 100%;
    line-height: 1.45;
    color: var(--ink);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
}

a {
    color: var(--brand);
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

/* ---------- Search bar ---------- */

.search {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
    padding: 0.875rem 1rem;
    background: var(--panel);
}

.search-field {
    display: grid;
    gap: 0.25rem;
    flex: 1 1 12rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.search-field-wide {
    flex: 2 1 14rem;
}

.search-field-narrow {
    flex: 0 1 9rem;
}

.search-field select,
.search-field input {
    min-height: 2.5rem;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-weight: 400;
    font-size: 1rem;
}

.search-field input:disabled,
.search-field select:disabled {
    background: var(--panel);
    color: var(--ink-muted);
}

.search-actions {
    display: flex;
    gap: 0.5rem;
}

.btn {
    min-height: 2.5rem;
    padding: 0.375rem 1rem;
    border: 1px solid var(--brand);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--brand);
    font: inherit;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.btn:hover {
    background: var(--selected);
}

.btn-primary {
    background: var(--brand);
    color: var(--brand-ink);
}

.btn-primary:hover {
    background: var(--brand-hover);
}

.btn-small {
    min-height: 2rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
}

.summary {
    margin: 0;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink-muted);
    font-size: 0.9375rem;
}

/* ---------- Map (and the fallback list) ---------- */

.results {
    display: grid;
}

.map {
    height: min(75vh, 42rem);
    min-height: 24rem;
}

/* Only shown when the map can't load. */
.dealer-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dealer-list > li {
    display: grid;
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid var(--line);
}

.dealer-list > li > .btn {
    justify-self: start;
}

.dealer {
    display: grid;
    gap: 0.25rem;
    font-size: 0.9375rem;
}

.dealer-name {
    margin: 0;
    font-size: 1rem;
}

.dealer-address,
.dealer-distance {
    margin: 0;
    color: var(--ink-muted);
}

.dealer-distance {
    font-weight: 600;
}

.dealer-contact {
    display: grid;
    gap: 0.125rem;
    margin: 0.25rem 0 0;
    padding: 0;
    list-style: none;
    overflow-wrap: anywhere;
}

.dealer-brands {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
}

.dealer-brands li {
    display: grid;
    place-items: center;
    min-width: 4.5rem;
    height: 2.25rem;
    padding: 0.25rem 0.375rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.dealer-brands li.is-selected {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px var(--brand);
}

.dealer-brands img {
    max-width: 5.5rem;
    max-height: 1.625rem;
    object-fit: contain;
}

/* Popup on the map uses the same markup. */
.gm-style .dealer {
    max-width: 18rem;
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- Pins ---------- */

/* All pins point at the exact spot with a tip at the bottom. */
.pin {
    position: relative;
    display: grid;
    place-items: center;
    border: 2px solid var(--brand);
    background: #ffffff;
    box-shadow: 0 1px 4px rgb(0 0 0 / 0.3);
    transform: translateY(-0.5rem);
}

.pin::after {
    content: "";
    position: absolute;
    bottom: -0.5rem;
    left: 50%;
    border: 0.4rem solid transparent;
    border-top-color: var(--brand);
    border-bottom: 0;
    transform: translateX(-50%);
}

/* A manufacturer is selected: its logo. */
.pin-logo {
    width: 4.25rem;
    height: 2.5rem;
    padding: 0.25rem;
    border-radius: var(--radius);
}

.pin-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Selected manufacturer without a logo yet: its name. */
.pin-name {
    max-width: 7rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    background: var(--brand);
    color: var(--brand-ink);
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
}

/* All manufacturers: KHL blue pin with the number of manufacturers the dealer sells. */
.pin-count {
    width: 2rem;
    height: 2rem;
    border-color: #ffffff;
    border-radius: 50%;
    background: var(--brand);
    color: var(--brand-ink);
    font-size: 0.875rem;
    font-weight: 700;
}

.pin-count::after {
    bottom: -0.55rem;
    border-top-color: var(--brand);
}

/* A group of nearby dealers when zoomed out: a dark, larger circle without a tip. */
.cluster {
    display: grid;
    place-items: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.5rem;
    border: 3px solid rgb(255 255 255 / 0.85);
    border-radius: 999px;
    background: var(--ink);
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 700;
    box-shadow: 0 0 0 4px rgb(31 42 51 / 0.25);
}

/* ---------- Logo strip ---------- */

.logo-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 1rem 1.5rem;
    align-items: center;
    justify-items: center;
    padding: 1.25rem 1rem;
    background: var(--panel);
}

.logo-strip a,
.logo-strip span {
    display: block;
}

.logo-strip img {
    display: block;
    max-width: 9.5rem;
    max-height: 3.5rem;
    object-fit: contain;
}

.logo-strip a:hover img {
    opacity: 0.8;
}

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
    .map {
        height: 65vh;
        min-height: 20rem;
    }
}

/* ---------- Error page ---------- */

.page-message {
    max-width: 40rem;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.muted {
    color: var(--ink-muted);
}
