/* ==========================================================================
   Buildings Near You — interactive map page
   Class prefix: map-page- / map-card / tg-pin / tg-cluster
   ========================================================================== */

.map-page {
    background-color: var(--sd-color-white);
}

/* ── Header ── */
.map-page__header {
    padding: clamp(7rem, 12vw, 10rem) clamp(1.5rem, 6vw, 4rem) clamp(2rem, 3vw, 2.75rem);
    background-color: var(--sd-color-white);
}

.map-page__header-inner {
    max-width: var(--sd-container-max, 1440px);
    margin-inline: auto;
}

.map-page__overline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--sd-font-family-primary);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--sd-color-cta);
    margin: 0 0 0.75rem;
}

.map-page__heading {
    font-family: var(--sd-font-family-primary);
    font-size: clamp(2.25rem, 5vw, 4rem); /* unified hero title scale */
    font-weight: 500;
    color: var(--sd-color-primary-dark);
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
}

.map-page__intro {
    font-family: var(--sd-font-family-primary);
    font-size: clamp(1rem, 1.4vw, 1.1rem);
    line-height: 1.7;
    color: var(--sd-color-gray-700, #404040);
    max-width: 640px;
    margin: 0 0 1.75rem;
}

/* ── Controls ── */
.map-page__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.map-page__search {
    display: flex;
    gap: 0.5rem;
}

.map-page__input {
    font-family: var(--sd-font-family-primary);
    font-size: 0.9375rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--sd-color-gray-300, #d4d4d4);
    border-radius: 999px;
    background: var(--sd-color-white);
    width: min(240px, 56vw);
}

.map-page__input:focus {
    outline: 2px solid var(--sd-color-cta);
    outline-offset: 1px;
    border-color: transparent;
}

.map-page__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--sd-font-family-primary);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.7rem 1.25rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.map-page__btn--primary {
    background-color: var(--sd-color-cta);
    color: #fff;
}

.map-page__btn--primary:hover {
    background-color: var(--sd-color-cta-strong, #4f6b30);
}

.map-page__btn--ghost {
    background: transparent;
    color: var(--sd-color-primary-dark);
    border: 1px solid var(--sd-color-gray-300, #d4d4d4);
}

.map-page__btn--ghost:hover {
    border-color: var(--sd-color-cta);
    color: var(--sd-color-cta);
}

.map-page__nearby {
    font-family: var(--sd-font-family-primary);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--sd-color-cta);
    margin: 0;
}

/* ── Filter chips ── */
.map-page__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.map-chip {
    font-family: var(--sd-font-family-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    border: 1px solid var(--sd-color-gray-300, #d4d4d4);
    background: var(--sd-color-white);
    color: var(--sd-color-gray-700, #404040);
    cursor: pointer;
    transition: all 0.2s ease;
}

.map-chip:hover {
    border-color: var(--sd-color-cta);
    color: var(--sd-color-cta);
}

.map-chip.is-active {
    background-color: var(--sd-color-primary-dark);
    border-color: var(--sd-color-primary-dark);
    color: #fff;
}

/* ── Map ── */
.map-page__map-wrap {
    position: relative;
}

.map-page__map {
    height: clamp(540px, 72vh, 840px);
    background: #eef1ea;
    z-index: 0;
}

.map-page__error {
    padding: 3rem;
    text-align: center;
    font-family: var(--sd-font-family-primary);
    color: var(--sd-color-gray-600);
}

/* Brand pins — coloured by sector category (see categoryOf in map-page.js) */
.map-page {
    --tg-cat-education: var(--sd-color-cta, #5f7d3a);
    --tg-cat-commercial: #274c77;
    --tg-cat-sport: #d98324;
    --tg-cat-residential: #8e5f9e;
}

.tg-pin {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--tg-cat-education);
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(42, 54, 36, 0.45);
    transition: transform 0.15s ease;
}

.tg-pin--education,  .tg-cat--education  { background: var(--tg-cat-education); }
.tg-pin--commercial, .tg-cat--commercial { background: var(--tg-cat-commercial); }
.tg-pin--sport,      .tg-cat--sport      { background: var(--tg-cat-sport); }
.tg-pin--residential,.tg-cat--residential{ background: var(--tg-cat-residential); }

.tg-pin-wrap:hover .tg-pin {
    transform: scale(1.35);
}

/* Pin holding more than one project at the same location */
.tg-pin--multi {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tg-pin--multi b {
    font-family: var(--sd-font-family-primary);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
}

/* You-are-here marker */
.tg-you-wrap {
    pointer-events: none; /* let clicks reach a building pin sitting at the same coords */
}
.tg-you {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2563eb;
    border: 3px solid #fff;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45);
    animation: tg-you-pulse 2s infinite;
}

@keyframes tg-you-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45); }
    70%  { box-shadow: 0 0 0 16px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

/* Clusters */
.tg-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(95, 125, 58, 0.92);
    color: #fff;
    font-family: var(--sd-font-family-primary);
    font-weight: 700;
    border: 3px solid #fff;
    box-shadow: 0 4px 14px rgba(42, 54, 36, 0.3);
}

.tg-cluster span { line-height: 1; }
.tg-cluster--sm { font-size: 0.8125rem; }
.tg-cluster--md { font-size: 0.875rem; background: rgba(90, 124, 54, 0.94); }
.tg-cluster--lg { font-size: 1rem; background: var(--sd-color-primary, #36452f); }

/* Single-category clusters take that category's colour (after the tier
   rules so the tint wins over the tier background). */
.tg-cluster--commercial  { background: var(--tg-cat-commercial); }
.tg-cluster--sport       { background: var(--tg-cat-sport); }
.tg-cluster--residential { background: var(--tg-cat-residential); }

/* ── Colour key ── */
.map-legend {
    position: absolute;
    left: 4.25rem; /* clear of the floating cookie-consent button */
    bottom: 0.75rem;
    z-index: 500;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
    max-width: min(320px, calc(100vw - 6rem));
    padding: 0.5rem 0.85rem;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(42, 54, 36, 0.18);
    font-family: var(--sd-font-family-primary);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sd-color-gray-700, #404040);
}

.map-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.map-legend__swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(42, 54, 36, 0.35);
    flex: none;
}

/* ── Detail card ── */
.map-card {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: min(360px, calc(100vw - 2.5rem));
    max-height: calc(100% - 2.5rem);
    overflow-y: auto;
    background: var(--sd-color-white);
    border: 1px solid rgba(54, 69, 47, 0.08);
    border-radius: 8px;
    box-shadow: 0 16px 44px rgba(42, 54, 36, 0.22);
    z-index: 500;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.map-card.is-open {
    opacity: 1;
    transform: translateY(0);
}

.map-card__close {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: var(--sd-color-primary-dark);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.map-card__media {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #eef1ea;
}

.map-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.map-card__body {
    padding: 1.25rem 1.25rem 1.375rem;
}

.map-card__title {
    font-family: var(--sd-font-family-primary);
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--sd-color-primary-dark);
    line-height: 1.3;
    margin: 0 0 0.6rem;
    padding-right: 1.5rem;
}

.map-card__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.6rem;
}

.map-card__chip {
    font-family: var(--sd-font-family-primary);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--sd-color-cta);
    background: rgba(95, 125, 58, 0.1);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
}

.map-card__address {
    font-family: var(--sd-font-family-primary);
    font-size: 0.8438rem;
    line-height: 1.5;
    color: var(--sd-color-gray-600, #525252);
    margin: 0 0 0.9rem;
}

/* The `hidden` attribute must win over the display rules on card children
   (map-card__link/media/list), or a hidden element still shows. */
.map-card [hidden] { display: none !important; }

.map-card__link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--sd-font-family-primary);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--sd-color-cta);
    text-decoration: none;
}

.map-card__link svg { transition: transform 0.25s ease; }
.map-card__link:hover svg { transform: translateX(3px); }

/* Multi-project list (several buildings at one location) */
.map-card__list {
    display: flex;
    flex-direction: column;
    margin-top: 0.1rem;
}
.map-card__item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.1rem;
    border-top: 1px solid var(--sd-color-gray-200, #e5e5e5);
    font-family: var(--sd-font-family-primary);
    font-size: 0.85rem;
    color: var(--sd-color-gray-800, #262626);
    text-decoration: none;
}
.map-card__item:first-child { border-top: 0; }
a.map-card__item:hover .map-card__item-name { text-decoration: underline; }
.map-card__item-name { flex: 1 1 auto; font-weight: 600; }
.map-card__item-use {
    flex: 0 0 auto;
    font-size: 0.7rem;
    color: var(--sd-color-gray-600, #525252);
    white-space: nowrap;
}
.map-card__item-arrow { flex: 0 0 auto; color: var(--sd-color-cta); font-weight: 700; }

/* ── Mobile ── */
@media (max-width: 767px) {

    .map-page__map {
        height: 62vh;
    }

    /* Bottom sheet instead of floating card */
    .map-card {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 68%;
        border-radius: 8px 8px 0 0;
        transform: translateY(100%);
    }

    .map-card.is-open {
        transform: translateY(0);
    }

    .map-card__media {
        aspect-ratio: 21 / 9;
    }

    .map-page__search {
        width: 100%;
    }

    .map-page__input {
        flex: 1;
        width: auto;
    }
}
