/* ========================================
   historic.quest - Complete Styling System
   ======================================== */

/* Root CSS Variables & Custom Properties */
:root {
    /* Ancient Epoch */
    --ancient-primary: #0B1D3A;
    --ancient-secondary: #1B6B7D;
    --ancient-accent: #3ECFCF;

    /* Classical Epoch */
    --classical-primary: #1A2744;
    --classical-secondary: #4A6FA5;
    --classical-accent: #7DD3C0;

    /* Medieval Epoch */
    --medieval-primary: #2C1810;
    --medieval-secondary: #8B5E3C;
    --medieval-accent: #D4A056;

    /* Industrial Epoch */
    --industrial-primary: #1C1C1C;
    --industrial-secondary: #B87333;
    --industrial-accent: #E8822A;

    /* Modern Epoch */
    --modern-primary: #1A0A2E;
    --modern-secondary: #C73E6B;
    --modern-accent: #FF6B6B;

    /* Universal Constants */
    --plaque-text: #F0E6D2;
    --plaque-bg: rgba(30, 30, 30, 0.85);
    --plaque-bg-color: #1E1E1E;
    --rail-bg: #2A2A2A;
    --brass: #C9B06B;
    --overlay: rgba(74, 74, 74, 0.4);
    --overlay-color: #4A4A4A;

    /* Dynamic epoch variables (updated by JS) */
    --epoch-primary: var(--ancient-primary);
    --epoch-secondary: var(--ancient-secondary);
    --epoch-accent: var(--ancient-accent);

    /* Typography */
    --font-tech-mono: 'Share Tech Mono', monospace;
    --font-space-mono: 'Space Mono', monospace;
    --font-caveat: 'Caveat', cursive;

    /* Spacing & Layout */
    --viewport-height: 100vh;
    --scroll-width: 18000px;
}

/* ========================================
   Global Styles & Resets
   ======================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-space-mono);
    background-color: var(--epoch-primary);
    color: var(--plaque-text);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.03) 0px,
            rgba(255, 255, 255, 0.03) 1px,
            transparent 1px,
            transparent 2px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.03) 0px,
            rgba(255, 255, 255, 0.03) 1px,
            transparent 1px,
            transparent 2px
        );
    background-size: 4px 4px, 4px 4px;
}

/* ========================================
   Scroll Container & Track
   ======================================== */

.scroll-container {
    width: 100vw;
    height: 100vh;
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.scroll-container::-webkit-scrollbar {
    height: 8px;
}

.scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.scroll-container::-webkit-scrollbar-thumb {
    background: var(--brass);
    border-radius: 4px;
}

.scroll-track {
    position: relative;
    width: var(--scroll-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Parallax Layer System
   ======================================== */

.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}

.layer-sky {
    z-index: 1;
    background: linear-gradient(90deg,
        var(--ancient-primary) 0%,
        var(--classical-primary) 20%,
        var(--medieval-primary) 40%,
        var(--industrial-primary) 60%,
        var(--modern-primary) 100%
    );
}

.layer-distant {
    z-index: 2;
    pointer-events: none;
}

.distant-silhouettes {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 1000px;
    padding-left: 500px;
}

.silhouette-group {
    flex-shrink: 0;
    width: 400px;
    height: 200px;
    color: currentColor;
}

.silhouette-ancient {
    color: var(--ancient-secondary);
}

.silhouette-classical {
    color: var(--classical-secondary);
}

.silhouette-medieval {
    color: var(--medieval-secondary);
}

.silhouette-industrial {
    color: var(--industrial-secondary);
}

.silhouette-modern {
    color: var(--modern-secondary);
}

.layer-architecture {
    z-index: 3;
    display: flex;
    align-items: center;
}

.epoch-scenes {
    display: flex;
    gap: 3000px;
    width: 100%;
    height: 100%;
}

.epoch-scene {
    flex-shrink: 0;
    width: 2500px;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.isometric-scene {
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 600px;
}

.layer-ground {
    z-index: 4;
    overflow: hidden;
    bottom: 48px;
    height: calc(100% - 48px);
}

.ground-details {
    width: 100%;
    height: 100%;
    position: relative;
}

.ground-svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.layer-foreground {
    z-index: 5;
    pointer-events: none;
    bottom: 48px;
    height: calc(100% - 48px);
}

.mechanical-overlays {
    position: relative;
    width: 100%;
    height: 100%;
    color: #4A4A4A;
}

/* ========================================
   Gear Animations
   ======================================== */

.gear-cluster {
    position: absolute;
    width: 200px;
    height: 200px;
    opacity: 0.5;
    animation: rotate-gear 40s linear infinite;
}

.gear-ancient {
    left: 5%;
    top: 30%;
    animation-duration: 40s;
    animation-direction: normal;
}

.gear-classical {
    left: 22%;
    top: 25%;
    animation-duration: 45s;
    animation-direction: reverse;
}

.gear-medieval {
    left: 42%;
    top: 35%;
    animation-duration: 38s;
    animation-direction: normal;
}

.gear-industrial {
    left: 62%;
    top: 28%;
    animation-duration: 50s;
    animation-direction: reverse;
}

.gear-modern {
    left: 82%;
    top: 32%;
    animation-duration: 42s;
    animation-direction: normal;
}

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

/* ========================================
   Pendulum Animations
   ======================================== */

.pendulum {
    position: absolute;
    width: 100px;
    height: 200px;
    transform-origin: 50% 10px;
    animation: swing 3s ease-in-out infinite alternate;
}

.pendulum-ancient {
    left: 12%;
    top: 25%;
    animation-delay: 0s;
}

.pendulum-classical {
    left: 28%;
    top: 20%;
    animation-delay: 0.3s;
}

.pendulum-medieval {
    left: 48%;
    top: 28%;
    animation-delay: 0.6s;
}

.pendulum-industrial {
    left: 68%;
    top: 22%;
    animation-delay: 0.9s;
}

.pendulum-modern {
    left: 88%;
    top: 26%;
    animation-delay: 1.2s;
}

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

@keyframes swing {
    0% {
        transform: rotate(-15deg);
    }
    50% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(15deg);
    }
}

/* ========================================
   Pneumatic Tube Animation
   ======================================== */

.pneumatic-tube {
    position: absolute;
    width: 800px;
    height: 300px;
    left: 2000px;
    top: 150px;
    opacity: 0.6;
}

.tube-sphere {
    animation: float-sphere 6s linear infinite;
}

@keyframes float-sphere {
    0% {
        cx: 100;
    }
    100% {
        cx: 700;
    }
}

/* ========================================
   Information Plaques
   ======================================== */

.plaques-container {
    position: absolute;
    z-index: 6;
    top: 50%;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: translateY(-50%);
}

.plaque {
    position: absolute;
    width: 320px;
    padding: 20px;
    background-color: #1E1E1E;
    background-color: var(--plaque-bg);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    color: var(--plaque-text);
    font-family: var(--font-space-mono);
    font-size: 15px;
    line-height: 1.7;
    pointer-events: auto;
    transform: rotate(var(--plaque-rotation, 2deg)) scale(0);
    animation: plaque-spring 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    border-left: 4px solid var(--epoch-accent);
    opacity: 0;
}

.plaque:nth-child(odd) {
    --plaque-rotation: -2deg;
}

@keyframes plaque-spring {
    0% {
        transform: rotate(var(--plaque-rotation, 2deg)) scale(0);
        opacity: 0;
    }
    70% {
        transform: rotate(var(--plaque-rotation, 2deg)) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: rotate(var(--plaque-rotation, 2deg)) scale(1);
        opacity: 1;
    }
}

/* Individual plaque positioning */
#plaque-ancient-1 {
    left: 5%;
    top: -150px;
    animation-delay: 0.2s;
}

#plaque-ancient-2 {
    right: 8%;
    bottom: -180px;
    animation-delay: 0.4s;
}

#plaque-classical-1 {
    left: 8%;
    top: -150px;
    animation-delay: 0.2s;
}

#plaque-classical-2 {
    right: 10%;
    bottom: -180px;
    animation-delay: 0.4s;
}

#plaque-medieval-1 {
    left: 5%;
    top: -150px;
    animation-delay: 0.2s;
}

#plaque-medieval-2 {
    right: 8%;
    bottom: -180px;
    animation-delay: 0.4s;
}

#plaque-industrial-1 {
    left: 8%;
    top: -150px;
    animation-delay: 0.2s;
}

#plaque-industrial-2 {
    right: 10%;
    bottom: -180px;
    animation-delay: 0.4s;
}

#plaque-modern-1 {
    left: 5%;
    top: -150px;
    animation-delay: 0.2s;
}

#plaque-modern-2 {
    right: 8%;
    bottom: -180px;
    animation-delay: 0.4s;
}

.plaque-title {
    font-family: var(--font-tech-mono);
    font-size: 18px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 12px;
    color: var(--epoch-accent);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.plaque-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--plaque-text);
}

/* ========================================
   Hotspot & Pulse Animation
   ======================================== */

.hotspot {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: var(--epoch-accent);
    border-radius: 50%;
    cursor: pointer;
    transform: translate(-50%, -50%);
    z-index: 7;
    transition: transform 0.3s ease;
}

.hotspot:hover {
    transform: translate(-50%, -50%) scale(1.3);
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--epoch-accent);
    animation: pulse-expand 2s ease-out infinite;
    pointer-events: none;
}

.hotspot .pulse-ring::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--epoch-accent);
    animation: pulse-expand 2s ease-out infinite;
    animation-delay: 0.7s;
}

@keyframes pulse-expand {
    0% {
        transform: scale(0.5);
        opacity: 0.8;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* ========================================
   Timeline Rail (Fixed Navigation)
   ======================================== */

.timeline-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background-color: var(--rail-bg);
    border-top: 2px solid var(--brass);
    display: flex;
    align-items: center;
    z-index: 100;
    padding: 0 20px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.4);
}

.rail-track {
    display: flex;
    gap: 200px;
    width: 100%;
    height: 100%;
    align-items: center;
    position: relative;
}

.rail-marker {
    background: none;
    border: none;
    color: var(--brass);
    font-family: var(--font-caveat);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    padding: 8px 12px;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
}

.rail-marker::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 2px;
    height: 8px;
    background-color: var(--brass);
    transform: translateX(-50%);
}

.rail-marker:hover {
    color: #FFD700;
    transform: scale(1.1);
}

.scrubber-knob {
    position: absolute;
    width: 12px;
    height: 32px;
    background-color: var(--brass);
    border-radius: 4px;
    bottom: 8px;
    left: 20px;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: box-shadow 0.3s ease;
}

.scrubber-knob:active {
    cursor: grabbing;
    box-shadow: 0 4px 12px rgba(201, 176, 107, 0.6);
}

/* ========================================
   Paper Texture Overlay
   ======================================== */

.paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image:
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" result="noise" /></filter><rect width="100" height="100" fill="white" filter="url(%23noise)" opacity="0.03"/></svg>');
    pointer-events: none;
    z-index: 999;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    :root {
        --scroll-width: 12000px;
    }

    .epoch-scene {
        width: 1800px;
        gap: 1800px;
    }

    .plaque {
        width: 280px;
        font-size: 14px;
        padding: 16px;
    }

    .plaque-title {
        font-size: 16px;
    }

    .plaque-text {
        font-size: 13px;
    }

    .distant-silhouettes {
        gap: 600px;
        padding-left: 300px;
    }

    .silhouette-group {
        width: 300px;
        height: 150px;
    }

    .gear-cluster {
        width: 120px;
        height: 120px;
    }

    .pendulum {
        width: 60px;
        height: 120px;
    }

    .rail-track {
        gap: 120px;
    }

    .layer-foreground {
        opacity: 0.3;
    }
}

/* ========================================
   Print & Accessibility Utility Classes
   ======================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
   Animation Performance Optimization
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
