/* ============================================
   luminous.quest - Styles
   A sci-fi meditation on light itself
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    background: #070D1A;
    color: #C8C4D4;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    color: #E8E4F0;
    font-weight: 300;
}

h1 {
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.06em;
    line-height: 1.1;
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2.6rem);
    letter-spacing: 0.03em;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 1.2rem;
}

p {
    margin-bottom: 1.2rem;
}

p:last-child {
    margin-bottom: 0;
}

.mono-accent {
    font-family: 'DM Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: #D4A056;
    opacity: 0.7;
}

/* --- Background Layers --- */

/* Layer 0: Fixed deep gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #070D1A 0%, #0B1224 50%, #070D1A 100%);
    z-index: -10;
}

/* Layer 1: Ambient Glow */
#ambient-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -8;
    pointer-events: none;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
}

.glow-indigo {
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, #1A1040 0%, transparent 70%);
    top: 20%;
    left: -10%;
    animation: driftGlowIndigo 25s ease-in-out infinite alternate;
}

.glow-teal {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, #0A2A3C 0%, transparent 70%);
    top: 50%;
    right: -15%;
    animation: driftGlowTeal 30s ease-in-out infinite alternate;
}

@keyframes driftGlowIndigo {
    0% { transform: translate(0, 0); }
    100% { transform: translate(10vw, -8vh); }
}

@keyframes driftGlowTeal {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-8vw, 6vh); }
}

/* --- Particles --- */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -5;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.particle:nth-child(odd) {
    background: #D4A056;
    opacity: 0.15;
}

.particle:nth-child(even) {
    background: #4A8CC8;
    opacity: 0.10;
}

.p1  { width: 3px; height: 3px; left: 5%;  bottom: -10px; animation: floatUp 20s 0s infinite; }
.p2  { width: 2px; height: 2px; left: 12%; bottom: -10px; animation: floatUp 28s 2s infinite; }
.p3  { width: 4px; height: 4px; left: 22%; bottom: -10px; animation: floatUp 18s 5s infinite; }
.p4  { width: 2px; height: 2px; left: 30%; bottom: -10px; animation: floatUp 32s 1s infinite; }
.p5  { width: 3px; height: 3px; left: 38%; bottom: -10px; animation: floatUp 24s 8s infinite; }
.p6  { width: 2px; height: 2px; left: 45%; bottom: -10px; animation: floatUp 35s 3s infinite; }
.p7  { width: 4px; height: 4px; left: 52%; bottom: -10px; animation: floatUp 22s 7s infinite; }
.p8  { width: 3px; height: 3px; left: 58%; bottom: -10px; animation: floatUp 30s 4s infinite; }
.p9  { width: 2px; height: 2px; left: 65%; bottom: -10px; animation: floatUp 26s 6s infinite; }
.p10 { width: 3px; height: 3px; left: 72%; bottom: -10px; animation: floatUp 19s 9s infinite; }
.p11 { width: 2px; height: 2px; left: 78%; bottom: -10px; animation: floatUp 33s 2s infinite; }
.p12 { width: 4px; height: 4px; left: 85%; bottom: -10px; animation: floatUp 21s 11s infinite; }
.p13 { width: 3px; height: 3px; left: 90%; bottom: -10px; animation: floatUp 27s 0s infinite; }
.p14 { width: 2px; height: 2px; left: 95%; bottom: -10px; animation: floatUp 36s 5s infinite; }
.p15 { width: 3px; height: 3px; left: 8%;  bottom: -10px; animation: floatUp 23s 13s infinite; }
.p16 { width: 2px; height: 2px; left: 18%; bottom: -10px; animation: floatUp 40s 7s infinite; }
.p17 { width: 4px; height: 4px; left: 35%; bottom: -10px; animation: floatUp 17s 10s infinite; }
.p18 { width: 2px; height: 2px; left: 50%; bottom: -10px; animation: floatUp 29s 3s infinite; }
.p19 { width: 3px; height: 3px; left: 68%; bottom: -10px; animation: floatUp 15s 8s infinite; }
.p20 { width: 2px; height: 2px; left: 82%; bottom: -10px; animation: floatUp 38s 1s infinite; }

@keyframes floatUp {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    95% {
        opacity: 1;
    }
    100% {
        transform: translateY(-110vh) translateX(20px);
        opacity: 0;
    }
}

/* --- Sidebar --- */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 22%;
    min-width: 180px;
    max-width: 280px;
    height: 100vh;
    background: #0B1224;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 0;
    opacity: 0;
    transform: translateX(-100%);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-right: 1px solid rgba(180, 160, 220, 0.12);
}

#sidebar.visible {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-title {
    writing-mode: vertical-rl;
    font-family: 'Cormorant Garamond', serif;
    font-variant: small-caps;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: #E8E4F0;
    opacity: 0.3;
    transition: opacity 0.4s ease;
    margin-bottom: 3rem;
}

.sidebar-title:hover {
    opacity: 0.7;
}

.nav-nodes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    flex: 1;
    justify-content: center;
}

.nav-node {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.node-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #C8C4D4;
    opacity: 0.3;
    transition: all 0.4s ease;
    position: relative;
}

.node-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #D4A056;
    opacity: 0;
    transition: opacity 0.4s ease;
    filter: blur(6px);
}

.nav-node.active .node-dot {
    background: #F0D080;
    opacity: 1;
}

.nav-node.active .node-dot::after {
    opacity: 0.5;
    animation: pulseHalo 2s ease-in-out infinite;
}

@keyframes pulseHalo {
    0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.3); }
}

.node-label {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.85rem;
    color: #E8E4F0;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    white-space: nowrap;
    pointer-events: none;
}

.nav-node:hover .node-label {
    opacity: 0.9;
    transform: translateX(0);
}

/* --- Content Stage --- */
#content-stage {
    margin-left: 0;
    transition: margin-left 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body.sidebar-active #content-stage {
    margin-left: min(22%, 280px);
}

/* --- Sections --- */
.section {
    position: relative;
    width: 100%;
}

.section-source {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-spectrum {
    min-height: 150vh;
    padding: 8vh 5% 8vh 5%;
    display: flex;
    flex-direction: column;
    gap: 6vh;
}

.section-refraction {
    min-height: 150vh;
    padding: 8vh 5% 8vh 5%;
    display: flex;
    flex-direction: column;
    gap: 6vh;
    position: relative;
}

.section-observation {
    min-height: 100vh;
    padding: 8vh 5% 12vh 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6vh;
}

/* --- Hero --- */
.hero-container {
    text-align: center;
    position: relative;
    z-index: 2;
}

.hero-flare {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 80vw;
    max-width: 800px;
    height: 80vw;
    max-height: 800px;
    opacity: 0;
    transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

.hero-flare svg {
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
}

.hero-flare.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.hero-title {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.3s,
                transform 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.3s;
    position: relative;
    z-index: 3;
    color: #FFF8E8;
    text-shadow: 0 0 60px #E8C060, 0 0 120px rgba(74, 140, 200, 0.15);
}

.hero-title.active {
    opacity: 1;
    transform: scale(1);
}

.hero-subtitle {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.8s,
                transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.8s;
    margin-top: 1.5rem;
    position: relative;
    z-index: 3;
}

.hero-subtitle.active {
    opacity: 0.7;
    transform: translateY(0);
}

/* --- Content Panels --- */
.content-panel {
    background: #111B38;
    background: rgba(17, 27, 56, 0.6);
    backdrop-filter: blur(8px) saturate(1.2);
    -webkit-backdrop-filter: blur(8px) saturate(1.2);
    border-top: 1px solid rgba(180, 160, 220, 0.12);
    border-left: 1px solid rgba(180, 160, 220, 0.12);
    padding: 2.5rem 3rem;
    max-width: 680px;
    position: relative;
}

.content-panel h2 {
    text-shadow: 0 0 40px rgba(255, 248, 232, 0.08);
}

.content-panel .panel-label {
    display: block;
    margin-bottom: 1rem;
    text-transform: lowercase;
}

/* Panel positioning for staggered layout */
.panel-left {
    align-self: flex-start;
    margin-left: 3%;
    box-shadow: 0 8px 32px rgba(7, 13, 26, 0.5);
}

.panel-right {
    align-self: flex-end;
    margin-right: 3%;
    margin-left: auto;
    box-shadow: 0 6px 24px rgba(7, 13, 26, 0.45);
}

.panel-center {
    align-self: center;
    box-shadow: 0 4px 16px rgba(7, 13, 26, 0.4);
}

.panel-center-wide {
    align-self: center;
    max-width: 780px;
    box-shadow: 0 8px 32px rgba(7, 13, 26, 0.5);
}

.panel-far-left {
    align-self: flex-start;
    margin-left: 1%;
    box-shadow: 0 8px 32px rgba(7, 13, 26, 0.5);
}

.panel-far-right {
    align-self: flex-end;
    margin-right: 1%;
    margin-left: auto;
    box-shadow: 0 6px 24px rgba(7, 13, 26, 0.45);
}

/* Depth variations */
.depth-close {
    border-color: rgba(180, 160, 220, 0.18);
    transform: scale(1.02);
}

.depth-mid {
    border-color: rgba(180, 160, 220, 0.15);
    transform: scale(1.0);
}

.depth-far {
    border-color: rgba(180, 160, 220, 0.10);
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(7, 13, 26, 0.3);
}

/* --- Reveal Animations --- */
.reveal-panel {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal-panel.depth-close {
    transform: translateY(30px) scale(1.02);
}

.reveal-panel.depth-mid {
    transform: translateY(30px) scale(1.0);
}

.reveal-panel.depth-far {
    transform: translateY(30px) scale(0.98);
}

.reveal-panel.revealed {
    opacity: 1;
    transform: translateY(0);
}

.reveal-panel.revealed.depth-close {
    transform: translateY(0) scale(1.02);
}

.reveal-panel.revealed.depth-mid {
    transform: translateY(0) scale(1.0);
}

.reveal-panel.revealed.depth-far {
    transform: translateY(0) scale(0.98);
}

/* --- Light Field Dividers --- */
.light-field-divider {
    width: 100%;
    height: 120px;
    position: relative;
    overflow: hidden;
}

.light-field-divider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        #0B1224 15%,
        #1A1040 30%,
        #2A1850 50%,
        #1A1040 70%,
        #0B1224 85%,
        transparent 100%
    );
    animation: shiftDivider 20s linear infinite;
    opacity: 0.5;
}

.divider-2::before {
    animation-delay: -7s;
    background: linear-gradient(90deg,
        transparent 0%,
        #0B1224 15%,
        #0A2A3C 30%,
        #1A1040 50%,
        #0A2A3C 70%,
        #0B1224 85%,
        transparent 100%
    );
}

.divider-3::before {
    animation-delay: -14s;
}

@keyframes shiftDivider {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- Lens Flares --- */
.lens-flare {
    mix-blend-mode: screen;
    pointer-events: none;
}

.flare-anamorphic {
    width: 80%;
    max-width: 1200px;
    height: auto;
}

.flare-streak {
    align-self: center;
    text-align: center;
    overflow: visible;
}

.flare-hex-container {
    align-self: center;
    text-align: center;
}

.flare-hexagonal {
    width: 300px;
    height: 300px;
    margin: 2vh auto;
}

.flare-final-container {
    align-self: center;
    text-align: center;
}

.flare-final {
    width: min(500px, 80vw);
    height: min(500px, 80vw);
    margin: 0 auto;
}

/* --- Photon Paths --- */
.photon-path {
    position: absolute;
    width: 60px;
    height: 400px;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
}

.path-1 {
    right: 8%;
    top: 0;
}

.path-2 {
    left: 5%;
    top: 40%;
}

.photon-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.photon-line.drawn {
    stroke-dashoffset: 0;
}

/* --- Closing Glow --- */
.closing-glow {
    width: 100%;
    height: 200px;
    background: radial-gradient(ellipse at center bottom, rgba(232, 192, 96, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

/* --- Sidebar All-Glow Effect --- */
.nav-nodes.all-glow .nav-node .node-dot {
    background: #D4A056;
    opacity: 1;
}

.nav-nodes.all-glow .nav-node .node-dot::after {
    opacity: 0.5;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    #sidebar {
        width: 60px;
        min-width: 60px;
    }

    .sidebar-title {
        font-size: 0.65rem;
    }

    body.sidebar-active #content-stage {
        margin-left: 60px;
    }

    .content-panel {
        max-width: 100%;
        padding: 2rem;
    }

    .panel-left,
    .panel-right,
    .panel-far-left,
    .panel-far-right {
        margin-left: 0;
        margin-right: 0;
        align-self: stretch;
    }

    .section-spectrum,
    .section-refraction,
    .section-observation {
        padding: 6vh 4%;
    }
}

@media (max-width: 600px) {
    #sidebar {
        display: none;
    }

    body.sidebar-active #content-stage {
        margin-left: 0;
    }

    .content-panel {
        padding: 1.5rem;
    }

    .flare-hexagonal {
        width: 200px;
        height: 200px;
    }
}
