/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
    --font-display: 'Newsreader', Georgia, serif;
    --font-body: 'Source Sans 3', -apple-system, sans-serif;
    --color-bg: #fafaf8;
    --color-text: #1a1a1a;
    --color-text-secondary: #555;
    --color-text-tertiary: #767676;
    --color-accent-quant: #2166ac;
    --color-accent-ethno: #c4a35a;
    --color-border: #e5e5e3;
    --color-surface: #ffffff;
    --color-surface-alt: #f5f5f3;
    --color-bg-rgb: 250, 250, 248;
    --color-scrolly-bg: #f0f0ee;
    --project-nav-height: 56px;
    --chapter-nav-height: 52px;
}

[data-theme="dark"] {
    --color-bg: #121212;
    --color-text: #e8e6e3;
    --color-text-secondary: #b0aea8;
    --color-text-tertiary: #8a8880;
    --color-accent-quant: #5c9fd4;
    --color-accent-ethno: #f5c542;
    --color-border: #2a2a28;
    --color-surface: #1e1e1e;
    --color-surface-alt: #252523;
    --color-bg-rgb: 18, 18, 18;
    --color-scrolly-bg: #1a1a18;
}

/* Dark mode overrides for elements with semantic colors */
[data-theme="dark"] .method-status--published {
    background: #1b3a1e;
    color: #81c784;
}

[data-theme="dark"] .method-status--forthcoming {
    background: #3e2a14;
    color: #ffb74d;
}

[data-theme="dark"] .step--transition {
    background: #0a0a0a;
}

/* ============================================
   SKIP TO CONTENT (accessibility)
   ============================================ */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 999;
    padding: 8px 16px;
    background: var(--color-text);
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.9rem;
    border-radius: 0 0 4px 4px;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* Screen-reader-only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--project-nav-height) + var(--chapter-nav-height) + 24px);
}

body {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
}

/* Focus styles for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--color-accent-quant);
    outline-offset: 2px;
}

/* Reduced motion: disable animations for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   PROJECT NAV (back to portfolio)
   ============================================ */
.project-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    min-height: var(--project-nav-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    background: rgba(var(--color-bg-rgb), 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
}

.project-nav a {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--color-text-tertiary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.project-nav a:hover {
    color: var(--color-text);
}

/* Theme toggle */
.theme-toggle {
    margin-left: auto;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--color-text-secondary);
    transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    color: var(--color-text);
    border-color: var(--color-text-tertiary);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--color-accent-quant);
    outline-offset: 2px;
}

[data-theme="light"] .theme-toggle-icon::before,
:root:not([data-theme]) .theme-toggle-icon::before {
    content: '\263E'; /* moon */
}

[data-theme="dark"] .theme-toggle-icon::before {
    content: '\2600'; /* sun */
}

/* ============================================
   HEADER
   ============================================ */
.header {
    max-width: 800px;
    margin: 0 auto;
    padding: 100px 20px 60px;
    text-align: center;
}

.kicker {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-tertiary);
    margin-bottom: 16px;
}

.header h1 {
    font-family: var(--font-display);
    font-size: 2.8rem;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.15;
}

.subtitle {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.byline {
    font-size: 0.95rem;
    color: var(--color-text-tertiary);
}

.byline-affiliation {
    font-size: 0.85rem;
    color: var(--color-text-tertiary);
    margin-top: 4px;
}

/* ============================================
   INTRO SECTION
   ============================================ */
.intro {
    max-width: 680px;
    margin: 0 auto;
    padding: 20px 20px 60px;
}

.intro-lede {
    font-family: var(--font-display);
    font-size: 1.25rem;
    line-height: 1.75;
    margin-bottom: 28px;
}

.intro p {
    font-size: 1.1rem;
    margin-bottom: 24px;
    line-height: 1.7;
}

/* ============================================
   CHAPTER NAV
   ============================================ */
.chapter-nav {
    position: sticky;
    top: var(--project-nav-height);
    z-index: 190;
    background: rgba(var(--color-bg-rgb), 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(229, 229, 227, 0.65);
    border-bottom: 1px solid var(--color-border);
}

.chapter-nav-inner {
    display: flex;
    align-items: center;
    gap: 22px;
    min-height: var(--chapter-nav-height);
    padding: 0 20px;
    overflow-x: auto;
    scrollbar-width: none;
}

.chapter-nav-inner::-webkit-scrollbar {
    display: none;
}

.chapter-nav-link {
    position: relative;
    flex: 0 0 auto;
    padding: 0;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--color-text-tertiary);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.chapter-nav-link::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -12px;
    height: 2px;
    background: var(--color-accent-quant);
    opacity: 0;
    transform: scaleX(0.65);
    transform-origin: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chapter-nav-link:hover {
    color: var(--color-text);
}

.chapter-nav-link.is-active,
.chapter-nav-link[aria-current='location'] {
    color: var(--color-text);
}

.chapter-nav-link.is-active::after,
.chapter-nav-link[aria-current='location']::after {
    opacity: 1;
    transform: scaleX(1);
}

.step[id],
.tech-overview,
.methods {
    scroll-margin-top: calc(var(--project-nav-height) + var(--chapter-nav-height) + 24px);
}

/* ============================================
   SCROLLYTELLING SECTION
   ============================================ */
#scrolly {
    position: relative;
    display: flex;
    background-color: var(--color-scrolly-bg);
}

/* Sticky map container */
.sticky-map {
    position: sticky;
    top: 0;
    width: 60%;
    height: 100vh;
    flex-shrink: 0;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

#map {
    width: 100%;
    height: 100%;
}

/* Story text container */
.story {
    position: relative;
    width: 40%;
    padding: 40vh 0;
    /* Pass pointer events through transparent gaps between step cards so the
       map remains interactive. Each .step re-enables pointer events. */
    pointer-events: none;
}

/* ============================================
   SCROLL STEP CARDS (base)
   ============================================ */
.step {
    background: var(--color-surface);
    margin: 0 20px 80vh 20px;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    opacity: 0.3;
    transition: opacity 0.4s ease;
    pointer-events: auto;
}

.step.is-active {
    opacity: 1;
}

.step-label {
    display: block;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-tertiary);
    margin-bottom: 8px;
}

.step h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.25;
    color: var(--color-text);
}

.step h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 12px;
    margin-top: 24px;
    color: var(--color-text);
}

.step p {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
    line-height: 1.7;
}

.step p:last-child {
    margin-bottom: 0;
}

.step a {
    color: var(--color-text-secondary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.step a:hover {
    color: var(--color-text);
}

/* ============================================
   STEP TYPE VARIANTS
   ============================================ */

/* Quantitative sections: clean, analytical */
.step--quant {
    background: var(--color-surface);
}

/* Ethnographic sections: warm, organic */
.step--ethno {
    background: var(--color-surface-alt);
    border-left: 3px solid var(--color-accent-ethno);
}

/* Transition step (The Flip): dark, dramatic */
.step--transition {
    background: #1a1a1a;
    color: #f5f5f3;
    text-align: center;
}

.step--transition h2 {
    color: #f5f5f3;
}

.step--transition p {
    color: #bbb;
}

.step--transition .flip-context {
    font-size: 0.9rem;
    color: var(--color-text-tertiary);
    margin-top: 20px;
}

/* Synthesis step */
.step--synthesis {
    background: var(--color-surface);
    border-top: 3px solid var(--color-text);
}

/* ============================================
   DATA CALLOUTS
   ============================================ */
.data-callout {
    margin: 20px 0;
    padding: 12px 0;
}

.data-number {
    display: block;
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.data-label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-tertiary);
    margin-top: 4px;
}

/* ============================================
   COMPARISON LAYOUT (Part 3: The Gap)
   ============================================ */
.comparison {
    display: flex;
    gap: 16px;
    margin: 20px 0;
}

.comparison-col {
    flex: 1;
    padding: 16px;
    background: var(--color-surface-alt);
    border-radius: 6px;
}

.comparison-col h4 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.data-detail {
    font-size: 0.82rem;
    color: var(--color-text-tertiary);
    margin-top: 4px;
}

/* Study area b-roll videos inside comparison columns */
.video-wrapper {
    position: relative;
    isolation: isolate; /* contain child z-index so button doesn't escape into root stacking context */
    width: calc(100% + 32px); /* bleed to column edges */
    margin: 12px -16px -16px;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
    background: #1a1a1a; /* dark bg behind letterboxed video */
}

.comparison-video {
    display: block;
    width: 100%;
    height: auto;
}

/* Subtle audio toggle — always visible for mobile accessibility */
.video-audio-toggle {
    position: absolute;
    bottom: 7px;
    right: 7px;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 0.72rem;
    padding: 3px 6px;
    cursor: pointer;
    font-family: 'Source Sans 3', -apple-system, sans-serif;
    letter-spacing: 0.04em;
    transition: background 0.15s;
    z-index: 2;
}

.video-audio-toggle:hover,
.video-audio-toggle:focus-visible {
    background: rgba(0, 0, 0, 0.7);
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 1px;
}

/* Icon via pseudo-element — toggled with .is-unmuted class */
.video-audio-toggle::before {
    content: '🔇';
}

.video-audio-toggle.is-unmuted::before {
    content: '🔊';
}

/* ============================================
   ETHNOGRAPHIC THEME HEADINGS
   ============================================ */
.theme-heading {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    font-style: italic;
    color: var(--color-accent-ethno);
    margin-bottom: 20px;
}

/* ============================================
   QUOTE BLOCKS (photos + quotes)
   ============================================ */
.quote-block {
    margin: 28px -32px;
    background: var(--color-surface-alt);
    border-radius: 4px;
    overflow: hidden;
}

.quote-photo {
    width: 100%;
    height: auto;
    display: block;
}

.quote-block blockquote {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-style: italic;
    line-height: 1.65;
    padding: 20px 28px 12px;
    color: var(--color-text-secondary);
    border-left: 3px solid var(--color-accent-ethno);
    margin: 0;
}

.quote-block figcaption {
    padding: 0 28px 18px;
    font-size: 0.82rem;
    color: var(--color-text-tertiary);
}

.quote-block figcaption .quote-location {
    display: block;
    margin-top: 2px;
}

/* Ethnographic citations */
.ethno-citation {
    font-size: 0.85rem;
    color: var(--color-text-tertiary);
    font-style: italic;
    margin-top: 16px;
}

/* ============================================
   QUOTE MARKER POPUPS
   ============================================ */
.quote-popup .maplibregl-popup-content {
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 8px;
    padding: 16px 18px 14px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

.quote-popup .maplibregl-popup-close-button {
    color: var(--color-text-secondary);
    font-size: 1.05rem;
    padding: 6px 10px;
}

.quote-popup .maplibregl-popup-close-button:hover {
    background: transparent;
    color: var(--color-text);
}

.quote-popup .maplibregl-popup-close-button:focus-visible {
    border-radius: 4px;
}

.quote-popup-body {
    padding-right: 12px;
}

.quote-popup-quote {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-style: italic;
    line-height: 1.55;
    color: var(--color-text);
}

.quote-popup-location {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--color-text-tertiary);
}

.quote-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.quote-popup.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.quote-popup.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
    border-bottom-color: var(--color-surface);
}

.quote-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.quote-popup.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.quote-popup.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
    border-top-color: var(--color-surface);
}

.quote-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip {
    border-right-color: var(--color-surface);
}

.quote-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip {
    border-left-color: var(--color-surface);
}

/* ============================================
   FLIP OVERLAY (Part 4 transition)
   ============================================ */
.flip-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    opacity: 0;
    transition: opacity 1.2s ease;
    pointer-events: none;
    background: #1a1a1a;
}

.flip-overlay.is-active {
    opacity: 1;
}

.flip-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   MAP CONTROLS
   ============================================ */
.map-controls {
    position: absolute;
    left: 16px;
    bottom: 32px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    max-width: min(320px, calc(100% - 32px));
    pointer-events: none;
}

/* ============================================
   COMPASS & 3D TOGGLE (top-right map controls)
   ============================================ */
.maplibregl-ctrl-top-right {
    /* Push below project-nav + chapter-nav so controls don't get clipped */
    top: calc(var(--project-nav-height) + var(--chapter-nav-height) + 12px) !important;
}

.maplibregl-ctrl-top-right .maplibregl-ctrl-group {
    background: rgba(var(--color-bg-rgb), 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.maplibregl-ctrl-top-right .maplibregl-ctrl-group button {
    background-color: transparent;
    border: none;
    color: var(--color-text);
}

/* Dark mode: invert the compass SVG so the needle is visible */
[data-theme="dark"] .maplibregl-ctrl-compass .maplibregl-ctrl-icon {
    filter: invert(1);
}

.pitch-toggle-btn {
    width: 29px;
    height: 29px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--color-text);
    background: transparent;
    border: none;
    padding: 0;
    line-height: 1;
}

.pitch-toggle-btn:hover {
    background: rgba(var(--color-bg-rgb), 0.6);
}

.pitch-toggle-btn:focus-visible {
    outline: 2px solid var(--color-accent-quant);
    outline-offset: -2px;
    border-radius: 4px;
}

/* ============================================
   TYPOLOGY SELECTOR
   ============================================ */
.typology-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(var(--color-bg-rgb), 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    border-radius: 10px;
    padding: 12px;
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.78rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.typology-selector.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.typology-selector-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.typology-selector-toggle:focus-visible {
    outline: 2px solid var(--color-accent-quant);
    outline-offset: 2px;
    border-radius: 6px;
}

.typology-selector-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.typology-selector-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text);
}

.typology-selector-current {
    display: none;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.typology-selector-chevron {
    display: block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--color-text-secondary);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.typology-selector.is-expanded .typology-selector-chevron {
    transform: rotate(180deg);
}

.typology-selector-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.typology-selector-options[hidden] {
    display: none;
}

.typology-option {
    cursor: pointer;
    margin: 0;
}

.typology-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.typology-option span {
    display: block;
    padding: 7px 13px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    color: var(--color-text-secondary);
    background: rgba(var(--color-bg-rgb), 0.72);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    font-weight: 600;
    white-space: nowrap;
}

.typology-option input:checked + span {
    background: var(--color-accent-quant);
    border-color: var(--color-accent-quant);
    color: #fff;
}

.typology-option input:focus-visible + span {
    outline: 2px solid var(--color-accent-quant);
    outline-offset: 1px;
}

/* ============================================
   MAP LEGEND
   ============================================ */
.map-legend {
    background: rgba(var(--color-bg-rgb), 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 6px;
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    max-width: 200px;
    line-height: 1.4;
    touch-action: pan-y;
}

.map-legend.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.legend-title {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    color: var(--color-text);
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Legend toggle (collapsible) */
.legend-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: left;
}

.legend-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--color-text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.map-legend.is-expanded .legend-chevron {
    transform: rotate(180deg);
}

.legend-body {
    display: none;
}

.map-legend.is-expanded .legend-body {
    display: block;
    margin-top: 8px;
}

/* ============================================
   METHODS SECTION
   ============================================ */
.methods {
    max-width: 720px;
    margin: 0 auto;
    padding: 80px 20px 120px;
}

.methods > h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.methods > p {
    font-size: 1.05rem;
    color: var(--color-text-secondary);
    margin-bottom: 48px;
    line-height: 1.7;
}

/* Collapsible method panels */
.method-panel {
    border-top: 1px solid var(--color-border);
}

.method-panel:last-of-type {
    border-bottom: 1px solid var(--color-border);
}

.method-panel summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 0;
    cursor: pointer;
    list-style: none;
}

.method-panel summary::-webkit-details-marker {
    display: none;
}

.method-panel summary::before {
    content: '+';
    font-size: 1.3rem;
    font-weight: 300;
    color: var(--color-text-tertiary);
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.method-panel[open] summary::before {
    content: '\2212'; /* minus sign */
}

.method-panel summary h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    flex-grow: 1;
}

/* Status badges */
.method-status {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.method-status--published {
    background: #e8f5e9;
    color: #1b5e20;
}

.method-status--forthcoming {
    background: #fff3e0;
    color: #bf360c;
}

/* Panel content */
.method-content {
    padding: 0 0 24px 32px;
    font-size: 0.98rem;
    line-height: 1.7;
    color: var(--color-text-secondary);
}

.method-content p {
    margin-bottom: 14px;
}

.method-content p:last-child {
    margin-bottom: 0;
}

.method-steps {
    padding-left: 18px;
    margin: 12px 0;
}

.method-steps li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.method-themes {
    padding-left: 18px;
    margin: 12px 0;
}

.method-themes li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.method-citation {
    font-size: 0.88rem;
    color: var(--color-text-tertiary);
    border-left: 2px solid var(--color-border);
    padding-left: 16px;
    margin-top: 18px;
    line-height: 1.6;
}

.method-citation a {
    color: var(--color-text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Method figures */
.method-figure {
    margin: 20px 0;
}

.method-figure img {
    width: 100%;
    border-radius: 4px;
}

.method-figure figcaption {
    font-size: 0.82rem;
    color: var(--color-text-tertiary);
    margin-top: 8px;
}

/* Method metrics strip */
.method-metrics {
    display: flex;
    gap: 16px;
    margin: 16px 0 20px;
}

.method-metric-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 12px 8px;
    background: var(--color-surface-alt);
    border-radius: 6px;
}

.method-metric-value {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-accent-quant);
}

.method-metric-label {
    font-size: 0.75rem;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

/* Data sources table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    margin-top: 12px;
}

.data-table th {
    text-align: left;
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 2px solid var(--color-border);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-tertiary);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

/* Methods footer */
.methods-footer {
    margin-top: 60px;
    padding-top: 32px;
    border-top: 1px solid var(--color-border);
}

.methods-footer h3 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.methods-footer p {
    font-size: 0.98rem;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    line-height: 1.7;
}

.methods-footer a {
    color: var(--color-text-secondary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.methods-footer a:hover {
    color: var(--color-text);
}

/* ============================================
   INLINE TECH NOTES (inside scroll steps)
   ============================================ */
.tech-note {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.tech-note-toggle {
    font-size: 0.82rem;
    color: var(--color-text-tertiary);
    cursor: pointer;
    list-style: none; /* remove default triangle */
    display: flex;
    align-items: center;
    gap: 6px;
}

.tech-note-toggle::-webkit-details-marker {
    display: none;
}

.tech-note-toggle .tech-note-icon {
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.tech-note[open] .tech-note-icon {
    transform: rotate(90deg);
}

.tech-note-content {
    margin-top: 12px;
    padding-left: 16px;
    border-left: 2px solid var(--color-accent-quant);
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--color-text-secondary);
}

.tech-note-content p {
    margin: 0 0 8px;
}

.tech-note-content p:last-child {
    margin-bottom: 0;
}

.tech-note-repo {
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
    font-style: italic;
}

.tech-note-content a {
    color: var(--color-accent-quant);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ============================================
   TECHNICAL STACK OVERVIEW
   ============================================ */
.tech-overview {
    max-width: 720px;
    margin: 0 auto;
    padding: 80px 20px 0;
}

.tech-overview > h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.tech-overview-intro {
    font-size: 1rem;
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: 32px;
}

.tech-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.tech-card {
    background: var(--color-surface-alt);
    padding: 24px;
    border-radius: 6px;
}

.tech-card-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent-quant);
    font-weight: 500;
}

.tech-card h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 6px 0 12px;
}

.tech-tools {
    font-family: 'Source Code Pro', 'SF Mono', 'Menlo', monospace;
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.tech-metric {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.tech-number {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-accent-quant);
}

/* ============================================
   METHOD ROLE ATTRIBUTION
   ============================================ */
.method-role {
    background: var(--color-surface-alt);
    border-left: 3px solid var(--color-accent-quant);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    line-height: 1.6;
    border-radius: 0 4px 4px 0;
}

.method-repo {
    font-size: 0.88rem;
    color: var(--color-text-tertiary);
    font-style: italic;
    margin-top: 8px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    :root {
        --project-nav-height: 50px;
        --chapter-nav-height: 48px;
    }

    .maplibregl-ctrl-top-right {
        right: 8px;
    }

    #scrolly {
        flex-direction: column;
    }

    .project-nav {
        padding: 0 16px;
    }

    .chapter-nav-inner {
        gap: 18px;
        padding: 0 16px;
    }

    .chapter-nav-link {
        font-size: 0.78rem;
    }

    .sticky-map {
        width: 100%;
        height: 50vh;
        z-index: 10; /* raised from 1 — ensure map always paints above story card elements */
    }

    .map-controls {
        left: 8px;
        right: 8px;
        bottom: 12px;
        height: calc(100% - 24px);
        gap: 8px;
        justify-content: flex-end;
        max-width: none;
        min-height: 0;
    }

    .typology-selector {
        width: auto;
        max-width: min(220px, calc(100% - 16px));
        padding: 8px 10px;
        gap: 0;
    }

    .typology-selector.is-expanded {
        gap: 8px;
    }

    .typology-selector-toggle {
        cursor: pointer;
    }

    .typology-selector-current {
        display: block;
    }

    .typology-selector-title {
        font-size: 0.68rem;
    }

    .typology-selector-options {
        width: 100%;
        gap: 6px;
    }

    .typology-option span {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    /* Let touch events pass through story gaps to the map below */
    .story {
        width: 100%;
        padding: 20px 0;
        pointer-events: none;
    }

    .step {
        margin: 0 16px 50vh 16px;
        padding: 24px;
        pointer-events: auto;
    }

    .header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    /* Comparison stacks vertically on mobile */
    .comparison {
        flex-direction: column;
    }

    /* Quote blocks: adjust for smaller step padding */
    .quote-block {
        margin: 20px -24px;
    }

    /* Legend adjusts */
    .map-legend {
        max-width: min(220px, 100%);
        font-size: 0.72rem;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .map-legend.is-expanded .legend-body {
        flex: 1 1 auto;
        max-height: 116px;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-right: 4px;
        touch-action: pan-y;
    }

    .typology-selector.is-visible + .map-legend.is-expanded .legend-body {
        max-height: 64px;
    }

    .typology-selector.is-visible.is-expanded + .map-legend.is-expanded .legend-body {
        max-height: 48px;
    }

    /* Data callout numbers scale down */
    .data-number {
        font-size: 1.8rem;
    }

    /* Data table: horizontal scroll on overflow */
    .data-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Tech stack grid: single column on mobile */
    .tech-grid {
        grid-template-columns: 1fr;
    }

    .tech-overview {
        padding: 60px 16px 0;
    }

    .tech-overview > h2 {
        font-size: 1.6rem;
    }

    /* Methods section */
    .methods {
        padding: 60px 16px;
    }

    .method-content {
        padding-left: 20px;
    }

    .method-metrics {
        flex-wrap: wrap;
        gap: 10px;
    }

    .method-metric-item {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
    }

    /* Flip overlay photo: landscape crop hint on shorter mobile map */
    .flip-photo {
        object-position: center 30%;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.7rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .intro-lede {
        font-size: 1.1rem;
    }

    .step {
        margin: 0 12px 50vh 12px;
        padding: 20px;
    }

    .quote-block {
        margin: 16px -20px;
    }

    .comparison-col h3 {
        font-size: 0.85rem;
    }

    .data-number {
        font-size: 1.5rem;
    }

    .methods > h2 {
        font-size: 1.5rem;
    }
}
