/* === Palette Reference: #0e1a24 #1b2d3a #eae6db #e8f0e4 #c4d4c0 #7eb89e #b3527a #d4a84b #2a3d40 === */

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

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

body {
    background: #0e1a24;
    color: #e8f0e4;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* === Progress Ruler === */
.progress-ruler {
    position: fixed;
    left: 0;
    top: 0;
    width: 3vw;
    min-width: 40px;
    height: 100vh;
    background: #0e1a24;
    z-index: 100;
    border-right: 1px solid rgba(126, 184, 158, 0.1);
}

.ruler-line {
    position: absolute;
    left: 50%;
    top: 5%;
    width: 1px;
    height: 90%;
    background: rgba(126, 184, 158, 0.3);
}

.ruler-fill {
    position: absolute;
    left: 50%;
    bottom: 5%;
    width: 2px;
    height: 0%;
    background: #7eb89e;
    transform: translateX(-0.5px);
    transition: height 0.1s linear;
}

.ruler-ticks {
    position: absolute;
    left: 0;
    top: 5%;
    width: 100%;
    height: 90%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.tick {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.tick .numeral {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    color: rgba(126, 184, 158, 0.5);
    letter-spacing: 0.06em;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

/* === Aurora === */
.aurora-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.aurora-svg {
    width: 100%;
    height: 100%;
}

.aurora-path {
    will-change: transform;
    contain: layout style paint;
}

.aurora-1 {
    animation: aurora-sway 19s ease-in-out infinite;
}

.aurora-2 {
    animation: aurora-sway 13s ease-in-out infinite reverse;
}

.aurora-3 {
    animation: aurora-sway 17s ease-in-out infinite;
    animation-delay: -5s;
}

.aurora-4 {
    animation: aurora-sway 11s ease-in-out infinite reverse;
    animation-delay: -3s;
}

.aurora-5 {
    animation: aurora-sway 23s ease-in-out infinite;
    animation-delay: -8s;
}

@keyframes aurora-sway {
    0% { transform: translateX(-3vw) scaleY(1); }
    50% { transform: translateX(3vw) scaleY(1.04); }
    100% { transform: translateX(-3vw) scaleY(1); }
}

/* === Scenes === */
.scene {
    position: relative;
    z-index: 1;
    margin-left: 3vw;
}

/* === Opening === */
.opening {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.opening-content {
    text-align: center;
    max-width: 80vw;
}

.site-title {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #e8f0e4;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.site-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.8rem, 1.1vw, 1rem);
    color: #7eb89e;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 3rem;
}

.desk-illustration {
    max-width: 60vw;
    margin: 0 auto;
    opacity: 0;
    animation: desk-fade-in 1.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s forwards;
}

.desk-illustration.reversed {
    max-width: 50vw;
    opacity: 0;
    animation: none;
    transform: scaleX(-1);
}

.desk-illustration.reversed.visible {
    animation: desk-fade-in 2s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes desk-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.desk-illustration.reversed.visible {
    animation-name: desk-fade-in-reversed;
}

@keyframes desk-fade-in-reversed {
    from { opacity: 0; transform: scaleX(-1) translateY(20px); }
    to { opacity: 1; transform: scaleX(-1) translateY(0); }
}

.impossible-desk {
    width: 100%;
    height: auto;
}

/* === Section Dividers === */
.section-divider {
    padding: 2rem 0;
    overflow: hidden;
}

.divider-svg {
    width: 100%;
    height: 20px;
}

.divider-path {
    transition: d 1s ease-out;
}

.divider-path.warped {
    d: path("M0,10 C360,0 720,20 1080,5 C1260,0 1380,15 1440,10");
}

/* === Dialectical Z-Pattern === */
.z-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 4vw, 4rem);
    padding: clamp(2rem, 4vw, 4rem);
    min-height: 80vh;
    align-items: center;
}

.z-row.reverse {
    direction: rtl;
}

.z-row.reverse > * {
    direction: ltr;
}

/* === Text Panel === */
.text-panel {
    background: #1b2d3a;
    border-radius: 2px;
    padding: clamp(2rem, 4vw, 4rem);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.text-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-marker {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.section-index {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7eb89e;
}

.text-panel h2 {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #e8f0e4;
    letter-spacing: 0.03em;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.text-panel p {
    color: #c4d4c0;
    margin-bottom: 1.25rem;
    text-indent: -1.5em;
    padding-left: 1.5em;
}

.pull-quote {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: 1.4em;
    color: #b3527a;
    border-left: 3px solid #7eb89e;
    padding-left: 1.5rem;
    margin: 2rem 0;
    text-indent: 0;
    line-height: 1.4;
}

/* === Image Panel === */
.image-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.image-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.illustration {
    width: 100%;
    max-width: 400px;
    height: auto;
}

/* === Annotations === */
.annotation-trigger {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: #7eb89e;
    text-underline-offset: 3px;
    cursor: help;
    position: relative;
    color: #e8f0e4;
}

.tooltip-card {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: #1b2d3a;
    border: 1px solid #7eb89e;
    border-radius: 3px;
    padding: 0.75rem 1rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #c4d4c0;
    width: max-content;
    max-width: 280px;
    box-shadow: 0 4px 20px rgba(126, 184, 158, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 50;
    text-indent: 0;
    padding-left: 1rem;
}

.tooltip-card.active {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    pointer-events: auto;
}

/* === Footnotes === */
.footnote-marker {
    color: #d4a84b;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75em;
    cursor: help;
    position: relative;
}

.footnote-marker .tooltip-card {
    bottom: calc(100% + 8px);
}

/* === Coda === */
.coda {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coda-content {
    text-align: center;
    max-width: 70vw;
}

.coda-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-size: 1.3rem;
    color: #c4d4c0;
    line-height: 1.8;
    opacity: 0;
    transition: opacity 3s cubic-bezier(0.25, 0.1, 0.25, 1);
    margin-top: 3rem;
}

.coda-text.visible {
    opacity: 1;
}

/* === Coda Aurora Intensify === */
body.coda-active .aurora-path {
    animation-duration: 8s !important;
}

body.coda-active .aurora-svg {
    opacity: 1.3;
}

body.coda-active .aurora-1 { animation-duration: 15s !important; }
body.coda-active .aurora-2 { animation-duration: 10s !important; }
body.coda-active .aurora-3 { animation-duration: 13s !important; }
body.coda-active .aurora-4 { animation-duration: 9s !important; }
body.coda-active .aurora-5 { animation-duration: 18s !important; }

/* === Responsive === */
@media (max-width: 768px) {
    .progress-ruler {
        display: none;
    }

    .scene {
        margin-left: 0;
    }

    .z-row {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 1.5rem;
    }

    .z-row.reverse {
        direction: ltr;
    }

    .text-panel {
        padding: 1.5rem;
    }

    .desk-illustration,
    .desk-illustration.reversed {
        max-width: 90vw;
    }

    .coda-content {
        max-width: 90vw;
    }
}
