/* ============================================================
   Paul's Missionary Journeys — Map App Component Styles
   Authored to complete the interactive map shell that app.js
   requires. Loaded after styles.css (base design tokens).
   Palette: Meridian x Illuminated Manuscript x Parchment.

   IMPORTANT: All core design tokens (--accent-mahogany,
   --accent-gold, --bg-parchment, --ink-*, --border-*, fonts,
   radii, shadows) are OWNED by /styles.css. Do NOT re-declare
   them here — redefining them clobbers the shared palette used
   by the site nav, buttons, headings and footer on this page.
   Only ADD map-specific extension tokens below.
   ============================================================ */

/* Map-only EXTENSION tokens (not defined in styles.css).
   Values are derived from the site palette in /styles.css. */
:root {
    --font-serif-body: 'Cormorant Garamond', Georgia, serif;
    --active-color: var(--accent-gold);

    /* Paper surfaces */
    --bg-paper-dark: #F3ECE0;
    --bg-paper-card: #FAF6ED;

    /* Ink scale extension */
    --ink-faint: #9E9184;
    --ink-light: #FBF9F4;

    /* Gold scale extension */
    --accent-gold-bright: #D8B160;
    --accent-gold-pale: #F7F1E4;

    /* Mahogany tint derived from --accent-mahogany (#4A120E)
       for gradients (sidebar header, progress fill). */
    --accent-mahogany-light: #7A352C;

    --border-strong: rgba(197, 160, 89, 0.75);
}

.map-app,
.map-app * { box-sizing: border-box; }

.map-app {
    font-family: var(--font-body);
    background: var(--bg-parchment);
    color: var(--ink-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* ---------- Masthead ---------- */
.paul-masthead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.5rem;
    background: rgba(250, 247, 238, 0.92);
    border-bottom: 1px solid var(--border-delicate);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(6px);
}
.paul-masthead-brand {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--accent-mahogany);
    font-size: 1.05rem;
    text-transform: uppercase;
}
.paul-masthead-brand .sub { display: block; font-size: 0.78rem; letter-spacing: 0.18em; color: var(--accent-gold); font-weight: 600; }
.paul-masthead-links { display: flex; align-items: center; gap: 1rem; }
.paul-masthead-links a { color: var(--accent-mahogany); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.paul-masthead-links a:hover { color: var(--accent-gold); }

/* ---------- Hero ---------- */
.paul-hero {
    position: relative;
    text-align: center;
    padding: 2.6rem 1.5rem 2rem;
    overflow: hidden;
}
#heroCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.paul-hero-inner { position: relative; z-index: 2; max-width: 900px; margin: 0 auto; }
.paul-hero-badge { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--accent-gold); font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600; }
.paul-hero h1 {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    margin: 0.8rem 0 0.6rem;
    color: var(--accent-mahogany);
    line-height: 1.1;
}
.paul-hero-quote { font-family: var(--font-serif-body); font-style: italic; color: var(--ink-muted); font-size: 1.2rem; max-width: 720px; margin: 0 auto; }
.paul-hero-quote .ref { font-style: normal; font-weight: 700; color: var(--accent-mahogany); letter-spacing: 0.08em; }

/* burst diamonds in the hero title */
.burst-diamond {
    display: inline-block;
    width: 0.55rem; height: 0.55rem;
    background: linear-gradient(135deg, var(--accent-gold-bright), var(--accent-gold));
    transform: rotate(45deg);
    margin: 0 0.4rem;
    vertical-align: middle;
    cursor: pointer;
    transition: transform .2s;
}
.burst-anim { transform: rotate(45deg) scale(1.6); }

/* ---------- Controls Bar ---------- */
.paul-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem 1.4rem;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    background: var(--bg-paper-light);
    border-block: 1px solid var(--border-delicate);
}
.control-group { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.control-label { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; }

.map-search-wrap { display: flex; align-items: center; gap: 0.4rem; }
#mapSearchInput {
    padding: 0.5rem 0.8rem; border: 1px solid var(--border-strong); border-radius: 8px;
    background: var(--bg-paper-light); color: var(--ink-primary); font-size: 0.9rem; min-width: 220px;
}
#btnSearch {
    padding: 0.5rem 0.9rem; border: none; border-radius: 8px; background: var(--accent-mahogany);
    color: #fff; font-weight: 600; cursor: pointer;
}
#btnSearch:hover { background: var(--accent-mahogany-hover); }

#journeyFilterChips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.filter-chip {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.35rem 0.7rem; border-radius: 999px; border: 1px solid var(--border-strong);
    background: var(--bg-paper-light); color: var(--ink-primary); font-size: 0.82rem; font-weight: 700;
    cursor: pointer; opacity: 0.45; transition: all .2s;
}
.filter-chip.active { opacity: 1; color: #fff; background: var(--chip-color, var(--accent-gold)); border-color: var(--chip-color, var(--accent-gold)); }

#timelineSlider { accent-color: var(--accent-gold); cursor: pointer; width: min(280px, 45vw); }

.paul-keys-hint { font-size: 0.72rem; color: var(--ink-faint); }

/* ---------- Journey Tabs ---------- */
.paul-tabs {
    display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center;
    padding: 1.1rem 1.5rem; background: var(--bg-paper-dark);
    border-bottom: 1px solid var(--border-delicate);
}
#journeyTabs { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.journey-tab {
    min-width: 150px; text-align: left; cursor: pointer;
    border: 1px solid var(--border-delicate); border-left: 4px solid var(--tab-color);
    background: var(--bg-paper-card); border-radius: var(--radius-card);
    padding: 0.7rem 0.9rem; color: var(--ink-primary); transition: all .2s;
}
.journey-tab:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(43,35,31,0.08); }
.journey-tab.active { border-color: var(--tab-color); background: #fff; box-shadow: 0 8px 22px rgba(197,160,89,0.18); }
.tab-header { display: flex; justify-content: space-between; align-items: center; }
.tab-badge { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; color: var(--accent-mahogany); background: var(--accent-gold-light); border-radius: 999px; padding: 0.1rem 0.5rem; }
.tab-dates { font-size: 0.68rem; color: var(--ink-faint); }
.tab-title { font-family: var(--font-heading); font-weight: 700; font-size: 1rem; margin: 0.35rem 0 0.1rem; }
.tab-scripture { font-size: 0.74rem; color: var(--accent-mahogany); }

/* ---------- Main Map + Sidebar layout ----------
   Story-first proportions: the narrative/video panel is the primary
   surface (~62%), the route map is the compact companion (~38%). */
.paul-stage {
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 0;
    /* Taller atlas so the story panel shows more of the animated clip at once. */
    height: clamp(560px, calc(100vh - 4rem), 880px);
    min-height: 620px;
    border: 1px solid var(--border-delicate);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
#mapContainer { width: 100%; height: 100%; z-index: 1; background: var(--bg-paper-light); }
#mapContainer.leaflet-container { font-family: inherit; }

/* Sidebar */
.paul-sidebar {
    display: flex; flex-direction: column;
    background: var(--bg-paper-light); border-left: 1px solid var(--border-delicate);
    height: 100%; max-height: 100%; min-height: 0; overflow: visible; min-width: 0;
    position: relative; z-index: 500;
}
#scrollSidebar { position: relative; }
#scrollSidebar.collapsed { width: 0; border-left: 0; }
#scrollSidebar.collapsed > :not(.sidebar-toggle-zone) { visibility: hidden; }
/* Collapse the second (story/sidebar) column and let the map fill the stage. */
.paul-stage:has(#scrollSidebar.collapsed) { grid-template-columns: 1fr 0; }
.sidebar-toggle-zone { position: absolute; top: 0; right: 100%; z-index: 5; }
#sidebarToggleBtn {
    background: var(--accent-mahogany); color: #fff; border: none; cursor: pointer;
    padding: 0.6rem 0.5rem; border-radius: 8px 0 0 8px; font-size: 0.9rem;
}
.sidebar-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent-mahogany) 0%, var(--accent-mahogany-light) 100%);
    color: var(--ink-light); padding: 1.1rem 1.2rem;
}
#sidebarJourneyBadge { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--accent-gold); color: var(--accent-mahogany); }
#sidebarJourneyTitle { font-family: var(--font-heading); font-size: 1.5rem; margin: 0.5rem 0 0.15rem; }
#sidebarJourneyRef { font-size: 0.85rem; opacity: 0.9; }

.sidebar-tabs { flex-shrink: 0; display: flex; border-bottom: 1px solid var(--border-faint); background: var(--bg-paper-dark); }
.sidebar-tab-btn {
    flex: 1; padding: 0.7rem 0.5rem; border: none; background: transparent; cursor: pointer;
    font-size: 0.8rem; font-weight: 600; color: var(--ink-muted); border-bottom: 2px solid transparent;
}
.sidebar-tab-btn.active { color: var(--accent-mahogany); border-bottom-color: var(--accent-gold); background: var(--bg-paper-light); }

.sidebar-body {
    flex: 1 1 0;
    min-height: 0;
    height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-gold) var(--bg-paper-card);
}
.sidebar-body::-webkit-scrollbar { width: 6px; }
.sidebar-body::-webkit-scrollbar-track { background: var(--bg-paper-card); border-radius: 3px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--accent-gold); border-radius: 3px; }
.sidebar-body::-webkit-scrollbar-thumb:hover { background: var(--accent-mahogany); }

.sidebar-view { display: none; min-height: 0; }
.sidebar-view.active { display: block; }

/* Playback bar — pinned directly under the sidebar tabs, above the first
   waypoint node, so controls are seen first (esp. mobile vertical view). */
.sidebar-playback { flex-shrink: 0; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-faint); background: var(--bg-paper-card); }
.playback-row { display: flex; align-items: center; gap: 0.5rem; }
.sidebar-playback .playback-row:first-child { justify-content: space-between; gap: 0.5rem; }
.playback-row + .playback-row { margin-top: 0.4rem; }
.playback-btn {
    width: 38px; height: 38px; border: 1px solid var(--border-strong); border-radius: 50%;
    background: var(--bg-paper-light); color: var(--accent-mahogany); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.playback-btn:hover { background: var(--accent-gold-pale); }
.map-voice-select {
    min-height: 32px;
    padding: 0 0.4rem;
    font-family: var(--font-body);
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--ink-primary);
    background: var(--bg-paper-light);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s ease;
    outline: none;
    max-width: 140px;
}
.map-voice-select:hover,
.map-voice-select:focus {
    border-color: var(--accent-gold);
    color: var(--accent-mahogany);
}
.sword-track { flex: 1; height: 8px; background: var(--accent-gold-pale); border-radius: 999px; overflow: hidden; border: 1px solid var(--border-faint); }
#swordFireFill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent-gold), var(--accent-mahogany-light)); transition: width 0.05s linear; }
#swordFireFill.timer-running { background: linear-gradient(90deg, var(--accent-gold-bright), var(--accent-mahogany)); }
.countdown-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--ink-muted); }
#waypointCounter { font-weight: 700; color: var(--accent-mahogany); }

/* ---------- Waypoint cards (Itinerary) ---------- */
.waypoint-card {
    display: flex; gap: 0.7rem; padding: 0.75rem; margin-bottom: 0.6rem;
    border: 1px solid var(--border-faint); border-radius: var(--radius-card);
    background: var(--bg-paper-card); cursor: pointer; transition: all .18s;
}
.waypoint-card:hover { border-color: var(--border-strong); box-shadow: 0 4px 12px rgba(43,35,31,0.06); }
.waypoint-card.active { border-color: var(--accent-gold); background: #fff; box-shadow: 0 6px 16px rgba(197,160,89,0.2); }
.step-marker {
    flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; border: 2px solid;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: var(--accent-mahogany); background: var(--bg-paper-light);
}
.waypoint-card-content { min-width: 0; }
.waypoint-card-header { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.waypoint-card-title { font-weight: 700; font-family: var(--font-heading); }
.waypoint-card-scripture { font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.waypoint-card-region { font-size: 0.72rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.waypoint-card-summary { font-size: 0.82rem; color: var(--ink-muted); margin: 0.35rem 0 0; }

/* ---------- Detail / Overview panels ---------- */
.waypoint-detail-panel { animation: fadein .3s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.detail-banner { border-left: 4px solid; border-radius: var(--radius-card); padding: 0.8rem 1rem; margin-bottom: 1rem; background: var(--bg-paper-card); }
.detail-step-tag { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.detail-city-title { font-family: var(--font-heading); font-size: 1.6rem; margin: 0.35rem 0 0.4rem; color: var(--accent-mahogany); }
.detail-meta-row { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--ink-muted); }
.scripture-box { border: 1px solid; border-radius: var(--radius-card); padding: 0.9rem 1rem; margin-bottom: 1rem; background: var(--bg-paper-light); }
.scripture-box-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid; padding-bottom: 0.4rem; margin-bottom: 0.6rem; }
.scripture-label { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); font-weight: 700; }
.scripture-ref-badge { font-size: 0.8rem; font-weight: 700; }
.verses-container .verse-item { margin-bottom: 0.5rem; }
.verse-num { display: inline-block; min-width: 1.6rem; font-weight: 700; color: var(--accent-gold); }
.verse-text { font-family: var(--font-serif-body); font-size: 1rem; }
.narrative-box { margin-bottom: 1rem; padding: 0.9rem 1rem; border-radius: var(--radius-card); background: var(--bg-paper-light); border: 1px solid var(--border-faint); }
.section-subheading { font-family: var(--font-heading); font-size: 1rem; margin: 0 0 0.4rem; }
.narrative-text { color: var(--ink-muted); font-size: 0.92rem; }
.key-events-list { margin: 0; padding-left: 1.1rem; color: var(--ink-muted); font-size: 0.9rem; }
.key-events-list li { margin-bottom: 0.25rem; }
.characters-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.character-tag { background: var(--accent-gold-pale); border: 1px solid var(--border-delicate); color: var(--accent-mahogany); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.78rem; }

/* Waypoint illustration figure (detail panel) — media + caption only, no toolbar. */
.wp-figure { margin: 0 0 1rem; border: 1px solid var(--border-delicate); border-radius: var(--radius-card); overflow: hidden; background: var(--bg-paper-card); }
/* Detail panel media: fit the full clip into the visible panel height so it is
   never cropped off — letterboxed/darkened rather than cut. */
.wp-img { display: block; width: 100%; max-height: 62vh; height: auto; object-fit: contain; background: #0d0a08; }
.wp-figure figcaption { padding: 0.35rem 0.7rem; font-size: 0.74rem; color: var(--ink-muted); background: var(--bg-paper-light); }

/* Journey overview waypoint gallery */
.wp-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.6rem; }
.wp-gallery img, .wp-gallery video { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-faint); display: block; }
.wp-gallery img, .wp-gallery video { cursor: pointer; transition: transform .15s; }
.wp-gallery img:hover, .wp-gallery video:hover { transform: scale(1.04); border-color: var(--accent-gold); }

/* ---------- Leaflet custom pins & popups ---------- */
.custom-leaflet-pin { background: transparent; border: none; }
.custom-pin-marker { display: flex; align-items: center; justify-content: center; }
.pin-disc {
    width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.75rem; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.custom-pin-marker.active-pin .pin-disc { outline: 3px solid var(--accent-gold-bright); transform: scale(1.15); transition: transform .15s; }
.map-popup-card { min-width: 200px; }
.popup-step-tag { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.popup-title { font-family: var(--font-heading); font-size: 1.05rem; font-weight: 700; }
.popup-ref { font-size: 0.8rem; color: var(--accent-mahogany); margin-bottom: 0.3rem; }
.popup-summary { font-size: 0.82rem; color: var(--ink-muted); margin-bottom: 0.5rem; }
.popup-btn { border: none; color: #fff; padding: 0.4rem 0.7rem; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 0.8rem; }

/* ------------------------------------------------------------------
   Slim the banner/header areas on the atlas page so the route map and
   the animated clips get the viewport. Scoped to .map-app only — the
   shared site styles.css keeps its own (taller) page-header look.
   ------------------------------------------------------------------ */
.map-app .page-header { padding: 0.6rem var(--sp-4) 0.5rem; }
.map-app .page-header .gold-badge { margin-bottom: 0.15rem; font-size: 0.62rem; padding: 0.22rem 0.6rem; }
.map-app .page-header h1 { font-size: clamp(1.35rem, 2.5vw, 1.9rem); margin-bottom: 0.2rem; }
.map-app .page-header p { font-size: 0.88rem; line-height: 1.45; max-width: 760px; }

.map-app .section { padding: 1.1rem 0 1.25rem; }

.map-app .paul-controls { padding: 0.7rem 1.25rem; }
.map-app .paul-tabs { padding: 0.7rem 1.25rem; }

/* Compact the story panel's journey header into a single slim row so the
   animated clip below gets the vertical space. Falls back to wrapping (two
   tidy lines) on narrow panels. */
.map-app .sidebar-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    padding: 0.3rem 0.95rem;
}
.map-app #sidebarJourneyBadge { font-size: 0.54rem; padding: 0.06rem 0.4rem; margin: 0; white-space: nowrap; }
.map-app #sidebarJourneyTitle {
    font-size: 0.92rem;
    margin: 0;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 0 1 auto;
}
.map-app #sidebarJourneyRef { font-size: 0.7rem; line-height: 1.15; white-space: nowrap; }

/* ---------- Responsive ---------- */
/* Narrow desktop/tablet landscape: shrink the map column so the story
   panel never drops below a comfortable reading width (~420px+). */
@media (max-width: 1100px) and (min-width: 901px) {
    .paul-stage { grid-template-columns: 380px 1fr; }
    .paul-stage:has(#scrollSidebar.collapsed) { grid-template-columns: 1fr 0; }
}
@media (max-width: 900px) {
    .paul-stage { grid-template-columns: 1fr; height: auto; min-height: 0; }
    .paul-stage:has(#scrollSidebar.collapsed) { grid-template-columns: 1fr; grid-template-rows: auto 0; }
    #mapContainer { height: 55vh; }
    .paul-sidebar {
        border-left: none;
        border-top: 1px solid var(--border-delicate);
        height: auto;
        max-height: none;
    }
    .sidebar-body {
        height: auto;
        max-height: 60vh;
        overflow-y: auto;
    }
    #scrollSidebar.collapsed { width: 100%; height: 0; }
    .sidebar-toggle-zone { top: auto; right: 0; bottom: 100%; }
    #sidebarToggleBtn { border-radius: 8px 8px 0 0; }
    .paul-masthead { flex-direction: column; gap: 0.4rem; align-items: flex-start; }
}

/* Active narration voice + engine, mirroring the reader's "Neural Audio" status.
   The map and the reader keep separate voice preferences on purpose; this is the
   label that makes which one is in use visible. */
.map-voice-status {
    font-size: 0.72rem;
    color: var(--ink-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 15rem;
    align-self: center;
    padding-left: 0.5rem;
    opacity: 0.85;
}
