/* ============================================================
   Journey Through Time — Main Stylesheet
   Antique manuscript / cinematic historical theme
   ============================================================ */

:root {
    /* Palette */
    --gold: #c9a227;
    --gold-light: #e8c547;
    --gold-glow: rgba(201, 162, 39, 0.55);
    --gold-soft: rgba(201, 162, 39, 0.15);
    --copper: #8b6914;
    --bronze: #6b4c1e;
    --parchment: #e8dcc4;
    --parchment-dark: #d4c4a0;
    --parchment-edge: #b89860;
    --ink: #2c1810;
    --ink-light: #4a3020;
    --leather: #1a0f08;
    --leather-mid: #2a1810;
    --leather-light: #3d2518;
    --map-sea: #3a5068;
    --map-water-mask: #c5d4e0;
    --red-line: #6b2020;

    /* Typography */
    --font-ar: 'Amiri', 'Traditional Arabic', serif;
    --font-en: 'Cinzel', 'Playfair Display', Georgia, serif;
    --font-body: 'Playfair Display', Georgia, serif;

    /* Layout */
    --header-h: 72px;
    --timeline-w: 360px;
    --transition: 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--leather);
}

/* ── Header ─────────────────────────────────────────────── */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    z-index: 1000;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 40%),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0,0,0,0.03) 2px,
            rgba(0,0,0,0.03) 4px
        ),
        linear-gradient(180deg, var(--leather-light) 0%, var(--leather) 100%);
    border-bottom: 2px solid var(--bronze);
    box-shadow:
        0 4px 20px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(201, 162, 39, 0.2);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1.5rem;
    max-width: 100%;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-emblem {
    width: 52px;
    height: 52px;
    color: var(--gold);
    filter: drop-shadow(0 0 6px var(--gold-glow));
    flex-shrink: 0;
}

.logo-emblem svg {
    width: 100%;
    height: 100%;
}

.brand-text {
    line-height: 1.2;
}

.brand-title-ar {
    font-family: var(--font-ar);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold-light);
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.brand-title-en {
    font-family: var(--font-en);
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    color: rgba(201, 162, 39, 0.7);
    margin-top: 2px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ctrl-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: linear-gradient(180deg, var(--leather-light) 0%, var(--leather-mid) 100%);
    border: 1px solid var(--bronze);
    border-radius: 4px;
    color: var(--gold);
    font-family: var(--font-en);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.08),
        0 2px 6px rgba(0,0,0,0.4);
}

.ctrl-btn:hover {
    border-color: var(--gold);
    color: var(--gold-light);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.1),
        0 0 12px var(--gold-soft);
}

.ctrl-btn.active {
    background: linear-gradient(180deg, #3d2a10 0%, var(--leather-light) 100%);
    border-color: var(--gold);
    box-shadow: 0 0 16px var(--gold-glow);
}

.ctrl-icon {
    width: 18px;
    height: 18px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--bronze);
    border-radius: 4px;
    min-width: 160px;
}

.search-box--disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.search-icon {
    width: 16px;
    height: 16px;
    color: var(--gold);
    flex-shrink: 0;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--parchment);
    font-family: var(--font-en);
    font-size: 0.8rem;
    width: 100%;
}

.search-box input::placeholder {
    color: rgba(201, 162, 39, 0.4);
}

/* ── Main Layout ────────────────────────────────────────── */

.main-layout {
    display: flex;
    height: 100vh;
    padding-top: var(--header-h);
}

/* ── Timeline Panel ─────────────────────────────────────── */

.timeline-panel {
    width: var(--timeline-w);
    flex-shrink: 0;
    height: calc(100vh - var(--header-h));
    overflow: hidden;
    position: relative;
    z-index: 100;
    background: var(--leather);
}

.parchment-scroll {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.parchment-edge {
    height: 24px;
    flex-shrink: 0;
    background:
        radial-gradient(ellipse at center, var(--parchment-edge) 0%, var(--parchment-dark) 70%);
    opacity: 0.9;
}

.parchment-edge--top {
    background:
        linear-gradient(180deg, var(--parchment-edge) 0%, var(--parchment) 100%);
    clip-path: polygon(0 100%, 5% 60%, 12% 90%, 20% 50%, 30% 85%, 40% 40%, 50% 80%, 60% 45%, 70% 90%, 80% 55%, 90% 85%, 95% 65%, 100% 100%, 100% 0, 0 0);
}

.parchment-edge--bottom {
    background:
        linear-gradient(0deg, var(--parchment-edge) 0%, var(--parchment) 100%);
    clip-path: polygon(0 0, 5% 40%, 12% 10%, 20% 50%, 30% 15%, 40% 60%, 50% 20%, 60% 55%, 70% 10%, 80% 45%, 90% 15%, 95% 35%, 100% 0, 100% 100%, 0 100%);
}

.parchment-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E"),
        linear-gradient(180deg, #f0e6cc 0%, var(--parchment) 20%, var(--parchment-dark) 100%);
    box-shadow:
        inset -8px 0 20px rgba(0,0,0,0.15),
        inset 8px 0 20px rgba(0,0,0,0.08);
    scrollbar-width: thin;
    scrollbar-color: var(--bronze) transparent;
}

.parchment-content::-webkit-scrollbar {
    width: 6px;
}

.parchment-content::-webkit-scrollbar-thumb {
    background: var(--bronze);
    border-radius: 3px;
}

.timeline-track {
    position: relative;
    padding: 2rem 1rem 3rem;
    min-height: 100%;
}

.timeline-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    background: linear-gradient(180deg, var(--red-line), #4a1515, var(--red-line));
    box-shadow: 0 0 4px rgba(107, 32, 32, 0.5);
    z-index: 0;
    pointer-events: none;
}

.timeline-items {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
    z-index: 1;
}

/* Timeline Item */
.timeline-item {
    display: grid;
    grid-template-columns: 1fr 28px 1fr;
    align-items: center;
    gap: 0.5rem;
    padding: 1.1rem 0;
    cursor: pointer;
    position: relative;
    transition: all var(--transition);
}

.timeline-item:hover .timeline-node,
.timeline-item.hovered .timeline-node {
    transform: scale(1.15);
    box-shadow: 0 0 14px var(--gold-glow);
}

.timeline-item.hovered .timeline-label {
    color: var(--copper);
}

.timeline-item.active {
    z-index: 2;
}

.timeline-item.active .timeline-node {
    background: radial-gradient(circle, var(--gold-light) 0%, var(--gold) 60%, var(--copper) 100%);
    box-shadow:
        0 0 20px var(--gold-glow),
        0 0 40px rgba(201, 162, 39, 0.3);
    transform: scale(1.2);
    animation: nodePulse 2s ease-in-out infinite;
}

.timeline-item.active .timeline-label {
    color: var(--copper);
    text-shadow: 0 0 12px var(--gold-soft);
}

.timeline-item.active .timeline-icon-frame {
    border-color: var(--gold);
    box-shadow:
        0 0 20px var(--gold-glow),
        inset 0 0 10px var(--gold-soft);
}

@keyframes nodePulse {
    0%, 100% { box-shadow: 0 0 20px var(--gold-glow), 0 0 40px rgba(201,162,39,0.3); }
    50% { box-shadow: 0 0 30px var(--gold-glow), 0 0 60px rgba(201,162,39,0.45); }
}

.timeline-label {
    text-align: end;
    padding-right: 0.75rem;
    padding-left: 0.25rem;
    transition: all var(--transition);
    position: relative;
    z-index: 5;
}

body.lang-en .timeline-label {
    text-align: start;
    padding-right: 0;
    padding-left: 0.5rem;
    order: 3;
}

body.lang-en .timeline-icon-wrap {
    order: 1;
}

.timeline-name-ar {
    font-family: var(--font-ar);
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
}

.timeline-name-en {
    font-family: var(--font-en);
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: var(--ink-light);
    text-transform: uppercase;
    margin-top: 2px;
}

.timeline-date {
    font-family: var(--font-ar);
    font-size: 0.75rem;
    color: var(--bronze);
    margin-top: 3px;
    opacity: 0.85;
}

body.lang-en .timeline-date {
    font-family: var(--font-en);
    font-size: 0.7rem;
}

.timeline-node {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--gold-light) 0%, var(--gold) 70%);
    border: 2px solid var(--copper);
    position: relative;
    z-index: 2;
    justify-self: center;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-node::after {
    content: none;
}

.timeline-node--toggle {
    cursor: pointer;
    background: radial-gradient(circle, var(--gold-light) 0%, var(--gold) 70%);
}

.timeline-node--toggle .node-toggle {
    font-size: 16px;
    font-weight: 700;
    color: var(--leather);
    line-height: 1;
    user-select: none;
}

.timeline-node--leaf {
    width: 10px;
    height: 10px;
    background: var(--bronze);
    border: 1px solid var(--copper);
}

.timeline-node--leaf::after {
    content: none;
}

/* Century — primary visible items */
.timeline-item--century .timeline-name-ar {
    font-size: 1.1rem;
}

.timeline-item--century .timeline-icon-frame {
    width: 62px;
    height: 62px;
}

/* Expandable branches — keep nodes on the center line */
.timeline-block--branch {
    position: relative;
}

.timeline-branches {
    position: relative;
}

.timeline-item--branch {
    padding: 0.55rem 0;
    grid-template-columns: 1fr 28px 1fr;
}

.timeline-item--branch .timeline-label {
    padding-right: 1.5rem;
}

body.lang-en .timeline-item--branch .timeline-label {
    padding-right: 0.75rem;
    padding-left: 1.5rem;
}

.timeline-item--branch .timeline-node--leaf {
    width: 12px;
    height: 12px;
    z-index: 3;
}

.timeline-item--branch .timeline-name-ar {
    font-size: 0.85rem;
    font-weight: 600;
}

.timeline-item--branch .timeline-event-title {
    font-family: var(--font-ar);
    font-size: 0.72rem;
    color: var(--ink-light);
    line-height: 1.4;
    margin-top: 3px;
    opacity: 0.9;
}

body.lang-en .timeline-item--branch .timeline-event-title {
    font-family: var(--font-body);
}

.timeline-item--prophet {
    padding: 0.65rem 0;
}

.timeline-item--prophet-inline {
    padding: 0.7rem 0;
}

.timeline-item--prophet-inline .timeline-name-ar {
    font-size: 0.95rem;
    color: var(--copper);
}

.timeline-item--prophet-inline .timeline-node--leaf {
    width: 16px;
    height: 16px;
    background: var(--gold);
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.45);
}

.timeline-item--group .timeline-name-ar {
    font-size: 1rem;
    color: var(--copper);
}

.timeline-icon-spacer {
    width: 32px;
    height: 1px;
}

.timeline-item--year .timeline-icon-wrap {
    visibility: hidden;
    pointer-events: none;
}

.timeline-icon-wrap {
    display: flex;
    justify-content: flex-start;
    padding-left: 0.25rem;
    position: relative;
    z-index: 1;
}

.timeline-icon-frame {
    width: 56px;
    height: 56px;
    border: 2px solid var(--bronze);
    background:
        linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 50%),
        var(--parchment-dark);
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.15),
        2px 3px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.timeline-icon {
    width: 32px;
    height: 32px;
    color: var(--ink-light);
    opacity: 0.85;
}

/* ── Map Panel ──────────────────────────────────────────── */

.map-panel {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.history-map {
    width: 100%;
    height: 100%;
    background: var(--map-sea);
    z-index: 1;
}

/* Antique filter on map tiles */
.history-map .leaflet-tile-pane,
.history-map .leaflet-labels-pane {
    filter: sepia(0.55) saturate(0.7) brightness(0.9) contrast(1.05);
}

.history-map .leaflet-container {
    background: #c8b88a;
    font-family: var(--font-en);
}

.map-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 400;
    background:
        radial-gradient(ellipse at center, transparent 50%, rgba(26, 15, 8, 0.35) 100%),
        linear-gradient(180deg, rgba(26,15,8,0.15) 0%, transparent 10%, transparent 90%, rgba(26,15,8,0.2) 100%);
}

/* Continent mask — paint undiscovered land as water until discovery year */
.continent-mask-canvas {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    filter: sepia(0.55) saturate(0.7) brightness(0.9) contrast(1.05);
}

.continent-mask-canvas--land {
    z-index: 450;
}

.continent-mask-canvas--labels {
    z-index: 560;
}

.palestine-label-canvas {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 565;
    pointer-events: none;
}

.history-map .leaflet-marker-pane {
    z-index: 680;
}

.history-map .leaflet-popup-pane {
    z-index: 700;
}

.map-continent-legend {
    position: absolute;
    bottom: 1rem;
    inset-inline-start: 1rem;
    z-index: 800;
    max-width: 220px;
    padding: 0.65rem 0.85rem;
    background: rgba(244, 232, 208, 0.92);
    border: 1px solid var(--bronze);
    box-shadow: 2px 3px 12px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.map-range-control {
    position: absolute;
    bottom: 1rem;
    inset-inline-end: 1rem;
    z-index: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.7rem;
    background: rgba(244, 232, 208, 0.92);
    border: 1px solid var(--bronze);
    box-shadow: 2px 3px 12px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(2px);
    pointer-events: auto;
}

.map-range-label {
    font-family: var(--font-ar);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
}

.lang-en .map-range-label {
    font-family: var(--font-en);
}

.map-range-stepper {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.map-range-btn {
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border: 1px solid var(--bronze);
    border-radius: 3px;
    background: var(--leather-mid);
    color: var(--gold);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.map-range-btn:hover:not(:disabled) {
    background: var(--leather-light);
    color: var(--gold-light);
}

.map-range-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.map-range-value {
    min-width: 2.5rem;
    text-align: center;
    font-family: var(--font-en);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--copper);
}

.map-captions-toggle {
    margin-top: 0.15rem;
    padding: 0.28rem 0.55rem;
    border: 1px solid var(--bronze);
    border-radius: 3px;
    background: var(--leather-mid);
    color: var(--gold);
    font-family: var(--font-ar);
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.lang-en .map-captions-toggle {
    font-family: var(--font-en);
}

.map-captions-toggle:hover {
    background: var(--leather-light);
    color: var(--gold-light);
}

.map-captions-toggle.is-active {
    background: rgba(192, 57, 43, 0.15);
    color: #8b2e2e;
    border-color: rgba(192, 57, 43, 0.45);
}

.map-legend-title {
    margin: 0 0 0.45rem;
    font-family: var(--font-ar);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.02em;
}

.lang-en .map-legend-title {
    font-family: var(--font-en);
}

.map-legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.map-legend-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.72rem;
    line-height: 1.3;
    color: var(--ink-light);
    border-bottom: 1px dotted rgba(90, 62, 30, 0.25);
    padding-bottom: 0.2rem;
}

.map-legend-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.map-legend-name {
    font-family: var(--font-ar);
    font-weight: 600;
}

.lang-en .map-legend-name {
    font-family: var(--font-en);
}

.map-legend-year {
    font-family: var(--font-en);
    font-size: 0.68rem;
    color: var(--copper);
    white-space: nowrap;
}

.map-legend-empty {
    font-size: 0.72rem;
    color: var(--ink-light);
    font-style: italic;
}

.connection-beam {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 450;
}

/* Golden pulse marker */
.golden-marker-wrap.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
    overflow: visible !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.golden-marker {
    background: transparent !important;
    border: none !important;
}

.golden-marker-stack {
    position: relative;
    width: 0;
    height: 0;
    overflow: visible;
    pointer-events: none;
}

.marker-pulse {
    position: absolute;
    left: 0;
    top: 0;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: default;
}

.marker-pulse::before,
.marker-pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, var(--gold-light) 0%, var(--gold) 50%, transparent 70%);
}

.marker-pulse::before {
    animation: mapPulse 2s ease-out infinite;
}

.marker-pulse::after {
    width: 12px;
    height: 12px;
    inset: 6px;
    background: var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
}

.marker-dot {
    position: absolute;
    left: 0;
    top: 0;
    width: 10px;
    height: 10px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 6px var(--gold-glow);
    opacity: 0.85;
    pointer-events: auto;
    cursor: default;
}

@keyframes mapPulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

/* Event caption beside map marker */
.map-event-caption {
    position: absolute;
    top: 50%;
    pointer-events: auto;
    cursor: default;
    width: max-content;
    max-width: min(340px, 52vw);
    padding: 1.15rem 0.65rem 0.32rem;
    background: rgba(244, 232, 208, 0.93);
    border: 1px solid rgba(107, 76, 30, 0.55);
    border-radius: 3px;
    box-shadow: 1px 2px 8px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(2px);
    transform: translateY(-50%);
    font-size: 0.72rem;
    line-height: 1.35;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    writing-mode: horizontal-tb;
    text-align: start;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.map-caption-close {
    position: absolute;
    top: 0.18rem;
    inset-inline-start: 0.22rem;
    width: 1.05rem;
    height: 1.05rem;
    padding: 0;
    border: none;
    border-radius: 2px;
    background: #c0392b;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
    z-index: 2;
}

.map-caption-close:hover {
    background: #a93226;
}

.marker-point--restore {
    cursor: pointer;
}

.map-event-caption:hover {
    border-color: rgba(107, 76, 30, 0.9);
    box-shadow: 2px 4px 16px rgba(0, 0, 0, 0.32);
}

.leaflet-marker-icon.map-marker-raised {
    z-index: 99999 !important;
}

.golden-marker-stack--ltr .map-event-caption {
    left: 14px;
    right: auto;
}

.golden-marker-stack--rtl .map-event-caption {
    right: 14px;
    left: auto;
}

.map-event-caption__date,
.map-event-caption__text,
.map-event-caption__sep {
    display: inline;
}

.map-event-caption__date {
    font-family: var(--font-en);
    font-weight: 700;
    color: var(--copper);
}

.lang-ar .map-event-caption__date {
    font-family: var(--font-ar);
}

.map-event-caption__sep {
    color: rgba(107, 76, 30, 0.55);
    font-weight: 400;
}

.map-event-caption__text {
    font-family: var(--font-ar);
    font-weight: 600;
    color: var(--ink);
}

.lang-en .map-event-caption__text {
    font-family: var(--font-en);
    font-size: 0.7rem;
}

.map-event-caption--range {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.22rem;
    max-height: min(220px, 36vh);
    overflow-y: auto;
    padding: 1.2rem 0.55rem 0.38rem;
}

.map-event-caption__line {
    display: block;
    line-height: 1.35;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.map-event-caption__line--active {
    background: rgba(212, 168, 83, 0.22);
    border-radius: 2px;
    padding: 0.08rem 0.2rem;
    margin-inline: -0.2rem;
}

.map-event-caption__line .map-event-caption__date,
.map-event-caption__line .map-event-caption__text,
.map-event-caption__line .map-event-caption__sep {
    display: inline;
}

.map-event-caption__body {
    display: block;
}

.map-event-caption__links {
    display: block;
    margin-top: 0.12rem;
    font-size: 0.65rem;
    line-height: 1.3;
}

.map-caption-link {
    pointer-events: auto;
    cursor: pointer;
    text-decoration: underline;
    font-family: var(--font-en);
    font-weight: 600;
}

.map-caption-link--wiki {
    color: #2563eb;
}

.map-caption-link--video {
    color: #dc2626;
    margin-inline-start: 0.55rem;
}

.map-caption-link--disabled {
    opacity: 0.4;
    cursor: default;
    text-decoration: none;
    pointer-events: none;
}

.lang-ar .map-caption-link--video {
    font-family: var(--font-ar);
}

/* Map overlay image layer */
.map-overlay-layer {
    pointer-events: none;
    mix-blend-mode: multiply;
    opacity: 0.55;
    transition: opacity var(--transition);
}

/* ── Iframe Viewer ──────────────────────────────────────── */

.iframe-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.iframe-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.iframe-panel {
    width: min(900px, 92vw);
    height: min(600px, 85vh);
    background: var(--leather);
    border: 2px solid var(--bronze);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7);
    transform: scale(0.95);
    transition: transform var(--transition);
}

.iframe-overlay.visible .iframe-panel {
    transform: scale(1);
}

.iframe-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: var(--leather-mid);
    border-bottom: 1px solid var(--bronze);
}

.iframe-title {
    font-family: var(--font-en);
    font-size: 0.8rem;
    color: var(--gold);
    letter-spacing: 0.05em;
}

.iframe-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--gold);
    cursor: pointer;
    line-height: 1;
}

.iframe-close:hover {
    color: var(--gold-light);
}

.iframe-panel iframe {
    flex: 1;
    border: none;
    background: #fff;
}

/* ── RTL Adjustments ────────────────────────────────────── */

body.lang-ar .timeline-item {
    direction: rtl;
}

body.lang-ar .header-brand {
    flex-direction: row;
}

body.lang-en .timeline-item {
    direction: ltr;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 768px) {
    :root {
        --timeline-w: 280px;
        --header-h: 64px;
    }

    .brand-title-ar {
        font-size: 1.1rem;
    }

    .brand-title-en {
        display: none;
    }

    .search-box {
        display: none;
    }
}

@media (max-width: 540px) {
    .main-layout {
        flex-direction: column;
    }

    .timeline-panel {
        width: 100%;
        height: 40vh;
    }

    .map-panel {
        height: 60vh;
    }

    .map-continent-legend {
        bottom: auto;
        top: 0.5rem;
        inset-inline-start: 0.5rem;
        max-width: 160px;
        font-size: 0.9em;
    }

    .map-range-control {
        bottom: 0.5rem;
        inset-inline-end: 0.5rem;
        padding: 0.45rem 0.55rem;
    }
}

/* Leaflet controls styling */
.history-map .leaflet-control-zoom a {
    background: var(--leather-mid) !important;
    color: var(--gold) !important;
    border-color: var(--bronze) !important;
}

.history-map .leaflet-control-zoom a:hover {
    background: var(--leather-light) !important;
    color: var(--gold-light) !important;
}

.history-map .leaflet-control-attribution {
    background: rgba(26, 15, 8, 0.7) !important;
    color: rgba(201, 162, 39, 0.6) !important;
    font-size: 9px !important;
}

.history-map .leaflet-control-attribution a {
    color: var(--gold) !important;
}
