/* ============================================
   relativity.quest - Ocean Deep / Surreal / Frutiger Aero
   ============================================ */

:root {
    --abyssal: #0B132B;
    --bathyal: #1B2838;
    --photic: #62B6CB;
    --reef: #BEE9E8;
    --bioluminescent: #E0FBFC;
    --twilight: #5E7C8B;
    --hadal: #1B4965;
    --thermal: #E07A5F;
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-enter: 500ms;
    --stagger: 80ms;
}

/* ---- Reset & Base ---- */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background: var(--abyssal);
    background-image: linear-gradient(
        to bottom,
        #0B132B 0%,
        #1B2838 40%,
        #0B132B 100%
    );
    color: #c8d6dc;
    font-family: 'Fira Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw + 0.6rem, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

/* ---- Waypoint Navigation Rail ---- */

#waypoint-rail {
    position: fixed;
    top: 50%;
    left: clamp(16px, 3vw, 48px);
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#waypoint-rail::before {
    content: '';
    position: absolute;
    left: 3.5px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(27, 73, 101, 0.3);
}

.waypoint {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(27, 73, 101, 0.6);
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.waypoint.active {
    background: var(--photic);
    border-color: var(--photic);
}

/* ---- Page Sections (shared) ---- */

.page-section {
    min-height: 80vh;
    padding-block: clamp(4rem, 8vh, 8rem);
    position: relative;
    display: grid;
    grid-template-columns:
        [margin-left] minmax(24px, 1fr)
        [content-start] minmax(0, 320px)
        [midpoint] minmax(0, 480px)
        [content-end] minmax(24px, 1fr)
        [margin-right];
    align-content: center;
}

/* ---- Section Content (two-zone) ---- */

.section-content {
    grid-column: content-start / content-end;
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 480px);
    gap: 2rem;
}

.annotation-col {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.body-col {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.body-col.full-width {
    grid-column: 1 / -1;
}

/* ---- Gravitational Drift ---- */

.drift-1 { transform: translateX(0); }
.drift-2 { transform: translateX(-24px); }
.drift-3 { transform: translateX(20px); }
.drift-4 { transform: translateX(-36px); }

/* ---- Typography ---- */

.section-heading {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.02em;
    line-height: 1.15;
    color: var(--reef);
}

.body-text {
    max-width: 62ch;
    text-wrap: pretty;
    font-weight: 400;
    color: #c8d6dc;
}

.annotation-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.72rem, 0.9vw, 0.85rem);
    color: var(--photic);
    letter-spacing: 0.03em;
    text-transform: lowercase;
}

.annotation-text {
    font-family: 'Fira Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    color: var(--twilight);
    line-height: 1.6;
}

.annotation-panel {
    background: rgba(27, 73, 101, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* ---- Hero Section ---- */

#hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hero-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    position: relative;
    z-index: 2;
}

.hero-watermark {
    position: absolute;
    width: 50vw;
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
}

.hero-lightcone {
    width: clamp(200px, 40vw, 400px);
    height: auto;
}

.hero-title {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    color: var(--reef);
    letter-spacing: 0.02em;
    line-height: 1.15;
    opacity: 0;
    transform: translateY(12px);
}

.hero-subtitle {
    font-family: 'Fira Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.4vw, 1.2rem);
    color: var(--twilight);
    opacity: 0;
    transform: translateY(12px);
}

.hero-title.visible,
.hero-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 600ms ease, transform 600ms var(--bounce);
}

.hero-subtitle.visible {
    transition-delay: 300ms;
}

/* ---- Void Spaces ---- */

.void-space {
    height: 30vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.void-space[data-drift="0"] .void-diagram { margin-left: 20%; }
.void-space[data-drift="1"] .void-diagram { margin-right: 30%; }
.void-space[data-drift="2"] .void-diagram { margin-left: 10%; }
.void-space[data-drift="3"] .void-diagram { margin-right: 15%; }
.void-space[data-drift="4"] .void-diagram { margin-left: 25%; }

.void-diagram {
    opacity: 0.6;
}

.light-cone-small { width: 80px; height: 80px; }
.light-cone-medium { width: 200px; height: 200px; }
.geodesic-arc { width: 200px; height: 80px; }

.spiral-geodesic {
    width: 120px;
    height: 120px;
}

.spiral-rotate {
    transform-origin: center;
    animation: spiral-spin 60s linear infinite;
}

@keyframes spiral-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ---- Geodesic Animated Stroke ---- */

.geodesic-animated {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: geodesic-draw 12s linear infinite;
}

@keyframes geodesic-draw {
    0% { stroke-dashoffset: 300; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -300; }
}

/* ---- Clock Pair ---- */

.clock-pair {
    width: 100px;
    height: 50px;
}

/* ---- Section Background Elements ---- */

.section-bg-grid,
.section-bg-waves,
.section-bg-branches {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.section-content {
    position: relative;
    z-index: 1;
}

/* ---- Warped Grid ---- */

.warped-grid-container {
    grid-column: content-start / content-end;
    margin-top: 3rem;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.warped-grid {
    width: 100%;
    max-width: 500px;
    height: auto;
    background: rgba(27, 73, 101, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
}

/* ---- Immersive Demo ---- */

.immersive-demo {
    grid-column: content-start / content-end;
    margin-top: 3rem;
    position: relative;
    z-index: 1;
}

.demo-label {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.demo-instruction {
    font-weight: 300;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    color: var(--twilight);
}

#time-demo-svg {
    width: 100%;
    max-width: 600px;
    height: auto;
    background: rgba(27, 73, 101, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    cursor: default;
}

#geodesic-demo-svg {
    width: 100%;
    max-width: 600px;
    height: auto;
    background: rgba(27, 73, 101, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    cursor: crosshair;
}

/* ---- Coda Section ---- */

.coda-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.coda-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 4vw, 3rem);
    color: var(--reef);
    text-align: center;
    max-width: 20ch;
    line-height: 1.3;
}

/* ---- Bounce-Enter Animations ---- */

.bounce-item {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity var(--duration-enter) ease,
                transform var(--duration-enter) var(--bounce);
}

.bounce-item.bounce-x {
    transform: translateX(-16px);
}

.bounce-item.bounce-scale {
    transform: scale(0.92);
}

.bounce-item.in-view {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
}

/* ---- Stagger Delays ---- */

.bounce-item:nth-child(1) { transition-delay: calc(0 * var(--stagger)); }
.bounce-item:nth-child(2) { transition-delay: calc(1 * var(--stagger)); }
.bounce-item:nth-child(3) { transition-delay: calc(2 * var(--stagger)); }
.bounce-item:nth-child(4) { transition-delay: calc(3 * var(--stagger)); }
.bounce-item:nth-child(5) { transition-delay: calc(4 * var(--stagger)); }
.bounce-item:nth-child(6) { transition-delay: calc(5 * var(--stagger)); }
.bounce-item:nth-child(7) { transition-delay: calc(6 * var(--stagger)); }

/* ---- Reduced Motion ---- */

@media (prefers-reduced-motion: reduce) {
    .bounce-item {
        transition-duration: 0ms;
        transform: none;
        opacity: 1;
    }

    .spiral-rotate {
        animation: none;
    }

    .geodesic-animated {
        animation: none;
        stroke-dashoffset: 0;
    }

    .hero-title,
    .hero-subtitle {
        opacity: 1;
        transform: none;
    }
}

/* ---- Responsive: < 768px ---- */

@media (max-width: 768px) {
    .page-section {
        grid-template-columns:
            [margin-left] minmax(12px, 1fr)
            [content-start] minmax(0, 92vw)
            [content-end] minmax(12px, 1fr);
    }

    .section-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .drift-1,
    .drift-2,
    .drift-3,
    .drift-4 {
        transform: translateX(0);
    }

    .drift-1 { transform: translateX(8px); }
    .drift-2 { transform: translateX(-10px); }
    .drift-3 { transform: translateX(12px); }
    .drift-4 { transform: translateX(-8px); }

    #waypoint-rail {
        left: 8px;
        gap: 18px;
    }

    #waypoint-rail::before {
        left: 2.5px;
    }

    .waypoint {
        width: 6px;
        height: 6px;
    }

    .void-space {
        height: 15vh;
    }

    .void-space .void-diagram {
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .immersive-demo {
        grid-column: 1 / -1;
        padding: 0 12px;
    }

    .warped-grid-container {
        grid-column: 1 / -1;
        padding: 0 12px;
    }

    .coda-section {
        grid-template-columns: 1fr;
    }

    .body-col.full-width {
        grid-column: 1;
    }
}

/* ---- Particle Trails ---- */

.particle-trail {
    fill: none;
    stroke-linecap: round;
}

.test-particle {
    transition: opacity 0.3s ease;
}
