/* ============================================================
   relativity.quest — Cinematic Spacetime Design
   Colors: #060612, #0a0a2e, #1e1b4b, #f0f0ff, #3b82f6, #ef4444, #fbbf24, #6366f1
   Fonts: Orbitron (display), Lato (body), STIX Two Math (equations)
   ============================================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    background: #060612;
    color: #f0f0ff;
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    line-height: 1.8;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ── Star Field (fixed parallax background) ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(circle, #f0f0ff 0.5px, transparent 0.5px) 0 0 / 200px 200px,
        radial-gradient(circle, #f0f0ff 0.4px, transparent 0.4px) 100px 100px / 200px 200px,
        radial-gradient(circle, #f0f0ff 0.3px, transparent 0.3px) 50px 150px / 200px 200px,
        radial-gradient(circle, rgba(99,102,241,0.6) 0.6px, transparent 0.6px) 73px 37px / 200px 200px,
        radial-gradient(circle, rgba(59,130,246,0.5) 0.4px, transparent 0.4px) 157px 83px / 200px 200px,
        #060612;
    background-attachment: fixed;
}

/* Additional sparse star layer */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(circle, #f0f0ff 0.5px, transparent 0.5px) 23px 67px / 300px 300px,
        radial-gradient(circle, #f0f0ff 0.3px, transparent 0.3px) 147px 211px / 300px 300px,
        radial-gradient(circle, rgba(251,191,36,0.4) 0.6px, transparent 0.6px) 83px 189px / 400px 400px,
        radial-gradient(circle, rgba(239,68,68,0.3) 0.4px, transparent 0.4px) 263px 43px / 400px 400px;
    background-attachment: fixed;
}

/* Hidden SVG filter element */
#svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ── Scene Sections ── */
.scene {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 6rem 2rem;
    transition: opacity 0.6s ease;
}

.scene.fade-out {
    opacity: 0.2;
}

.scene.fade-in {
    opacity: 1;
}

/* ── Content Panels ── */
.content-panel {
    position: relative;
    z-index: 10;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(10, 10, 30, 0.65);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 2.5rem;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 0 60px rgba(59, 130, 246, 0.08);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease, box-shadow 0.4s ease;
}

.content-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.content-panel.visible:hover {
    box-shadow: 0 0 80px rgba(59, 130, 246, 0.15);
}

.panel-right {
    margin-left: auto;
    margin-right: 4rem;
}

.panel-left {
    margin-right: auto;
    margin-left: 4rem;
}

.centered-panel {
    margin: 0 auto;
    text-align: center;
}

/* ── Hero Section ── */
#hero {
    background: transparent;
    justify-content: center;
    align-items: center;
}

/* Spacetime Grid */
.spacetime-grid {
    position: absolute;
    inset: -10%;
    background:
        linear-gradient(#6366f1 1px, transparent 1px),
        linear-gradient(90deg, #6366f1 1px, transparent 1px);
    background-size: 40px 40px;
    background-color: transparent;
    opacity: 0.18;
    filter: url(#warp);
    z-index: 0;
    animation: grid-breathe 8s ease-in-out infinite;
}

@keyframes grid-breathe {
    0%, 100% { opacity: 0.18; transform: scale(1); }
    50% { opacity: 0.25; transform: scale(1.02); }
}

/* Hero glow */
.hero-glow {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: radial-gradient(ellipse 60% 60% at 50% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero-panel {
    max-width: 700px;
    text-align: center;
    border-color: rgba(99, 102, 241, 0.35);
    background: rgba(6, 6, 18, 0.75);
}

.hero-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: #6366f1;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(99, 102, 241, 0.4);
    display: inline-block;
    padding: 0.3rem 1rem;
    border-radius: 2px;
}

.hero-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.title-line-1 {
    font-size: clamp(1rem, 3vw, 1.4rem);
    color: #6366f1;
    letter-spacing: 0.25em;
}

.title-line-2 {
    font-size: clamp(2.5rem, 8vw, 5.5rem);
    color: #f0f0ff;
    text-shadow:
        0 0 40px rgba(99, 102, 241, 0.6),
        0 0 80px rgba(59, 130, 246, 0.3);
    letter-spacing: 0.08em;
}

.hero-subtitle {
    font-size: 1rem;
    color: rgba(240, 240, 255, 0.75);
    max-width: 500px;
    margin: 0 auto 2rem;
    line-height: 1.8;
}

/* Hero Stats HUD */
.hero-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.8rem 1.5rem;
    flex: 1;
    background: rgba(99, 102, 241, 0.04);
}

.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #3b82f6;
    letter-spacing: 0.05em;
}

.stat-label {
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: rgba(240, 240, 255, 0.4);
    text-transform: uppercase;
    margin-top: 0.2rem;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: rgba(99, 102, 241, 0.3);
}

/* Scroll cue */
.scroll-cue {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
}

.scroll-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 0.3em;
    color: rgba(240, 240, 255, 0.3);
}

.scroll-arrow {
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, rgba(99, 102, 241, 0.6), transparent);
    animation: pulse-down 2s ease-in-out infinite;
}

@keyframes pulse-down {
    0%, 100% { opacity: 0.4; transform: scaleY(0.8); }
    50% { opacity: 1; transform: scaleY(1); }
}

/* ── Section Labels & Typography ── */
.section-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: #6366f1;
    text-transform: uppercase;
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    font-weight: 700;
    color: #f0f0ff;
    line-height: 1.2;
    margin-bottom: 1.2rem;
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.section-body {
    font-size: 1rem;
    color: rgba(240, 240, 255, 0.8);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

/* ── Equation Blocks ── */
.equation-block {
    background: rgba(30, 27, 75, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-top: 1rem;
}

.eq-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    color: #6366f1;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.equation {
    font-family: 'STIX Two Math', serif;
    font-size: 1.4rem;
    color: #f0f0ff;
    text-align: center;
    padding: 0.5rem 0;
    letter-spacing: 0.05em;
}

.eq-desc {
    font-size: 0.75rem;
    color: rgba(240, 240, 255, 0.45);
    text-align: center;
    margin-top: 0.3rem;
    font-style: italic;
}

/* ── Special Relativity Section Background ── */
.sr-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 80% 50%, rgba(59, 130, 246, 0.05) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 20% 50%, rgba(99, 102, 241, 0.05) 0%, transparent 60%);
}

/* ── Light Cone (Time Dilation) ── */
.light-cone-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 6rem;
    pointer-events: none;
    z-index: 1;
}

.light-cone {
    position: absolute;
    left: 8%;
    width: 320px;
    height: 320px;
}

.light-cone-future {
    top: 50%;
    transform: translateY(-100%);
    clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
    background: rgba(59, 130, 246, 0.15);
    border-left: 1px solid rgba(59, 130, 246, 0.4);
    border-right: 1px solid rgba(59, 130, 246, 0.4);
    animation: cone-pulse 6s ease-in-out infinite;
}

.light-cone-past {
    top: 50%;
    transform: translateY(0%);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    background: rgba(239, 68, 68, 0.1);
    border-left: 1px solid rgba(239, 68, 68, 0.3);
    border-right: 1px solid rgba(239, 68, 68, 0.3);
    animation: cone-pulse 6s ease-in-out infinite reverse;
}

@keyframes cone-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.cone-apex {
    position: absolute;
    left: calc(8% + 160px - 5px);
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f0f0ff;
    box-shadow: 0 0 16px #f0f0ff, 0 0 32px rgba(240, 240, 255, 0.5);
    z-index: 2;
    animation: apex-glow 3s ease-in-out infinite;
}

@keyframes apex-glow {
    0%, 100% { box-shadow: 0 0 16px #f0f0ff, 0 0 32px rgba(240, 240, 255, 0.5); }
    50% { box-shadow: 0 0 24px #f0f0ff, 0 0 50px rgba(240, 240, 255, 0.8); }
}

.cone-label {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    font-weight: 700;
}

.cone-future-label {
    left: calc(8% + 130px);
    top: calc(50% - 180px);
    color: #3b82f6;
}

.cone-past-label {
    left: calc(8% + 140px);
    top: calc(50% + 160px);
    color: #ef4444;
}

/* ── Clock Pair Demo ── */
.dilation-demo {
    margin-top: 1.5rem;
}

.clock-pair {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.clock-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.clock-face {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.5);
    background: rgba(30, 27, 75, 0.6);
    position: relative;
}

.clock-hand {
    position: absolute;
    width: 2px;
    height: 24px;
    background: #f0f0ff;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg);
}

.clock-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    color: rgba(240, 240, 255, 0.6);
    text-transform: uppercase;
}

/* ── Length Contraction Visual ── */
.lc-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 100% 40% at 50% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 60%);
}

.contraction-visual {
    position: absolute;
    left: 5%;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 3rem;
    z-index: 2;
    pointer-events: none;
}

.ship-rest, .ship-contracted {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
}

.ship-rest .ship-body {
    width: 220px;
    height: 28px;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.5), rgba(59, 130, 246, 0.2));
    border: 1px solid rgba(59, 130, 246, 0.5);
    border-radius: 3px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.ship-contracted .ship-body {
    width: 97px; /* 44% of 220px ≈ 97px */
    height: 28px;
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.5), rgba(239, 68, 68, 0.2));
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 3px;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.ship-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    color: rgba(240, 240, 255, 0.45);
    text-transform: uppercase;
}

/* ── Mass-Energy Section ── */
.me-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 70% at 50% 50%, rgba(251, 191, 36, 0.04) 0%, transparent 65%);
}

.equation-hero {
    font-family: 'STIX Two Math', serif;
    font-size: clamp(4rem, 10vw, 8rem);
    font-weight: 400;
    line-height: 1;
    margin: 1rem 0 1.5rem;
    letter-spacing: 0.02em;
    animation: eq-pulse 4s ease-in-out infinite;
}

@keyframes eq-pulse {
    0%, 100% { text-shadow: 0 0 40px rgba(251, 191, 36, 0.3), 0 0 80px rgba(251, 191, 36, 0.1); }
    50% { text-shadow: 0 0 60px rgba(251, 191, 36, 0.5), 0 0 120px rgba(251, 191, 36, 0.2); }
}

.eq-E { color: #fbbf24; }
.eq-equals { color: rgba(240, 240, 255, 0.6); font-size: 0.8em; }
.eq-m { color: #f0f0ff; }
.eq-c { color: #3b82f6; }
.eq-2 {
    color: #ef4444;
    font-size: 0.5em;
    vertical-align: super;
    position: relative;
    top: -0.3em;
}

.me-legend {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
    text-align: left;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.85rem;
    color: rgba(240, 240, 255, 0.7);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── General Relativity — Gravity Well ── */
.gravity-well-container {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 55%;
    height: 80%;
    z-index: 1;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gravity-grid {
    position: absolute;
    inset: -20%;
    background:
        linear-gradient(rgba(99, 102, 241, 0.25) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.25) 1px, transparent 1px);
    background-size: 40px 40px;
    transform-style: preserve-3d;
    transform: perspective(600px) rotateX(55deg);
    animation: gravity-warp 10s ease-in-out infinite;
}

@keyframes gravity-warp {
    0%, 100% { filter: url(#warp); opacity: 0.6; }
    50% { opacity: 0.85; }
}

.mass-body {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, #fbbf24 0%, rgba(251, 191, 36, 0.5) 40%, transparent 70%);
    box-shadow:
        0 0 30px rgba(251, 191, 36, 0.6),
        0 0 60px rgba(251, 191, 36, 0.3),
        0 0 100px rgba(251, 191, 36, 0.1);
    z-index: 2;
    animation: mass-pulse 5s ease-in-out infinite;
}

@keyframes mass-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(251,191,36,0.6), 0 0 60px rgba(251,191,36,0.3); }
    50% { transform: scale(1.08); box-shadow: 0 0 50px rgba(251,191,36,0.8), 0 0 100px rgba(251,191,36,0.4); }
}

/* ── Doppler / Redshift Section ── */
.doppler-visual {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}

.doppler-source {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f0f0ff;
    box-shadow: 0 0 20px #f0f0ff;
    z-index: 2;
    /* Source moves right */
    animation: source-move 6s linear infinite;
}

@keyframes source-move {
    0% { left: 20%; }
    100% { left: 65%; }
}

.doppler-waves {
    position: absolute;
    width: 100%;
    height: 100%;
}

.wave {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(99, 102, 241, 0.4);
    animation: wave-expand 3s ease-out infinite;
}

.wave-1 { animation-delay: 0s; }
.wave-2 { animation-delay: 0.6s; }
.wave-3 { animation-delay: 1.2s; }
.wave-4 { animation-delay: 1.8s; }
.wave-5 { animation-delay: 2.4s; }

@keyframes wave-expand {
    0% { width: 0; height: 0; opacity: 0.8; border-color: rgba(99, 102, 241, 0.6); }
    50% { border-color: rgba(59, 130, 246, 0.3); }
    100% { width: 300px; height: 300px; opacity: 0; border-color: rgba(239, 68, 68, 0.1); }
}

.shift-bars {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1.2rem;
}

.shift-bar {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.shift-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    color: rgba(240, 240, 255, 0.5);
    text-transform: uppercase;
}

.shift-spectrum {
    height: 24px;
    border-radius: 3px;
    width: 100%;
}

.blueshift-spectrum {
    background: linear-gradient(to right, #1e1b4b, #6366f1, #3b82f6, #60a5fa, #93c5fd);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.redshift-spectrum {
    background: linear-gradient(to right, #fbbf24, #f97316, #ef4444, #dc2626, #1e1b4b);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

/* ── Legacy Section ── */
.legacy-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% 50%, rgba(99, 102, 241, 0.06) 0%, transparent 60%);
}

.legacy-title {
    font-size: clamp(1.6rem, 4vw, 2.8rem);
}

.legacy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
}

.legacy-item {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.8rem;
    background: rgba(30, 27, 75, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 6px;
}

.legacy-icon {
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.legacy-text {
    font-size: 0.85rem;
    color: rgba(240, 240, 255, 0.75);
    line-height: 1.5;
}

.legacy-text small {
    font-size: 0.75rem;
    color: rgba(240, 240, 255, 0.45);
}

.final-quote {
    font-size: 1rem;
    color: rgba(240, 240, 255, 0.6);
    font-style: italic;
    line-height: 1.7;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(99, 102, 241, 0.2);
}

.quote-attr {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    color: #6366f1;
    margin-top: 0.5rem;
    font-style: normal;
}

/* ── Section Backgrounds ── */
#special-relativity {
    background: linear-gradient(180deg, transparent 0%, rgba(10, 10, 46, 0.3) 50%, transparent 100%);
}

#time-dilation {
    background: linear-gradient(180deg, transparent 0%, rgba(6, 6, 18, 0.2) 50%, transparent 100%);
}

#length-contraction {
    background: linear-gradient(180deg, transparent 0%, rgba(10, 10, 46, 0.25) 50%, transparent 100%);
}

#mass-energy {
    background: linear-gradient(180deg, transparent 0%, rgba(30, 20, 5, 0.3) 50%, transparent 100%);
}

#general-relativity {
    background: linear-gradient(180deg, transparent 0%, rgba(10, 10, 46, 0.3) 50%, transparent 100%);
}

#doppler {
    background: linear-gradient(180deg, transparent 0%, rgba(6, 6, 18, 0.2) 50%, transparent 100%);
}

#legacy {
    background: linear-gradient(180deg, transparent 0%, rgba(10, 10, 46, 0.35) 100%);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .panel-right,
    .panel-left {
        margin: 0 auto;
    }

    .light-cone-container {
        display: none;
    }

    .contraction-visual {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        flex-direction: row;
        margin-bottom: 1.5rem;
    }

    .gravity-well-container {
        position: relative;
        width: 100%;
        height: 200px;
        transform: none;
        top: auto;
        margin-bottom: 1.5rem;
    }

    .scene {
        flex-direction: column;
        padding: 4rem 1.5rem;
    }

    .legacy-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .hero-stats {
        flex-direction: column;
    }

    .stat-divider {
        width: 80%;
        height: 1px;
    }

    .clock-pair {
        gap: 1rem;
    }
}
