/* Full-screen map homepage */
html, body { height: 100%; margin: 0; }
body.map-shell { overflow: hidden; font-family: var(--sans); }

#map {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: #a9c7d8;
    z-index: 0;
}

/* ---------- Translucent collapsible nav overlay ---------- */
.map-panel {
    position: fixed;
    top: 0.75rem;
    left: 4rem; /* clear the Leaflet zoom controls on the top-left */
    z-index: 1000;
    width: min(340px, calc(100vw - 5.1rem));
    background: rgba(28, 26, 23, 0.55);
    -webkit-backdrop-filter: blur(12px) saturate(1.1);
    backdrop-filter: blur(12px) saturate(1.1);
    border: 1px solid rgba(176, 133, 67, 0.45);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    color: #f5f1e8;
    overflow: hidden;
    transition: box-shadow .2s ease;
}

.map-panel__bar {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .8rem 1rem;
    cursor: pointer;
    user-select: none;
}
.map-panel__mark { color: var(--gold); font-size: 1.5rem; line-height: 1; }
.map-panel__title { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; letter-spacing: .4px; flex: 1; }
.map-panel__toggle {
    width: 34px; height: 34px; border-radius: 10px;
    border: 1px solid rgba(245,241,232,.25);
    background: rgba(245,241,232,.08);
    display: grid; place-items: center; cursor: pointer;
    transition: background .15s ease;
}
.map-panel__toggle:hover { background: rgba(245,241,232,.18); }
.map-panel__toggle span, .map-panel__toggle span::before, .map-panel__toggle span::after {
    content: ""; display: block; width: 16px; height: 2px; background: #f5f1e8; position: relative; transition: transform .2s ease, opacity .2s ease;
}
.map-panel__toggle span::before { position: absolute; top: -5px; }
.map-panel__toggle span::after { position: absolute; top: 5px; }

/* Expanded (default): show an × to collapse the panel */
.map-panel__toggle span { transform: rotate(45deg); }
.map-panel__toggle span::before { transform: rotate(90deg) translateX(5px); }
.map-panel__toggle span::after { opacity: 0; }

/* Collapsible body */
.map-panel__body {
    max-height: 70vh;
    overflow-y: auto;
    padding: 0 1rem 1rem;
    transition: max-height .28s ease, opacity .2s ease, padding .28s ease;
}
.map-panel.collapsed .map-panel__body { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; }

/* Collapsed: show a hamburger (☰) to expand the panel */
.map-panel.collapsed .map-panel__toggle span { transform: none; }
.map-panel.collapsed .map-panel__toggle span::before { transform: none; }
.map-panel.collapsed .map-panel__toggle span::after { opacity: 1; }

.map-nav { display: flex; flex-direction: column; gap: .1rem; margin-bottom: .9rem; }
.map-nav a {
    color: #f5f1e8; padding: .5rem .6rem; border-radius: 9px; font-weight: 500; font-size: .95rem;
    display: flex; align-items: center; gap: .55rem;
}
.map-nav a:hover { background: rgba(245,241,232,.12); text-decoration: none; }

.map-nav__admin { margin-top: .45rem; align-self: flex-start; border: 1px solid rgba(245,241,232,.22); }
.map-nav__admin.is-on { color: #7bd88f; }
.map-nav__admin.is-off { color: #f0b37a; }
.map-nav__admin:hover { background: rgba(245,241,232,.12); }

.map-panel__divider { height: 1px; background: rgba(245,241,232,.15); margin: .5rem 0 .9rem; }
.map-panel__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: rgba(245,241,232,.6); margin: 0 0 .35rem; font-weight: 600; }

.map-filter { display: flex; flex-direction: column; gap: .7rem; }
.map-filter input, .map-filter select {
    width: 100%; padding: .5rem .6rem; border-radius: 9px;
    border: 1px solid rgba(245,241,232,.22);
    background: rgba(245,241,232,.1); color: #f5f1e8; font-size: .9rem;
}
.map-filter input::placeholder { color: rgba(245,241,232,.55); }
.map-filter select option { color: #1c1a17; }
.map-filter input:focus, .map-filter select:focus { outline: none; border-color: var(--gold); background: rgba(245,241,232,.16); }

.map-count { font-size: .82rem; color: rgba(245,241,232,.7); margin-top: .7rem; }
.map-count b { color: var(--gold); }

/* Subtle version tag at the bottom of the menu */
.map-panel .app-version {
    display: block; margin-top: .8rem; text-align: right;
    font-size: .68rem; letter-spacing: .5px; color: rgba(245,241,232,.4);
}

/* Loading + error toast */
.map-toast {
    position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
    z-index: 1100; background: rgba(28,26,23,.85); color: #f5f1e8;
    padding: .6rem 1.1rem; border-radius: 999px; font-size: .88rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.3); border: 1px solid rgba(176,133,67,.4);
}

/* ---------- Marker + popup styling ---------- */
.castle-pin {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    background: var(--gold, #b08543);
    color: #fff; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid #fffdf8;
    box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.castle-pin span { transform: rotate(45deg); font-size: 15px; line-height: 1; }

.leaflet-popup-content-wrapper { border-radius: 14px; padding: 0; overflow: hidden; box-shadow: 0 12px 32px rgba(0,0,0,.25); }
.leaflet-popup-content { margin: 0; width: 264px !important; }
.leaflet-popup-content p { margin: 0; }
.castle-popup__img { width: 100%; height: 150px; object-fit: cover; display: block; background: #ece5d6; }
.castle-popup__body { padding: .8rem .9rem 1rem; font-family: var(--sans, sans-serif); }
.castle-popup__title { font-family: var(--serif, serif); font-size: 1.3rem; font-weight: 700; color: #1c1a17; line-height: 1.1; margin: 0 0 .2rem; }
.castle-popup__meta { font-size: .8rem; color: #6b6459; margin-bottom: .5rem; }
.castle-popup__desc { font-size: .85rem; color: #4a453e; margin-bottom: .7rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.castle-popup__badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 600; background: #ece5d6; color: #8a6630; margin-bottom: .5rem; }
.castle-popup__link { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .88rem; color: #8a6630; }

/* Cluster color tuned to the palette */
.marker-cluster-castle { background: rgba(176,133,67,.35); }
.marker-cluster-castle div { background: rgba(176,133,67,.85); color: #fff; font-family: var(--sans, sans-serif); font-weight: 600; }

.leaflet-control-layers { border-radius: 12px !important; box-shadow: 0 8px 24px rgba(0,0,0,.2) !important; }
