:root {
    --bg-title: #ffffff;
    --bg-warm: #fdeee5;
    --bg-neutral: #f3f4f8;
    --bg-tech: #f1f8f5;
    --bg-data: #f5f5f5;
    --bg-alert: #fbe2dc;
    --bg-insight: #fcf2e6;

    --text-primary:   #1a1a1a;
    --text-secondary: #555555;
    --subtitle-color: #333333;

    --accent-warm:    #ff6b6b;
    --accent-cool:    #4ecdc4;
    --accent-caution: #ffd93d;
    --accent-extreme: #ff4757;

    --overlay-soft:   rgba(0, 0, 0, 0.05);
    --overlay-med:    rgba(0, 0, 0, 0.07);
    --overlay-lite:   rgba(0, 0, 0, 0.03);
    --overlay-border: rgba(0, 0, 0, 0.12);

    --title-overlay-from: rgba(255, 255, 255, 0.30);
    --title-overlay-to:   rgba(255, 255, 255, 0.60);

    --btn-bg: #1a1a1a;
    --btn-fg: #ffffff;

    --noise-opacity: 0.05;
    --shimmer-from:  0.02;
    --shimmer-to:    0.06;

    --panel-bg:     rgba(255, 255, 255, 0.78);
    --panel-border: rgba(0, 0, 0, 0.08);

    --font-display: 'Crimson Pro', serif;
    --font-body:    'Source Sans 3', sans-serif;
}

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

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--bg-warm);
    overflow-x: hidden;
    transition: background-color 0.8s ease;
}

h1,
h2 {
    font-family: var(--font-display);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
}

h2 {
    font-size: 2rem;
}

p {
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 800px;
    margin-bottom: 1.5rem;
}

strong {
    color: var(--text-primary);
    font-weight: 600;
}

.title-subtitle {
    font-size: 1.3rem;
    color: var(--subtitle-color);
    font-weight: 300;
    line-height: 1.8;
}

/* Scroll Snap Container */
.story-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

/* Section Styling */
.scroll-section {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
    overflow: hidden;
}

.content-wrapper {
    position: relative;
    z-index: 2;
    max-width: 800px;
    width: 100%;
    opacity: 0;
    transform: translateY(30px);
    transition: all 1s ease-out;
}

.scroll-section.active .content-wrapper {
    opacity: 1;
    transform: translateY(0);
}

/* Animations */
.animate-text {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease-out;
}

.scroll-section.active .animate-text {
    opacity: 1;
    transform: translateY(0);
}

.delay-1 { transition-delay: 0.2s; }
.delay-2 { transition-delay: 0.4s; }
.delay-3 { transition-delay: 0.6s; }

/* Content Images (transparent PNGs blend into the bg) */
.content-image {
    width: 90%;
    height: auto;
}

.content-plot {
    width: 100%;
    height: auto;
    border-radius: 0px;
}

/* Split Layout */
.split-layout {
    display: flex;
    align-items: center;
    gap: 4rem;
    max-width: 1200px;
    text-align: left;
}

.split-layout .text-content {
    flex: 1;
    min-width: 300px;
}

.split-layout .image-content {
    flex: 1.2;
    min-width: 300px;
}

.split-layout .content-image {
    margin-top: 0;
}

/* Impact Section */
.impact-section {
    text-align: center;
}

.definition-text {
    font-size: 1.3rem;
    font-weight: 300;
    margin: 2rem auto;
    max-width: 700px;
    text-align: center;
    padding: 1.5rem;
    border-radius: 0 12px 12px 0;
}

.comparison-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    margin-top: 3rem;
}

.stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.big-number {
    font-size: 5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-secondary);
}

.stat-block.highlight .big-number {
    color: var(--accent-extreme);
    text-shadow: 0 0 30px rgba(255, 71, 87, 0.3);
}

.stat-desc {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.5rem;
    color: var(--text-primary);
}

.stat-divider {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    opacity: 0.5;
}

.key-insight {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--overlay-soft);
    border-left: 4px solid var(--accent-extreme);
    border-radius: 0 8px 8px 0;
    font-size: 1.1rem;
    line-height: 1.6;
}

.call-to-action {
    margin-top: 3rem;
    padding: 2rem;
    background: linear-gradient(135deg, var(--overlay-med), var(--overlay-lite));
    border: 1px solid var(--overlay-border);
    border-radius: 12px;
    text-align: center;
}

.call-to-action p {
    margin-bottom: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: auto;
    margin-right: auto;
}

.links-container {
    max-width: 1000px;
    width: 100%;
}

.split-layout.reverse {
    flex-direction: row-reverse;
}

/* Fullbleed: figure fills the section, text in an overlay panel */
.fullbleed-section .background-element { display: none; }

.fullbleed-figure {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.fullbleed-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 2.5rem 3rem;
    border-radius: 16px;
    max-width: 650px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.fullbleed-panel h2 { margin-bottom: 1rem; }
.fullbleed-panel p  { margin-bottom: 0; }

/* Stacked: figure on top, text below */
.stacked-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    max-width: 1100px;
    text-align: center;
}

.stacked-layout .image-content {
    width: 100%;
    text-align: center;
}

.stacked-layout .image-content img {
    max-height: 55vh;
    width: auto;
    max-width: 100%;
}

.stacked-layout .text-content {
    max-width: 800px;
}

/* Pull quote */
.quote-layout {
    text-align: center;
    max-width: 1000px;
}

.pull-quote {
    font-family: var(--font-display);
    font-size: 2.4rem;
    line-height: 1.3;
    font-style: italic;
    color: var(--text-primary);
    margin: 0;
    position: relative;
    padding: 0 2rem;
}

.pull-quote::before {
    content: '\201C';
    font-size: 6rem;
    line-height: 0;
    vertical-align: -0.4em;
    color: var(--accent-extreme);
    margin-right: 0.15em;
    opacity: 0.8;
}

.pull-attribution {
    margin-top: 2rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Stats grid (3-4 cards) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    max-width: 1100px;
    margin: 3rem auto 0 auto;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: var(--overlay-soft);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--accent-cool);
    font-family: var(--font-display);
    line-height: 1;
}

.stat-item.caution .stat-number { color: var(--accent-caution); }
.stat-item.warm    .stat-number { color: var(--accent-warm); }
.stat-item.extreme .stat-number { color: var(--accent-extreme); }

.stat-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
}

/* Bar chart (vanilla, no CDN). Bars grow when the section becomes .active;
   value labels and a provenance caption fade in after. Hover/focus = exact value. */
.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2.5rem;
    height: 320px;
    max-width: 880px;
    margin: 3rem auto 0 auto;
    padding: 0 1rem;
    border-bottom: 1px solid var(--panel-border);
}

.chart-bar {
    position: relative;
    flex: 1 1 0;
    max-width: 150px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    outline: none;
}

.chart-bar-track {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    align-items: flex-end;
    min-height: 0;
}

.chart-bar-fill {
    position: relative;
    width: 100%;
    height: 0;
    color: var(--accent-cool);
    background: currentColor;
    border-radius: 10px 10px 0 0;
    transition: height 1.1s cubic-bezier(0.22, 1, 0.36, 1),
                filter 0.2s ease, box-shadow 0.2s ease;
    transition-delay: 0.45s, 0s, 0s;
}

.scroll-section.active .chart-bar-fill {
    height: var(--bar-h);
}

.chart-bar.warm    .chart-bar-fill { color: var(--accent-warm); }
.chart-bar.cool    .chart-bar-fill { color: var(--accent-cool); }
.chart-bar.caution .chart-bar-fill { color: var(--accent-caution); }
.chart-bar.extreme .chart-bar-fill { color: var(--accent-extreme); }

.chart-bar:hover .chart-bar-fill,
.chart-bar:focus .chart-bar-fill {
    filter: brightness(1.12) saturate(1.1);
    box-shadow: 0 0 26px -2px currentColor;
}

.chart-bar-value {
    position: absolute;
    top: -2.1rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.2s ease;
    transition-delay: 1.3s;
}

.scroll-section.active .chart-bar-value { opacity: 1; }

.chart-bar:hover .chart-bar-value,
.chart-bar:focus .chart-bar-value {
    transform: translateX(-50%) translateY(-4px) scale(1.08);
    transition-delay: 0s;
}

.chart-bar-label {
    margin-top: 0.9rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.35;
    min-height: 2.6em;
}

.chart-provenance {
    max-width: 700px;
    margin: 1.4rem auto 0 auto;
    text-align: center;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-secondary);
    opacity: 0.85;
}

/* Comparison columns (two text blocks side by side) */
.comparison-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.5rem;
    max-width: 1100px;
    margin: 2.5rem auto 0 auto;
}

.comparison-column {
    padding: 1.75rem;
    background: var(--overlay-soft);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
}

.comparison-column h3 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.comparison-column.warm    h3 { color: var(--accent-warm); }
.comparison-column.cool    h3 { color: var(--accent-cool); }
.comparison-column.extreme h3 { color: var(--accent-extreme); }
.comparison-column.caution h3 { color: var(--accent-caution); }

.comparison-column p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 0;
    color: var(--text-secondary);
}

/* Background Elements */
.background-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 100, 100, 0.04) 0%, transparent 70%),
        linear-gradient(0deg, transparent 0%, rgba(255, 200, 150, 0.06) 50%, transparent 100%);
    background-size: 100% 100%, 100% 200%;
    pointer-events: none;
    animation: heatwave 8s infinite linear;
    opacity: 1;
}

.title-bg {
    background: linear-gradient(var(--title-overlay-from), var(--title-overlay-to));
    background-size: cover;
    background-position: center;
    opacity: 0.2;
    mix-blend-mode: normal;
    animation: none;
}

/* When a cover.png is supplied, the title-bg inline-style overrides
   the background-image and bumps opacity; this class can be added
   alongside .title-bg in non-inline scenarios. */
.title-bg.has-cover {
    opacity: 0.55;
}

@keyframes heatwave {
    0%   { background-position: 50% 50%, 0% 0%; }
    100% { background-position: 50% 50%, 0% -200%; }
}

.background-element::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    opacity: var(--noise-opacity);
    animation: shimmer 4s infinite alternate;
}

@keyframes shimmer {
    0%   { opacity: var(--shimmer-from); transform: scale(1); }
    100% { opacity: var(--shimmer-to);   transform: scale(1.02); }
}

.btn-link {
    display: inline-block;
    margin-top: 2rem;
    padding: 1rem 2rem;
    background: var(--btn-bg);
    color: var(--btn-fg);
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    transition: transform 0.3s ease;
}

.btn-link:hover {
    transform: translateY(-2px);
}

/* ============================================================
   Mobile responsiveness
   Sections are locked to 100vh with overflow:hidden on desktop,
   which clips any stacked content taller than the viewport on a
   phone. Below we let sections grow, relax scroll-snap, and scale
   down oversized display type so nothing overflows or is cut off.
   ============================================================ */

/* Tablets and below: let tall sections breathe instead of clipping */
@media (max-width: 968px) {
    .story-container {
        scroll-snap-type: y proximity;   /* relax so tall content isn't trapped */
    }
    .scroll-section {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;              /* avoids mobile URL-bar jump */
        overflow: visible;               /* don't clip stacked image+text */
        padding: 3.5rem 1.5rem;
    }
    .content-image { width: 100%; }
    .stacked-layout .image-content img { max-height: 45vh; }

    /* split layouts stack into a single centered column */
    .split-layout,
    .split-layout.reverse {
        flex-direction: column;
        text-align: center;
        gap: 2rem;
    }
    .split-layout .text-content,
    .split-layout .image-content {
        width: 100%;
    }
}

/* Phones */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.6rem; margin-bottom: 1rem; }
    p  { font-size: 1.05rem; line-height: 1.55; }

    .scroll-section { padding: 3rem 1.25rem; }

    .title-subtitle { font-size: 1.05rem; line-height: 1.6; }

    /* big numbers must not overflow narrow screens */
    .big-number      { font-size: 3.2rem; }
    .stat-number     { font-size: 2rem; }
    .definition-text { font-size: 1.1rem; padding: 1rem; }

    /* stats grid: 2 columns, then 1 on very small screens */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-top: 2rem;
    }
    .stat-item  { padding: 1.1rem; }
    .stat-label { font-size: 0.78rem; }

    /* pull quote */
    .pull-quote { font-size: 1.6rem; padding: 0 0.5rem; }
    .pull-quote::before { font-size: 4rem; }
    .pull-attribution { letter-spacing: 1.5px; }

    /* comparison columns stack */
    .comparison-columns {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        margin-top: 1.75rem;
    }
    .comparison-stats {
        flex-direction: column;
        gap: 2rem;
    }
    .stat-divider { transform: rotate(90deg); }

    /* bar chart: shrink so labels and values still fit */
    .bar-chart       { height: 240px; gap: 1rem; padding: 0 0.25rem; margin-top: 2rem; }
    .chart-bar-value { font-size: 1.05rem; top: -1.6rem; }
    .chart-bar-label { font-size: 0.7rem; letter-spacing: 0.5px; }

    /* callouts / CTA / panels */
    .call-to-action   { padding: 1.5rem; margin-top: 2rem; }
    .call-to-action p { font-size: 1.1rem; }
    .key-insight      { padding: 1.1rem; font-size: 1rem; }
    .fullbleed-panel  { padding: 1.5rem 1.25rem; }
    .btn-link         { padding: 0.85rem 1.5rem; }
}

/* Very narrow phones: single-column stats, tighter headings */
@media (max-width: 480px) {
    .stats-grid  { grid-template-columns: 1fr; }
    h1           { font-size: 1.7rem; }
    .big-number  { font-size: 2.6rem; }
    .comparison-stats { gap: 1.5rem; }
}
