/* ============================================
   chrono.games - Temporal Research Facility
   ============================================ */

/* CSS Custom Properties */
:root {
    --void-base: #08081A;
    --panel-depth: #12122A;
    --frost-edge: #8A9BDC;
    --text-primary: #C8CDE8;
    --text-bright: #E8ECFF;
    --temporal-violet: #7B6FE0;
    --deep-indigo: #3D2B8C;
    --amber-signal: #D4A853;
    --ripple-cyan: #4FC3C9;
    --alert-magenta: #C74B8F;

    --panel-bg: rgba(18, 18, 42, 0.55);
    --panel-bg-edge: rgba(18, 18, 42, 0.35);
    --panel-border: rgba(138, 155, 220, 0.12);
    --readout-bg: rgba(10, 10, 30, 0.7);
    --specimen-border: rgba(138, 155, 220, 0.2);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--void-base);
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* ============================================
   Timeline Spine
   ============================================ */
#timeline-spine {
    position: fixed;
    left: 8%;
    top: 0;
    width: 4px;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.spine-line {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
    background: rgba(138, 155, 220, 0.2);
}

.spine-node {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--temporal-violet);
    opacity: 0.5;
    animation: spineNodePulse 3s ease-in-out infinite;
}

.spine-node[data-stratum="1"] { top: 10%; }
.spine-node[data-stratum="2"] { top: 30%; }
.spine-node[data-stratum="3"] { top: 50%; }
.spine-node[data-stratum="4"] { top: 70%; }
.spine-node[data-stratum="5"] { top: 90%; }

/* Spine thickening near nodes */
.spine-node::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -20px;
    width: 4px;
    height: 40px;
    transform: translateX(-50%);
    background: rgba(138, 155, 220, 0.25);
    border-radius: 2px;
}

@keyframes spineNodePulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ============================================
   Strata (Sections)
   ============================================ */
.stratum {
    position: relative;
    z-index: 2;
    min-height: 100vh;
}

.stratum-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 40px;
    position: relative;
}

/* ============================================
   Stratum 1: Signal Received (Hero)
   ============================================ */
.stratum-1 {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: transparent;
}

.stratum-1 .stratum-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0;
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 64px;
    letter-spacing: 0.12em;
    color: var(--text-bright);
    text-transform: uppercase;
    opacity: 0;
    animation: heroFadeIn 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.6s forwards;
}

@keyframes heroFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-readout {
    margin-top: 32px;
    opacity: 0;
    animation: heroFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 1.0s forwards;
}

/* ============================================
   Glassmorphic Panels
   ============================================ */
.observation-panel {
    background: radial-gradient(ellipse at center, var(--panel-bg), var(--panel-bg-edge));
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 32px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Ripple effect container */
.observation-panel .ripple-effect,
.specimen-window .ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 0%, rgba(79, 195, 201, 0.06) 50%, transparent 100%);
    pointer-events: none;
    transform: scale(0);
    animation: rippleExpand 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes rippleExpand {
    from { transform: scale(0); opacity: 1; }
    to { transform: scale(4); opacity: 0; }
}

/* ============================================
   Readout Strips
   ============================================ */
.readout-strip {
    background: var(--readout-bg);
    border: 1px solid rgba(138, 155, 220, 0.08);
    border-radius: 4px;
    padding: 12px 24px;
    display: inline-flex;
    align-items: center;
    gap: 16px;
    box-shadow: inset 0 0 20px rgba(123, 111, 224, 0.05);
}

.readout-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--frost-edge);
    opacity: 0.7;
}

.readout-value {
    font-family: 'Orbitron', sans-serif;
    font-weight: 500;
    font-size: 18px;
    color: var(--amber-signal);
    letter-spacing: 0.04em;
}

/* ============================================
   Specimen Windows
   ============================================ */
.specimen-window {
    background: radial-gradient(ellipse at center, var(--panel-bg), var(--panel-bg-edge));
    border: 2px solid var(--specimen-border);
    border-radius: 8px;
    padding: 40px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: relative;
    overflow: hidden;
    animation: specimenPulse 4s ease-in-out infinite;
}

@keyframes specimenPulse {
    0%, 100% { box-shadow: 0 0 40px rgba(100, 80, 220, 0.08); }
    50% { box-shadow: 0 0 40px rgba(100, 80, 220, 0.18); }
}

/* ============================================
   Drift Markers
   ============================================ */
.drift-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border-radius: 20px;
    background: rgba(10, 10, 30, 0.6);
    border: 1px solid rgba(138, 155, 220, 0.1);
}

.drift-time {
    font-family: 'Orbitron', sans-serif;
    font-weight: 500;
    font-size: 12px;
    color: var(--amber-signal);
    letter-spacing: 0.02em;
}

/* ============================================
   Stratum 2: Instruments Found
   ============================================ */
.stratum-2 {
    min-height: 110vh;
    padding-top: 60px;
}

.stratum-2-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 40px;
    align-items: start;
}

.panel-hourglass {
    grid-column: 2 / 7;
    transform: rotate(-0.4deg) translateY(0px);
}
.panel-hourglass.visible {
    transform: rotate(-0.4deg) translateY(0);
}

.panel-pendulum {
    grid-column: 7 / 12;
    transform: rotate(0.6deg) translateY(40px);
}
.panel-pendulum.visible {
    transform: rotate(0.6deg) translateY(40px);
}

.panel-clock {
    grid-column: 4 / 9;
    transform: rotate(-0.3deg) translateY(0px);
}
.panel-clock.visible {
    transform: rotate(-0.3deg) translateY(0);
}

.drift-marker-1 {
    grid-column: 1 / 3;
    justify-self: center;
    align-self: center;
}

.drift-marker-2 {
    grid-column: 10 / 13;
    justify-self: center;
}

.drift-marker-3 {
    grid-column: 2 / 4;
    justify-self: center;
}

.panel-illustration {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.instrument-svg {
    width: 160px;
    height: auto;
}

.panel-text p {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-primary);
}

/* ============================================
   SVG Animations
   ============================================ */

/* Sand particles floating */
.sand-particle {
    animation: sandDrift 12s ease-in-out infinite;
}
.sp-1 { animation-delay: 0s; }
.sp-2 { animation-delay: -2.4s; }
.sp-3 { animation-delay: -4.8s; }
.sp-4 { animation-delay: -7.2s; }
.sp-5 { animation-delay: -9.6s; }

@keyframes sandDrift {
    0%, 100% { transform: translateY(0px); opacity: 0.8; }
    25% { transform: translateY(-15px); opacity: 0.5; }
    50% { transform: translateY(-30px); opacity: 0.3; }
    75% { transform: translateY(-15px); opacity: 0.6; }
}

/* Pendulum path dash animation */
.pendulum-path {
    animation: pendulumDash 6s ease-in-out infinite;
}
.path-left { animation-delay: 0s; }
.path-right { animation-delay: -3s; }

@keyframes pendulumDash {
    0%, 100% { stroke-dashoffset: 0; }
    50% { stroke-dashoffset: 16; }
}

/* Clock hands - each rotates at a different speed (Fibonacci-esque) */
.clock-hand {
    transform-origin: 100px 100px;
}
.hand-1 { animation: clockRotate 8s linear infinite; }
.hand-2 { animation: clockRotate 13s linear infinite; }
.hand-3 { animation: clockRotate 21s linear infinite; }
.hand-4 { animation: clockRotate 34s linear infinite; }
.hand-5 { animation: clockRotate 55s linear infinite; }
.hand-6 { animation: clockRotate 89s linear infinite; }
.hand-7 { animation: clockRotate 120s linear infinite; }

/* Ghost trails - offset by 2 degrees, slightly slower */
.clock-ghost {
    transform-origin: 100px 100px;
}
.ghost-1 { animation: clockRotateGhost 8s linear infinite; }
.ghost-2 { animation: clockRotateGhost 13s linear infinite; }
.ghost-3 { animation: clockRotateGhost 21s linear infinite; }

@keyframes clockRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes clockRotateGhost {
    from { transform: rotate(-4deg); }
    to { transform: rotate(356deg); }
}

/* ============================================
   Stratum 3: Calibration
   ============================================ */
.stratum-3 {
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.stratum-3-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 48px;
}

.calibration-dial-container {
    width: 400px;
    height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.calibration-dial-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.dial-wrapper {
    width: 300px;
    height: 300px;
    cursor: grab;
}

.dial-wrapper:active {
    cursor: grabbing;
}

.dial-svg {
    width: 100%;
    height: 100%;
}

.dial-pointer-group {
    transition: transform 0.15s ease-out;
    transform-origin: 150px 150px;
}

.dial-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--frost-edge);
    opacity: 0.5;
    margin-top: 16px;
    text-align: center;
}

.calibration-readout-left,
.calibration-readout-right {
    flex-direction: column;
    gap: 8px;
    min-width: 120px;
}

/* Dial snap pulse */
@keyframes dialSnap {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.dial-snap {
    animation: dialSnap 150ms ease-out;
}

/* ============================================
   Stratum 4: Observation Log
   ============================================ */
.stratum-4 {
    min-height: 120vh;
}

.stratum-4-sequence {
    display: flex;
    flex-direction: column;
    gap: 48px;
    max-width: 720px;
    margin-left: 15%;
}

.log-panel {
    padding: 40px;
}

.log-panel-1 { transform: rotate(-0.5deg); }
.log-panel-1.visible { transform: rotate(-0.5deg); }
.log-panel-2 { transform: rotate(0.3deg); }
.log-panel-2.visible { transform: rotate(0.3deg); }
.log-panel-3 { transform: rotate(-0.7deg); }
.log-panel-3.visible { transform: rotate(-0.7deg); }
.log-panel-4 { transform: rotate(0.4deg); }
.log-panel-4.visible { transform: rotate(0.4deg); }
.log-panel-5 { transform: rotate(-0.3deg); }
.log-panel-5.visible { transform: rotate(-0.3deg); }

.chapter-marker {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 28px;
    letter-spacing: 0.06em;
    color: var(--temporal-violet);
    text-transform: uppercase;
    margin-bottom: 24px;
}

.log-panel p {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-primary);
}

/* ============================================
   Stratum 5: Drift
   ============================================ */
.stratum-5 {
    min-height: 150vh;
    position: relative;
}

.stratum-5-fade {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 80px;
    padding-top: 120px;
}

.drift-panel {
    max-width: 500px;
    text-align: center;
}

.drift-panel p {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-primary);
}

.drift-readout-1,
.drift-readout-2 {
    display: inline-flex;
}

.erratic-readout {
    animation: erraticFlicker 2s ease-in-out infinite;
}

@keyframes erraticFlicker {
    0%, 100% { opacity: 1; }
    30% { opacity: 0.7; }
    50% { opacity: 1; }
    70% { opacity: 0.4; }
    85% { opacity: 0.9; }
}

.drift-marker-final {
    margin-top: 60px;
}

.void-terminus {
    height: 50vh;
}

/* ============================================
   Responsive / Mobile
   ============================================ */
@media (max-width: 768px) {
    .hero-title {
        font-size: 32px;
        letter-spacing: 0.08em;
    }

    .stratum-inner {
        padding: 60px 20px;
    }

    .stratum-2-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .panel-hourglass,
    .panel-pendulum,
    .panel-clock {
        grid-column: 1 / -1;
        width: 90%;
        margin: 0 auto;
    }

    .drift-marker-1,
    .drift-marker-2,
    .drift-marker-3 {
        grid-column: 1 / -1;
        justify-self: center;
    }

    .stratum-3-layout {
        flex-direction: column;
        gap: 24px;
    }

    .calibration-dial-container {
        width: 280px;
        height: 280px;
    }

    .dial-wrapper {
        width: 240px;
        height: 240px;
    }

    .calibration-readout-left,
    .calibration-readout-right {
        flex-direction: row;
    }

    .stratum-4-sequence {
        margin-left: 0;
        max-width: 100%;
    }

    .log-panel {
        padding: 24px;
    }

    .chapter-marker {
        font-size: 22px;
    }

    #timeline-spine {
        left: 4%;
    }

    .readout-value {
        font-size: 14px;
    }

    .instrument-svg {
        width: 120px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 24px;
    }

    .observation-panel {
        padding: 20px;
    }

    .panel-text p,
    .log-panel p,
    .drift-panel p {
        font-size: 14px;
    }
}
