/* Design Tokens & Variables */
:root {
    --bg-primary: #070709;
    --bg-secondary: #101016;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --gold: #dfb15b;
    --gold-glow: rgba(223, 177, 91, 0.4);
    --gold-dark: #8c6212;
    --accent-crimson: #ef5350;
    --accent-purple: #7e57c2;
    --accent-purple-glow: rgba(126, 87, 194, 0.4);
    --chat-saveliy: rgba(223, 177, 91, 0.1);
    --chat-anastasia: rgba(239, 83, 80, 0.1);
    --chat-friend: rgba(148, 163, 184, 0.1);
    --border-glass: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(15, 15, 25, 0.6);
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-smooth: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Styles & Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.7;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Ambient glow elements */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.15;
    transition: var(--transition-smooth);
}

.bg-glow-1 {
    top: -10%;
    left: -10%;
    background: radial-gradient(circle, var(--gold) 0%, transparent 70%);
}

.bg-glow-2 {
    bottom: 10%;
    right: -10%;
    background: radial-gradient(circle, var(--accent-crimson) 0%, transparent 70%);
}

body.shattered .bg-glow-1 {
    background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
}

body.shattered .bg-glow-2 {
    background: radial-gradient(circle, #5e35b1 0%, transparent 70%);
}

/* Typography */
h1, h2, h3, .chapter-badge {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

p {
    margin-bottom: 1.5rem;
    font-weight: 300;
    color: var(--text-primary);
}

/* Container */
.story-container {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 24px 100px 24px;
    position: relative;
    z-index: 1;
}

/* Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 0;
    position: relative;
}

.hero-content {
    max-width: 680px;
    animation: fadeInDown 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero-subtitle {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 20px;
    display: block;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #ffffff 30%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.hero-title .and-word {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 400;
    color: var(--gold);
    -webkit-text-fill-color: initial;
}

.hero-desc {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 300;
    margin-bottom: 40px;
}

/* Scroll indicator */
.scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 40px;
}

.arrow-down {
    width: 12px;
    height: 12px;
    border-bottom: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
    transform: rotate(45deg);
    animation: bounce 2s infinite;
}

/* Chapter Styles */
.chapter-section {
    padding: 100px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.chapter-badge {
    font-size: 0.9rem;
    color: var(--gold);
    border: 1px solid var(--gold);
    padding: 4px 16px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 20px;
    letter-spacing: 0.1em;
    background: rgba(223, 177, 91, 0.05);
}

.chapter-heading {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 50px;
    line-height: 1.3;
}

/* Story elements reveal on scroll */
.story-block {
    margin-bottom: 2.5rem;
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1), transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Highlights and visual cues */
.highlight-box {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-left: 4px solid var(--gold);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin: 40px 0;
}

.highlight-box p {
    margin: 0;
    font-style: italic;
}

.text-glow p {
    text-shadow: 0 0 15px rgba(223, 177, 91, 0.2);
}

/* Pulse effects */
.pulse-gold {
    box-shadow: 0 0 20px rgba(223, 177, 91, 0.1);
    animation: goldGlowPulse 4s infinite alternate;
}

/* Floating HUD Egg Status */
.egg-hud {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 100;
    background: rgba(10, 10, 15, 0.75);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 16px 20px;
    width: 280px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: var(--transition-smooth);
}

.egg-hud-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.egg-hud-icon-wrapper {
    flex-shrink: 0;
    transition: transform 0.5s ease;
}

.egg-hud-info {
    flex-grow: 1;
}

.egg-hud-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 2px;
}

.egg-hud-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
    transition: color 0.3s ease;
}

.egg-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.egg-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), #ffb300);
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.egg-hud-hp {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Shattered status styles */
body.shattered .egg-hud {
    border-color: rgba(126, 87, 194, 0.3);
    box-shadow: 0 20px 40px rgba(126, 87, 194, 0.15);
}

body.shattered .egg-progress-fill {
    background: linear-gradient(90deg, var(--accent-purple), #5e35b1);
}

body.shattered #egg-status-val {
    color: #b39ddb;
}

body.shattered #egg-hp-val {
    color: var(--accent-purple);
    font-weight: bold;
}

/* Egg SVG path and sub-element styles */
#egg-path-normal {
    opacity: 1;
    transition: opacity 0.8s ease;
}

#egg-path-broken {
    opacity: 0;
    transition: opacity 0.8s ease;
}

#egg-crack {
    opacity: 0;
    transition: opacity 0.5s ease;
}

#egg-bandaid {
    opacity: 0;
    transition: opacity 0.5s ease 0.3s;
}

body.shattered #egg-path-normal {
    opacity: 0;
}

body.shattered #egg-path-broken {
    opacity: 1;
}

body.shattered #egg-crack {
    opacity: 1;
}

body.shattered #egg-bandaid {
    opacity: 1;
}

/* Egg Shake and Crack animations */
.shake-egg {
    animation: eggHurt 0.15s infinite alternate;
}

.egg-bounce {
    animation: eggBounceAnim 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.egg-pulse-fast, .egg-hud-icon-wrapper.pulse {
    animation: eggPulseFast 0.6s infinite alternate ease-in-out;
}

@keyframes eggPulseFast {
    0% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(223, 177, 91, 0.5)); }
    100% { transform: scale(1.15); filter: drop-shadow(0 0 20px rgba(223, 177, 91, 0.9)); }
}

@keyframes eggBounceAnim {
    0% { transform: scale(1); }
    50% { transform: scale(1.25) rotate(8deg); }
    100% { transform: scale(1); }
}

@keyframes eggHurt {
    0% { transform: translate(2px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(0px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(2px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(2px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

/* Chat bubble styling (Telegram UI Vibe) */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 35px 0;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    max-width: 85%;
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
    border: 1.5px solid;
}

.msg-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.msg-author {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Saveliy Messages style */
.sender-saveliy {
    align-self: flex-start;
}

.sender-saveliy .msg-avatar {
    background: rgba(223, 177, 91, 0.1);
    color: var(--gold);
    border-color: var(--gold);
}

.sender-saveliy .msg-bubble {
    background: var(--chat-saveliy);
    border: 1px solid rgba(223, 177, 91, 0.2);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.sender-saveliy .msg-author {
    color: var(--gold);
}

/* Anastasia Messages style */
.sender-anastasia {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.sender-anastasia .msg-avatar {
    background: rgba(239, 83, 80, 0.1);
    color: #ff8a80;
    border-color: #ff8a80;
}

.sender-anastasia .msg-bubble {
    background: var(--chat-anastasia);
    border: 1px solid rgba(239, 83, 80, 0.25);
    border-bottom-right-radius: 4px;
    color: var(--text-primary);
}

.sender-anastasia .msg-author {
    color: #ff8a80;
}

/* Friends Chat Messages style */
.sender-friend {
    align-self: flex-start;
}
.sender-friend .msg-avatar {
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
    border-color: #cbd5e1;
}
.sender-friend .msg-bubble {
    background: var(--chat-friend);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-bottom-left-radius: 4px;
}
.sender-friend .msg-author { color: #94a3b8; }

.sender-friend2 {
    align-self: flex-start;
}
.sender-friend2 .msg-avatar {
    background: rgba(126, 87, 194, 0.1);
    color: #b39ddb;
    border-color: #b39ddb;
}
.sender-friend2 .msg-bubble {
    background: rgba(126, 87, 194, 0.08);
    border: 1px solid rgba(126, 87, 194, 0.15);
    border-bottom-left-radius: 4px;
}
.sender-friend2 .msg-author { color: #b39ddb; }

/* Inline dialogues in narrative blocks */
.inline-chat {
    margin: 15px 0 0 0;
    max-width: 100%;
}
.inline-chat .message {
    max-width: 100%;
}

.narrative-span {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.95em;
}

/* Image blocks & Media styling */
.media-block {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin: 60px 0;
}

.media-block.reverse {
    flex-direction: column;
}

.image-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.image-wrapper:hover {
    transform: scale(1.02);
    border-color: rgba(223, 177, 91, 0.3);
}

.story-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: filter 0.5s ease;
}

.image-wrapper:hover .story-img {
    filter: brightness(1.05);
}

.image-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    padding: 20px 20px 10px 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 400;
}

/* Special Chapters: Climax & Disaster */
.pulse-gold {
    border: 1px solid rgba(223, 177, 91, 0.3);
}

.disaster-block {
    border: 2px solid rgba(239, 83, 80, 0.3);
    background: rgba(239, 83, 80, 0.05);
    padding: 30px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.disaster-block::before {
    content: "🥚 💥";
    position: absolute;
    right: 20px;
    bottom: 10px;
    font-size: 3rem;
    opacity: 0.15;
}

.final-chapter {
    border-bottom: none;
}

.alert-badge {
    color: var(--accent-crimson);
    border-color: var(--accent-crimson);
    background: rgba(239, 83, 80, 0.05);
}

.alert-heading {
    text-shadow: 0 0 20px rgba(239, 83, 80, 0.3);
}

.shatter-text {
    font-weight: bold;
    font-size: 1.05rem;
    color: #fff;
    text-shadow: 0 0 10px rgba(239, 83, 80, 0.2);
}

.purple-egg-box {
    border-left-color: var(--accent-purple) !important;
    background: rgba(126, 87, 194, 0.05);
    box-shadow: 0 10px 30px rgba(126, 87, 194, 0.1);
}

.chat-friends {
    background: rgba(15, 15, 25, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 25px;
    margin: 40px 0;
}

.chat-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    margin-bottom: 15px;
    display: inline-block;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 4px;
}

/* Outro and Credits */
.outro-credits {
    text-align: center;
    margin-top: 80px;
    padding: 50px 0;
    border-top: 1px dashed var(--border-glass);
}

.outro-credits h3 {
    font-size: 1.8rem;
    color: var(--gold);
    margin-bottom: 15px;
}

.outro-credits p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 30px;
}

.restart-btn {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    border: none;
    color: #070709;
    padding: 12px 30px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 10px 20px rgba(223, 177, 91, 0.25);
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(223, 177, 91, 0.4);
}

/* Lightbox Modal */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    padding-top: 80px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(6, 6, 8, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
    animation: zoom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: var(--text-secondary);
    padding: 20px 0;
    font-size: 0.9rem;
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 40px;
    color: #fff;
    font-size: 40px;
    font-weight: 300;
    transition: 0.3s;
    cursor: pointer;
}

.lightbox-close:hover {
    color: var(--gold);
}

/* Right Navigation Dots */
.chapter-nav {
    position: fixed;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 90;
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    transition: var(--transition-smooth);
    position: relative;
}

.nav-dot:hover, .nav-dot.active {
    background: var(--gold);
    transform: scale(1.4);
}

.nav-dot::before {
    content: attr(data-tooltip);
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background: rgba(10,10,15,0.85);
    border: 1px solid var(--border-glass);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.nav-dot:hover::before {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Screen Shake Effect */
.shake-screen {
    animation: screenShakeAnim 0.4s ease-in-out;
}

@keyframes screenShakeAnim {
    0% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-8px, -5px) rotate(-1deg); }
    20% { transform: translate(10px, 8px) rotate(1deg); }
    30% { transform: translate(-12px, -3px) rotate(-0.5deg); }
    40% { transform: translate(12px, 8px) rotate(1deg); }
    50% { transform: translate(-10px, -5px) rotate(-1deg); }
    60% { transform: translate(8px, 6px) rotate(0.5deg); }
    70% { transform: translate(-5px, -3px) rotate(-0.5deg); }
    80% { transform: translate(5px, 3px) rotate(0deg); }
    90% { transform: translate(-2px, -1px) rotate(0deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* Keyframes animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0) rotate(45deg);
    }
    40% {
        transform: translateY(-10px) rotate(45deg);
    }
    60% {
        transform: translateY(-5px) rotate(45deg);
    }
}

@keyframes goldGlowPulse {
    from {
        box-shadow: 0 0 15px rgba(223, 177, 91, 0.1);
        border-color: rgba(223, 177, 91, 0.2);
    }
    to {
        box-shadow: 0 0 30px rgba(223, 177, 91, 0.3);
        border-color: rgba(223, 177, 91, 0.5);
    }
}

@keyframes zoom {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .egg-hud {
        top: auto;
        bottom: 20px;
        right: 20px;
        width: calc(100% - 40px);
        max-width: 320px;
    }
    .chapter-nav {
        display: none; /* Hide timeline navigation on mobile for cleaner screen space */
    }
}

@media (max-width: 768px) {
    html {
        font-size: 16px;
    }
    .hero-title {
        font-size: 2.3rem;
    }
    .chapter-heading {
        font-size: 1.6rem;
    }
    .message {
        max-width: 92%;
    }
    .story-container {
        padding-bottom: 120px; /* Space for bottom egg-hud on mobile */
    }
    .image-caption {
        font-size: 0.75rem;
        padding: 10px;
    }
}
