/* =================================
   RESET & VARIABLES
   ================================= */

:root {
    /* Deep field background */
    --color-deep-field: #0B0E1A;
    --color-secondary-bg: #141829;
    --color-warm-primary: #D4A34B;
    --color-cool-primary: #6B7FD7;
    --color-text-primary: #E8DCC8;
    --color-text-secondary: #C4BFA6;
    --color-text-tertiary: #7A7590;
    --color-accent-highlight: #E8943A;
    --color-soft-accent: #A89EC9;
    --color-danger: #C45C4A;

    --font-display: 'EB Garamond', serif;
    --font-body: 'Cormorant Garamond', serif;
    --font-mono: 'Space Mono', monospace;

    --spacing-unit: 16px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body), serif;
    background-color: var(--color-deep-field);
    color: var(--color-text-secondary);
    overflow-x: hidden;
    line-height: 1.75;
}

/* =================================
   STARFIELD CANVAS
   ================================= */

#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
}

/* =================================
   NAVIGATION
   ================================= */

nav.nav {
    position: fixed;
    top: 40px;
    left: 40px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-logo {
    font-family: var(--font-mono);
    font-size: 20px;
    color: var(--color-warm-primary);
    font-weight: 400;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: color 0.3s ease;
}

.nav-logo:hover {
    color: var(--color-accent-highlight);
}

.nav-menu {
    display: flex;
    gap: 25px;
    align-items: center;
}

.nav-item {
    font-family: var(--font-body);
    font-size: 13px;
    letter-spacing: 0.18em;
    color: var(--color-text-tertiary);
    text-decoration: none;
    text-transform: uppercase;
    transition: all 0.3s ease;
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--color-warm-primary);
    transition: width 0.3s ease;
}

.nav-item:hover {
    color: var(--color-warm-primary);
}

.nav-item:hover::before {
    width: 100%;
}

/* =================================
   SCENE CONTAINER
   ================================= */

.scene {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--color-deep-field);
    z-index: 10;
}

.scene-1 {
    background-color: var(--color-deep-field);
    height: 100vh;
}

.scene-2 {
    background-color: var(--color-deep-field);
    background-image:
        radial-gradient(ellipse at 30% 50%, rgba(168, 158, 201, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 40%, rgba(212, 163, 75, 0.08) 0%, transparent 50%);
}

.scene-3 {
    background-color: var(--color-deep-field);
    background-image:
        radial-gradient(ellipse at 40% 60%, rgba(212, 163, 75, 0.1) 0%, transparent 70%);
}

.scene-4 {
    background-color: var(--color-deep-field);
    background-image:
        radial-gradient(ellipse at 20% 40%, rgba(168, 158, 201, 0.08) 0%, transparent 50%);
}

.scene-5 {
    background-color: var(--color-deep-field);
    background-image:
        radial-gradient(ellipse at 50% 50%, rgba(212, 163, 75, 0.15) 0%, transparent 70%);
}

.scene-content {
    position: relative;
    z-index: 2;
    text-align: center;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
}

.aperture-wipe {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-deep-field);
    pointer-events: none;
    z-index: 1;
}

/* =================================
   TYPOGRAPHY
   ================================= */

.display-heading {
    font-family: var(--font-display);
    font-size: clamp(64px, 12vw, 120px);
    font-weight: 800;
    color: var(--color-text-primary);
    letter-spacing: 0.08em;
    line-height: 1.05;
    margin-bottom: 20px;
    opacity: 0;
    transform: translateY(20px);
}

.display-heading.closing {
    font-size: clamp(48px, 10vw, 100px);
}

.subtitle {
    font-family: var(--font-display);
    font-size: clamp(20px, 3vw, 36px);
    font-weight: 500;
    font-style: italic;
    color: var(--color-soft-accent);
    letter-spacing: 0.04em;
    opacity: 0;
    transform: translateY(20px);
}

.subtitle.closing {
    font-size: clamp(18px, 2.5vw, 28px);
}

.section-subtitle {
    font-family: var(--font-display);
    font-size: clamp(28px, 4vw, 48px);
    font-weight: 500;
    font-style: italic;
    color: var(--color-soft-accent);
    letter-spacing: 0.04em;
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(-20px);
}

.body-text {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.75;
    color: var(--color-text-secondary);
    opacity: 0.9;
    max-width: 38em;
    margin-bottom: 30px;
    text-align: left;
}

.body-text.caption {
    font-size: 13px;
    letter-spacing: 0.18em;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    margin-top: 40px;
}

.italic {
    font-style: italic;
}

/* =================================
   MACRO STAR MARKER
   ================================= */

.macro-star {
    position: absolute;
    width: 60px;
    height: 60px;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-warm-primary);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    opacity: 0;
    box-shadow: 0 0 30px rgba(212, 163, 75, 0.3);
    animation: star-fade-in 1s ease-out 0.3s forwards;
}

@keyframes star-fade-in {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

/* =================================
   SCROLL CHEVRON
   ================================= */

.scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    color: var(--color-warm-primary);
    opacity: 0.3;
    animation: chevron-pulse 1.5s ease-in-out infinite;
}

@keyframes chevron-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: translateX(-50%) translateY(0);
    }
    50% {
        opacity: 0.8;
        transform: translateX(-50%) translateY(8px);
    }
}

/* =================================
   CONSTELLATION LAYOUT (SCENE 2)
   ================================= */

.constellation-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 500px;
    margin: 40px auto;
}

.armillary-sphere {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: rotate-slow 120s linear infinite;
}

@keyframes rotate-slow {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.orbital-text {
    position: absolute;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.orbital-text h3 {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--color-warm-primary);
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}

.orbital-text p {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text-secondary);
    max-width: 150px;
}

.orbital-text-1 {
    top: 50%;
    left: 5%;
    transform: translateY(-50%);
}

.orbital-text-2 {
    top: 10%;
    right: 5%;
}

.orbital-text-3 {
    bottom: 10%;
    right: 5%;
}

.orbital-text-4 {
    bottom: 50%;
    left: 5%;
    transform: translateY(50%);
}

.constellation-lines {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

/* =================================
   STAR CHART (SCENE 3)
   ================================= */

.star-chart {
    width: 100%;
    max-width: 1000px;
    height: 400px;
    margin: 60px auto;
}

.constellation-node {
    transition: all 0.3s ease;
}

.constellation-node:hover {
    r: 8;
    stroke: var(--color-accent-highlight);
    filter: drop-shadow(0 0 10px rgba(232, 148, 58, 0.6));
}

.star-labels {
    position: relative;
    width: 100%;
    height: 300px;
    margin-bottom: 40px;
}

.star-label {
    position: absolute;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.label-title {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--color-warm-primary);
    font-weight: 500;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.label-text {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--color-text-secondary);
    max-width: 120px;
}

/* =================================
   DEEP FIELD (SCENE 4)
   ================================= */

.deep-field-container {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.deep-field-text {
    flex: 1;
    margin-left: 15%;
    margin-right: 100px;
    max-width: 38em;
}

.deep-field-text .section-subtitle {
    text-align: left;
    margin-bottom: 40px;
}

.deep-field-text .body-text {
    opacity: 0;
    transform: translateY(10px);
}

.sextant-illustration {
    position: absolute;
    right: 10%;
    width: 250px;
    height: 250px;
    opacity: 0.4;
    animation: rotate-slow-2 120s linear infinite;
}

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

/* =================================
   CLOSING SIGNAL (SCENE 5)
   ================================= */

.signal-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(212, 163, 75, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

/* =================================
   INTERSECTION OBSERVER ANIMATIONS
   ================================= */

.scene-1 .display-heading {
    animation: heading-reveal 1s ease-out forwards;
}

@keyframes heading-reveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scene-1 .subtitle {
    animation: subtitle-reveal 0.8s ease-out 0.2s forwards;
}

@keyframes subtitle-reveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade in on scroll for other headings and content */
.scene:not(.scene-1) .display-heading {
    animation: heading-reveal 1s ease-out forwards;
}

.scene .section-subtitle {
    animation: section-subtitle-reveal 0.8s ease-out 0.3s forwards;
}

@keyframes section-subtitle-reveal {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */

@media (max-width: 768px) {
    nav.nav {
        flex-direction: column;
        gap: 15px;
        top: 20px;
        left: 20px;
    }

    .nav-menu {
        flex-direction: column;
        gap: 10px;
    }

    .scene-content {
        padding: 40px 20px;
    }

    .deep-field-container {
        flex-direction: column;
    }

    .deep-field-text {
        margin-left: 0;
        margin-right: 0;
    }

    .sextant-illustration {
        position: relative;
        right: auto;
        margin-top: 40px;
    }

    .constellation-container {
        height: 400px;
    }

    .display-heading {
        font-size: 48px;
    }

    .subtitle {
        font-size: 18px;
    }

    .section-subtitle {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .display-heading {
        font-size: 36px;
    }

    .subtitle {
        font-size: 14px;
    }

    .body-text {
        font-size: 16px;
    }

    .orbital-text p {
        max-width: 100%;
    }
}

/* =================================
   REDUCED MOTION
   ================================= */

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }

    html {
        scroll-behavior: auto;
    }
}
