/* Excerpts copied verbatim from the live site stylesheet (world-map/css/style.css).
   Selected rules only; nothing is edited. Page-specific additions are in css/noah.css. */

/* === Design tokens ===
   The landing page's aesthetic is the site's design system. Everything
   below should draw from this vocabulary: two font families, one navy
   background, ivory text, one action blue, one narrative gold. Map DATA
   colours (nations, languages, eras, the green ancient-world inset) are
   information, not decoration, and deliberately stay outside the tokens. */
:root {
    --bg: #05070f;                        /* page night-navy */
    --surface: rgba(14, 19, 34, 0.92);    /* panels, cards, controls */
    --surface-soft: rgba(14, 19, 34, 0.7);
    --ink: #e8ecf5;                       /* primary ivory text */
    --ink-strong: #ffffff;
    --ink-muted: rgba(232, 236, 245, 0.72);
    --ink-faint: rgba(232, 236, 245, 0.45);
    --line: rgba(110, 168, 255, 0.16);    /* hairline borders */
    --line-strong: rgba(110, 168, 255, 0.4);
    --accent: #6ea8ff;                    /* actions and links */
    --accent-strong: #a0c4ff;             /* hover / active */
    --accent-wash: rgba(110, 168, 255, 0.08);
    --gold: #d4af5a;                      /* scripture, progress, emphasis */
    --gold-bright: #e8c878;
    --font-body: 'EB Garamond', Georgia, serif;
    --font-display: 'Cormorant Garamond', Georgia, serif;
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Links default to the action blue everywhere; anything unstyled used to
   fall back to the browser's dark-blue default, unreadable on the navy. */
a {
    color: var(--accent);
    text-decoration-color: rgba(110, 168, 255, 0.45);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--accent-strong);
}

/* === Main Map === */
#main-map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Match the dark basemap: Leaflet's default light-grey container otherwise
       shows through wherever tiles have not loaded yet (visible as a bright
       surround during camera flights). */
    background: var(--bg);
    transition: opacity 2s ease;
}

#main-map .leaflet-container,
#main-map.leaflet-container {
    background: var(--bg);
}

/* Esri World Hillshade blended over the dark basemap: inverted so slopes read
   as a faint glow, giving mountains and plains physical relief at high zoom
   (the Zagros foothills exist!) without touching the palette. */
.hillshade-tiles {
    filter: invert(1);
    mix-blend-mode: screen;
    opacity: 0.12;
    transition: opacity 0.25s ease;
}

/* During Leaflet's zoom animation the animated panes promote to their own
   compositing layers and the screen blend detaches: the hillshade then paints
   as raw light-grey terrain rectangles sliding over the dark map (worst on
   zoom-out camera flights, with journey lines riding on top). Fade it out for
   the flight and back in when the camera settles. */
.leaflet-zoom-anim .hillshade-tiles {
    opacity: 0;
}

/* === Date Display === */
#date-display {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--surface);
    backdrop-filter: blur(8px);
    padding: 8px 24px;
    border-radius: 24px;
    font-size: 18px;
    font-weight: bold;
    color: var(--ink-muted);
    letter-spacing: 1px;
    border: 1px solid var(--line);
}

/* === Event Banner === */
#event-banner {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--surface);
    backdrop-filter: blur(12px);
    padding: 16px 32px;
    border-radius: 0;
    max-width: 760px;
    width: 90vw;
    text-align: center;
    border: 1px solid rgba(110, 168, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: opacity 0.8s ease, transform 0.8s ease, border-color 0.3s ease;
}

#event-banner.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    pointer-events: none;
}

#event-banner-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--ink-strong);
    margin-bottom: 4px;
}

#event-banner-location {
    font-size: 12px;
    color: #6ea8ff;
    font-style: italic;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

#event-banner-location.hidden {
    display: none;
}

#event-banner-image {
    display: block;
    width: 100%;
    max-height: 480px;
    object-fit: cover;
    object-position: center 20%;
    border-radius: 4px;
    margin: 8px 0 12px;
    opacity: 0.92;
}

#event-banner-image.hidden {
    display: none;
}

#event-banner-description {
    font-size: 14px;
    color: var(--ink-muted);
    line-height: 1.5;
}

#event-banner-description p {
    margin: 0 0 0.7em 0;
}

#event-banner-description p:last-child {
    margin-bottom: 0;
}

#event-banner-source {
    margin-top: 8px;
    font-size: 12px;
    color: var(--ink-faint);
}

#event-banner-source a {
    color: var(--ink-faint);
    text-decoration: none;
}

#event-banner-source a:hover {
    text-decoration: underline;
}

#event-banner.paused {
    border-color: rgba(212, 175, 90, 0.6);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 16px rgba(212, 175, 90, 0.3);
    animation: bannerPulse 2s ease-in-out infinite;
}

@keyframes bannerPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 16px rgba(212, 175, 90, 0.15); }
    50%      { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 28px rgba(212, 175, 90, 0.5); }
}

.banner-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

#banner-hint.hidden {
    display: none;
}

/* === Layer Panel === */
#layer-panel {
    font-family: var(--font-body);
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1000;
    background: var(--surface);
    backdrop-filter: blur(8px);
    padding: 12px 16px;
    border-radius: 0;
    border: 1px solid var(--line);
    min-width: 140px;
}

.layer-panel-title {
    font-family: var(--font-body);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-faint);
    margin-bottom: 8px;
}

.layer-toggle {
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-muted);
}

.layer-toggle input[type="checkbox"] {
    accent-color: var(--accent);
}

/* === Auto-zoom toggle === */
.autozoom-btn {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--ink-faint);
    background: var(--accent-wash);
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    user-select: none;
}

.autozoom-btn:hover {
    background: rgba(110, 168, 255, 0.18);
    color: var(--ink-muted);
}

.autozoom-btn.active {
    background: rgba(110, 168, 255, 0.2);
    color: var(--accent-strong);
    border-color: var(--line-strong);
}

/* === Timeline Container === */
#timeline-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(to top, var(--surface), var(--surface-soft));
    backdrop-filter: blur(8px);
    padding: 8px 20px 16px;
}

/* Timeline markers row */
#timeline-markers.hidden {
    display: none;
}

#timeline-markers {
    position: relative;
    height: 24px;
    margin: 0 60px 0 40px;
}

.timeline-marker {
    position: absolute;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--ink-faint);
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.2s;
}

.timeline-marker:hover {
    color: var(--ink-muted);
}

.timeline-marker::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 6px;
    background: rgba(110, 168, 255, 0.4);
}

.timeline-marker.active {
    color: var(--accent-strong);
    font-weight: bold;
}

/* Slider row */
#timeline-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

#play-btn {
    background: rgba(110, 168, 255, 0.18);
    border: 1px solid var(--line-strong);
    color: var(--ink-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#play-btn:hover {
    background: rgba(110, 168, 255, 0.25);
}

#play-btn.playing {
    color: #ff8888;
}

/* Slider */
#timeline-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #2a2a5a, #4a4a8a, #6a6aaa);
    outline: none;
    cursor: pointer;
}

#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ink-faint);
    border: 2px solid var(--ink-muted);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(100, 100, 200, 0.5);
    transition: transform 0.1s;
}

#timeline-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#timeline-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ink-faint);
    border: 2px solid var(--ink-muted);
    cursor: pointer;
}

/* Speed control */
#speed-control {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.speed-btn {
    background: var(--accent-wash);
    border: 1px solid var(--line);
    color: var(--ink-faint);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.speed-btn:hover {
    background: rgba(110, 168, 255, 0.2);
    color: var(--ink-muted);
}

.speed-btn.active {
    background: rgba(110, 168, 255, 0.25);
    color: var(--accent-strong);
    border-color: var(--line-strong);
}

/* === People group labels (smudges are canvas-drawn) === */
.people-group-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-family: var(--font-display);
    font-size: 10px;
    font-style: italic;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    color: #e8ecf5;
    opacity: 0.5;
    text-shadow: 0 0 6px rgba(0,0,0,1), 0 0 12px rgba(0,0,0,0.9);
}

.people-group-pop {
    font-size: 8px;
    opacity: 0.7;
    color: #e8ecf5;
}

/* === Dot labels (travel, scatter, Nimrod, Patriarch) === */
.travel-dot-label,
.babel-scatter-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none;
}

/* === Nation labels === */
.nation-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0,0,0,1), 0 0 10px rgba(0,0,0,0.9);
}

/* === Legend Panel === */
#legend-panel {
    position: absolute;
    bottom: 90px;
    left: 16px;
    z-index: 1000;
    background: var(--surface);
    backdrop-filter: blur(8px);
    padding: 10px 14px;
    border-radius: 0;
    border: 1px solid var(--line);
    min-width: 130px;
    max-width: 300px; /* keeps the panel clear of the centred caption bar */
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    transition: opacity 0.3s;
}

#legend-panel.hidden {
    display: none;
}

.mobile-map-controls {
    display: none;
}

.mobile-map-btn {
    font-family: var(--font-body);
    min-height: 40px;
    padding: 8px 12px;
    background: rgba(20, 20, 40, 0.88);
    color: #d0d0e8;
    border: 1px solid var(--line);
    border-radius: 4px;
    backdrop-filter: blur(8px);
    font-size: 14px;
    cursor: pointer;
}

.mobile-map-btn.active {
    background: rgba(70, 70, 140, 0.9);
    border-color: rgba(160, 160, 220, 0.55);
}

.mobile-map-btn.hidden {
    display: none;
}

.legend-title {
    font-family: var(--font-body);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-faint);
    margin-bottom: 6px;
}

.legend-item {
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    font-size: 13px;
    color: var(--ink-muted);
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-item--sub {
    font-family: var(--font-body);
    padding-left: 16px;
    font-size: 13px;
    color: var(--ink-faint);
}

/* === Zoom Controls === */
.leaflet-control-zoom {
    border: 1px solid var(--line) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--ink-muted) !important;
    border-color: var(--line) !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(60, 60, 120, 0.85) !important;
    color: var(--ink-strong) !important;
}

/* === Banner claim label === */
#event-banner-claim {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-faint);
    margin-bottom: 4px;
}

#event-banner-claim.hidden {
    display: none;
}

/* Mobile */
@media (max-width: 768px) {
#date-display {
        top: 10px;
        max-width: calc(100vw - 120px);
        padding: 6px 14px;
        font-size: 14px;
        text-align: center;
        letter-spacing: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.mobile-map-controls {
        position: fixed;
        top: 52px;
        left: 10px;
        z-index: 1050;
        display: flex;
        gap: 8px;
        align-items: center;
    }

#layer-panel {
        display: none;
        top: auto;
        left: 12px;
        right: 12px;
        bottom: 96px;
        width: auto;
        min-width: 0;
        max-height: min(48vh, 360px);
        overflow-y: auto;
        padding: 14px 16px;
    }

#layer-panel.mobile-open {
        display: block;
    }

#legend-panel {
        display: none;
        left: 12px;
        right: 12px;
        bottom: 96px;
        width: auto;
        min-width: 0;
        max-height: min(48vh, 360px);
        padding: 14px 16px;
        z-index: 1050;
    }

#legend-panel.mobile-open:not(.hidden) {
        display: block;
    }

#timeline-container {
        padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    }

#timeline-markers {
        display: none;
    }

#timeline-slider-row {
        gap: 10px;
    }

#play-btn {
        width: 40px;
        height: 40px;
    }

#speed-control {
        display: none;
    }

#event-banner {
        max-width: 90%;
        padding: 12px 16px;
    }
}

/* The stylesheet has no generic .hidden rule; the speed/rate/CC buttons are
   swapped by JS via this class, so it needs an explicit rule here. */
.speed-btn.hidden {
    display: none;
}

@media (max-width: 768px) {
.speed-btn {
        padding: 3px 5px;
        font-size: 11px;
    }
}

/* ==========================================================================
   Cinematic chrome fade: during narrated playback the controls step back
   after a few idle seconds (standard video-player behaviour). Captions, the
   date, the journey label, and the story cards stay.
   ========================================================================== */
#layer-panel,
#legend-panel,
#timeline-container,
.mobile-map-controls,
.leaflet-control-zoom {
    transition: opacity 0.7s ease;
}

/* ==========================================================================
   Journey beat markers on the seek bar: one dot per story beat,
   clickable to jump there.
   ========================================================================== */
#slider-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

#slider-wrap #timeline-slider {
    width: 100%;
}

/* ==========================================================================
   Legend live highlight: the entry whose marks are drawing right now
   ========================================================================== */
.legend-item.legend-flash {
    color: var(--ink-strong);
}

.legend-item.legend-flash .legend-swatch {
    box-shadow: 0 0 8px 1px rgba(232, 200, 120, 0.55);
}

/* Hide alongside the marker row (chronology walkthrough) */
#timeline-container:has(#timeline-markers.hidden) #pauls-band {
    display: none;
}

/* Copied from the site: click popup chrome (Christianity layer ancestry popup) */
.ancestry-popup-wrap .leaflet-popup-content-wrapper {
    background: var(--surface);
    border: 1px solid rgba(110, 168, 255, 0.3);
    border-radius: 6px;
    color: var(--accent-strong);
    box-shadow: 0 4px 20px rgba(0,0,0,0.7);
    padding: 0;
}

.ancestry-popup-wrap .leaflet-popup-content {
    margin: 14px 16px;
}

.ancestry-popup-wrap .leaflet-popup-tip {
    background: var(--surface);
}

.ancestry-popup-wrap .leaflet-popup-close-button {
    color: var(--ink-faint) !important;
    font-size: 16px;
    top: 6px !important;
    right: 8px !important;
}

.ancestry-popup-wrap .leaflet-popup-close-button:hover {
    color: #aaccff !important;
}

/* Copied from the site (css/style.css, "Cinematic chrome fade") */
body.chrome-idle #layer-panel,
body.chrome-idle #legend-panel,
body.chrome-idle #timeline-container,
body.chrome-idle .mobile-map-controls,
body.chrome-idle .leaflet-control-zoom {
    opacity: 0;
    pointer-events: none;
}
