/**
 * Time Machine Museum - Steampunk Theme + Scrollytelling
 * Colors: Sepia, Gold, Dark Brown, Brass
 */

/* ============================================= 
   CSS RESET & VARIABLES
   ============================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Steampunk Color Palette */
    --sepia-dark: #1a1206;
    --sepia-mid: #2d1f0a;
    --sepia-light: #3d2a10;
    --brown-dark: #4a3520;
    --brown-wood: #5c4033;

    --gold-bright: #ffd700;
    --gold-muted: #d4af37;
    --brass: #b5a642;
    --copper: #b87333;
    --bronze: #cd7f32;

    --cream: #f5deb3;
    --parchment: #e8d4a8;
    --ivory: #fffff0;

    /* Glass Effects */
    --glass-bg: rgba(255, 220, 160, 0.08);
    --glass-border: rgba(255, 200, 100, 0.2);
    --glass-highlight: rgba(255, 215, 0, 0.15);

    /* Typography */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Nunito', sans-serif;
    --font-thai: 'Sarabun', 'Nunito', sans-serif;

    /* Gradients */
    --bg-gradient: linear-gradient(135deg,
            var(--sepia-dark) 0%,
            var(--sepia-mid) 25%,
            var(--sepia-light) 50%,
            var(--sepia-mid) 75%,
            var(--sepia-dark) 100%);

    --gold-gradient: linear-gradient(135deg,
            var(--gold-bright),
            var(--gold-muted),
            var(--brass),
            var(--gold-muted));
}

html,
body {
    height: 100vh;
    font-family: var(--font-body);
    background: var(--bg-gradient);
    color: var(--cream);
    overflow: hidden;
}

/* ============================================= 
   ANIMATED BACKGROUND PARTICLES
   ============================================= */

.particle-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.dust-particle {
    position: absolute;
    background: var(--gold-muted);
    border-radius: 50%;
    animation: dustFloat linear infinite;
    opacity: 0.4;
}

@keyframes dustFloat {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.4;
    }

    90% {
        opacity: 0.4;
    }

    100% {
        transform: translateY(-10vh) rotate(360deg);
        opacity: 0;
    }
}

/* Gear Overlay Pattern */
.gear-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 60% 40% at 20% 80%, rgba(181, 166, 66, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 50% 35% at 80% 20%, rgba(255, 215, 0, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 40% 30% at 50% 50%, rgba(184, 115, 51, 0.05) 0%, transparent 60%);
}

/* ============================================= 
   MAIN LAYOUT
   ============================================= */

.app-container {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: 16px 20px;
    gap: 12px;
}

/* ============================================= 
   HEADER
   ============================================= */

.header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}

.back-btn {
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    color: var(--gold-bright);
    font-size: 1.4rem;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 215, 0, 0.2);
}

.back-btn:hover {
    background: rgba(255, 200, 100, 0.25);
    border-color: var(--gold-bright);
    transform: scale(1.1) rotate(-5deg);
    box-shadow:
        0 6px 30px rgba(255, 215, 0, 0.3),
        inset 0 1px 0 rgba(255, 215, 0, 0.3);
}

.title-group {
    flex: 1;
}

.title-main {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 700;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-sub {
    font-family: var(--font-thai);
    font-size: 1rem;
    color: var(--brass);
    margin-top: 4px;
    letter-spacing: 1px;
}

.header-icon {
    font-size: 1.5rem;
    animation: gearSpin 8s linear infinite;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
}

@keyframes gearSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================= 
   SCROLLYTELLING CONTAINER
   ============================================= */

.scrollytelling-container {
    display: grid;
    grid-template-columns: 55% 45%;
    gap: 16px;
    min-height: 0;
    overflow: hidden;
}

/* ============================================= 
   IMAGE STAGE (Left Side)
   ============================================= */

.image-stage {
    position: relative;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.scene-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.scene-img.active {
    opacity: 1;
}

/* Scene Counter Badge */
.scene-counter {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--gold-muted);
    border-radius: 30px;
    padding: 8px 16px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--gold-bright);
    display: flex;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(8px);
}

.counter-current {
    font-weight: 700;
    font-size: 1.1rem;
}

.counter-divider {
    color: var(--brass);
}

.counter-total {
    color: var(--parchment);
}

/* ============================================= 
   STORY PANEL (Right Side)
   ============================================= */

.story-panel {
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
}

.story-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gold-gradient);
    opacity: 0.6;
}

.story-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.story-scroll::-webkit-scrollbar {
    width: 8px;
}

.story-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.story-scroll::-webkit-scrollbar-thumb {
    background: var(--brass);
    border-radius: 4px;
}

.story-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--gold-muted);
}

/* Story Intro */
.story-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    text-align: center;
    padding: 40px 20px;
}

.intro-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: floatGently 3s ease-in-out infinite;
}

@keyframes floatGently {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.intro-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--gold-bright);
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.intro-text {
    font-size: 1rem;
    color: var(--parchment);
    margin-bottom: 12px;
    line-height: 1.6;
}

.intro-text-th {
    font-family: var(--font-thai);
    font-size: 0.95rem;
    color: var(--brass);
    line-height: 1.6;
}

/* ============================================= 
   SCENE BLOCKS
   ============================================= */

.scene-block {
    min-height: 70vh;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.4s ease;
    opacity: 0.5;
}

.scene-block:last-child {
    border-bottom: none;
    min-height: 50vh;
}

.scene-block.active {
    opacity: 1;
}

.scene-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--gold-gradient);
    border-radius: 50%;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--sepia-dark);
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.scene-text-en {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--ivory);
    margin-bottom: 16px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.scene-text-th {
    font-family: var(--font-thai);
    font-size: 1rem;
    line-height: 1.9;
    color: var(--brass);
    padding-left: 16px;
    border-left: 3px solid var(--glass-border);
}

.scene-block.active .scene-text-th {
    border-left-color: var(--gold-muted);
}

/* ============================================= 
   TIMELINE SLIDER
   ============================================= */

.timeline-container {
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    padding: 12px 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
}

.timeline-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--brass);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 12px;
    text-align: center;
}

.timeline-track {
    position: relative;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 20px;
}

/* Timeline Line */
.timeline-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 60px;
    right: 60px;
    height: 4px;
    background: linear-gradient(90deg,
            var(--brown-dark),
            var(--brass),
            var(--gold-muted),
            var(--brass),
            var(--brown-dark));
    border-radius: 2px;
    transform: translateY(-50%);
    z-index: 0;
}

.era-marker {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.era-marker:hover {
    transform: translateY(-4px);
}

.era-marker:hover .era-dot {
    transform: scale(1.15);
    box-shadow: 0 0 25px var(--gold-bright);
}

.era-dot {
    width: 55px;
    height: 55px;
    background: var(--brown-wood);
    border: 3px solid var(--brass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
}

.era-marker.active .era-dot {
    background: var(--gold-muted);
    border-color: var(--gold-bright);
    transform: scale(1.1);
    box-shadow:
        0 0 35px rgba(255, 215, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

.era-label {
    font-family: var(--font-display);
    font-size: 0.65rem;
    color: var(--parchment);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
    max-width: 90px;
    transition: all 0.3s ease;
}

.era-marker.active .era-label {
    color: var(--gold-bright);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ============================================= 
   RESPONSIVE DESIGN
   ============================================= */

@media (max-width: 900px) {
    .scrollytelling-container {
        grid-template-columns: 1fr;
        grid-template-rows: 40vh 1fr;
    }

    .image-stage {
        border-radius: 16px;
    }

    .story-panel {
        border-radius: 16px;
    }

    .scene-block {
        min-height: 50vh;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 10px 14px;
        gap: 10px;
    }

    .header {
        gap: 12px;
    }

    .back-btn {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }

    .title-main {
        font-size: 1.1rem;
    }

    .scrollytelling-container {
        grid-template-rows: 35vh 1fr;
    }

    .era-dot {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }

    .era-label {
        font-size: 0.55rem;
    }

    .timeline-container {
        padding: 10px 14px;
    }

    .timeline-track {
        padding: 0 10px;
    }

    .timeline-track::before {
        left: 35px;
        right: 35px;
    }

    .scene-text-en {
        font-size: 1rem;
    }

    .scene-text-th {
        font-size: 0.9rem;
    }
}

/* ============================================= 
   ACCESSIBILITY
   ============================================= */

.era-marker:focus {
    outline: none;
}

.era-marker:focus .era-dot {
    box-shadow: 0 0 0 3px var(--gold-bright);
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}