/* ========================================
   CHRISTMAS LOADING SCREEN
   Beautiful animated Christmas tree loader
   Original SVG design by Angela Velasquez
   ======================================== */

/* ========================================
   CSS CUSTOM PROPERTIES
   ======================================== */
:root {
    /* Christmas Tree Colors */
    --xmas-tree-green: #42CE8E;
    --xmas-tree-shadow: #09B56B;
    --xmas-light-gold: #FFDF9F;
    --xmas-gift-pink: #DD4E85;
    --xmas-gift-red: #D10F50;
    --xmas-dark-blue: #39445B;
    --xmas-bg-dark: #0a0a1a;

    /* Animation Timings */
    --xmas-light-duration: 2s;
    --xmas-star-duration: 3s;
    --xmas-cat-delay: 2.5s;
}

/* ========================================
   LOADING SCREEN CONTAINER
   ======================================== */
.christmas-loading-screen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg,
        #0a0a1a 0%,
        #0f172a 30%,
        #1e293b 60%,
        #1a1a2e 100%
    );
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
    overflow: hidden;
}

.christmas-loading-screen.active {
    opacity: 1;
    visibility: visible;
}

.christmas-loading-screen.fade-out {
    opacity: 0;
    transition: opacity 1.2s ease-in-out;
}

/* ========================================
   AURORA BACKGROUND (behind tree)
   ======================================== */
.xmas-loading-aurora {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    overflow: hidden;
    opacity: 0.4;
    pointer-events: none;
}

.xmas-aurora-wave {
    position: absolute;
    width: 200%;
    height: 100%;
    will-change: transform;
}

.xmas-aurora-wave-1 {
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(0, 255, 135, 0.12) 30%,
        rgba(96, 239, 255, 0.15) 50%,
        transparent 70%
    );
    animation: xmasAuroraMove1 25s ease-in-out infinite;
}

.xmas-aurora-wave-2 {
    background: linear-gradient(180deg,
        transparent 10%,
        rgba(124, 58, 237, 0.1) 40%,
        rgba(0, 255, 135, 0.12) 60%,
        transparent 80%
    );
    animation: xmasAuroraMove2 30s ease-in-out infinite;
    animation-delay: -10s;
}

@keyframes xmasAuroraMove1 {
    0%, 100% { transform: translateX(-25%) scaleY(1); }
    50% { transform: translateX(0%) scaleY(1.1); }
}

@keyframes xmasAuroraMove2 {
    0%, 100% { transform: translateX(0%) scaleY(0.9); }
    50% { transform: translateX(-20%) scaleY(1.05); }
}

/* ========================================
   STARS BACKGROUND
   ======================================== */
.xmas-loading-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.xmas-star-layer {
    position: absolute;
    width: 2px;
    height: 2px;
    background: transparent;
    animation: xmasStarsTwinkle 4s ease-in-out infinite;
}

.xmas-star-layer-1 {
    box-shadow:
        50px 30px 0 1px rgba(255,255,255,0.8),
        150px 80px 0 1px rgba(255,255,255,0.6),
        280px 45px 0 1px rgba(255,255,255,0.7),
        400px 120px 0 1px rgba(255,255,255,0.5),
        520px 60px 0 1px rgba(255,255,255,0.8),
        80px 180px 0 1px rgba(255,255,255,0.6),
        200px 200px 0 1px rgba(255,255,255,0.7),
        350px 160px 0 1px rgba(255,255,255,0.5),
        480px 190px 0 1px rgba(255,255,255,0.8),
        600px 140px 0 1px rgba(255,255,255,0.6),
        100px 250px 0 1px rgba(255,255,255,0.7),
        250px 280px 0 1px rgba(255,255,255,0.5),
        420px 240px 0 1px rgba(255,255,255,0.8),
        550px 270px 0 1px rgba(255,255,255,0.6),
        700px 220px 0 1px rgba(255,255,255,0.7);
}

.xmas-star-layer-2 {
    box-shadow:
        120px 50px 0 1px rgba(255,255,255,0.5),
        220px 100px 0 2px rgba(255,255,255,0.7),
        340px 70px 0 1px rgba(255,255,255,0.6),
        460px 140px 0 1px rgba(255,255,255,0.8),
        40px 120px 0 2px rgba(255,255,255,0.5),
        180px 160px 0 1px rgba(255,255,255,0.7),
        300px 130px 0 1px rgba(255,255,255,0.6),
        440px 180px 0 2px rgba(255,255,255,0.8),
        580px 100px 0 1px rgba(255,255,255,0.5),
        650px 170px 0 1px rgba(255,255,255,0.7);
    animation-delay: -2s;
    animation-duration: 5s;
}

@keyframes xmasStarsTwinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ========================================
   SNOW PARTICLES (CSS only, light)
   ======================================== */
.xmas-loading-snow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.xmas-snowflake {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, rgba(255,248,231,0.9) 0%, transparent 70%);
    border-radius: 50%;
    animation: xmasSnowFall linear infinite;
    opacity: 0;
}

/* Generate 20 snowflakes with different positions and timings */
.xmas-snowflake:nth-child(1) { left: 5%; animation-duration: 8s; animation-delay: 0s; }
.xmas-snowflake:nth-child(2) { left: 10%; animation-duration: 10s; animation-delay: -2s; }
.xmas-snowflake:nth-child(3) { left: 15%; animation-duration: 7s; animation-delay: -4s; }
.xmas-snowflake:nth-child(4) { left: 20%; animation-duration: 9s; animation-delay: -1s; }
.xmas-snowflake:nth-child(5) { left: 25%; animation-duration: 11s; animation-delay: -3s; }
.xmas-snowflake:nth-child(6) { left: 30%; animation-duration: 8s; animation-delay: -5s; }
.xmas-snowflake:nth-child(7) { left: 35%; animation-duration: 10s; animation-delay: -2s; }
.xmas-snowflake:nth-child(8) { left: 40%; animation-duration: 7s; animation-delay: -4s; }
.xmas-snowflake:nth-child(9) { left: 45%; animation-duration: 9s; animation-delay: -1s; }
.xmas-snowflake:nth-child(10) { left: 50%; animation-duration: 11s; animation-delay: -3s; }
.xmas-snowflake:nth-child(11) { left: 55%; animation-duration: 8s; animation-delay: -5s; }
.xmas-snowflake:nth-child(12) { left: 60%; animation-duration: 10s; animation-delay: -2s; }
.xmas-snowflake:nth-child(13) { left: 65%; animation-duration: 7s; animation-delay: -4s; }
.xmas-snowflake:nth-child(14) { left: 70%; animation-duration: 9s; animation-delay: -1s; }
.xmas-snowflake:nth-child(15) { left: 75%; animation-duration: 11s; animation-delay: -3s; }
.xmas-snowflake:nth-child(16) { left: 80%; animation-duration: 8s; animation-delay: -5s; }
.xmas-snowflake:nth-child(17) { left: 85%; animation-duration: 10s; animation-delay: -2s; }
.xmas-snowflake:nth-child(18) { left: 90%; animation-duration: 7s; animation-delay: -4s; }
.xmas-snowflake:nth-child(19) { left: 95%; animation-duration: 9s; animation-delay: -1s; }
.xmas-snowflake:nth-child(20) { left: 3%; animation-duration: 11s; animation-delay: -6s; }

@keyframes xmasSnowFall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ========================================
   TREE CONTAINER
   ======================================== */
.xmas-tree-container {
    position: relative;
    width: 90%;
    max-width: 400px;
    margin-bottom: 20px;
    z-index: 10;
}

.xmas-tree-svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 30px rgba(0,0,0,0.5));
}

/* ========================================
   TREE ENTRANCE ANIMATION
   ======================================== */
.xmas-tree-svg {
    animation: xmasTreeEntrance 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes xmasTreeEntrance {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(50px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ========================================
   LIGHT GLOW ANIMATIONS
   Each light has 2 shadow layers for realistic glow
   ======================================== */

/* Shadow Layer 2 (outer glow) - slower, bigger */
.xmas-tree-svg .shadow-2 {
    animation: xmasLightGlow2 var(--xmas-light-duration) ease-in-out infinite;
}

/* Shadow Layer 1 (inner glow) - faster, smaller */
.xmas-tree-svg .shadow-1 {
    animation: xmasLightGlow1 var(--xmas-light-duration) ease-in-out infinite;
}

/* Different delays for each row of lights for wave effect */
/* Row 1 - Top (1 light) */
#l1-r1-s2, #l1-r1-s1, #l1-r1 { animation-delay: 0s; }

/* Row 2 (3 lights) */
#l1-r2-s2, #l1-r2-s1, #l1-r2 { animation-delay: 0.2s; }
#l2-r2-s2, #l2-r2-s1, #l2-r2 { animation-delay: 0.4s; }
#l3-r2-s2, #l3-r2-s1, #l3-r2 { animation-delay: 0.3s; }

/* Row 3 (3 lights) */
#l1-r3-s2, #l1-r3-s1, #l1-r3 { animation-delay: 0.5s; }
#l2-r3-s2, #l2-r3-s1, #l2-r3 { animation-delay: 0.1s; }
#l3-r3-s2, #l3-r3-s1, #l3-r3 { animation-delay: 0.6s; }

/* Row 4 - Bottom (5 lights) */
#l1-r4-s2, #l1-r4-s1, #l1-r4 { animation-delay: 0.3s; }
#l2-r4-s2, #l2-r4-s1, #l2-r4 { animation-delay: 0.7s; }
#l3-r4-s2, #l3-r4-s1, #l3-r4 { animation-delay: 0.2s; }
#l4-r4-s2, #l4-r4-s1, #l4-r4 { animation-delay: 0.5s; }
#l5-r4-s2, #l5-r4-s1, #l5-r4 { animation-delay: 0.4s; }

@keyframes xmasLightGlow2 {
    0%, 100% {
        opacity: 0.2;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

@keyframes xmasLightGlow1 {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

/* Light bulbs themselves - subtle pulse */
.xmas-tree-svg [id^="l"][id$="-r1"]:not([id*="-s"]),
.xmas-tree-svg [id^="l"][id$="-r2"]:not([id*="-s"]),
.xmas-tree-svg [id^="l"][id$="-r3"]:not([id*="-s"]),
.xmas-tree-svg [id^="l"][id$="-r4"]:not([id*="-s"]) {
    animation: xmasLightBulb var(--xmas-light-duration) ease-in-out infinite;
}

@keyframes xmasLightBulb {
    0%, 100% {
        opacity: 0.8;
        filter: brightness(1);
    }
    50% {
        opacity: 1;
        filter: brightness(1.3);
    }
}

/* ========================================
   STAR ANIMATION (top of tree)
   ======================================== */
#star {
    animation: xmasStarPulse var(--xmas-star-duration) ease-in-out infinite;
    transform-origin: center center;
}

#star-s1 {
    animation: xmasStarGlow1 var(--xmas-star-duration) ease-in-out infinite;
}

#star-s2 {
    animation: xmasStarGlow2 var(--xmas-star-duration) ease-in-out infinite;
}

@keyframes xmasStarPulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        filter: brightness(1);
    }
    25% {
        transform: scale(1.05) rotate(2deg);
    }
    50% {
        transform: scale(1.1) rotate(0deg);
        filter: brightness(1.4);
    }
    75% {
        transform: scale(1.05) rotate(-2deg);
    }
}

@keyframes xmasStarGlow1 {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.15);
    }
}

@keyframes xmasStarGlow2 {
    0%, 100% {
        opacity: 0.15;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(1.25);
    }
}

/* Star rays - additional sparkle effect */
#star::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    background: radial-gradient(circle, rgba(255,223,159,0.4) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    animation: xmasStarRays 2s ease-in-out infinite;
}

@keyframes xmasStarRays {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); }
}

/* ========================================
   CAT ANIMATION
   ======================================== */
#cat {
    opacity: 0;
    transform: translateY(60px);
    animation: xmasCatAppear 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: var(--xmas-cat-delay);
}

@keyframes xmasCatAppear {
    0% {
        opacity: 0;
        transform: translateY(60px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cat eyes blink */
#cat-eye-left, #cat-eye-right,
#cat-eye-left-pupil, #cat-eye-right-pupil {
    animation: xmasCatBlink 4s ease-in-out infinite;
    animation-delay: calc(var(--xmas-cat-delay) + 1s);
}

@keyframes xmasCatBlink {
    0%, 45%, 55%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(0.1);
    }
}

/* Cat whiskers wiggle */
#cat-line-left-up, #cat-line-left-down,
#cat-line-right-up, #cat-line-right-down {
    animation: xmasCatWhiskers 3s ease-in-out infinite;
    animation-delay: calc(var(--xmas-cat-delay) + 0.5s);
    transform-origin: center;
}

#cat-line-right-up, #cat-line-right-down {
    animation-delay: calc(var(--xmas-cat-delay) + 0.7s);
}

@keyframes xmasCatWhiskers {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(2deg); }
    75% { transform: rotate(-2deg); }
}

/* ========================================
   GIFTS ANIMATION
   ======================================== */
#gift-yellow, #gift-red {
    animation: xmasGiftBounce 3s ease-in-out infinite;
}

#gift-red {
    animation-delay: 0.5s;
}

@keyframes xmasGiftBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Gift bows sparkle */
#gift-yellow-bow, #gift-red-bow {
    animation: xmasGiftBowSparkle 2s ease-in-out infinite;
}

#gift-red-bow {
    animation-delay: 0.3s;
}

@keyframes xmasGiftBowSparkle {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

/* ========================================
   TITLE AND TEXT
   ======================================== */
.xmas-loading-title {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 700;
    color: var(--xmas-light-gold);
    text-align: center;
    margin: 0;
    text-shadow:
        0 0 10px rgba(255, 223, 159, 0.5),
        0 0 20px rgba(255, 223, 159, 0.3),
        0 0 40px rgba(255, 223, 159, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.15em;
    animation: xmasTitleGlow 3s ease-in-out infinite, xmasTitleEntrance 1s ease-out forwards;
    animation-delay: 0.5s, 0s;
    opacity: 0;
    z-index: 10;
}

@keyframes xmasTitleEntrance {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes xmasTitleGlow {
    0%, 100% {
        text-shadow:
            0 0 10px rgba(255, 223, 159, 0.5),
            0 0 20px rgba(255, 223, 159, 0.3),
            0 0 40px rgba(255, 223, 159, 0.2),
            0 2px 4px rgba(0, 0, 0, 0.5);
    }
    50% {
        text-shadow:
            0 0 15px rgba(255, 223, 159, 0.7),
            0 0 30px rgba(255, 223, 159, 0.5),
            0 0 60px rgba(255, 223, 159, 0.3),
            0 2px 4px rgba(0, 0, 0, 0.5);
    }
}

/* ========================================
   LOADING TEXT WITH ANIMATED DOTS
   ======================================== */
.xmas-loading-text {
    font-family: 'Inter', sans-serif;
    font-size: clamp(1rem, 4vw, 1.25rem);
    color: rgba(255, 223, 159, 0.7);
    text-align: center;
    margin-top: 15px;
    letter-spacing: 0.1em;
    animation: xmasLoadingTextEntrance 1s ease-out forwards;
    animation-delay: 0.8s;
    opacity: 0;
    z-index: 10;
}

@keyframes xmasLoadingTextEntrance {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.xmas-loading-dots {
    display: inline-block;
    min-width: 24px;
    text-align: left;
}

.xmas-loading-dots::after {
    content: '';
    animation: xmasLoadingDots 1.5s steps(4, end) infinite;
}

@keyframes xmasLoadingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

/* ========================================
   PROGRESS BAR (subtle)
   ======================================== */
.xmas-loading-progress {
    width: 200px;
    max-width: 60%;
    height: 3px;
    background: rgba(255, 223, 159, 0.1);
    border-radius: 3px;
    margin-top: 20px;
    overflow: hidden;
    animation: xmasProgressEntrance 1s ease-out forwards;
    animation-delay: 1s;
    opacity: 0;
    z-index: 10;
}

@keyframes xmasProgressEntrance {
    0% {
        opacity: 0;
        transform: scaleX(0.5);
    }
    100% {
        opacity: 1;
        transform: scaleX(1);
    }
}

.xmas-loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg,
        var(--xmas-light-gold) 0%,
        #FFE4B5 50%,
        var(--xmas-light-gold) 100%
    );
    background-size: 200% 100%;
    border-radius: 3px;
    animation: xmasProgressShimmer 2s linear infinite;
    width: 30%;
    transition: width 0.3s ease-out;
}

@keyframes xmasProgressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   ATTRIBUTION (small, subtle)
   ======================================== */
.xmas-loading-attribution {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.2);
    text-align: center;
    z-index: 10;
}

.xmas-loading-attribution a {
    color: rgba(255, 223, 159, 0.3);
    text-decoration: none;
}

.xmas-loading-attribution a:hover {
    color: rgba(255, 223, 159, 0.6);
}

/* ========================================
   PINE TREES SILHOUETTE (bottom)
   ======================================== */
.xmas-loading-pines {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 12vh;
    background: #050508;
    clip-path: polygon(
        0% 100%,
        0% 70%,
        3% 45%, 6% 75%,
        9% 35%, 12% 70%,
        14% 50%, 17% 78%,
        20% 25%, 24% 72%,
        27% 40%, 30% 75%,
        33% 55%, 36% 80%,
        39% 30%, 43% 73%,
        46% 48%, 49% 78%,
        52% 38%, 56% 75%,
        59% 55%, 62% 80%,
        65% 28%, 69% 72%,
        72% 45%, 75% 78%,
        78% 35%, 82% 74%,
        85% 52%, 88% 80%,
        91% 40%, 94% 75%,
        97% 60%, 100% 78%,
        100% 100%
    );
    z-index: 5;
}

/* ========================================
   GROUND GLOW
   ======================================== */
.xmas-loading-ground-glow {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 25vh;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(150, 200, 255, 0.03) 60%,
        rgba(150, 200, 255, 0.06) 100%
    );
    pointer-events: none;
    z-index: 4;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */
@media (max-width: 480px) {
    .xmas-tree-container {
        width: 85%;
        max-width: 300px;
    }

    .xmas-loading-title {
        letter-spacing: 0.1em;
    }

    /* Reduce snowflakes on mobile */
    .xmas-snowflake:nth-child(n+12) {
        display: none;
    }

    /* Simpler aurora on mobile */
    .xmas-aurora-wave-2 {
        display: none;
    }

    /* Slower animations for performance */
    :root {
        --xmas-light-duration: 2.5s;
        --xmas-star-duration: 4s;
    }

    .xmas-loading-pines {
        height: 10vh;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .xmas-tree-container {
        width: 80%;
        max-width: 250px;
    }

    .xmas-loading-progress {
        width: 150px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .xmas-tree-container {
        max-width: 200px;
        margin-bottom: 10px;
    }

    .xmas-loading-title {
        font-size: 1.5rem;
    }

    .xmas-loading-text {
        font-size: 0.9rem;
        margin-top: 5px;
    }

    .xmas-loading-progress {
        margin-top: 10px;
    }

    .xmas-loading-pines,
    .xmas-loading-ground-glow {
        display: none;
    }
}

/* ========================================
   REDUCED MOTION PREFERENCE
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .xmas-tree-svg,
    .xmas-loading-title,
    .xmas-loading-text,
    .xmas-loading-progress,
    #cat,
    .xmas-snowflake,
    .xmas-aurora-wave,
    .xmas-star-layer {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .xmas-tree-svg .shadow-1,
    .xmas-tree-svg .shadow-2 {
        animation: none !important;
        opacity: 0.5 !important;
    }

    #star, #star-s1, #star-s2 {
        animation: none !important;
    }

    .xmas-loading-dots::after {
        content: '...';
        animation: none;
    }

    .xmas-loading-progress-bar {
        animation: none;
        width: 100%;
    }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */
@media (prefers-contrast: high) {
    .christmas-loading-screen {
        background: #000;
    }

    .xmas-loading-title {
        color: #fff;
        text-shadow: none;
    }

    .xmas-loading-text {
        color: rgba(255, 255, 255, 0.9);
    }
}

/* ========================================
   PRINT (hide loading screen)
   ======================================== */
@media print {
    .christmas-loading-screen {
        display: none !important;
    }
}
