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

:root {
    --brand: #fecd08;
    --surface: #ffffff;
    --brand-bg-light: #fff8d6;
    --brand-fg-dark: #8a6700;
    --border: #e4e7ec;
    --text-1: #111827;
    --text-2: #4b5563;
    --text-3: #9ca3af;
    --radius: 10px;
}

html,
body {
    height: 100%;
    font-family: "DM Sans", sans-serif;
    overflow: hidden;
}
body.cards-view {
    height: auto;
    min-height: 100%;
    overflow: visible;
    background: #f8fafc;
}
html:has(body.cards-view) {
    height: auto;
    overflow: visible;
}

/* ── Map ── */
#map {
    width: 100%;
    height: 100%;
    min-height: 480px;
}
body.cards-view #map {
    display: block;
    height: 600px;
    min-height: 420px;
    width: 100%;
}
.maplibregl-ctrl-attrib {
    display: none !important;
}
.maplibregl-ctrl-geocoder {
    font-family: "DM Sans", sans-serif;
    margin: 12px;
    min-width: 280px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.12);
}
.maplibregl-ctrl-geocoder input:focus {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

/* ── Cards view ── */
#cards-view {
    display: none;
    margin: 0 2rem;
    padding-top: 18px;
}
body.cards-view #cards-view {
    display: block;
}

.cards-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}
.cards-subtitle {
    font-size: 13px;
    color: var(--text-2);
}
.cards-count {
    font-family: "DM Mono", monospace;
    color: var(--text-3);
}

.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 16px;
    margin-bottom: 32px;
}
@media (min-width: 720px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 14px 14px 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    transition:
        transform 0.15s,
        border-color 0.15s,
        box-shadow 0.15s;
}
.card:hover,
.card:focus-visible,
.card.active {
    transform: translateY(-1px);
    border-color: var(--brand);
    box-shadow: 0 10px 26px rgba(26, 86, 219, 0.12);
    outline: none;
}
.card-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}
.card-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

.card-address {
    font-size: 12px;
    color: var(--text-2);
    line-height: 1.45;
}

.text-break {
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
    min-width: 0;
}


.cards-empty {
    font-size: 13px;
    color: var(--text-3);
}

.pills {
    flex: 1;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-direction: row;
    flex-wrap: wrap;
}

/* ── Access-type pills ── */
.pu-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    font-family: "DM Sans", sans-serif;
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 8px;
    white-space: nowrap;
    width: max-content;
}


.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    font-family: "DM Sans", sans-serif;
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 8px;
    white-space: nowrap;
    width: max-content;
}

.access-public {
    background: #fff8d6;
    color: #8a6700;
}
.access-tenant {
    background: #fff3b0;
    color: #7a5c00;
}

/* ── Door availability badges ── */
.door-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.availability-as-of {
    color: var(--text-3);
    font-size: 10px;
    white-space: nowrap;
}
.card .door-section {
    padding: 0;
    border-bottom: 0;
}
.door-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    font-family: "DM Sans", sans-serif;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    width: max-content;
}
.door-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.door-available {
    background: #e7f6ec;
    color: #137333;
}
.door-available::before {
    background: #137333;
}
.door-full {
    background: #f1f2f4;
    color: #6b7280;
}
.door-full::before {
    background: #9ca3af;
}

/* ── Loading ── */
#loading {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 2000;
}
body.cards-view #loading {
    background: rgba(248, 250, 252, 0.9);
}
.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
#loading p {
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
}

/* ── Error banner ── */
#error-banner {
    display: none;
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 10px 16px;
    font-size: 13px;
    color: #991b1b;
    z-index: 1500;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    max-width: 90vw;
}
body.cards-view #error-banner {
    position: static;
    transform: none;
    margin: 0 auto 12px;
    white-space: normal;
    max-width: 100%;
}

/* ── Marker ── */
.locker-pin-icon {
    cursor: pointer;
}

/* ── Popup ── */
.maplibregl-popup-content {
    border-radius: var(--radius) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.13) !important;
    padding: 0 !important;
    overflow: hidden;
    border: 1px solid var(--border);
    font-family: "DM Sans", sans-serif;
    width: 320px;
}
.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
    border-bottom-color: var(--surface);
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
    border-top-color: var(--surface);
}

.pu-header {
    padding: 13px 15px 11px;
    border-bottom: 1px solid var(--border);
}
.pu-row1 {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
}
.pu-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
    line-height: 1.35;
    max-width: 135px;
}
.pu-addr {
    font-size: 12px;
    color: var(--text-2);
    line-height: 1.45;
    margin-bottom: 3px;
}

.pu-section {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
}
.pu-section:last-child {
    border-bottom: none;
}
.pu-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
}
.pu-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.pu-label-row .pu-label {
    margin-bottom: 0;
}
.pu-label-row .status-badge {
    margin-bottom: 0;
}
.status-badge.is-open {
    background: #e7f6ec;
    color: #137333;
}
.status-badge.is-closed {
    background: #fdecec;
    color: #b3261e;
}

.pu-hours-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-2);
}
.pu-hours-days {
    font-weight: 500;
    color: var(--text-1);
    min-width: 90px;
    flex-shrink: 0;
}
.badge-24 {
    font-size: 10px;
    font-weight: 600;
    font-family: "DM Mono", monospace;
    color: var(--brand-fg-dark);
    background: var(--brand-bg-light);
    padding: 1px 6px;
    border-radius: 4px;
}
.pu-no-hours {
    font-size: 12px;
    color: var(--text-3);
}

.pu-img-wrap {
    width: 100%;
    background: var(--border);
    max-height: 350px;
    overflow: auto;
}

.pu-img-container {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 0;
}

.pu-img-container.multi {
    grid-template-columns: repeat(2, 1fr);
}

.pu-img-container.many {
    grid-template-columns: repeat(3, 1fr);
}

.pu-img {
    display: block;
    width: 100% !important;
    height: 160px !important;
    max-height: 160px !important;
    min-height: 160px !important;
    aspect-ratio: auto !important;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}

.pu-img:hover {
    opacity: 0.85;
}
