/* ============================================================================
   HASHCHAMPIONS - PIXEL ART ANIMATIONS
   Mario/Minecraft/Stardew Valley inspired cozy fantasy vibe
   ============================================================================ */

/* ============================================================================
   1. FLICKERING TORCHES
   Warm glow effect with opacity/brightness variation
   ============================================================================ */

.torch-container {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
    /* Container crops the image - sized to show torch without palette */
    width: 110px;
    height: 150px;
}

.torch-container.top-left {
    top: 20px;
    left: 20px;
}

.torch-container.top-right {
    top: 20px;
    right: 20px;
    transform: scaleX(-1);
}

.torch-container.bottom-left {
    bottom: 20px;
    left: 20px;
}

.torch-container.bottom-right {
    bottom: 20px;
    right: 20px;
    transform: scaleX(-1);
}

.torch-image {
    /* Image is ~256x256 with palette on right ~30% */
    /* Scale up and position to crop out the palette */
    width: 200px;
    height: 200px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    /* Slower flicker for smoother effect */
    animation: torchFlicker 0.8s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(254, 128, 25, 0.6));
    /* Position to show torch, hiding the palette on the right */
    object-fit: none;
    object-position: 15% 25%;
    /* Clip to ensure no palette visible */
    clip-path: inset(0 25% 0 0);
}

@keyframes torchFlicker {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 8px rgba(254, 128, 25, 0.6));
    }
    15% {
        filter: brightness(1.08) drop-shadow(0 0 10px rgba(254, 128, 25, 0.7));
    }
    30% {
        filter: brightness(0.97) drop-shadow(0 0 7px rgba(254, 128, 25, 0.55));
    }
    45% {
        filter: brightness(1.05) drop-shadow(0 0 11px rgba(254, 128, 25, 0.72));
    }
    60% {
        filter: brightness(0.98) drop-shadow(0 0 6px rgba(254, 128, 25, 0.5));
    }
    75% {
        filter: brightness(1.04) drop-shadow(0 0 9px rgba(254, 128, 25, 0.65));
    }
    90% {
        filter: brightness(1.02) drop-shadow(0 0 8px rgba(254, 128, 25, 0.58));
    }
}

/* Torch glow overlay effect */
.torch-glow {
    position: absolute;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(254, 128, 25, 0.3) 0%, rgba(250, 189, 47, 0.1) 40%, transparent 70%);
    animation: glowPulse 2.5s ease-in-out infinite;
    pointer-events: none;
    top: -30px;
    left: -28px;
    will-change: opacity, transform;
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.75;
        transform: scale(1);
    }
    25% {
        opacity: 0.85;
        transform: scale(1.03);
    }
    50% {
        opacity: 0.95;
        transform: scale(1.08);
    }
    75% {
        opacity: 0.85;
        transform: scale(1.04);
    }
}

/* ============================================================================
   2. FLOATING FIGURINES
   Gentle vertical bob animation (Stardew Valley character select style)
   ============================================================================ */

.character-parade {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    margin: var(--space-xl) 0;
    flex-wrap: wrap;
    padding: var(--space-md) 0;
}

.character-preview {
    width: 100px;
    height: 100px;
    border-radius: var(--border-radius);
    border: 3px solid var(--bg2);
    overflow: hidden;
    transition: all var(--transition-fast);
    position: relative;
    background: linear-gradient(135deg, var(--bg1) 0%, var(--bg-soft) 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    will-change: transform;
}

.character-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(250, 189, 47, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.character-preview:nth-child(1) { animation: floatBob 3.5s ease-in-out infinite; animation-delay: 0s; }
.character-preview:nth-child(2) { animation: floatBob 3.8s ease-in-out infinite; animation-delay: 0.3s; }
.character-preview:nth-child(3) { animation: floatBob 3.3s ease-in-out infinite; animation-delay: 0.6s; }
.character-preview:nth-child(4) { animation: floatBob 3.6s ease-in-out infinite; animation-delay: 0.9s; }
.character-preview:nth-child(5) { animation: floatBob 3.4s ease-in-out infinite; animation-delay: 1.2s; }
.character-preview:nth-child(6) { animation: floatBob 3.9s ease-in-out infinite; animation-delay: 1.5s; }
.character-preview:nth-child(7) { animation: floatBob 3.2s ease-in-out infinite; animation-delay: 1.8s; }
.character-preview:nth-child(8) { animation: floatBob 4.0s ease-in-out infinite; animation-delay: 2.1s; }

@keyframes floatBob {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-4px);
    }
    50% {
        transform: translateY(-8px);
    }
    75% {
        transform: translateY(-4px);
    }
}

.character-preview:hover {
    border-color: var(--orange);
    transform: scale(1.15) translateY(-5px) !important;
    box-shadow: 0 8px 24px rgba(254, 128, 25, 0.4);
    z-index: 10;
}

.character-preview:hover::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 2px solid var(--gold);
    border-radius: var(--border-radius);
    animation: selectGlow 0.5s ease-in-out infinite alternate;
}

@keyframes selectGlow {
    0% {
        box-shadow: 0 0 5px var(--gold), inset 0 0 5px transparent;
    }
    100% {
        box-shadow: 0 0 15px var(--gold), inset 0 0 5px rgba(250, 189, 47, 0.2);
    }
}

.character-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ============================================================================
   3. PARALLAX HERO
   Subtle depth movement on scroll/mouse move
   ============================================================================ */

.hero-section {
    position: relative;
    width: 100%;
    height: 65vh;
    min-height: 450px;
    overflow: hidden;
}

.hero-parallax-container {
    position: absolute;
    inset: -20px;
    transition: transform 0.3s ease-out;
    will-change: transform;
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    image-rendering: auto;
    transform: scale(1.1);
}

.hero-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: linear-gradient(to top, var(--bg) 0%, var(--bg) 10%, transparent 100%);
    pointer-events: none;
}

/* Vignette effect */
.hero-section::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(29, 32, 33, 0.4) 100%);
    pointer-events: none;
}

/* ============================================================================
   4. PARTICLE EMBERS (canvas handled in JS, CSS for fallback)
   ============================================================================ */

#ember-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    opacity: 0.8;
}

/* ============================================================================
   5. PULSING CTA BUTTON
   Gentle glow pulse on email signup button
   ============================================================================ */

.btn-primary.btn-glow {
    position: relative;
    animation: buttonPulse 3s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(254, 128, 25, 0.35);
}

@keyframes buttonPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(254, 128, 25, 0.35), 0 0 40px rgba(254, 128, 25, 0.1);
    }
    25% {
        box-shadow: 0 0 24px rgba(254, 128, 25, 0.45), 0 0 48px rgba(254, 128, 25, 0.14);
    }
    50% {
        box-shadow: 0 0 28px rgba(254, 128, 25, 0.55), 0 0 56px rgba(254, 128, 25, 0.18);
    }
    75% {
        box-shadow: 0 0 24px rgba(254, 128, 25, 0.45), 0 0 48px rgba(254, 128, 25, 0.14);
    }
}

.btn-primary.btn-glow:hover {
    animation: none;
    box-shadow: 0 0 40px rgba(254, 128, 25, 0.8), 0 0 80px rgba(254, 128, 25, 0.3);
}

/* ============================================================================
   6. TWINKLING STARS
   Background star twinkle effect
   ============================================================================ */

.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--cream);
    border-radius: 50%;
    animation: twinkle var(--twinkle-duration, 3s) ease-in-out infinite;
    animation-delay: var(--twinkle-delay, 0s);
    opacity: 0.1;
    will-change: opacity, transform;
}

.star.large {
    width: 4px;
    height: 4px;
    background: var(--gold);
}

@keyframes twinkle {
    0%, 100% {
        opacity: 0.1;
        transform: scale(0.8);
    }
    25% {
        opacity: 0.4;
        transform: scale(0.9);
    }
    50% {
        opacity: 0.8;
        transform: scale(1);
    }
    75% {
        opacity: 0.5;
        transform: scale(0.95);
    }
}

/* ============================================================================
   7. SCROLL-TRIGGERED REVEALS
   Fade-in elements as you scroll
   ============================================================================ */

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

.reveal-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}

/* Stagger delays for groups */
.reveal-stagger > *:nth-child(1) { transition-delay: 0s; }
.reveal-stagger > *:nth-child(2) { transition-delay: 0.1s; }
.reveal-stagger > *:nth-child(3) { transition-delay: 0.2s; }
.reveal-stagger > *:nth-child(4) { transition-delay: 0.3s; }
.reveal-stagger > *:nth-child(5) { transition-delay: 0.4s; }
.reveal-stagger > *:nth-child(6) { transition-delay: 0.5s; }
.reveal-stagger > *:nth-child(7) { transition-delay: 0.6s; }
.reveal-stagger > *:nth-child(8) { transition-delay: 0.7s; }

/* ============================================================================
   DIVIDERS
   Ornate section dividers
   ============================================================================ */

.divider-ornate {
    width: 100%;
    max-width: 400px;
    height: auto;
    margin: var(--space-xl) auto;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    opacity: 0.7;
    filter: sepia(20%) brightness(1.1);
}

/* ============================================================================
   EMAIL SIGNUP WITH SCROLL PANEL BACKGROUND
   ============================================================================ */

.signup-section {
    position: relative;
    padding: var(--space-2xl) var(--space-xl);
    margin: var(--space-xl) auto;
    max-width: 500px;
    background-image: url('../assets/images/ui/ui_panel_frame_scroll.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.signup-section::before {
    content: '';
    position: absolute;
    inset: 20px;
    background: rgba(40, 40, 40, 0.85);
    border-radius: var(--border-radius);
    z-index: -1;
}

/* ============================================================================
   LOADING SCREEN ANIMATION
   ============================================================================ */

.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

.page-loader.loaded {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    text-align: center;
}

.loader-icon {
    width: 64px;
    height: 64px;
    animation: loaderBounce 0.6s ease-in-out infinite alternate;
}

@keyframes loaderBounce {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-10px);
    }
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    .torch-container {
        display: none;
    }

    .character-preview {
        width: 70px;
        height: 70px;
    }

    .hero-section {
        height: 50vh;
        min-height: 350px;
    }

    .divider-ornate {
        max-width: 280px;
    }
}

@media (max-width: 480px) {
    .character-preview {
        width: 60px;
        height: 60px;
    }

    .signup-section {
        padding: var(--space-xl) var(--space-md);
    }
}

/* ============================================================================
   REDUCED MOTION
   Respect user preferences
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .torch-image,
    .torch-glow,
    .character-preview,
    .btn-primary.btn-glow,
    .star,
    .loader-icon {
        animation: none !important;
    }

    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .hero-parallax-container {
        transition: none;
    }
}
