/* Story Maps immersive viewer.
   A fixed full-viewport map sits behind (.sm-body > #sm-map, z 1); the
   narrative (.sm-scroll, z 2) scrolls over it as glass cards. The accent
   colour is injected per-brand from the template (--sm-accent). */

:root {
    --sm-accent: #35c56f;
    --sm-bg: #0b1410;
    --sm-card-bg: rgba(10, 18, 14, 0.78);
    --sm-card-border: rgba(255, 255, 255, 0.09);
    --sm-text: #e9f2ec;
    --sm-text-muted: rgba(233, 242, 236, 0.62);
    --sm-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --sm-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

.sm-body {
    margin: 0;
    background: var(--sm-bg);
    color: var(--sm-text);
    font-family: var(--sm-sans);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Map ---------- */

#sm-map {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: var(--sm-bg);
}
/* Keep the (legally required) tile attribution visible above the story. */
#sm-map .maplibregl-ctrl-bottom-right {
    position: fixed;
    z-index: 8;
}

/* Full-screen photo backdrops for background='image' chapters: fixed over
   the map, under the scrolling narrative, cross-faded per chapter. */
.sm-bgs {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}
.sm-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.8s ease;
}
.sm-bg.is-active { opacity: 1; }
.sm-bg::after {
    /* gentle scrim so the floating card stays readable on bright photos */
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 8, 0.25);
}

@media (prefers-reduced-motion: reduce) {
    .sm-bg { transition: none; }
}

/* ---------- Scroll container ---------- */

.sm-scroll { position: relative; z-index: 2; }

/* ---------- Progress bar ---------- */

.sm-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    z-index: 12;
    background: rgba(255, 255, 255, 0.08);
}
.sm-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--sm-accent), #9be8bd);
    transition: width 0.15s linear;
}

/* ---------- Top bar ---------- */

.sm-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px 26px;
    background: linear-gradient(180deg, rgba(5, 10, 8, 0.72) 0%,
                                rgba(5, 10, 8, 0.35) 55%, transparent 100%);
    pointer-events: none;
}
.sm-topbar a, .sm-topbar button { pointer-events: auto; }

.sm-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sm-text);
    text-decoration: none;
    font-size: 0.95rem;
    min-width: 0;
}
.sm-brand img {
    height: 30px;
    width: auto;
    border-radius: 6px;
    flex: none;
}
.sm-brand-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sm-brand-sep { color: var(--sm-text-muted); }
.sm-brand-section {
    color: var(--sm-text-muted);
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.sm-brand:hover .sm-brand-section { color: var(--sm-accent); }

.sm-topbar-right { display: flex; align-items: center; gap: 10px; }

.sm-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    border-radius: 999px;
    border: 1px solid var(--sm-card-border);
    background: rgba(10, 18, 14, 0.55);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--sm-text);
    font: 600 0.83rem var(--sm-sans);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.sm-share-btn:hover { border-color: var(--sm-accent); color: var(--sm-accent); }

/* Embed mode: no topbar; one pill linking back to the full story. */
.sm-embed-open {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--sm-card-border);
    background: rgba(10, 18, 14, 0.62);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--sm-text);
    font: 600 0.8rem var(--sm-sans);
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
}
.sm-embed-open:hover { border-color: var(--sm-accent); color: var(--sm-accent); }

.sm-draft-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border-radius: 999px;
    background: rgba(214, 158, 46, 0.18);
    border: 1px solid rgba(214, 158, 46, 0.55);
    color: #f0c060;
    font: 600 0.78rem var(--sm-sans);
    letter-spacing: 0.03em;
}

/* ---------- Cover ---------- */

.sm-cover {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 18vh 6vw 14vh;
    background: radial-gradient(120% 90% at 50% 10%,
                                #16352a 0%, #0d1d16 55%, #081109 100%);
    background-size: cover;
    background-position: center;
}
.sm-cover-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(5, 10, 8, 0.5) 0%,
                                rgba(5, 10, 8, 0.35) 45%,
                                rgba(5, 10, 8, 0.78) 100%);
}
.sm-cover-content {
    position: relative;
    max-width: 880px;
    animation: sm-rise 0.9s ease-out both;
}
.sm-cover-orglogo {
    height: 54px;
    width: auto;
    margin-bottom: 26px;
    border-radius: 10px;
}
.sm-cover-title {
    margin: 0 0 18px;
    font-size: clamp(2.3rem, 6.5vw, 4.4rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.08;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.55);
}
.sm-cover-subtitle {
    margin: 0 auto 26px;
    max-width: 640px;
    font-family: var(--sm-serif);
    font-size: clamp(1.05rem, 2.4vw, 1.4rem);
    line-height: 1.55;
    color: rgba(233, 242, 236, 0.88);
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}
.sm-cover-byline {
    font-size: 0.92rem;
    color: rgba(233, 242, 236, 0.78);
    letter-spacing: 0.02em;
}
.sm-dot-sep { margin: 0 8px; color: var(--sm-text-muted); }

.sm-scroll-cue {
    position: absolute;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: rgba(233, 242, 236, 0.8);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.sm-scroll-cue i {
    font-size: 1.4rem;
    animation: sm-bounce 1.8s ease-in-out infinite;
}

@keyframes sm-rise {
    from { opacity: 0; transform: translateY(26px); }
    to { opacity: 1; transform: none; }
}
@keyframes sm-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50% { transform: translateY(7px); opacity: 1; }
}

/* ---------- Chapters ---------- */

.sm-chapter {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    padding: 14vh 5vw;
}
.sm-layout-left { justify-content: flex-start; }
.sm-layout-right { justify-content: flex-end; }
.sm-layout-center, .sm-layout-full { justify-content: center; }

.sm-card {
    width: min(440px, 92vw);
    padding: 26px 30px 30px;
    border-radius: 18px;
    background: var(--sm-card-bg);
    border: 1px solid var(--sm-card-border);
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
    backdrop-filter: blur(14px) saturate(1.15);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    opacity: 0.35;
    transform: translateY(14px) scale(0.985);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.sm-layout-full .sm-card { width: min(860px, 94vw); }
.sm-chapter.is-active .sm-card {
    opacity: 1;
    transform: none;
}

.sm-card-kicker {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: var(--sm-accent);
    margin-bottom: 10px;
}
.sm-card-title {
    margin: 0 0 14px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
}
.sm-card-body {
    font-family: var(--sm-serif);
    font-size: 1.05rem;
    line-height: 1.75;
    color: rgba(233, 242, 236, 0.92);
}
.sm-card-body p { margin: 0 0 1em; }
.sm-card-body p:last-child { margin-bottom: 0; }
.sm-card-body a { color: var(--sm-accent); }
.sm-card-body blockquote {
    margin: 1em 0;
    padding-left: 14px;
    border-left: 3px solid var(--sm-accent);
    color: var(--sm-text-muted);
    font-style: italic;
}

.sm-card-media { margin: 0 0 16px; }
.sm-card-media img {
    display: block;
    width: 100%;
    border-radius: 12px;
}
.sm-card-media figcaption {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--sm-text-muted);
}
.sm-video-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
}
.sm-video-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ---------- Chapter dots ---------- */

.sm-dots {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sm-dots button {
    width: 10px;
    height: 10px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: background 0.25s, transform 0.25s, border-color 0.25s;
}
.sm-dots button:hover { border-color: #fff; }
.sm-dots button.is-active {
    background: var(--sm-accent);
    border-color: var(--sm-accent);
    transform: scale(1.35);
    box-shadow: 0 0 12px rgba(53, 197, 111, 0.6);
}

/* ---------- Legend ---------- */

.sm-legend {
    position: fixed;
    left: 18px;
    bottom: 40px;
    z-index: 9;
    max-width: 260px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--sm-card-bg);
    border: 1px solid var(--sm-card-border);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    font-size: 0.8rem;
}
.sm-legend-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 3px 0;
    color: rgba(233, 242, 236, 0.9);
}
.sm-legend-swatch {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    flex: none;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* ---------- Toast ---------- */

.sm-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    padding: 10px 22px;
    border-radius: 999px;
    background: rgba(10, 18, 14, 0.92);
    border: 1px solid var(--sm-accent);
    color: var(--sm-text);
    font-size: 0.85rem;
    animation: sm-rise 0.25s ease-out both;
}

/* ---------- Outro / data sources ---------- */

.sm-outro {
    position: relative;
    background: #0a120e;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12vh 6vw 10vh;
}
.sm-outro-inner { max-width: 780px; margin: 0 auto; }

.sm-outro-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 10px;
    font-size: 1.7rem;
    letter-spacing: -0.01em;
}
.sm-outro-heading i { color: var(--sm-accent); }
.sm-outro-blurb {
    margin: 0 0 34px;
    max-width: 560px;
    color: var(--sm-text-muted);
    line-height: 1.65;
}

.sm-source-card {
    margin-bottom: 16px;
    padding: 18px 22px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--sm-card-border);
    transition: border-color 0.25s;
}
.sm-source-card:hover { border-color: rgba(255, 255, 255, 0.2); }
.sm-source-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.sm-source-head a {
    color: var(--sm-text);
    font-weight: 600;
    text-decoration: none;
}
.sm-source-head a:hover { color: var(--sm-accent); }
.sm-type-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: none;
}
.sm-source-type {
    margin-left: auto;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sm-text-muted);
}
.sm-source-citation {
    margin: 0 0 12px;
    padding-left: 14px;
    border-left: 3px solid var(--sm-accent);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--sm-text-muted);
}
.sm-source-actions {
    display: flex;
    gap: 18px;
    font-size: 0.82rem;
}
.sm-source-actions a,
.sm-source-actions button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--sm-accent);
    font: 600 0.82rem var(--sm-sans);
    text-decoration: none;
    cursor: pointer;
}
.sm-source-actions a:hover,
.sm-source-actions button:hover { text-decoration: underline; }

.sm-pgis-credits {
    margin-top: 30px;
    padding: 18px 22px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--sm-card-border);
}
.sm-pgis-credits h3 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 10px;
    font-size: 1rem;
}
.sm-pgis-credits h3 i { color: var(--sm-accent); }
.sm-pgis-credits ul {
    margin: 0;
    padding-left: 20px;
    color: var(--sm-text-muted);
    font-size: 0.9rem;
    line-height: 1.8;
}

.sm-outro-footer {
    margin-top: 56px;
    padding-top: 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    text-align: center;
}
.sm-outro-meta {
    display: flex;
    justify-content: center;
    gap: 26px;
    flex-wrap: wrap;
    margin-bottom: 26px;
    color: var(--sm-text-muted);
    font-size: 0.88rem;
}
.sm-outro-meta i { color: var(--sm-accent); margin-right: 5px; }
.sm-outro-cta {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 12px 28px;
    border-radius: 999px;
    background: var(--sm-accent);
    color: #06130b;
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}
.sm-outro-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(53, 197, 111, 0.35);
}
.sm-outro-brandline {
    margin: 30px 0 0;
    font-size: 0.8rem;
    color: var(--sm-text-muted);
}

/* ---------- Mobile ---------- */

@media (max-width: 900px) {
    .sm-dots { display: none; }
}

@media (max-width: 720px) {
    .sm-topbar { padding: 10px 14px 22px; }
    .sm-brand-name { display: none; }
    .sm-brand-sep { display: none; }
    .sm-share-btn span { display: none; }
    .sm-share-btn { padding: 7px 11px; }

    .sm-chapter {
        align-items: flex-end;
        padding: 12vh 4vw 9vh;
    }
    .sm-layout-left, .sm-layout-right,
    .sm-layout-center, .sm-layout-full { justify-content: center; }
    .sm-card, .sm-layout-full .sm-card {
        width: 100%;
        padding: 20px 20px 24px;
    }
    .sm-card-title { font-size: 1.3rem; }
    .sm-card-body { font-size: 1rem; }

    .sm-legend {
        left: 12px;
        bottom: 30px;
        max-width: 200px;
        padding: 9px 12px;
        font-size: 0.72rem;
    }
    .sm-source-type { display: none; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .sm-cover-content, .sm-scroll-cue i, .sm-toast { animation: none; }
    .sm-card {
        transition: opacity 0.3s ease;
        transform: none;
    }
    .sm-chapter.is-active .sm-card { transform: none; }
    .sm-progress-fill { transition: none; }
}
