/* ============================================
   postp.io - Post-Production Visual Identity
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-shadow: #0d0b08;
    --charcoal-sepia: #1c1915;
    --timeline-spine: #4a3728;
    --muted-bronze: #6b5d4f;
    --dusty-clay: #8c7b6a;
    --faded-copper: #b8956e;
    --amber-flare: #d4a24c;
    --overexposed-cream: #faf8f5;
    --warm-parchment: #e8e2d8;
    --teal-shadow: #2d4a4e;
    --teal-deep: #1a3538;
    --amber-cooled: #c49a40;
    --midtone: #a89a8a;

    /* Dynamic accent colors (shift via JS on scroll) */
    --accent-amber: #d4a24c;
    --accent-teal: #2d4a4e;

    --grain-opacity: 0.03;
    --grain-blur: 0px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    letter-spacing: 0.01em;
    line-height: 1.7;
    color: var(--muted-bronze);
    background-color: var(--overexposed-cream);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2.8rem, 7vw, 6rem);
    letter-spacing: 0.02em;
    line-height: 1.05;
    color: var(--charcoal-sepia);
}

h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2.4rem);
    letter-spacing: 0.02em;
    line-height: 1.25;
    color: var(--charcoal-sepia);
    margin-bottom: 0.75em;
}

p {
    margin-bottom: 1em;
}

/* --- Film Grain Overlay --- */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: var(--grain-opacity);
    filter: blur(var(--grain-blur));
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    transition: opacity 0.3s ease;
}

/* --- Light Leak Accents --- */
#light-leaks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.light-leak {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(212, 162, 76, 0.12) 0%, rgba(212, 162, 76, 0) 70%);
    pointer-events: none;
    will-change: transform;
}

/* --- Timecode Display (Fixed) --- */
#timecode-display {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--accent-amber);
    opacity: 0.6;
    z-index: 100;
    letter-spacing: 0.05em;
    transition: opacity 0.5s ease;
}

#timecode-display.faded {
    opacity: 0;
}

/* --- Timecode Watermarks --- */
#timecode-watermarks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.timecode-watermark {
    position: absolute;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    color: var(--timeline-spine);
    opacity: 0.15;
    letter-spacing: 0.05em;
    user-select: none;
}

.timecode-watermark.watermark-left {
    left: 2rem;
}

.timecode-watermark.watermark-right {
    right: 2rem;
}

/* --- Timeline Spine --- */
#timeline-spine {
    position: absolute;
    left: 50%;
    top: 100vh;
    width: 1px;
    height: calc(100% - 100vh);
    background: var(--timeline-spine);
    transform: translateX(-50%);
    z-index: 2;
}

/* --- Zone Backgrounds --- */
.zone {
    position: relative;
    width: 100%;
}

.zone-1 {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--overexposed-cream);
}

.zone-2 {
    padding: 8rem 0;
    background: linear-gradient(
        to bottom,
        var(--overexposed-cream) 0%,
        #e8e2d8 20%,
        #d5ccc0 50%,
        #a89a8a 80%,
        #6b5d4f 100%
    );
}

.zone-3 {
    padding: 4rem 0 0;
    background: linear-gradient(
        to bottom,
        #6b5d4f 0%,
        var(--charcoal-sepia) 40%,
        var(--deep-shadow) 100%
    );
}

/* --- Hero Section --- */
.hero-content {
    text-align: center;
    z-index: 5;
    position: relative;
}

#hero-title {
    transition: color 2s cubic-bezier(0.16, 0.6, 0.4, 1);
}

#hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    letter-spacing: 0.08em;
    color: var(--muted-bronze);
    margin-top: 1.2rem;
    transition: color 2s cubic-bezier(0.16, 0.6, 0.4, 1), opacity 2s cubic-bezier(0.16, 0.6, 0.4, 1);
}

/* Overexposed state (initial) */
.overexposed {
    color: var(--overexposed-cream) !important;
    opacity: 0;
}

/* Revealed state */
.revealed#hero-title {
    color: var(--charcoal-sepia) !important;
    opacity: 1;
}

.revealed#hero-subtitle {
    color: var(--muted-bronze) !important;
    opacity: 1;
}

/* --- Node Label --- */
.node-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--dusty-clay);
    display: block;
    margin-bottom: 0.5rem;
}

/* --- Timeline Nodes --- */
.timeline-node {
    position: relative;
    margin-bottom: 6rem;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.timeline-node.node-left {
    margin-right: 52%;
    padding-left: 4%;
    padding-right: 2%;
    transform: translateX(-30px);
    text-align: right;
}

.timeline-node.node-right {
    margin-left: 52%;
    padding-right: 4%;
    padding-left: 2%;
    transform: translateX(30px);
    text-align: left;
}

/* Revealed state */
.timeline-node.node-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Node sizing */
.node-primary .node-content {
    max-width: 55vw;
}

.node-secondary .node-content {
    max-width: 35vw;
}

.node-compressed {
    margin-bottom: 3rem;
}

.node-compressed .node-content {
    max-width: 30vw;
}

.node-content {
    display: inline-block;
    background: rgba(250, 248, 245, 0.06);
    border: 1px solid rgba(107, 93, 79, 0.15);
    border-radius: 6px;
    padding: 2rem 2.5rem;
    backdrop-filter: blur(2px);
}

/* Node content in dark zones */
.zone-3 .node-content {
    background: rgba(13, 11, 8, 0.3);
    border-color: rgba(168, 154, 138, 0.1);
}

.zone-3 h2 {
    color: var(--warm-parchment);
}

.zone-3 p {
    color: var(--dusty-clay);
}

.zone-3 .node-label {
    color: var(--faded-copper);
}

/* Teal hover accent for nodes in dark zone */
.zone-3 .node-content:hover {
    border-color: #1a3538;
}

/* Cooled amber for connector dots in zone-2 lower half */
.zone-2 .timeline-node:nth-child(n+4) .connector-dot {
    fill: #c49a40;
}

/* Midtone transition zone text */
.zone-2 .timeline-node:nth-child(n+5) p {
    color: #a89a8a;
}

/* --- Connectors --- */
.connector {
    position: absolute;
    top: 50%;
    width: 200px;
    height: 2px;
    transform: translateY(-50%);
    overflow: visible;
}

.connector-left {
    right: -200px;
}

.connector-right {
    left: -200px;
}

.connector line {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.4s ease;
}

.node-visible .connector line {
    stroke-dashoffset: 0;
}

.connector-dot {
    opacity: 0;
    transition: opacity 0.2s ease 0.4s;
}

.node-visible .connector-dot {
    opacity: 1;
}

/* Connector dot pulse animation */
@keyframes connectorPulse {
    0% { r: 3; opacity: 1; }
    50% { r: 6; opacity: 0.5; }
    100% { r: 3; opacity: 1; }
}

.node-visible .connector-dot {
    animation: connectorPulse 0.6s ease 0.4s 1;
}

/* --- Waveform Decoration --- */
.waveform-decoration {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 30px;
    margin-top: 1rem;
    opacity: 0.3;
}

.waveform-decoration span {
    display: block;
    width: 2px;
    background-color: var(--muted-bronze);
    border-radius: 1px;
}

/* Varied heights for waveform bars */
.waveform-decoration span:nth-child(1) { height: 8px; }
.waveform-decoration span:nth-child(2) { height: 14px; }
.waveform-decoration span:nth-child(3) { height: 6px; }
.waveform-decoration span:nth-child(4) { height: 22px; }
.waveform-decoration span:nth-child(5) { height: 10px; }
.waveform-decoration span:nth-child(6) { height: 28px; }
.waveform-decoration span:nth-child(7) { height: 16px; }
.waveform-decoration span:nth-child(8) { height: 12px; }
.waveform-decoration span:nth-child(9) { height: 24px; }
.waveform-decoration span:nth-child(10) { height: 8px; }
.waveform-decoration span:nth-child(11) { height: 18px; }
.waveform-decoration span:nth-child(12) { height: 6px; }
.waveform-decoration span:nth-child(13) { height: 20px; }
.waveform-decoration span:nth-child(14) { height: 10px; }
.waveform-decoration span:nth-child(15) { height: 26px; }
.waveform-decoration span:nth-child(16) { height: 14px; }
.waveform-decoration span:nth-child(17) { height: 8px; }
.waveform-decoration span:nth-child(18) { height: 22px; }
.waveform-decoration span:nth-child(19) { height: 12px; }
.waveform-decoration span:nth-child(20) { height: 16px; }

/* Waveform in right-aligned nodes */
.node-left .waveform-decoration {
    justify-content: flex-end;
}

/* --- Film-Out --- */
#film-out {
    width: 100%;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--deep-shadow);
    margin-top: 4rem;
    position: relative;
}

.film-out-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2.4rem);
    color: var(--warm-parchment);
    opacity: 0.4;
    letter-spacing: 0.1em;
    font-style: italic;
}

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
    .timeline-node.node-left,
    .timeline-node.node-right {
        margin-left: 10%;
        margin-right: 10%;
        padding-left: 2%;
        padding-right: 2%;
        text-align: left;
    }

    .timeline-node.node-left {
        transform: translateX(-20px);
    }

    .timeline-node.node-right {
        transform: translateX(20px);
    }

    .node-primary .node-content,
    .node-secondary .node-content,
    .node-compressed .node-content {
        max-width: 100%;
    }

    .connector {
        display: none;
    }

    #timeline-spine {
        left: 5%;
    }

    .timecode-watermark.watermark-left {
        display: none;
    }

    #timecode-display {
        bottom: 1rem;
        right: 1rem;
        font-size: 0.6rem;
    }
}

@media (max-width: 600px) {
    .timeline-node.node-left,
    .timeline-node.node-right {
        margin-left: 5%;
        margin-right: 5%;
    }

    .node-content {
        padding: 1.5rem;
    }

    .timeline-node {
        margin-bottom: 4rem;
    }

    .node-compressed {
        margin-bottom: 2rem;
    }
}

/* --- Spine thickness transition (thickens toward bottom) --- */
#timeline-spine {
    background: linear-gradient(
        to bottom,
        var(--timeline-spine) 0%,
        var(--timeline-spine) 70%,
        var(--muted-bronze) 100%
    );
}
