/* =======================================
   1. Color Variables (Custom Properties)
   ======================================= */
:root {
    --color-dark-base: #131414; /* Dark background */
    --color-gold-text: #B4905B; /* Primary text/Modal color */
    --color-gold-light: #C79F52; /* Title accent */
    --color-gold-hover: #c49d54; /* Hover/Interaction color */
    --color-copper: #7A5829; /* Secondary button/Dark accent */
    --color-neutral: #6c757d; /* Neutral/Caption color */
}

/* =======================================
   2. Base Layout & Map
   ======================================= */
body { 
    margin: 0; 
    padding: 0; 
    height: 100vh;
    overflow: hidden; 
    background-color: #f8f9fa; 
}
#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

/* =======================================
   3. Custom Marker & Label Styling
   ======================================= */
@keyframes soft-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); filter: brightness(1.2); }
}

/* Marker */
.custom-marker {
    font-size: 30px; 
    color: var(--color-copper);
    cursor: pointer;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -100%); 
    transition: color 0.3s; 
    display: inline-block; 
    z-index: 1;
}

/* Marker Icon Animation */
.fa-icon {
    display: inline-block; 
    transition: color 0.3s;
    will-change: transform;
}
.custom-marker:hover .fa-icon {
    color: var(--color-gold-hover); 
    animation: soft-pulse 1.5s infinite ease-in-out alternate;
    text-shadow: 0 0 8px var(--color-gold-hover);
}
.custom-marker:hover {
    color: var(--color-gold-hover);
}

/* Marker Label (The 'Rollout' Element) */
.marker-label {
    position: absolute;
    left: 17px; 
    top: 27px;  
    
    color: var(--color-gold-text);
    background-color: rgba(19, 20, 20, 0.6); 
    
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap; 
    
    max-width: 0; 
    opacity: 0; 
    overflow: hidden; 
    
    transition: max-width 1.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                opacity 1.2s ease-out,
                background-color 0.2s ease-in-out;
    
    pointer-events: none; 
}

/* Hover & Visible States */
.custom-marker:hover .marker-label {
    max-width: 300px; 
    opacity: 1; 
    background-color: rgba(19, 20, 20, 0.8); 
    pointer-events: auto;
}
.marker-label.is-visible {
    max-width: 300px; 
    opacity: 1; 
    background-color: rgba(19, 20, 20, 0.6); 
    pointer-events: auto; 
}
.marker-label.is-visible:hover {
    background-color: rgba(19, 20, 20, 0.8); 
}

/* =======================================
  3.1. Stacked Marker Styling (Moeder & Kind)
  ======================================= */

/* Verberg Kind-markers op lage zoom (toegevoegd door JS) */
.custom-marker.is-hidden-by-stack {
    display: none !important;
}

/* De Moeder-marker krijgt het Stacked Uiterlijk */
.custom-marker.is-stack-leader {
    position: relative; 
    /* Zorgt ervoor dat de gestapelde marker nog steeds de hover-puls activeert op het icoon */
    display: inline-block; 
}

/* De Moeder-marker ZELF verliest de standaard marker kleur om de badge te laten domineren */
.custom-marker.is-stack-leader .fa-icon {
    /* Maak het basisicoon iets minder prominent */
    color: var(--color-gold-text); 
}

/* De Telteller (Badge) - We gebruiken ::after */
.custom-marker.is-stack-leader::after {
    content: attr(data-stack-count); /* Toont de waarde uit data-stack-count */
    position: absolute;
    bottom: 25px; 
    left: 20px;
    
    /* Vormgeving van de Badge */
    background-color: var(--color-dark-base); /* ⬅️ DONKERE ACHTERGROND */
    color: var(--color-gold-text);          /* ⬅️ GOUDEN TEKST */
    border: 1px solid rgba(180, 144, 91, 0.4); /* ⬅️ ZEER SUBTIELE, ZACHTE RAND */
    
    font-size: 0.75rem;
    font-weight: 500; /* Iets minder vet */
    line-height: 1;
    
    padding: 3px 5px;
    border-radius: 10px;
    min-width: 25px; 
    text-align: center;
    
    /* ⬅️ SUBTIELE SCHADUW DIE DE "MYSTIEK" VERHOOGT */
    box-shadow: 0 0 8px rgba(180, 144, 91, 0.5), 0 1px 4px rgba(0, 0, 0, 0.8);
    
    opacity: 1;
    transition: opacity 0.3s;
    z-index: 10; 
}

/* Verberg de teller als de marker 'uitgeklapt' is (is-expanded) */
.custom-marker.is-stack-leader.is-expanded::after {
    opacity: 0;
    pointer-events: none; /* Niet interfereert met clicks */
}

/* =======================================
   4. Modal Base Styling
   ======================================= */

/* General Transition & Modal Content */
.modal.fade .modal-dialog { transition: transform 0.7s ease-out, opacity 0.7s ease-out; }
.modal.fade { transition: opacity 0.7s linear; }

#markerModal .modal-content,
#infoModal .modal-content,
#compassModal .modal-content { 
    --bs-modal-bg: var(--color-dark-base); 
    --bs-modal-color: var(--color-gold-text); 
    
    background-color: var(--bs-modal-bg);
    color: var(--bs-modal-color);
    box-shadow: 0 0 20px rgba(168, 122, 56, 0.4), 
                0 0 5px rgba(28, 25, 23, 0.8); 
    border-radius: 12px;
    transform: translateY(-5px); 
    transition: transform 0.3s ease;
}

/* Header & Footer Consistency */
#markerModal .modal-header, #markerModal .modal-footer,
#infoModal .modal-header, #infoModal .modal-footer,
#compassModal .modal-header, #compassModal .modal-footer { 
    border: none;
    background-color: var(--color-dark-base); 
    border-color: var(--color-dark-base);
    border-top: 0;
    border-bottom: 0;
}

#markerModal .modal-header,
#infoModal .modal-header,
#compassModal .modal-header {
    box-shadow: 
        0 2px 5px -2px rgba(168, 122, 56, 0.3) inset,
        0 -2px 5px -2px rgba(168, 122, 56, 0.3) inset;
}

/* Modal Titles */
.modal-header { justify-content: center; }
#markerModal .modal-title, #infoModal .modal-title, #compassModal .modal-title {
    font-family: 'Cinzel Decorative', cursive;
    color: var(--color-gold-light); 
    font-size: 2.0rem; /* User defined size */
    text-align: center;
}
#markerModalLabel, #infoModalLabel, #compassModalLabel { width: 100%; }

/* Close Button Styling (X) */
.modal-header .btn-close {
    position: absolute; 
    top: 15px;
    right: 15px;
    margin: 0;
    z-index: 1050; 
}
#imageZoomModal .modal-header .btn-close {
    z-index: 1051; 
}
.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%); 
    opacity: 0.7; 
}
.btn-close:hover {
    filter: sepia(0.5) saturate(1.5) hue-rotate(-20deg) brightness(1.2); 
    opacity: 1; 
}

/* Secondary Button Styling (Modal Footer) */
.btn-secondary {
    --bs-btn-bg: var(--color-copper); 
    --bs-btn-color: var(--color-dark-base); 
    --bs-btn-border-color: var(--color-copper);
    --bs-btn-hover-bg: #58401D; 
    --bs-btn-active-bg: #58401D; 
}

/* Modal Sizes */
.modal-fullscreen-custom .modal-dialog {
    height: 95vh;
    max-width: 95vw;
    margin: 10px auto;
}
#infoModal .modal-dialog {
    max-width: 95%; 
    margin: 1rem auto;
}

.map-attributions {
    font-size: 0.8rem;
}

@media (min-width: 768px) {
    #infoModal .modal-dialog {
        max-width: 60%; 
        margin: 1.75rem auto;
    }
}

/* =======================================
   5. Modal Content & Typography
   ======================================= */

#markerModal .modal-body, #infoModal .modal-body {
    /* 1. Crucial: Reset width to auto so it follows the parent container */
    width: auto; 
    
    /* 2. Set the max-limit for large screens */
    max-width: 800px; 
    
    /* 3. Padding stays INSIDE the width calculation */
    box-sizing: border-box; 
    padding: 30px; 
    
    /* 4. Center the content box */
    margin: 0 auto; 
    
    /* 5. Text safety */
    text-align: justify;
    font-size: 1.1rem;
    line-height: 1.6;
    overflow-x: hidden;
    overflow-wrap: break-word;
}

/* 6. Adjust the Modal Dialog (the container) for that tricky 769px+ range */
@media (min-width: 768px) {
    #infoModal .modal-dialog, 
    #markerModal .modal-dialog {
        /* On small tablets/screens, give the modal more room to breathe */
        width: 90%; 
        max-width: none; /* Override default Bootstrap limits temporarily */
    }
}

/* 7. Return to standard sizes for Laptops/Desktops */
@media (min-width: 992px) {
    #infoModal .modal-dialog, 
    #markerModal .modal-dialog {
        width: 80%;
        max-width: 900px; /* Gives enough room for the 800px body + padding */
    }
}

@media (min-width: 1200px) {
    #infoModal .modal-dialog, 
    #markerModal .modal-dialog {
        width: 60%;
        max-width: 1000px;
    }
}

/* Compass Modal Body (Full width layout) */
#compassModal .modal-body {
    max-width: 100%; 
    margin: 0; 
    padding: 20px 0; 
    font-size: 1.1rem;
    line-height: 1.6;
    overflow-y: auto; 
    text-align: left; 
}

/* Typography */
#markerModal .modal-body blockquote {
    color: var(--color-gold-hover);
    border-left: 3px solid var(--color-gold-text);
    padding-left: 20px;
    margin: 20px 0;
    font-style: italic;
    font-size: 1.2rem;
}
.note {
    font-size: 0.95rem;
    color: #a89f91 !important; /* Warm gray */
}

/* Images/Figures (for Marker Modal) */
#markerModal .figure {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
@media (min-width: 992px) {
    #markerModal .figure { max-width: 700px; }
}
#markerModal .figure-caption {
    color: var(--color-neutral) !important;
    font-size: 0.9rem;
    margin-top: 5px;
    text-align: left !important;
    padding: 0 !important; 
    width: 100% !important; 
}

/* =======================================
   6. Custom Compass Modal List
   ======================================= */

.compass-group-header {
    padding: 15px 30px 5px 30px; 
    font-weight: 700;
    color: var(--color-gold-light);
    margin-top: 15px;
    margin-bottom: 0;
}

.country-header {
    font-size: 1.2rem;
    padding-top: 25px;
    letter-spacing: 1px;
}

/* Region Header Styling (Gold, Larger) */
.region-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-gold-text);
    padding: 10px 30px 0 30px; 
}

.compass-list-item {
    background-color: transparent;
    border: none;
    color: var(--color-gold-text);
    padding: 10px 30px; 
    transition: background-color 0.2s;
}

.compass-list-item:hover, .compass-list-item:focus {
    background-color: rgba(180, 144, 91, 0.1);
    color: var(--color-gold-light);
}

/* Item Title Styling (Gray, Smaller) */
.compass-item-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-neutral); 
    display: inline;
}

/* Subtitle/Coordinates Styling (Compact on 1 line) */
.compass-item-subtitle {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--color-copper); 
    display: inline; 
    margin-left: 10px; 
}

.compass-list-item.indent {
    padding-left: 50px; 
}

/* =======================================
   7. Map Controls & Overlays
   ======================================= */

/* Custom Info Overlay (Whispers of Forgotten Places) */
#info-overlay {
    position: absolute; 
    bottom: 20px; 
    right: 20px; 
    z-index: 10; 
    display: flex;
    align-items: center;
    gap: 10px; 
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5); 
}
#overlay-text {
    font-family: 'Cinzel Decorative', cursive; 
    color: var(--color-gold-text); 
    font-size: 1.6rem; 
    text-shadow: 0 0 8px rgba(0, 0, 0, 1), 0 0 1px rgba(0, 0, 0, 0.7); 
    background-color: rgba(19, 20, 20, 0.7);
    padding: 5px 10px;
    border-radius: 3px;
    opacity: 0.8;
    transition: opacity 0.3s, background-color 0.3s;
}
#overlay-text:hover {
    opacity: 1;
    background-color: rgba(28, 25, 23, 0.9);
}
#info-icon {
    font-size: 24px;
    color: var(--color-copper);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
}
#info-icon:hover {
    opacity: 1;
    color: var(--color-gold-light);
}

/* MapLibre Controls (Navigation/Zoom/Attribution) */
.maplibregl-ctrl-group {
    background-color: var(--color-dark-base) !important; 
    border-radius: 4px;
    box-shadow: 0 0 5px rgba(180, 144, 91, 0.4); 
    border: 1px solid rgba(180, 144, 91, 0.2);
}
.maplibregl-ctrl-icon {
    color: var(--color-gold-text) !important; 
    background-color: transparent !important; 
    font-size: 1.1em;
}
.maplibregl-ctrl button:not(:disabled):hover .maplibregl-ctrl-icon,
.maplibregl-ctrl button:not(:disabled):focus .maplibregl-ctrl-icon {
    color: var(--color-gold-hover) !important; 
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Attribution Control (Info Icon) */
.maplibregl-ctrl-attrib {
    font-size: 10px; 
    background-color: var(--color-dark-base); 
    color: var(--color-gold-text); 
    opacity: 0.9;
    padding: 0 5px;
    border-radius: 4px;
    box-shadow: 0 0 5px rgba(180, 144, 91, 0.4); 
    border: 1px solid rgba(180, 144, 91, 0.2);
}
.maplibregl-ctrl-attrib a {
    color: var(--color-gold-light) !important;
    text-decoration: none;
}
.maplibregl-ctrl-attrib a:hover {
    text-decoration: underline;
}

/* Custom Compass Button */
.custom-compass-ctrl { margin-top: 5px; }
.custom-compass-button {
    width: 29px;
    height: 29px;
    display: block;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    background-color: transparent;
    transition: background-color 0.3s;
}
.custom-compass-icon {
    font-size: 1.1em;
    color: var(--color-gold-text);
    transform: rotate(calc(360deg - var(--maplibregl-bearing))); 
    display: inline-block;
}
.custom-compass-button:hover { background-color: rgba(255, 255, 255, 0.05); }
.custom-compass-button:hover .custom-compass-icon { color: var(--color-gold-hover); }


/* ==================================================================
 * 8. MOBILE STYLES (Media Query for screens <= 768px width)
 * ================================================================== */

@media (max-width: 768px) {
    
    /* Body & HTML */
    body, html {
        background-color: var(--color-dark-base); 
        color: var(--color-gold-text);
    }
    
    /* Custom Info Overlay (Bottom) */
    #info-overlay {
        bottom: 0; left: 0; right: 0; width: 100%;
        margin: 0; padding: 0; 
        justify-content: center; align-items: center;
        height: 50px; z-index: 100; 
        background-color: var(--color-dark-base); 
        opacity: 0.8; 
        box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.5); 
        top: auto;
    }
    #overlay-text {
        font-size: 1.1rem; background-color: transparent; 
        padding: 0 10px; opacity: 1; 
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
    }
    #overlay-text:hover { background-color: transparent; }
    #info-icon {
        font-size: 20px; padding-right: 0; padding-left: 10px; 
        color: var(--color-gold-text); opacity: 1;
    }

    /* Modal Title and Close Button Fix */
    #markerModal .modal-header, #infoModal .modal-header, #compassModal .modal-header {
        padding-top: 20px; padding-bottom: 20px; align-items: center; 
    }
    .modal-header .btn-close {
        top: 10px; right: 15px; transform: scale(0.9); 
    }
    #markerModalLabel, #infoModalLabel, #compassModalLabel {
        padding: 0 40px; font-size: 1.4rem; 
    }
    
    /* MapLibre Attribution Control Repositioning */
    .maplibregl-ctrl-bottom-left {
        bottom: 50px !important; left: 0 !important; right: auto !important; z-index: 10; 
    }

    /* Compass List Mobile Adjustment */
    #compassModal .compass-group-header {
        padding-left: 15px;
        padding-right: 15px;
    }
    #compassModal .compass-list-item {
        padding-left: 15px;
        padding-right: 15px;
    }
    #compassModal .compass-list-item.indent {
        padding-left: 30px; 
    }
}

section a, #infoModal a {
    color: var(--color-copper);
}

/* =======================================
   9. Content Specific Styles (Accordion)
   ======================================= */

/* General Cemetery Pin Styles */

/* Photo Grid */
.secret-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    padding: 20px 0;
    width: 100%;
}

/* Individual Photo Box */
.secret-photo-box {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: black;
}

.secret-photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Mysterious start: grayscale and dimmed */
    filter: grayscale(1) opacity(0.5);
    transition: filter 0.6s ease, transform 0.6s ease;
    cursor: zoom-in;
}

/* Reveal on hover */
.secret-photo-box:hover img {
    filter: grayscale(0) opacity(1);
    transform: scale(1.05);
}

/* Micro-story overlay (appears on hover) */
.photo-story-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(19, 20, 20, 0.8);
    color: var(--color-gold-text);
    font-size: 0.8rem;
    padding: 8px;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}

.secret-photo-box:hover .photo-story-overlay {
    transform: translateY(0);
}

/* Accordion Styling */

/* 1. Accordion Item & Lines */
#cemeteryAccordion .accordion-item {
    background-color: transparent;
    border: none; 
    /* Soft separator line */
    border-bottom: 1px solid rgba(180, 144, 91, 0.2); 
    /* Add a little margin so the rounded active state doesn't look squashed */
    margin-bottom: 5px; 
}
#cemeteryAccordion .accordion-item:last-child {
    border-bottom: none;
}

/* 2. Accordion Button (Base State - Always Padded & Rounded) */
.whisper-accordion-header .accordion-button {
    /* Font settings */
    font-family: 'Cinzel Decorative', cursive; 
    font-size: 1.2rem; 
    
    /* Colors */
    background-color: transparent; 
    color: var(--color-gold-text);
    
    /* Apply padding and radius ALWAYS, not just when active */
    padding: 20px 15px; 
    border-radius: 12px !important; 
    
    /* Remove default Bootstrap styles */
    box-shadow: none; 
    border: none;

    /* Smooth color transition */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Chevron icon color fix */
.whisper-accordion-header .accordion-button::after {
    filter: invert(63%) sepia(11%) saturate(1143%) hue-rotate(3deg) brightness(96%) contrast(89%); 
    transform: scale(0.8); 
}

/* 3. Active State (Only Color Change) */
.whisper-accordion-header .accordion-button:not(.collapsed) {
    color: var(--color-gold-light);
    
    /* Only change the background color, layout remains stable */
    background-color: rgba(180, 144, 91, 0.04); 
}

/* Focus state cleanup */
.whisper-accordion-header .accordion-button:focus {
    box-shadow: none !important;
    border-color: transparent !important;
}