/**
 * Branch Location page
 *
 * Towns on the left, the branches in the selected town on the right.
 */

.branch-locator {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 40px;
    align-items: start;
    margin: 10px 0 20px;
}

/* Town list */
.branch-towns {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.branch-town {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 16px 18px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-left: 3px solid transparent;
    border-radius: var(--radius-md);
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
}

.branch-town:hover {
    border-color: var(--color-primary);
}

.branch-town.is-active {
    background: var(--purple-50);
    border-color: var(--color-border);
    border-left-color: var(--color-primary);
}

.branch-town-name {
    color: var(--color-primary);
    font-size: 1.05rem;
    font-weight: 600;
}

.branch-town-count {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Branch panel */
.branch-panel {
    display: none;
}

.branch-panel.is-active {
    display: block;
}

.branch-panel-title {
    font-family: var(--font-heading);
    color: var(--color-primary);
    font-size: 1.4rem;
    margin: 0 0 18px;
}

.branch-card {
    padding: 20px 22px;
    margin-bottom: 16px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.branch-card:last-child {
    margin-bottom: 0;
}

.branch-card-name {
    color: var(--color-primary);
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 8px;
}

.branch-card-address {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    margin: 0 0 14px;
}

.branch-card-mobile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-primary);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
}

.branch-card-mobile:hover {
    color: var(--color-primary-dark);
}

@media (max-width: 767px) {
    .branch-locator {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    /* One town per row is a lot of scrolling on a phone, so they sit inline. */
    .branch-towns {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .branch-town {
        width: auto;
        flex: 1 1 160px;
    }

    /*
     * Accordion mode. The script moves each panel under the town that opens it
     * and flags the locator, so without JavaScript the tabbed layout above
     * stays and every branch is still listed.
     */
    .branch-locator.is-accordion {
        gap: 0;
    }

    .is-accordion .branch-panels {
        display: none;
    }

    .is-accordion .branch-towns {
        flex-direction: column;
        gap: 12px;
    }

    .is-accordion .branch-town {
        display: grid;
        grid-template-columns: 1fr 16px;
        align-items: center;
        gap: 4px 12px;
        width: 100%;
        flex: none;
    }

    .is-accordion .branch-town-name,
    .is-accordion .branch-town-count {
        grid-column: 1;
    }

    /* Chevron, pointing down when shut and up once the town is open. */
    .is-accordion .branch-town::after {
        content: "";
        grid-column: 2;
        grid-row: 1 / span 2;
        justify-self: end;
        width: 9px;
        height: 9px;
        margin-top: -3px;
        border-right: 2px solid var(--color-primary);
        border-bottom: 2px solid var(--color-primary);
        transform: rotate(45deg);
        transition: var(--transition-fast);
    }

    .is-accordion .branch-town.is-active::after {
        margin-top: 3px;
        transform: rotate(-135deg);
    }

    .is-accordion .branch-town.is-active {
        border-bottom-color: transparent;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    /* The open panel butts up against the town button that opened it. */
    .is-accordion .branch-panel.is-active {
        margin-top: -12px;
        padding: 4px 18px 18px;
        background: var(--purple-50);
        border: 1px solid var(--color-border);
        border-top: 0;
        border-left: 3px solid var(--color-primary);
        border-radius: 0 0 var(--radius-md) var(--radius-md);
        animation: branch-panel-open 0.18s ease;
    }

    /* The town button already names the town. */
    .is-accordion .branch-panel-title {
        display: none;
    }

    .is-accordion .branch-card {
        padding: 14px 16px;
        margin-bottom: 12px;
    }

    @keyframes branch-panel-open {
        from {
            opacity: 0;
            transform: translateY(-6px);
        }

        to {
            opacity: 1;
            transform: none;
        }
    }
}
