/* ============================================
   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;
}

/* ============================================
   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;
}

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) {
    *, *::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;
    padding: 14px 24px;
    background: rgba(250, 250, 248, 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: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* ============================================
   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;
}

/* ============================================
   SCROLLYTELLING SECTION
   ============================================ */
#scrolly {
    position: relative;
    display: flex;
    background-color: #f0f0ee;
}

/* Sticky map container */
.sticky-map {
    position: sticky;
    top: 0;
    width: 60%;
    height: 100vh;
    flex-shrink: 0;
}

#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: white;
    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: #444;
    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: white;
}

/* Ethnographic sections: warm, organic */
.step--ethno {
    background: #faf9f7;
    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: #888;
    margin-top: 20px;
}

/* Synthesis step */
.step--synthesis {
    background: white;
    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: #f5f5f3;
    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;
    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: #f8f7f5;
    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: #333;
    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;
}

/* ============================================
   MAP DIVIDER (Part 3 split-view effect)
   ============================================ */
.map-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: rgba(255, 255, 255, 0.85);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.map-divider.is-visible {
    opacity: 1;
}

.divider-label {
    position: absolute;
    top: 16px;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #1a1a1a;
    background: rgba(255, 255, 255, 0.88);
    padding: 4px 10px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.divider-label--left {
    right: 16px;
}

.divider-label--right {
    left: 16px;
}

/* ============================================
   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 LEGEND
   ============================================ */
.map-legend {
    position: absolute;
    bottom: 32px;
    left: 16px;
    z-index: 10;
    background: rgba(255, 255, 255, 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: #333;
    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;
}

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

.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;
}

/* ============================================
   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: #444;
}

.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: #777;
    border-left: 2px solid #ddd;
    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;
}

/* 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 #ddd;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #666;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    color: #444;
    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: #f5f5f3;
    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: #f0f4f8;
    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) {
    #scrolly {
        flex-direction: column;
    }

    .sticky-map {
        width: 100%;
        height: 50vh;
        z-index: 1;
    }

    /* 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;
    }

    /* No split divider on mobile */
    .map-divider {
        display: none;
    }

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

    /* Legend adjusts */
    .map-legend {
        bottom: 12px;
        left: 8px;
        font-size: 0.72rem;
    }

    /* 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;
    }

    /* 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;
    }
}
