/* ============================================================================
   Trilha da Coroa — efeitos da marca (estrelinhas, poeira de fada, partículas em canvas, herói flutuante com
   balões de fala e coleta de estrelas com prêmio). Construídos pela mentora ao longo de meses e PRESERVADOS na
   versão editorial de 2026-11: ficam nas seções escuras, abaixo do conteúdo (z-index), e são desligados por
   completo com prefers-reduced-motion. Scripts em wwwroot/effects/ (entrada: effectsInit.js).
   ============================================================================ */

/* Sparkles animation layer */
.tdc-sparkles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

    .tdc-sparkles::before,
    .tdc-sparkles::after {
        content: "";
        position: absolute;
        width: 4px;
        height: 4px;
        background: white;
        border-radius: 50%;
        box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.9), 0 0 20px 4px rgba(135, 185, 235, 0.5);
        animation: tdc-sparkle-float 8s ease-in-out infinite;
        pointer-events: none;
    }

    .tdc-sparkles::before {
        top: 15%;
        right: 20%;
        animation-delay: 0s;
    }

    .tdc-sparkles::after {
        bottom: 30%;
        left: 15%;
        animation-delay: 4s;
    }

@keyframes tdc-sparkle-float {
    0%, 100% {
        opacity: 0.3;
        transform: translateY(0) scale(1);
    }

    25% {
        opacity: 1;
        transform: translateY(-10px) scale(1.5);
    }

    50% {
        opacity: 0.5;
        transform: translateY(-5px) scale(1.2);
    }

    75% {
        opacity: 0.8;
        transform: translateY(-15px) scale(1.3);
    }
}

/* Magical floating animation */
.tdc-float {
    animation: tdc-float-gentle 6s ease-in-out infinite;
}

@keyframes tdc-float-gentle {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

/* Fairy tale stars decoration - golden 4-pointed stars */
.tdc-fairy-stars {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 3;
}

.tdc-fairy-star {
    position: absolute;
    width: 20px;
    height: 20px;
    animation: tdc-star-twinkle 4s ease-in-out infinite;
    animation-fill-mode: backwards;
    pointer-events: none;
}

    /* Duas barras cruzadas formam a estrela de 4 pontas. (A declaração antiga "content: "", position: absolute;"
       era inválida e as estrelas nunca apareciam; corrigido em 2026-11.) */
    .tdc-fairy-star::before,
    .tdc-fairy-star::after {
        content: "";
        position: absolute;
        background: linear-gradient(180deg, rgba(255, 215, 0, 1) 0%, rgba(255, 235, 160, 0.8) 50%, rgba(218, 165, 32, 0.3) 100%);
        border-radius: 50%;
        pointer-events: none;
    }

    .tdc-fairy-star::before {
        width: 2px;
        height: 100%;
        left: 50%;
        top: 0;
        transform: translateX(-50%);
    }

    .tdc-fairy-star::after {
        height: 2px;
        width: 100%;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
    }

/* Lapis lazuli variant */
.tdc-fairy-star--lapis::before,
.tdc-fairy-star--lapis::after {
    background: linear-gradient(180deg, rgba(135, 185, 235, 1) 0%, rgba(180, 210, 245, 0.8) 50%, rgba(65, 135, 206, 0.3) 100%);
}

.tdc-fairy-star--sm {
    width: 12px;
    height: 12px;
}

.tdc-fairy-star--lg {
    width: 28px;
    height: 28px;
}

    .tdc-fairy-star--lg::before {
        width: 4px;
    }

    .tdc-fairy-star--lg::after {
        height: 4px;
    }

@keyframes tdc-star-twinkle {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    25% {
        opacity: 0.4;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    75% {
        opacity: 0.9;
        transform: scale(1.05);
    }

    100% {
        opacity: 0.4;
        transform: scale(1);
    }
}

/* White glow star effect - with lapis and gold accents */
.tdc-glow-star {
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.9), 0 0 16px 5px rgba(135, 185, 235, 0.5), 0 0 24px 8px rgba(90, 159, 224, 0.2);
    animation: tdc-glow-pulse 3s ease-in-out infinite;
    animation-fill-mode: backwards;
    pointer-events: none;
}

/* Vibrant Yellow Gold variant */
.tdc-glow-star--gold {
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.95), 0 0 16px 5px rgba(255, 223, 0, 0.6), 0 0 26px 8px rgba(255, 215, 0, 0.3);
}

.tdc-glow-star--sm {
    width: 4px;
    height: 4px;
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.8), 0 0 15px 4px rgba(135, 185, 235, 0.4);
}

/* Small gold variant */
.tdc-glow-star--gold.tdc-glow-star--sm {
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.9), 0 0 15px 4px rgba(255,223, 0, 0.6);
}

.tdc-glow-star--lg {
    width: 8px;
    height: 8px;
    box-shadow: 0 0 10px 3px rgba(255, 255, 255, 1), 0 0 20px 6px rgba(135, 185, 235, 0.6), 0 0 30px 10px rgba(90, 159, 224, 0.25);
}

/* Large gold variant */
.tdc-glow-star--gold.tdc-glow-star--lg {
    box-shadow: 0 0 10px 3px rgba(255, 255, 255, 1), 0 0 20px 6px rgba(255, 223, 0, 0.6), 0 0 32px 10px rgba(255, 215, 0, 0.3);
}

@keyframes tdc-glow-pulse {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    25%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }

    62% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Remove old golden trail - now using shooting stars in JS */
.tdc-golden-trail {
    display: none;
}

/* Extra floating particles via CSS for more density */
.tdc-fairy-dust {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

.tdc-fairy-dust-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    animation: tdc-dust-float 12s ease-in-out infinite;
    pointer-events: none;
}

/* Vibrant Yellow Gold particle */
.tdc-fairy-dust-particle--gold {
    background: linear-gradient(135deg, #FFDF00, #FFD700);
    box-shadow: 0 0 10px 3px rgba(255, 223, 0, 0.7);
}

/* Lapis Lazuli particle */
.tdc-fairy-dust-particle--lapis {
    background: linear-gradient(135deg, #87B9EB, #4187CE);
    box-shadow: 0 0 8px 2px rgba(65, 135, 206, 0.5);
}

/* White/neutral particle */
.tdc-fairy-dust-particle--white {
    background: white;
    box-shadow: 0 0 8px 3px rgba(255, 255, 255, 0.8);
}

@keyframes tdc-dust-float {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.5);
    }

    15% {
        opacity: 0.8;
    }

    50% {
        opacity: 0.6;
        transform: translateY(-30px) scale(1);
    }

    85% {
        opacity: 0.4;
    }

    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.3);
    }
}

/* Hero floating mini image wobble animation */
@keyframes heroFloatWobble {
    0%, 100% {
        transform: scale(1) translateY(0) rotate(0deg);
    }
    25% {
        transform: scale(1) translateY(-8px) rotate(1.5deg);
    }
    50% {
        transform: scale(1.02) translateY(-3px) rotate(-1deg);
    }
    75% {
        transform: scale(1) translateY(-10px) rotate(0.5deg);
    }
}

/* Dramatic entrance glow pulse */
@keyframes heroFloatGlowPulse {
    0%, 100% {
        filter: drop-shadow(0 10px 30px rgba(255, 210, 80, 0.4))
                drop-shadow(0 4px 15px rgba(0, 0, 0, 0.5));
    }
    50% {
        filter: drop-shadow(0 15px 40px rgba(255, 210, 80, 0.6))
                drop-shadow(0 8px 25px rgba(0, 0, 0, 0.4))
                drop-shadow(0 0 20px rgba(255, 210, 80, 0.3));
    }
}

/* ===================================
   Hero Floating Image Effect
   =================================== */

/* Main hero image transition for scroll effect */
#hero-image-container #hero-oval-image,
#hero-image-container canvas {
    will-change: opacity, transform;
    transform-origin: center bottom;
}

/* Floating hero mini image container */
#hero-floating-container {
    will-change: opacity, transform;
    transform-origin: center center;
}

/* Glow effect inside floating container */
#hero-floating-container .relative > div:first-child {
    transition: opacity 0.3s ease-out;
}

/* Image/canvas inside floating container */
#hero-floating-container img,
#hero-floating-container canvas {
    animation: heroFloatGlowPulse 3s ease-in-out infinite;
    animation-play-state: paused;
}

/* Activate glow pulse when container is visible */
#hero-floating-container[style*="opacity: 1"] img,
#hero-floating-container[style*="opacity: 1"] canvas,
#hero-floating-container[style*="opacity:1"] img,
#hero-floating-container[style*="opacity:1"] canvas {
    animation-play-state: running;
}

/* ===================================
   Mini Hero Collected Stars Container
   =================================== */

.tdc-mini-hero-sparkles {
    position: absolute;
    inset: -15px;
    pointer-events: none;
    z-index: 5;
    /* Removed rotation animation - stars are now dynamically positioned */
}

/* Legacy sparkle styles removed - now using dynamic collected stars */
/* The .mini-hero-collected-star class is styled via JavaScript in starCollector.js */

/* Mobile adjustments for floating image */
@media (max-width: 768px) {
    #hero-floating-container {
        bottom: 1rem;
        right: 1rem;
    }
    
    #hero-floating-container img,
    #hero-floating-container canvas {
        width: 100px;
        max-height: 140px;
    }
    
    .tdc-mini-sparkle {
        --radius: 60px;
        width: 4px;
        height: 4px;
    }
    
    .tdc-mini-hero-sparkles {
        inset: -15px;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    #hero-floating-container,
    #hero-image-container #hero-oval-image,
    #hero-image-container canvas {
        transition: none !important;
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
    
    #hero-floating-container {
        display: none !important;
    }
    
    .tdc-mini-sparkle {
        animation: none !important;
    }
    
    .hero-speech-bubble {
        display: none !important;
    }
}

/* ===================================
   Estrelinhas clicáveis (effects/starClicks.js)
   Toda estrelinha visível e a foto do herói (grande ou miniatura) dão estrela no clique. As estrelinhas seguem
   sem capturar o ponteiro; o cursor de clique vem da classe no <html> quando o mouse está perto de uma.
   =================================== */
.is-star-hover,
.is-star-hover body {
    cursor: pointer;
}

.is-star-game #hero-image-container #hero-oval-image,
.is-star-game #hero-image-container canvas {
    cursor: pointer;
}

.is-star-game #hero-floating-container.is-clickable #hero-floating-image {
    pointer-events: auto;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tdc-fairy-star.is-collected,
.tdc-glow-star.is-collected,
.tdc-fairy-dust-particle.is-collected {
    animation: tdc-star-collected 0.45s ease-out forwards !important;
    animation-play-state: running !important;
}

@keyframes tdc-star-collected {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    60% {
        opacity: 0.9;
        transform: scale(2.4);
    }

    100% {
        opacity: 0;
        transform: scale(0.2);
    }
}

/* ===================================
   Prêmio esperando o clique (effects/prizeBeacon.js + starCollector.js)
   Com todas as estrelas coletadas, o <html> ganha is-prize-ready: o céu inteiro some (canvas de partículas, poeira
   de fada, estrelas de 4 pontas e brilhos) para nada disputar a atenção, e quem abre o prêmio (a Jess do herói, a
   miniatura do canto e o logotipo) pulsa forte soltando estrelinhas e anéis. Sai quando o prêmio é aberto.
   =================================== */
.tdc-lazy-particles,
.tdc-fairy-dust,
.tdc-fairy-stars,
.tdc-sparkles {
    transition: opacity 0.45s ease;
}

.is-prize-ready .tdc-lazy-particles,
.is-prize-ready .tdc-fairy-dust,
.is-prize-ready .tdc-fairy-stars,
.is-prize-ready .tdc-sparkles {
    opacity: 0 !important;
}

.is-prize-ready:not(.is-prize-claimed) #hero-image-container #hero-oval-image {
    animation: tdc-float-gentle 6s ease-in-out infinite, tdc-prize-pulse 0.85s ease-in-out infinite;
    animation-play-state: running !important;
}

.is-prize-ready:not(.is-prize-claimed) #hero-floating-container #hero-floating-image {
    animation: tdc-prize-pulse 0.85s ease-in-out infinite;
    animation-play-state: running !important;
}

.is-prize-ready:not(.is-prize-claimed) #header-logo {
    animation: tdc-prize-pulse-logo 0.85s ease-in-out infinite;
}

.is-prize-ready:not(.is-prize-claimed) .hero-complete-glow,
.is-prize-ready:not(.is-prize-claimed) .logo-complete-glow,
.is-prize-ready:not(.is-prize-claimed) .mini-hero-complete-glow {
    animation: tdc-prize-glow 0.85s ease-in-out infinite;
}

.is-prize-ready:not(.is-prize-claimed) .prize-speech-bubble {
    animation: prizeBubblePulse 0.85s ease-in-out infinite !important;
}

@keyframes tdc-prize-pulse {
    0%, 100% {
        scale: 1;
        filter: drop-shadow(0 0 6px rgba(255, 210, 80, 0.35)) brightness(1);
    }

    50% {
        scale: 1.06;
        filter: drop-shadow(0 0 30px rgba(255, 210, 80, 0.9)) brightness(1.14);
    }
}

@keyframes tdc-prize-pulse-logo {
    0%, 100% {
        scale: 1;
        filter: drop-shadow(0 0 4px rgba(255, 210, 80, 0.4));
    }

    50% {
        scale: 1.16;
        filter: drop-shadow(0 0 16px rgba(255, 210, 80, 1));
    }
}

@keyframes tdc-prize-glow {
    0%, 100% {
        opacity: 0.55;
        scale: 0.96;
    }

    50% {
        opacity: 1;
        scale: 1.18;
    }
}

/* Estrelinhas e anéis que saem de quem pulsa: fixos na tela, nunca capturam clique. */
.tdc-prize-spark,
.tdc-prize-ring {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    will-change: transform, opacity;
}

.tdc-prize-spark {
    filter: drop-shadow(0 0 5px currentColor);
}

.tdc-prize-ring {
    border-radius: 50%;
    border: 3px solid rgba(255, 210, 80, 0.9);
    box-shadow: 0 0 14px rgba(255, 210, 80, 0.55), inset 0 0 10px rgba(255, 210, 80, 0.35);
}

/* ===================================
   Pause animations during scroll
   =================================== */
.is-scrolling .tdc-fairy-star,
.is-scrolling .tdc-glow-star,
.is-scrolling .tdc-fairy-dust-particle,
.is-scrolling .tdc-float,
.is-scrolling .tdc-hero-sparkle,
.is-scrolling .tdc-sparkles::before,
.is-scrolling .tdc-sparkles::after,
.is-scrolling .tdc-play-button,
.is-scrolling #hero-floating-container img,
.is-scrolling #hero-floating-container canvas {
    animation-play-state: paused !important;
}

/* ===================================
   Hero Speech Bubble
   =================================== */

.hero-speech-bubble {
    position: absolute;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    color: #1A3A5C;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.4;
    pointer-events: none;
    z-index: 100;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(250, 250, 252, 0.98));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Main Hero Bubble - positioned to the left of hero head */
.hero-speech-bubble--main {
    top: 20%;
    left: -10%;
    padding: 14px 20px;
    border-radius: 20px 20px 20px 6px;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 2px rgba(255, 255, 255, 0.9);
    font-size: 17px;
    max-width: 280px;
    min-width: 200px;
    text-align: left;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 250ms ease-out, transform 250ms ease-out;
}

/* Main bubble tail - pointing right */
.hero-speech-bubble--main .bubble-tail {
    position: absolute;
    bottom: 8px;
    right: -10px;
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 12px solid rgba(250, 250, 252, 0.98);
    filter: drop-shadow(2px 1px 2px rgba(0, 0, 0, 0.1));
}

/* Floating Mini Hero Bubble - positioned above the mini hero */
.hero-speech-bubble--floating {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(0) scale(1);
    margin-bottom: 14px;
    padding: 10px 16px;
    border-radius: 16px;
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.2),
        0 2px 6px rgba(0, 0, 0, 0.15),
        inset 0 1px 2px rgba(255, 255, 255, 0.9);
    font-size: 14px;
    max-width: 180px;
    min-width: 130px;
    text-align: center;
    opacity: 1;
    transition: opacity 250ms ease-out, transform 250ms ease-out;
}

/* Floating bubble tail - pointing down */
.hero-speech-bubble--floating .bubble-tail {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid rgba(250, 250, 252, 0.98);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

/* Pop-in animation for the bubble */
@keyframes heroSpeechBubbleIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.8);
    }
    50% {
        transform: translateY(-2px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Subtle floating animation when visible */
@keyframes heroSpeechBubbleFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

/* Gold shimmer effect for star messages */
@keyframes heroSpeechBubbleShimmer {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.hero-speech-bubble.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(255, 250, 220, 0.95) 25%,
        rgba(255, 235, 180, 0.95) 50%,
        rgba(255, 250, 220, 0.95) 75%,
        rgba(255, 255, 255, 0.95) 100%
    );
    background-size: 200% 100%;
    animation: heroSpeechBubbleShimmer 2s ease-in-out infinite;
}

/* Animation states for bubbles */
.hero-speech-bubble--main.bubble-hidden {
    opacity: 0;
    transform: translateY(5px) scale(0.95);
}

.hero-speech-bubble--main.bubble-fade-out {
    opacity: 0.3;
    transform: translateY(-3px) scale(0.98);
}

.hero-speech-bubble--floating.bubble-hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(5px) scale(0.95);
}

.hero-speech-bubble--floating.bubble-fade-out {
    opacity: 0.3;
    transform: translateX(-50%) translateY(-3px) scale(0.98);
}

/* Tablet adjustments */
@media (max-width: 1024px) {
    .hero-speech-bubble--main {
        top: 15%;
        left: -5%;
        padding: 12px 16px;
        font-size: 15px;
        max-width: 240px;
        min-width: 180px;
    }
}

/* Mobile adjustments for speech bubble */
@media (max-width: 768px) {
    .hero-speech-bubble--main {
        top: 5%;
        left: 5%;
        padding: 10px 14px;
        font-size: 13px;
        max-width: 180px;
        min-width: 140px;
        border-radius: 16px 16px 16px 4px;
    }
    
    .hero-speech-bubble--main .bubble-tail {
        bottom: 6px;
        right: -8px;
        border-top: 5px solid transparent;
        border-bottom: 5px solid transparent;
        border-left: 10px solid rgba(250, 250, 252, 0.98);
    }
    
    .hero-speech-bubble--floating {
        padding: 8px 12px;
        font-size: 12px;
        max-width: 140px;
        min-width: 100px;
        margin-bottom: 10px;
        border-radius: 12px;
    }
    
    .hero-speech-bubble--floating .bubble-tail {
        bottom: -6px;
        border-left: 6px solid transparent;
        border-right: 6px solid transparent;
        border-top: 8px solid rgba(250, 250, 252, 0.98);
    }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
    .hero-speech-bubble--main {
        top: 15%;
        left: -2%;
        padding: 8px 12px;
        font-size: 11px;
        max-width: 150px;
        min-width: 110px;
    }
    
    .hero-speech-bubble--floating {
        padding: 6px 10px;
        font-size: 11px;
        max-width: 120px;
        min-width: 90px;
        margin-bottom: 8px;
    }
}


/* ===================================
   Com JavaScript, as estrelinhas só aparecem depois de reposicionadas no fundo livre da seção
   (effects/starFieldLayout.js); sem JavaScript ficam nas posições do servidor.
   =================================== */
.js .tdc-fairy-dust:not(.is-laid-out),
.js .tdc-fairy-stars:not(.is-laid-out) {
    visibility: hidden;
}

/* ===================================
   Redução de movimento: nenhum efeito decorativo roda (estrelas, poeira, canvas, herói flutuante)
   =================================== */
@media (prefers-reduced-motion: reduce) {
    .tdc-fairy-dust,
    .tdc-fairy-stars,
    .tdc-sparkles,
    .tdc-lazy-particles,
    #hero-floating-container {
        display: none !important;
    }
}

