html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: #f7f7f7;
    overflow-x: hidden;
    overflow-y: hidden;
}
body {
    height: 100vh;
    min-width: 100vw;
    box-sizing: border-box;
    padding: 0;
    background: #f7f7f7;
    display: flex;
    flex-direction: column;
}

*, *::before, *::after {
    box-sizing: border-box;
}
/* Mobile browsers: use small viewport height to avoid bottom overflow */
@supports (height: 100svh) {
    body {
        height: 100svh;
    }
}

/* Allow scrolling on text/content pages */
body.page-text {
    overflow: auto;
}

/* Text pages: justify paragraphs and add more left/right whitespace */
body.page-text .page-content {
    padding-left: clamp(14px, 3vw, 36px);
    padding-right: clamp(14px, 3vw, 36px);
}
body.page-text .page-content p,
body.page-text .page-content li {
    text-align: justify;
    text-justify: inter-word;
    hyphens: none;
}

/* Text pages: centered logo/link block */
body.page-text .page-content .page-logo {
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
}
body.page-text .page-content .page-logo a {
    display: inline-block;
}
body.page-text .page-content .page-logo img {
    display: block;
    height: auto;
    max-width: min(90px, 20vw);
}

/* Selected Bibliography page: do not justify text */
body.page-text[data-page-title="Selected Bibliography"] .page-content p,
body.page-text[data-page-title="Selected Bibliography"] .page-content li {
    text-align: left;
    text-justify: auto;
}

/* Selected Bibliography: add vertical spacing between entries */
body.page-text .page-content .bibliography-list li {
    margin-bottom: 0.6rem;
}
body.page-text .page-content .bibliography-list li:last-child {
    margin-bottom: 0;
}

#map {
    flex: 1 1 auto;
    height: 1px;
    width: 98vw;
    margin: 0 auto;
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    background: #eaeaea;
    max-width: 1200px;
    max-height: none;
    min-height: 140px;
    min-width: 260px;
    display: block;
}

.top-bar, .middle-bar, .bottom-bar {
    margin-left: auto;
    margin-right: auto;
    max-width: 1200px;
}
.top-bar {
    margin-top: clamp(8px, 1.2vh, 14px);
    margin-bottom: clamp(6px, 0.8vh, 12px);
    border-radius: 18px;
    padding: 1.2vh 2vw 1.2vh 2vw;
}
.top-bar h1 {
    font-size: 2.3rem;
    color: #7c2bc0;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-align: center;
    flex: 1;
    margin: 0;
    font-family: 'Segoe UI', 'Montserrat', 'Arial', sans-serif;
    text-shadow: 0 2px 8px rgba(156,48,204,0.08), 0 1px 2px rgba(44,62,80,0.04);
    background: linear-gradient(90deg, #7c2bc0 10%, #27ae60 90%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Clickable site title: keep identical appearance (no underline/blue) */
.site-title-link {
    text-decoration: none;
    color: inherit;
    display: inline-block;
}
.site-title-link:hover {
    text-decoration: none;
}
.site-title-link:visited {
    color: inherit;
}

/* Ensure the gradient text rendering stays intact when the title is an <a> */
.top-bar h1 .site-title-link {
    background: linear-gradient(90deg, #7c2bc0 10%, #27ae60 90%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 8px rgba(156,48,204,0.08), 0 1px 2px rgba(44,62,80,0.04);
}
.middle-bar {
    margin-bottom: clamp(6px, 0.8vh, 12px);
    border-radius: 14px;
    padding: 0.8vh 0 0.8vh 0;
}
.bottom-bar {
    margin-top: clamp(6px, 0.8vh, 12px);
    margin-bottom: clamp(6px, 0.8vh, 12px);
    border-radius: 14px;
    width: 98vw;
    max-width: 1200px;
}

@media (max-width: 900px) {
    #map {
        min-height: 110px;
        width: 99vw;
    }
    .top-bar, .middle-bar, .bottom-bar {
        max-width: 99vw;
    }
    .bottom-bar {
        margin-top: 0.5vh;
        margin-bottom: 0.5vh;
        width: 99vw;
    }
}

@media (max-width: 600px) {
    body {
        min-width: 0;
        width: 100%;
    }
    #map {
        min-height: 70px;
        width: 100%;
        margin: 0;
    }
    .top-bar, .middle-bar, .bottom-bar {
        max-width: 100%;
        border-radius: 0;
    }
    .top-bar {
        margin-top: 0.3vh;
        margin-bottom: 0.3vh;
        padding: 0.5vh 0.5vw 0.5vh 0.5vw;
    }
    .top-bar h1 {
        font-size: 1.3rem !important;
        line-height: 1.2;
        padding: 0.2em 0;
    }
    .middle-bar {
        margin-bottom: 0.3vh;
        padding: 0.5vh 0 0.5vh 0;
    }
    .bottom-bar {
        margin-top: 0.3vh;
        margin-bottom: 0.3vh;
        width: 100%;
        box-shadow: none !important;
    }
    .d-flex.flex-row.align-items-center.w-100.justify-content-center[style*="gap: 18px;"] {
        flex-direction: column !important;
        gap: 8px !important;
        align-items: stretch !important;
    }
    #layer-switcher {
        width: 100%;
        flex-direction: row;
        justify-content: center;
    }
    #layer-switcher label {
        font-size: 0.95rem !important;
        padding: 0.3em 0.5em !important;
        min-width: 0;
        flex: 1 1 50%;
        text-align: center;
    }

    /* Center the Explore Films by label when stacked on small screens */
    .middle-bar span[style*="font-size: 1.18rem"] {
        min-width: 0 !important;
        width: 100% !important;
        text-align: center !important;
        display: block !important;
    }
    .bottom-bar span[style*="font-size: 1.18rem"] {
        font-size: 1rem !important;
        min-width: 0 !important;
        text-align: center !important;
        width: 100% !important;
    }
    .bottom-bar .w-100.d-flex.align-items-center.justify-content-between {
        gap: 8px !important;
    }
    .bottom-bar input[type="range"] {
        width: 100% !important;
    }

    /* Override inline spacing so everything fits on phones */
    #currentYearBar {
        margin-top: 8px !important;
        margin-bottom: 6px !important;
    }
    #yearFilterBar {
        margin-top: 6px !important;
        margin-bottom: 10px !important;
    }
    #yearFilterLine {
        padding-top: 6px !important;
        padding-bottom: 8px !important;
    }
}

/* Year filter arrow buttons: match site accent styling */
.year-arrow-btn {
    border-color: #9c30cc;
    color: #9c30cc;
    background: #fff;
    border-radius: 8px;
    line-height: 1;
    padding: 0.25rem 0.55rem;
    font-weight: 700;
}
.year-arrow-btn:hover,
.year-arrow-btn:focus {
    background: #9c30cc;
    color: #fff;
    border-color: #9c30cc;
}
.year-arrow-btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(156, 48, 204, 0.2);
}

/* Year slider layout + ticks */
.year-controls {
    flex-wrap: nowrap;
}

.year-slider-area {
    /* Keep arrows from touching the slider */
    margin: 0 18px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;

    /* Approximate native thumb size so we can align the thumb center with endpoints */
    --slider-thumb-size: 20px;
    --slider-track-height: 6px;
}

/* Make the track span the full visual width so the thumb center represents the selected year.
   This intentionally allows the thumb to overflow a bit at the ends. */
#yearSlider {
    width: calc(100% + var(--slider-thumb-size));
    margin-left: calc(var(--slider-thumb-size) / -2);
    margin-right: calc(var(--slider-thumb-size) / -2);
}

.year-ticks {
    position: absolute;
    left: calc(var(--slider-thumb-size) / -2);
    right: calc(var(--slider-thumb-size) / -2);
    top: 50%;
    transform: translateY(-50%);
    height: var(--slider-track-height);
    pointer-events: none;
}

.year-tick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(82, 109, 144, 0.55);
}

/* Current year display (below map, above filter; page background) */
#currentYearDisplay {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.1;
    font-family: 'Segoe UI', 'Montserrat', 'Arial', sans-serif;
    color: #526d90;
}
@media (max-width: 600px) {
    #currentYearDisplay {
        font-size: 1.05rem;
    }
}

@media (max-width: 600px) {
    .year-controls {
        flex-wrap: nowrap !important;
        width: 100%;
        min-width: 0;
        justify-content: center;
        gap: 8px !important;
    }
    .year-slider-area {
        margin: 0 8px;
        width: auto;
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Override the inline width (440px) on small screens so the slider can shrink.
       Keeps min/max labels + arrows + slider all on a single line. */
    #yearSlider {
        width: 100% !important;
        min-width: 0;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .year-ticks {
        left: 0;
        right: 0;
    }

    .year-side {
        white-space: nowrap;
        flex: 0 0 auto;
        gap: 6px !important;
    }
    .year-arrow-btn {
        padding: 0.2rem 0.45rem;
        border-radius: 8px;
    }
    #yearMinLabel,
    #yearMaxLabel {
        font-size: 0.9rem !important;
    }
}

/* Navigation menu (below title, above explore toggle) */
.nav-bar {
    margin-left: auto;
    margin-right: auto;
    max-width: 1200px;
    width: 98vw;
    background: transparent;
    padding: 2px 0;
    margin-bottom: clamp(6px, 0.8vh, 12px);
}
.nav-menu {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 6px;
}

/* Mobile hamburger menu (only active on small screens) */
.nav-toggle {
    display: none;
    appearance: none;
    border: 1px solid rgba(82, 109, 144, 0.35);
    background: #fff;
    color: #526d90;
    border-radius: 10px;
    padding: 0.25rem 0.6rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    line-height: 1;
}
.nav-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(156, 48, 204, 0.2);
}
.nav-toggle-icon {
    display: inline-block;
    width: 18px;
    height: 12px;
    position: relative;
}
.nav-toggle-icon::before,
.nav-toggle-icon::after,
.nav-toggle-icon span {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}
.nav-toggle-icon::before,
.nav-toggle-icon::after {
    content: "";
}
.nav-toggle-icon::before {
    top: 0;
}
.nav-toggle-icon span {
    top: 5px;
}
.nav-toggle-icon::after {
    bottom: 0;
}
.nav-menu a {
    display: inline-block;
    text-decoration: none;
    padding: 0.2rem 0;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    font-family: 'Segoe UI', 'Montserrat', 'Arial', sans-serif;
    color: #526d90;
    white-space: nowrap;
}
.nav-menu a:hover {
    text-decoration: underline;
}
.nav-menu a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(156, 48, 204, 0.2);
}
@media (max-width: 600px) {
    .nav-bar {
        width: 100vw;
        padding: 2px 0;
        margin-bottom: 0.3vh;
    }

    /* Hide horizontal scrolling menu and replace with hamburger */
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        margin: 0 auto;
    }

    .nav-menu {
        display: none;
        overflow-x: visible;
        overflow-y: auto;
        max-height: 60vh;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        padding: 8px 12px;
    }

    .nav-bar.nav-open .nav-menu {
        display: flex;
    }

    .nav-menu a {
        font-size: 0.98rem;
        padding: 0.25rem 0;
    }
}

/* Simple page content styling for new pages */
.page-content {
    margin-left: auto;
    margin-right: auto;
    max-width: 1200px;
    width: 98vw;
    flex: 1 1 auto;
    overflow: auto;
    padding: 8px 0 18px 0;
}
body.page-text .page-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    line-height: 1.2;
    font-family: 'Segoe UI', 'Montserrat', 'Arial', sans-serif;
    color: #526d90;
    text-align: center;
    margin: 10px 0 22px 0;
}
.page-content p,
.page-content li {
    font-size: 1rem;
    line-height: 1.6;
    font-family: 'Segoe UI', 'Montserrat', 'Arial', sans-serif;
    color: #2c3e50;
}
body.page-text .page-content h3 {
    font-size: 1.12rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    line-height: 1.25;
    font-family: 'Segoe UI', 'Montserrat', 'Arial', sans-serif;
    color: #526d90;
    margin: 18px 0 14px 0;
}
.page-content ul {
    padding-left: 1.2rem;
    margin: 8px 0 12px 0;
}
.page-content a {
    color: #526d90;
}
