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

:root {
    --canvas-deep: #0d1117;
    --canvas-mid: #161b22;
    --canvas-surface: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent-teal: #2dd4bf;
    --accent-amber: #f59e0b;
    --accent-violet: #a78bfa;
    --accent-coral: #f87171;
    --grid-ghost: rgba(45, 212, 191, 0.04);
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Source Serif 4', serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --ease-standard: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--canvas-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* === BACKGROUND GRID === */
.bg-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(45, 212, 191, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(45, 212, 191, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* === SECTION NAV === */
.section-nav {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nav-num {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s var(--ease-standard), text-shadow 0.3s var(--ease-standard);
}

.nav-num.active {
    color: var(--accent-teal);
    text-shadow: 0 0 12px rgba(45, 212, 191, 0.5);
}

.nav-num:hover {
    color: var(--text-primary);
}

/* === Z-SECTIONS === */
.z-section {
    position: relative;
    min-height: 100vh;
    z-index: 1;
    padding: 60px 80px;
    display: flex;
    align-items: center;
}

.z-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 40px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 70vh;
}

.z-tl { align-self: start; justify-self: start; }
.z-tr { align-self: start; justify-self: end; }
.z-bl { align-self: end; justify-self: start; }
.z-br { align-self: end; justify-self: end; }

/* Reversed Z for alternating sections */
.z-reversed .z-tl { justify-self: end; }
.z-reversed .z-tr { justify-self: start; }
.z-reversed .z-bl { justify-self: end; }
.z-reversed .z-br { justify-self: start; }

/* Convergence layout */
.z-convergence {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    justify-items: center;
}

.z-center {
    max-width: 800px;
    text-align: center;
}

/* === TYPOGRAPHY === */
.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 9rem);
    letter-spacing: -0.03em;
    line-height: 0.95;
    color: var(--text-primary);
}

.teal {
    color: var(--accent-teal);
}

.hero-subtitle {
    margin-top: 20px;
    color: var(--text-secondary);
}

.mono {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 5rem);
    letter-spacing: -0.03em;
    line-height: 0.95;
    color: var(--text-primary);
}

.section-label {
    display: block;
    color: var(--accent-teal);
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.body-text:last-child {
    margin-bottom: 0;
}

.serif-light {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    color: var(--accent-amber);
    font-size: clamp(1.1rem, 1.5vw, 1.3rem);
    line-height: 1.6;
}

.question-text {
    margin-bottom: 16px;
}

.annotation {
    display: block;
    margin-top: 16px;
    color: var(--text-secondary);
}

.amber-text {
    color: var(--accent-amber);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.2rem, 1.6vw, 1.4rem);
}

.convergence-heading {
    margin-bottom: 40px;
}

/* === SVGs === */
.skyline-svg {
    width: 100%;
    max-width: 600px;
    height: auto;
}

.section-diagram {
    width: 100%;
    max-width: 300px;
    height: auto;
}

.convergence-diagram {
    width: 100%;
    max-width: 400px;
    height: auto;
    margin: 30px auto;
    display: block;
}

/* Window animations */
.window {
    fill: transparent;
}

.window.lit {
    fill: var(--accent-amber);
    opacity: 0.8;
}

@keyframes windowPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.window.lit {
    animation: windowPulse var(--pulse-duration, 4s) ease-in-out infinite;
}

/* Draw-line animation */
.draw-line {
    opacity: 0;
    transition: opacity 0.3s;
}

.draw-line.animated {
    opacity: 1;
}

/* === DISCLOSURE === */
.disclosure {
    max-width: 560px;
}

.disclosure-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    cursor: pointer;
    padding: 12px 0;
    user-select: none;
}

.disclosure-header:hover .hypothesis {
    color: var(--text-primary);
}

.disclosure-header:hover .disclosure-toggle {
    border-color: var(--accent-teal);
}

.hypothesis {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.6;
    color: var(--text-secondary);
    transition: color 0.15s var(--ease-standard);
}

.disclosure-toggle {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    position: relative;
    margin-top: 4px;
    border: 1px solid var(--text-secondary);
    border-radius: 2px;
    transition: border-color 0.15s var(--ease-standard), transform 0.3s var(--ease-spring);
}

.toggle-line {
    position: absolute;
    background: var(--text-secondary);
    transition: transform 0.3s var(--ease-spring), background 0.15s;
}

.toggle-line.h {
    width: 10px;
    height: 1.5px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.toggle-line.v {
    width: 1.5px;
    height: 10px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.disclosure.open .disclosure-toggle {
    transform: rotate(45deg);
    border-color: var(--accent-teal);
}

.disclosure.open .toggle-line {
    background: var(--accent-teal);
}

.disclosure.open .hypothesis {
    color: var(--text-primary);
}

.disclosure-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out, padding 0.5s ease-out;
    padding: 0 0 0 36px;
}

.disclosure.open .disclosure-content {
    max-height: 600px;
    padding: 8px 0 20px 36px;
}

.disclosure-content .body-text {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s var(--ease-standard), transform 0.4s var(--ease-standard);
}

.disclosure.open .disclosure-content .body-text {
    opacity: 1;
    transform: translateY(0);
}

.disclosure.open .disclosure-content .body-text:nth-child(1) { transition-delay: 0.08s; }
.disclosure.open .disclosure-content .body-text:nth-child(2) { transition-delay: 0.16s; }
.disclosure.open .disclosure-content .body-text:nth-child(3) { transition-delay: 0.24s; }

/* === HERO SECTION === */
.hero-section {
    background: linear-gradient(180deg, var(--canvas-deep) 0%, var(--canvas-mid) 100%);
}

/* Section backgrounds alternating */
#section-1 { background-color: var(--canvas-deep); }
#section-2 { background-color: var(--canvas-mid); }
#section-3 { background-color: var(--canvas-deep); }
#section-4 {
    background: radial-gradient(ellipse at center, var(--canvas-mid) 0%, var(--canvas-deep) 70%);
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
    .z-section {
        padding: 40px 24px 40px 60px;
    }

    .z-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 30px;
        min-height: auto;
    }

    .z-tl, .z-tr, .z-bl, .z-br {
        justify-self: start !important;
        align-self: start !important;
    }

    .z-reversed .z-tl,
    .z-reversed .z-tr,
    .z-reversed .z-bl,
    .z-reversed .z-br {
        justify-self: start !important;
    }

    .section-nav {
        left: 10px;
    }

    .disclosure {
        max-width: 100%;
    }
}

@media (max-width: 600px) {
    .z-section {
        padding: 30px 16px 30px 50px;
    }

    .hero-title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }
}
