/**
 * bw_locations frontend styles.
 *
 * Colours are declared as custom properties so integrators can adapt the
 * appearance from their own stylesheet without overriding rules.
 */

.bwlocations {
    --bwlocations-accent: #1268ff;
    --bwlocations-text: #1c2b3d;
    --bwlocations-muted: #64748b;
    --bwlocations-border: #dce5f1;
    --bwlocations-surface: #ffffff;
    --bwlocations-surface-alt: #f5f8fc;
    --bwlocations-radius: 12px;
    --bwlocations-height: 520px;
    --bwlocations-panel-width: 360px;

    /*
     * One frame around head, toolbar and both columns: the list and the map
     * belong to the same component and should not read as separate blocks.
     */
    overflow: hidden;
    border: 1px solid var(--bwlocations-border);
    border-radius: var(--bwlocations-frame-radius, 24px);
    background: var(--bwlocations-surface-alt);
    color: var(--bwlocations-text);
}

.bwlocations__body {
    display: grid;
}

.bwlocations--left .bwlocations__body {
    grid-template-columns: var(--bwlocations-panel-width) minmax(0, 1fr);
}

.bwlocations--right .bwlocations__body {
    grid-template-columns: minmax(0, 1fr) var(--bwlocations-panel-width);
}

.bwlocations--right .bwlocations__panel {
    order: 2;
    border-right: 0;
    border-left: 1px solid var(--bwlocations-border);
}

.bwlocations--below .bwlocations__body,
.bwlocations--nolist .bwlocations__body {
    grid-template-columns: minmax(0, 1fr);
}

.bwlocations--below .bwlocations__panel {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--bwlocations-border);
}

@media (max-width: 900px) {
    .bwlocations--left .bwlocations__body,
    .bwlocations--right .bwlocations__body {
        grid-template-columns: minmax(0, 1fr);
    }

    .bwlocations__panel {
        order: 2;
        /* Stacked below the map the list may grow with its content. */
        height: auto;
        max-height: none;
        border-right: 0;
        border-left: 0;
        border-top: 1px solid var(--bwlocations-border);
    }

    .bwlocations__list {
        overflow-y: visible;
    }
}

/* The list below the map is not height-bound either. */
.bwlocations--below .bwlocations__panel {
    height: auto;
}

/*
 * Fallback width, used when no container class is configured. Installations
 * with their own layout set bwlocations.containerClass instead.
 */
.bwlocations-container {
    width: 100%;
    max-width: 1180px;
    margin-inline: auto;
}

/* Section head ------------------------------------------------------------- */

.bwlocations__head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--bwlocations-border);
    background: var(--bwlocations-surface);
}

.bwlocations__headtext {
    flex: 1 1 auto;
    min-width: 0;
}

.bwlocations__headline {
    margin: 0;
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.bwlocations__subline {
    margin: 4px 0 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--bwlocations-muted);
}

/* Toolbar ------------------------------------------------------------------ */

.bwlocations__toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--bwlocations-border);
    background: var(--bwlocations-surface-alt);
}

/* The search takes the free width, the counter keeps its content width. */
.bwlocations__toolbar .bwlocations__search {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 620px) {
    .bwlocations__toolbar {
        flex-wrap: wrap;
    }
}

/* Panel -------------------------------------------------------------------- */

/*
 * Fixed to the map height so both columns end on the same line. Search field
 * and counter sit inside this height; the list takes what remains.
 */
.bwlocations__panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: var(--bwlocations-height);
    padding: 12px;
    border-right: 1px solid var(--bwlocations-border);
    background: var(--bwlocations-surface-alt);
}

.bwlocations__search {
    flex: 0 0 auto;
}

/*
 * The label duplicates the placeholder visually. It stays in the markup for
 * screen readers, which do not announce a placeholder reliably.
 */
.bwlocations__searchlabel {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.bwlocations__searchfield {
    position: relative;
    display: flex;
    align-items: center;
}

.bwlocations__searchfield .bwlocations__icon {
    position: absolute;
    left: 14px;
    color: var(--bwlocations-muted);
    pointer-events: none;
}

.bwlocations__searchinput {
    width: 100%;
    height: 46px;
    padding: 0 44px;
    border: 1px solid var(--bwlocations-border);
    border-radius: var(--bwlocations-radius);
    background: var(--bwlocations-surface);
    color: inherit;
    font: inherit;
}

.bwlocations__searchinput:focus {
    outline: none;
    border-color: var(--bwlocations-accent);
    box-shadow: 0 0 0 3px rgba(18, 104, 255, 0.15);
}

/*
 * The browser's own clear control is hidden: it appears only in some engines
 * and sits where the custom button already is.
 */
.bwlocations__searchinput::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/*
 * Hidden until something is typed, so the field is not cluttered by a control
 * that would do nothing.
 */
.bwlocations__searchclear {
    position: absolute;
    right: 6px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--bwlocations-muted);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms, color 200ms, background 200ms;
}

.bwlocations__search.has-value .bwlocations__searchclear {
    opacity: 1;
    pointer-events: auto;
}

.bwlocations__searchclear:hover,
.bwlocations__searchclear:focus-visible {
    color: var(--bwlocations-accent);
    background: var(--bwlocations-surface-alt);
}

.bwlocations__count {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px 13px;
    border: 1px solid var(--bwlocations-border);
    border-radius: 99px;
    background: var(--bwlocations-surface-alt);
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--bwlocations-muted);
}

/* Live dot, signalling that the number follows the search. */
.bwlocations__count::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--bwlocations-accent);
    box-shadow: 0 0 10px var(--bwlocations-accent);
}

/* Without a number there is nothing to announce and nothing to show. */
.bwlocations__count:empty {
    display: none;
}

.bwlocations__noresults {
    margin: 0;
    padding: 40px 20px;
    text-align: center;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--bwlocations-muted);
}

.bwlocations__noresults[hidden] {
    display: none;
}

/*
 * Flex column instead of grid: grid rows would stretch or squeeze the items to
 * fill the track, which cut off card content.
 */
.bwlocations__list {
    margin: 0;
    padding: 0 4px 0 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}


.bwlocations--below .bwlocations__list {
    max-height: none;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.bwlocations__item {
    position: relative;
    /* Never shrink: the card must show its full content. */
    flex: 0 0 auto;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--bwlocations-border);
    border-radius: var(--bwlocations-radius);
    background: var(--bwlocations-surface);
    transition: border-color 220ms, box-shadow 220ms, transform 220ms;
}

/* Accent bar marking the active entry, animated instead of shifting layout. */
.bwlocations__item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--bwlocations-accent);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 220ms;
}

.bwlocations__item:hover,
.bwlocations__item:focus-visible {
    border-color: var(--bwlocations-accent);
    box-shadow: 0 6px 18px rgba(3, 25, 51, 0.08);
    transform: translateY(-1px);
    outline: none;
}

.bwlocations__item.is-active {
    border-color: var(--bwlocations-accent);
    box-shadow: 0 8px 24px rgba(18, 104, 255, 0.14);
}

.bwlocations__item.is-active::before {
    transform: scaleY(1);
}

.bwlocations__item[hidden] {
    display: none;
}

.bwlocations__card {
    padding: 18px 20px;
}

.bwlocations__cardhead {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bwlocations-border);
}

/*
 * Colours are set explicitly rather than inherited: host themes frequently
 * style headings globally, which would make the text unreadable on the card.
 */
.bwlocations__cardtitle,
.bwlocations .bwlocations__cardtitle {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--bwlocations-text);
}

.bwlocations__cardsubtitle {
    margin: 4px 0 0;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--bwlocations-muted);
}

/* Icon rows ---------------------------------------------------------------- */

.bwlocations__icon {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}

.bwlocations__row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 9px;
    font-size: 0.88rem;
    line-height: 1.5;
}

.bwlocations__row > .bwlocations__icon {
    /* Aligns the icon with the cap height of the first line. */
    margin-top: 2px;
    color: var(--bwlocations-accent);
}

.bwlocations__rowlabel {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.bwlocations__address {
    margin: 0;
    font-style: normal;
}

.bwlocations__hours ul,
.bwlocations__hourslist {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--bwlocations-muted);
}

.bwlocations__contactlink {
    color: var(--bwlocations-accent);
    text-decoration: none;
    word-break: break-word;
}

.bwlocations__contactlink:hover {
    text-decoration: underline;
}

.bwlocations__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--bwlocations-border);
}

.bwlocations__action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border: 1px solid var(--bwlocations-border);
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    color: var(--bwlocations-text);
    transition: border-color 200ms, color 200ms, background 200ms;
}

.bwlocations__action .bwlocations__icon {
    width: 15px;
    height: 15px;
}

.bwlocations__action:hover {
    border-color: var(--bwlocations-accent);
    background: rgba(18, 104, 255, 0.06);
    color: var(--bwlocations-accent);
}

.bwlocations__action--detail {
    background: var(--bwlocations-accent);
    border-color: var(--bwlocations-accent);
    color: #fff;
}

.bwlocations__action--detail:hover {
    background: var(--bwlocations-accent);
    color: #fff;
    filter: brightness(1.08);
}

@media (prefers-reduced-motion: reduce) {
    .bwlocations__item,
    .bwlocations__item::before,
    .bwlocations__action {
        transition: none;
    }

    .bwlocations__item:hover {
        transform: none;
    }
}

.bwlocations__empty {
    padding: 18px;
    border: 1px dashed var(--bwlocations-border);
    border-radius: var(--bwlocations-radius);
    color: var(--bwlocations-muted);
    text-align: center;
}

/* Map ---------------------------------------------------------------------- */

/* No radius of its own: the surrounding frame already clips the corners. */
.bwlocations__mapwrap {
    position: relative;
    min-width: 0;
    height: var(--bwlocations-height);
    overflow: hidden;
    background: var(--bwlocations-surface-alt);
}

.bwlocations__map {
    width: 100%;
    height: 100%;
}

/*
 * The texts come from the template via data attributes, so they follow the
 * site language instead of being fixed in the stylesheet.
 */
.bwlocations__map.is-loading::after {
    content: attr(data-loading-label);
}

.bwlocations__map.is-failed::after {
    content: attr(data-failed-label);
}

.bwlocations__map.is-loading::after,
.bwlocations__map.is-failed::after {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    text-align: center;
    color: var(--bwlocations-muted);
    font-size: 0.9rem;
}

/* Consent gate ------------------------------------------------------------- */

.bwlocations__consent {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bwlocations-surface-alt);
}

.bwlocations__consent[hidden] {
    display: none;
}

.bwlocations__consentinner {
    max-width: 460px;
    text-align: center;
}

.bwlocations__consenttitle {
    margin: 0 0 10px;
    font-size: 1.05rem;
    font-weight: 700;
}

.bwlocations__consenttext {
    margin: 0 0 18px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--bwlocations-muted);
}

.bwlocations__consentbutton {
    padding: 11px 22px;
    border: 0;
    border-radius: 999px;
    background: var(--bwlocations-accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.bwlocations__consentbutton:hover {
    filter: brightness(1.08);
}

.bwlocations__consentbutton:focus-visible {
    outline: 2px solid var(--bwlocations-accent);
    outline-offset: 3px;
}

/* Popup -------------------------------------------------------------------- */

.bwlocations__popup {
    min-width: 200px;
    font-size: 0.88rem;
    line-height: 1.5;
}

.bwlocations__popuptitle {
    display: block;
    font-size: 1rem;
    margin-bottom: 2px;
}

.bwlocations__popupsubtitle {
    display: block;
    margin-bottom: 8px;
    color: var(--bwlocations-muted);
}

.bwlocations__popupaddress {
    font-style: normal;
    margin-bottom: 8px;
}

.bwlocations__popuphours {
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
    color: var(--bwlocations-muted);
}

.bwlocations__popuplink,
.bwlocations__popuproute {
    display: block;
    color: var(--bwlocations-accent);
    text-decoration: none;
}

.bwlocations__popuproute {
    margin-top: 6px;
    font-weight: 600;
}

/* Detail view -------------------------------------------------------------- */

.bwlocations-detail__title {
    margin: 0 0 6px;
}

.bwlocations-detail__subtitle {
    margin: 0 0 20px;
    color: #64748b;
}

.bwlocations-detail__figure {
    margin: 0 0 24px;
}

.bwlocations-detail__figure img {
    width: 100%;
    height: auto;
    border-radius: 12px;
}

.bwlocations-detail__body {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 28px;
    align-items: start;
}

@media (max-width: 900px) {
    .bwlocations-detail__body {
        grid-template-columns: 1fr;
    }
}

.bwlocations-detail__block {
    padding: 18px;
    margin-bottom: 16px;
    border: 1px solid #dce5f1;
    border-radius: 12px;
}

.bwlocations-detail__blocktitle {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
}

.bwlocations__contactlist {
    margin: 0;
    font-size: 0.9rem;
}

.bwlocations__contactlist dt {
    font-weight: 600;
    margin-top: 8px;
}

.bwlocations__contactlist dt:first-child {
    margin-top: 0;
}

.bwlocations__contactlist dd {
    margin: 2px 0 0;
}

.bwlocations__contactlist a {
    color: #1268ff;
    text-decoration: none;
}
