/**
 * The Last Ember - Scrolling Story Page
 * Interactive narrative with parallax animations
 */

/* ===== CSS VARIABLES ===== */
:root {
    /* Colors */
    --flame-orange: #ff6b35;
    --flame-red: #f7931e;
    --flame-yellow: #ffd23f;
    --ash-gray: #4a4a4a;
    --ember-glow: #ff4500;
    --phoenix-gold: #ffa500;
    
    --bg-dark: #0a0a0a;
    --bg-ash: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #d0d0d0;
    --text-muted: #888888;
    
    /* Typography */
    --font-display: 'Cinzel', serif;
    --font-body: 'Crimson Text', Georgia, serif;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --space-4xl: 6rem;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 40px rgba(255, 107, 53, 0.6);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--bg-dark);
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-fast);
}

/* ===== SCROLL PROGRESS BAR ===== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 10000;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--flame-orange), var(--flame-red), var(--flame-yellow));
    width: 0%;
    transition: width 0.1s ease;
    box-shadow: 0 0 20px var(--ember-glow);
}

/* ===== NAVIGATION ===== */
.navbar {
    position: fixed;
    top: 20px;
    left: 0;
    right: 0;
    z-index: 9999;
    pointer-events: none;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-2xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    pointer-events: auto;
}

.nav-brand i {
    color: var(--flame-orange);
    filter: drop-shadow(0 0 10px var(--ember-glow));
    animation: flicker 2s ease-in-out infinite;
}

@keyframes flicker {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    animation: bounce 2s infinite;
}

.scroll-indicator i {
    font-size: 1.25rem;
    color: var(--flame-orange);
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(10px);
    }
}

/* ===== STORY SECTIONS ===== */
.story-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
}

.parallax-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(10, 10, 10, 0.7) 0%, rgba(10, 10, 10, 0.9) 100%);
}

.parallax-overlay.glow {
    background: linear-gradient(180deg, rgba(255, 107, 53, 0.3) 0%, rgba(10, 10, 10, 0.8) 100%);
}

.parallax-overlay.light {
    background: linear-gradient(180deg, rgba(255, 210, 63, 0.2) 0%, rgba(10, 10, 10, 0.6) 100%);
}

/* ===== PARTICLE LAYERS ===== */
.embers-layer,
.flames-layer,
.ash-layer,
.phoenix-particles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

/* ===== STORY CONTENT ===== */
.story-content {
    position: relative;
    z-index: 10;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-4xl) var(--space-2xl);
    width: 100%;
}

.chapter-number {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--flame-orange);
    text-transform: uppercase;
    letter-spacing: 0.3em;
    margin-bottom: var(--space-lg);
}

.story-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 7rem);
    font-weight: 900;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 0 40px rgba(255, 107, 53, 0.5);
}

.story-tagline {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--space-3xl);
}

.scroll-hint {
    text-align: center;
    font-size: 3rem;
    color: var(--flame-orange);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ===== TEXT BLOCKS ===== */
.text-block {
    max-width: 700px;
    margin: var(--space-3xl) 0;
}

.text-block.left {
    margin-right: auto;
}

.text-block.right {
    margin-left: auto;
}

.text-block.center {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.chapter-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xl);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.chapter-title.epic {
    font-size: clamp(3rem, 8vw, 5rem);
    text-align: center;
    background: linear-gradient(135deg, var(--flame-orange), var(--flame-yellow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 30px rgba(255, 107, 53, 0.6));
}

.story-text {
    font-size: 1.25rem;
    line-height: 2;
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.story-text.large {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.story-quote {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-style: italic;
    color: var(--flame-orange);
    padding: var(--space-xl);
    border-left: 4px solid var(--flame-orange);
    margin: var(--space-2xl) 0;
    text-shadow: 0 0 20px rgba(255, 107, 53, 0.4);
}

.story-quote.final {
    border: none;
    font-size: 2rem;
    text-align: center;
    padding: var(--space-3xl);
}

/* ===== IMAGE BLOCKS ===== */
.image-block {
    max-width: 600px;
    margin: var(--space-3xl) 0;
}

.image-block.left {
    margin-right: auto;
}

.image-block.right {
    margin-left: auto;
}

.image-block.full {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.image-block img {
    width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border: 2px solid rgba(255, 107, 53, 0.3);
}

.image-caption {
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
    margin-top: var(--space-md);
    font-size: 0.9rem;
}

/* ===== SPECIAL ELEMENTS ===== */
.traveler-sprite,
.phoenix-sprite {
    text-align: center;
    font-size: 5rem;
    color: var(--flame-orange);
    margin: var(--space-4xl) 0;
    filter: drop-shadow(0 0 30px var(--ember-glow));
}

.phoenix-sprite {
    font-size: 8rem;
    animation: phoenixFloat 3s ease-in-out infinite;
}

@keyframes phoenixFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.sunrise-effect {
    width: 100%;
    height: 200px;
    background: linear-gradient(180deg, rgba(255, 210, 63, 0.3) 0%, transparent 100%);
    margin: var(--space-4xl) 0;
    border-radius: 50%;
    filter: blur(40px);
}

/* ===== EPILOGUE ===== */
.epilogue {
    background: var(--bg-dark);
    min-height: 100vh;
}

.story-credits {
    text-align: center;
    margin: var(--space-4xl) 0;
    padding: var(--space-2xl);
    border-top: 2px solid rgba(255, 107, 53, 0.3);
    border-bottom: 2px solid rgba(255, 107, 53, 0.3);
}

.story-credits p {
    color: var(--text-muted);
    margin: var(--space-sm) 0;
}

.story-credits p:first-child {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.restart-button {
    text-align: center;
}

.btn-restart {
    display: inline-flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-2xl);
    background: linear-gradient(135deg, var(--flame-orange), var(--flame-red));
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 50px;
    box-shadow: var(--shadow-glow);
    transition: var(--transition-smooth);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.btn-restart:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 60px rgba(255, 107, 53, 0.8);
}

/* ===== SCROLL ANIMATIONS ===== */
[data-scroll] {
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-scroll].visible {
    opacity: 1;
}

[data-scroll="fade-up"] {
    transform: translateY(50px);
}

[data-scroll="fade-up"].visible {
    transform: translateY(0);
}

[data-scroll="slide-right"] {
    transform: translateX(-100px);
}

[data-scroll="slide-right"].visible {
    transform: translateX(0);
}

[data-scroll="slide-left"] {
    transform: translateX(100px);
}

[data-scroll="slide-left"].visible {
    transform: translateX(0);
}

[data-scroll="zoom-in"] {
    transform: scale(0.8);
}

[data-scroll="zoom-in"].visible {
    transform: scale(1);
}

[data-scroll="walk-in"] {
    transform: translateX(-100vw);
}

[data-scroll="walk-in"].visible {
    transform: translateX(0);
    transition: transform 3s linear;
}

[data-scroll="rise-up"] {
    transform: translateY(100vh) scale(0.5);
}

[data-scroll="rise-up"].visible {
    transform: translateY(0) scale(1);
    transition: all 2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-scroll="sunrise"] {
    opacity: 0;
    transform: translateY(50px) scale(0.5);
}

[data-scroll="sunrise"].visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: all 1.5s ease-out;
}

/* ===== PARTICLES ===== */
.ember,
.flame,
.ash-particle,
.phoenix-particle {
    position: absolute;
    pointer-events: none;
}

.ember {
    width: 6px;
    height: 6px;
    background: var(--flame-orange);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--ember-glow);
}

.flame {
    width: 40px;
    height: 60px;
    background: linear-gradient(180deg, var(--flame-yellow) 0%, var(--flame-orange) 50%, transparent 100%);
    border-radius: 50% 50% 0 0;
    filter: blur(2px);
}

.ash-particle {
    width: 4px;
    height: 4px;
    background: rgba(200, 200, 200, 0.6);
    border-radius: 50%;
}

.phoenix-particle {
    width: 8px;
    height: 8px;
    background: var(--phoenix-gold);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--phoenix-gold);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .story-content {
        padding: var(--space-2xl) var(--space-lg);
    }

    .text-block.left,
    .text-block.right {
        margin-left: 0;
        margin-right: 0;
    }

    .image-block.left,
    .image-block.right {
        margin-left: 0;
        margin-right: 0;
    }

    .story-text {
        font-size: 1.1rem;
    }

    .story-text.large {
        font-size: 1.3rem;
    }

    .chapter-title {
        font-size: 2rem;
    }

    .story-quote {
        font-size: 1.3rem;
        padding: var(--space-lg);
    }

    .traveler-sprite,
    .phoenix-sprite {
        font-size: 3rem;
    }

    .phoenix-sprite {
        font-size: 5rem;
    }

    .nav-container {
        padding: 0 var(--space-lg);
    }

    .scroll-indicator {
        display: none;
    }
}

@media (max-width: 480px) {
    .story-title {
        font-size: 2.5rem;
    }

    .story-tagline {
        font-size: 1.1rem;
    }

    .chapter-title.epic {
        font-size: 2.5rem;
    }

    .btn-restart {
        padding: var(--space-md) var(--space-xl);
        font-size: 0.9rem;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .scroll-progress,
    .navbar,
    .scroll-hint,
    .btn-restart {
        display: none;
    }

    .story-section {
        page-break-inside: avoid;
    }
}

