/* ===========================================
   relativity.quest - Styles
   A journey through spacetime
   =========================================== */

/* ----- CSS Custom Properties ----- */
:root {
    /* Palette: Doppler-shift spectrum */
    --spacetime-void: #08090E;
    --event-horizon: #111827;
    --approaching-violet: #6366F1;
    --cherenkov-blue: #38BDF8;
    --worldline-gold: #C9A84C;
    --receding-amber: #D97706;
    --cosmic-infrared: #991B1B;
    --gradient-center: #1a1f3a;

    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Crimson Pro', serif;
    --font-notation: 'Fira Code', monospace;

    /* Layout */
    --panel-tilt: 8deg;
    --panel-tilt-steep: 12deg;
}

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

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

body {
    background-color: var(--spacetime-void);
    color: #e2e8f0;
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    font-weight: 400;
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----- Particle Canvas Overlay ----- */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ----- Light-Cone Background SVG ----- */
#lightcone-bg {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120vw;
    height: 120vh;
    pointer-events: none;
    z-index: 0;
    animation: rotateCone 120s linear infinite;
    transform-origin: 50% 8.3%;
}

@keyframes rotateCone {
    0% {
        transform: translateX(-50%) rotate(0deg);
    }
    100% {
        transform: translateX(-50%) rotate(360deg);
    }
}

/* ----- Coordinate Navigation ----- */
#coord-nav {
    position: fixed;
    right: 2vw;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 100;
}

.coord-label {
    font-family: var(--font-notation);
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    font-weight: 400;
    color: var(--worldline-gold);
    text-decoration: none;
    opacity: 0.4;
    transition: opacity 0.4s ease, transform 0.3s ease;
    letter-spacing: 0.05em;
}

.coord-label:hover,
.coord-label.active {
    opacity: 1;
    transform: translateX(-4px);
}

/* ----- Section Base ----- */
.section {
    position: relative;
    z-index: 2;
    width: 100%;
}

/* ----- Section 1: THE SINGULARITY (Hero) ----- */
.section-hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hero-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* Gravitational Lensing Ring */
.lensing-ring-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(250px, 40vw, 500px);
    height: clamp(250px, 40vw, 500px);
    pointer-events: none;
}

.lensing-ring {
    width: 100%;
    height: 100%;
    animation: ringExpand 2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

@keyframes ringExpand {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.einstein-ring {
    animation: ringPulse 4s ease-in-out infinite;
    stroke-dasharray: 628;
    stroke-dashoffset: 0;
}

@keyframes ringPulse {
    0%, 100% {
        opacity: 0.6;
        stroke-width: 2;
    }
    50% {
        opacity: 1;
        stroke-width: 2.5;
    }
}

.einstein-ring-outer,
.einstein-ring-inner {
    animation: ringPulse 4s ease-in-out infinite;
    animation-delay: 1s;
}

/* Hero Title */
.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-weight: 700;
    color: var(--approaching-violet);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    position: relative;
    z-index: 5;
    opacity: 0;
    animation: titleFadeIn 1.5s ease-out 0.3s forwards;
    text-shadow: 0 0 60px rgba(99, 102, 241, 0.3), 0 0 120px rgba(99, 102, 241, 0.1);
}

@keyframes titleFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero Tagline */
.hero-tagline {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 400;
    color: var(--worldline-gold);
    letter-spacing: 0.04em;
    opacity: 0;
    animation: titleFadeIn 1.5s ease-out 0.8s forwards;
    position: relative;
    z-index: 5;
}

/* ----- Geodesic Flow Line Connectors ----- */
.geodesic-connector {
    display: block;
    width: clamp(200px, 30vw, 400px);
    height: 150px;
    position: relative;
    z-index: 2;
    margin: -40px auto;
    overflow: visible;
}

.geodesic-path {
    stroke-dasharray: 60 30;
    stroke-dashoffset: 0;
    animation: flowGeodesic 3s linear infinite;
}

@keyframes flowGeodesic {
    0% {
        stroke-dashoffset: 90;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.geodesic-1 { margin-left: 20%; }
.geodesic-2 { margin-left: 50%; }
.geodesic-3 { margin-left: 15%; }
.geodesic-4 { margin-left: 55%; }
.geodesic-5 { margin: -40px auto; width: clamp(300px, 60vw, 800px); }

/* ----- Content Panels ----- */
.section-panel {
    min-height: 80vh;
    display: flex;
    align-items: center;
    padding: 6vh 8vw;
    position: relative;
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.section-panel.visible {
    opacity: 1;
    transform: translateY(0) rotate(var(--panel-rotate, 0deg));
}

.section-inner {
    max-width: 650px;
    position: relative;
    padding: 3rem 3.5rem;
    background: var(--event-horizon);
    border-radius: 2px;
}

/* Panel positioning - Left diagonal */
.panel-left {
    justify-content: flex-start;
    --panel-rotate: 0deg;
}

.panel-left .section-inner {
    border-left: 2px solid var(--cherenkov-blue);
    transform: rotate(-2deg);
}

/* Panel positioning - Right diagonal */
.panel-right {
    justify-content: flex-end;
    --panel-rotate: 0deg;
}

.panel-right .section-inner {
    border-right: 2px solid var(--cherenkov-blue);
    transform: rotate(2deg);
}

/* Contracted panel (Section 4) */
.panel-contracted .section-inner {
    max-width: 570px;
}

/* Steep panel (Section 5) */
.panel-steep .section-inner {
    transform: rotate(3deg);
}

.panel-steep.panel-right .section-inner {
    border-right-color: var(--receding-amber);
}

/* Dilation section gradient */
#section-dilation .section-inner {
    background: radial-gradient(ellipse at center, var(--gradient-center), var(--event-horizon) 80%);
}

/* ----- Section Headings ----- */
.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 2rem;
}

.heading-blueshift {
    color: var(--approaching-violet);
}

.heading-transition {
    color: var(--worldline-gold);
}

.heading-redshift {
    color: var(--receding-amber);
}

/* ----- Body Text ----- */
.section-body {
    margin-bottom: 1.5rem;
    color: #c8ccd4;
    line-height: 1.72;
}

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

/* ----- Notation / Math Highlights ----- */
.notation {
    font-family: var(--font-notation);
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--worldline-gold);
    letter-spacing: 0.02em;
}

.notation-block {
    text-align: center;
    padding: 1.5rem 0;
    margin: 1rem 0;
    border-top: 1px solid rgba(201, 168, 76, 0.15);
    border-bottom: 1px solid rgba(201, 168, 76, 0.15);
}

.notation-block .notation {
    font-size: clamp(0.9rem, 1.3vw, 1.1rem);
}

/* ----- Time Dilation Clocks ----- */
.clock-container {
    position: absolute;
    top: 2rem;
    width: 50px;
    height: 50px;
}

.panel-left .clock-container {
    left: -70px;
}

.panel-right .clock-container {
    right: -70px;
}

.dilation-clock {
    width: 50px;
    height: 50px;
}

.clock-hand-minute {
    transform-origin: 25px 25px;
    animation: clockTick var(--clock-duration, 8s) linear infinite;
}

.clock-hand-hour {
    transform-origin: 25px 25px;
    animation: clockTick var(--clock-duration-hour, 96s) linear infinite;
}

@keyframes clockTick {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Clock speeds per section */
#section-observer .clock-hand-minute { --clock-duration: 8s; }
#section-observer .clock-hand-hour { --clock-duration-hour: 96s; }

#section-dilation .clock-hand-minute { --clock-duration: 6s; }
#section-dilation .clock-hand-hour { --clock-duration-hour: 72s; }

#section-contraction .clock-hand-minute { --clock-duration: 5s; }
#section-contraction .clock-hand-hour { --clock-duration-hour: 60s; }

#section-equivalence .clock-hand-minute { --clock-duration: 4s; }
#section-equivalence .clock-hand-hour { --clock-duration-hour: 48s; }

/* ----- Section 6: THE HORIZON ----- */
.section-horizon {
    height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.horizon-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--spacetime-void) 5%,
        var(--worldline-gold) 30%,
        var(--worldline-gold) 50%,
        var(--worldline-gold) 70%,
        var(--spacetime-void) 95%,
        transparent 100%
    );
    box-shadow: 0 0 30px rgba(201, 168, 76, 0.4), 0 0 60px rgba(201, 168, 76, 0.15);
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 1.2s ease;
}

.section-horizon.visible .horizon-line {
    opacity: 1;
}

.horizon-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.2rem, 3.5vw, 3rem);
    color: var(--cosmic-infrared);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: center;
    position: relative;
    z-index: 3;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease 0.5s, transform 1s ease 0.5s;
    text-shadow: 0 0 40px rgba(153, 27, 27, 0.4);
    padding: 0 2rem;
}

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

/* ----- Section 7: THE BEYOND (Footer) ----- */
.section-footer {
    min-height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

.footer-domain {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--cosmic-infrared);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.7;
}

.footer-tagline {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: #c8ccd4;
    opacity: 0.5;
}

.footer-attribution {
    font-family: var(--font-body);
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: #c8ccd4;
    opacity: 0.35;
    max-width: 500px;
}

.footer-coordinates {
    margin-top: 1rem;
    opacity: 0.4;
}

.footer-coordinates .notation {
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    color: var(--worldline-gold);
    opacity: 0.6;
}

/* ----- Lorentz Contraction Scroll Effect ----- */
.section-panel.entering {
    transform: scaleX(calc(1 - 0.08 * var(--scroll-progress, 0)));
}

/* ----- Responsive Adjustments ----- */
@media (max-width: 900px) {
    .panel-left,
    .panel-right {
        justify-content: center;
        padding: 4vh 4vw;
    }

    .section-inner {
        padding: 2rem 2rem;
        max-width: 90vw;
    }

    .panel-contracted .section-inner {
        max-width: 85vw;
    }

    .panel-left .section-inner,
    .panel-right .section-inner {
        transform: rotate(0deg);
    }

    .panel-steep .section-inner {
        transform: rotate(0deg);
    }

    .clock-container {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        margin-bottom: 1rem;
    }

    .panel-left .clock-container,
    .panel-right .clock-container {
        left: auto;
        right: auto;
    }

    #coord-nav {
        right: 1vw;
        gap: 1rem;
    }

    .geodesic-connector {
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

@media (max-width: 600px) {
    .section-inner {
        padding: 1.5rem 1.5rem;
    }

    #coord-nav {
        display: none;
    }

    .lensing-ring-container {
        width: 220px;
        height: 220px;
    }
}

/* ----- Scroll-triggered section opacity layers ----- */
.section-panel {
    --layer-opacity: 1;
}

.section-panel:nth-child(n+4) {
    --layer-opacity: 0.92;
}

.section-panel:nth-child(n+6) {
    --layer-opacity: 0.85;
}

.section-panel.visible .section-inner {
    opacity: var(--layer-opacity);
}

/* ----- Selection Styling ----- */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: #fff;
}

/* ----- Scrollbar Styling ----- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--spacetime-void);
}

::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.3);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.5);
}
