/**
 * Background Animado - Escola + Segura
 * Tema: Ambiente escolar seguro e acolhedor
 * @version 2.0.0
 */

/* ==========================================================================
   BACKGROUND PRINCIPAL COM ANIMAÇÃO - VERSÃO MELHORADA
   ========================================================================== */

body {
    position: relative;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9f0f5 100%);
    min-height: 100vh;
}

/* Elementos flutuantes do fundo - MAIS VISÍVEIS */
.ems-bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

/* ==========================================================================
   LIVROS FLUTUANTES - MAIOR OPACIDADE E MOVIMENTO
   ========================================================================== */

.ems-bg-book {
    position: absolute;
    opacity: 0.15; /* Aumentado de 0.05 para 0.15 */
    animation: float 15s infinite ease-in-out;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.1));
}

.ems-bg-book-1 {
    top: 10%;
    left: 5%;
    width: 140px; /* Aumentado */
    height: 100px; /* Aumentado */
    background: linear-gradient(135deg, var(--primary-color, #4CAF50), var(--secondary-color, #2196F3));
    border-radius: 5px 20px 20px 5px;
    transform: rotate(-15deg);
    animation-delay: 0s;
    animation-duration: 18s;
}

.ems-bg-book-1::before {
    content: '';
    position: absolute;
    left: 8px;
    width: 12px;
    height: 100%;
    background: rgba(255,255,255,0.5); /* Mais claro */
    border-radius: 3px;
}

.ems-bg-book-2 {
    bottom: 15%;
    right: 8%;
    width: 180px; /* Aumentado */
    height: 120px; /* Aumentado */
    background: linear-gradient(135deg, var(--secondary-color, #2196F3), var(--primary-color, #4CAF50));
    border-radius: 5px 25px 25px 5px;
    transform: rotate(10deg);
    animation-delay: 1s;
    animation-duration: 22s;
}

.ems-bg-book-2::before {
    content: '';
    position: absolute;
    left: 10px;
    width: 15px;
    height: 100%;
    background: rgba(255,255,255,0.5);
    border-radius: 3px;
    transform: rotate(-5deg);
}

.ems-bg-book-3 {
    top: 40%;
    right: 15%;
    width: 120px; /* Aumentado */
    height: 85px; /* Aumentado */
    background: linear-gradient(135deg, #ff9800, #ff5722);
    border-radius: 5px 15px 15px 5px;
    transform: rotate(25deg);
    animation-delay: 2s;
    animation-duration: 25s;
}

.ems-bg-book-3::before {
    content: '';
    position: absolute;
    left: 7px;
    width: 10px;
    height: 100%;
    background: rgba(255,255,255,0.5);
    border-radius: 3px;
}

/* ==========================================================================
   LÁPIS FLUTUANTES - MAIS VISÍVEIS E RÁPIDOS
   ========================================================================== */

.ems-bg-pencil {
    position: absolute;
    opacity: 0.15; /* Aumentado de 0.05 para 0.15 */
    animation: float-rotate 12s infinite ease-in-out;
    filter: drop-shadow(0 3px 3px rgba(0,0,0,0.1));
}

.ems-bg-pencil-1 {
    top: 20%;
    left: 15%;
    width: 120px; /* Aumentado */
    height: 10px; /* Aumentado */
    background: linear-gradient(90deg, #f1c40f, #e67e22);
    border-radius: 5px;
    transform: rotate(-45deg);
    animation-delay: 0.5s;
    animation-duration: 14s;
}

.ems-bg-pencil-1::before {
    content: '';
    position: absolute;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #e67e22;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.ems-bg-pencil-2 {
    bottom: 25%;
    left: 20%;
    width: 140px; /* Aumentado */
    height: 12px; /* Aumentado */
    background: linear-gradient(90deg, #2ecc71, #27ae60);
    border-radius: 6px;
    transform: rotate(30deg);
    animation-delay: 1.5s;
    animation-duration: 16s;
}

.ems-bg-pencil-2::before {
    content: '';
    position: absolute;
    right: -12px;
    width: 22px;
    height: 22px;
    background: #27ae60;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

/* ==========================================================================
   ESCUDOS DE PROTEÇÃO - MAIOR DESTAQUE
   ========================================================================== */

.ems-bg-shield {
    position: absolute;
    opacity: 0.12; /* Aumentado de 0.04 para 0.12 */
    animation: pulse-float 12s infinite ease-in-out;
    filter: drop-shadow(0 5px 8px rgba(0,0,0,0.15));
}

.ems-bg-shield-1 {
    top: 60%;
    right: 25%;
    width: 120px; /* Aumentado */
    height: 140px; /* Aumentado */
    background: linear-gradient(135deg, var(--primary-color, #4CAF50), #2ecc71);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    animation-delay: 0s;
    animation-duration: 18s;
}

.ems-bg-shield-2 {
    bottom: 10%;
    left: 30%;
    width: 100px; /* Aumentado */
    height: 120px; /* Aumentado */
    background: linear-gradient(135deg, #3498db, #2980b9);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    animation-delay: 2s;
    animation-duration: 20s;
}

.ems-bg-shield-3 {
    top: 15%;
    right: 40%;
    width: 90px; /* Novo elemento */
    height: 108px; /* Novo elemento */
    background: linear-gradient(135deg, #9c27b0, #7b1fa2);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    animation-delay: 4s;
    animation-duration: 22s;
    opacity: 0.1;
}

/* ==========================================================================
   BOLHAS DE PENSAMENTO - MAIOR IMPACTO VISUAL
   ========================================================================== */

.ems-bg-thought {
    position: absolute;
    opacity: 0.12; /* Aumentado de 0.06 para 0.12 */
    border-radius: 50%;
    animation: bounce-float 15s infinite ease-in-out;
    filter: blur(1px);
}

.ems-bg-thought-1 {
    top: 30%;
    left: 40%;
    width: 200px; /* Aumentado */
    height: 200px; /* Aumentado */
    background: radial-gradient(circle at 30% 30%, rgba(33, 150, 243, 0.2), rgba(33, 150, 243, 0.08));
    animation-delay: 0s;
    animation-duration: 25s;
}

.ems-bg-thought-2 {
    top: 70%;
    left: 70%;
    width: 250px; /* Aumentado */
    height: 250px; /* Aumentado */
    background: radial-gradient(circle at 70% 70%, rgba(76, 175, 80, 0.2), rgba(76, 175, 80, 0.08));
    animation-delay: 3s;
    animation-duration: 28s;
}

.ems-bg-thought-3 {
    top: 45%;
    left: 15%;
    width: 150px; /* Novo elemento */
    height: 150px; /* Novo elemento */
    background: radial-gradient(circle at 50% 50%, rgba(255, 152, 0, 0.15), rgba(255, 152, 0, 0.05));
    animation-delay: 6s;
    animation-duration: 22s;
}

/* ==========================================================================
   PARTÍCULAS BRILHANTES - MAIS NUMEROSAS E DINÂMICAS
   ========================================================================== */

.ems-bg-particle {
    position: absolute;
    width: 6px; /* Aumentado */
    height: 6px; /* Aumentado */
    background: radial-gradient(circle, rgba(76, 175, 80, 0.6), rgba(76, 175, 80, 0.1));
    border-radius: 50%;
    animation: twinkle 4s infinite ease-in-out;
    filter: blur(1px);
}

/* Mais partículas com posições variadas */
.ems-bg-particle:nth-child(1) { top: 20%; left: 30%; animation-delay: 0s; }
.ems-bg-particle:nth-child(2) { top: 50%; left: 70%; animation-delay: 0.5s; }
.ems-bg-particle:nth-child(3) { top: 80%; left: 20%; animation-delay: 1s; }
.ems-bg-particle:nth-child(4) { top: 30%; left: 80%; animation-delay: 1.5s; }
.ems-bg-particle:nth-child(5) { top: 70%; left: 40%; animation-delay: 2s; }
.ems-bg-particle:nth-child(6) { top: 45%; left: 55%; animation-delay: 2.5s; }
.ems-bg-particle:nth-child(7) { top: 15%; left: 65%; animation-delay: 3s; }
.ems-bg-particle:nth-child(8) { top: 85%; left: 75%; animation-delay: 3.5s; }
.ems-bg-particle:nth-child(9) { top: 35%; left: 15%; animation-delay: 4s; }
.ems-bg-particle:nth-child(10) { top: 65%; left: 85%; animation-delay: 4.5s; }
.ems-bg-particle:nth-child(11) { top: 25%; left: 45%; animation-delay: 5s; }
.ems-bg-particle:nth-child(12) { top: 75%; left: 55%; animation-delay: 5.5s; }

/* ==========================================================================
   NOVOS ELEMENTOS - MAIS DINÂMICA
   ========================================================================== */

/* Estrelas cadentes */
.ems-bg-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    animation: shooting-star 8s infinite linear;
    box-shadow: 0 0 10px 2px rgba(255,255,255,0.5);
}

.ems-bg-star-1 {
    top: 10%;
    left: -10%;
    animation-delay: 2s;
}

.ems-bg-star-2 {
    top: 30%;
    left: -10%;
    animation-delay: 5s;
}

.ems-bg-star-3 {
    top: 60%;
    left: -10%;
    animation-delay: 8s;
}

/* Folhas de papel */
.ems-bg-paper {
    position: absolute;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
    animation: drift 25s infinite linear;
    opacity: 0.08;
}

.ems-bg-paper-1 {
    top: 40%;
    left: -5%;
    animation-delay: 0s;
    animation-duration: 30s;
}

.ems-bg-paper-2 {
    top: 70%;
    left: -5%;
    animation-delay: 10s;
    animation-duration: 35s;
}

/* ==========================================================================
   ANIMAÇÕES MELHORADAS
   ========================================================================== */

@keyframes float {
    0% {
        transform: translateY(0) rotate(-15deg) scale(1);
    }
    25% {
        transform: translateY(-25px) rotate(-10deg) scale(1.02);
    }
    50% {
        transform: translateY(-30px) rotate(-8deg) scale(1.05);
    }
    75% {
        transform: translateY(-15px) rotate(-12deg) scale(1.02);
    }
    100% {
        transform: translateY(0) rotate(-15deg) scale(1);
    }
}

@keyframes float-rotate {
    0% {
        transform: translateY(0) rotate(-45deg) scale(1);
    }
    33% {
        transform: translateY(-20px) rotate(-30deg) scale(1.03);
    }
    66% {
        transform: translateY(-10px) rotate(-40deg) scale(0.98);
    }
    100% {
        transform: translateY(0) rotate(-45deg) scale(1);
    }
}

@keyframes pulse-float {
    0% {
        transform: scale(1) translateY(0);
        opacity: 0.12;
    }
    25% {
        transform: scale(1.15) translateY(-15px);
        opacity: 0.18;
    }
    50% {
        transform: scale(1.2) translateY(-20px);
        opacity: 0.2;
    }
    75% {
        transform: scale(1.1) translateY(-10px);
        opacity: 0.15;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 0.12;
    }
}

@keyframes bounce-float {
    0% {
        transform: scale(1) translateY(0);
    }
    20% {
        transform: scale(1.08) translateY(-15px);
    }
    40% {
        transform: scale(1.02) translateY(-5px);
    }
    60% {
        transform: scale(0.95) translateY(8px);
    }
    80% {
        transform: scale(0.98) translateY(3px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

@keyframes twinkle {
    0% {
        opacity: 0.1;
        transform: scale(1);
    }
    25% {
        opacity: 0.5;
        transform: scale(1.8);
    }
    50% {
        opacity: 0.8;
        transform: scale(2.2);
    }
    75% {
        opacity: 0.4;
        transform: scale(1.5);
    }
    100% {
        opacity: 0.1;
        transform: scale(1);
    }
}

@keyframes shooting-star {
    0% {
        transform: translateX(0) translateY(0) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
        transform: translateX(20vw) translateY(20vh) scale(2);
    }
    20% {
        opacity: 0.4;
        transform: translateX(40vw) translateY(40vh) scale(1.5);
    }
    30% {
        opacity: 0;
        transform: translateX(60vw) translateY(60vh) scale(0.5);
    }
    100% {
        transform: translateX(120vw) translateY(120vh) scale(0);
        opacity: 0;
    }
}

@keyframes drift {
    0% {
        transform: translateX(0) rotate(45deg) scale(1);
        opacity: 0.08;
    }
    25% {
        transform: translateX(25vw) translateY(-10vh) rotate(90deg) scale(1.2);
        opacity: 0.15;
    }
    50% {
        transform: translateX(50vw) translateY(-20vh) rotate(135deg) scale(1.1);
        opacity: 0.12;
    }
    75% {
        transform: translateX(75vw) translateY(-10vh) rotate(180deg) scale(0.9);
        opacity: 0.08;
    }
    100% {
        transform: translateX(120vw) translateY(0) rotate(225deg) scale(0.7);
        opacity: 0.05;
    }
}

/* ==========================================================================
   RESPONSIVIDADE - AJUSTADA PARA NOVOS ELEMENTOS
   ========================================================================== */

@media (max-width: 992px) {
    .ems-bg-book,
    .ems-bg-pencil,
    .ems-bg-shield,
    .ems-bg-thought,
    .ems-bg-particle {
        opacity: 0.12;
    }
    
    .ems-bg-star,
    .ems-bg-paper {
        display: none; /* Esconder elementos mais complexos em tablets */
    }
}

@media (max-width: 768px) {
    .ems-bg-book,
    .ems-bg-pencil,
    .ems-bg-shield,
    .ems-bg-thought {
        opacity: 0.15; /* Mais visível em mobile */
    }
    
    .ems-bg-thought-1,
    .ems-bg-thought-2,
    .ems-bg-thought-3 {
        width: 80px;
        height: 80px;
    }
    
    .ems-bg-book-1,
    .ems-bg-book-2,
    .ems-bg-book-3 {
        transform: scale(0.7);
    }
    
    .ems-bg-particle {
        width: 4px;
        height: 4px;
    }
}

@media (max-width: 480px) {
    .ems-bg-animation {
        display: block; /* Mostrar em mobile, mas com menos elementos */
    }
    
    .ems-bg-book,
    .ems-bg-pencil,
    .ems-bg-shield,
    .ems-bg-thought {
        opacity: 0.1;
    }
    
    .ems-bg-star,
    .ems-bg-paper {
        display: none;
    }
    
    .ems-bg-particle {
        display: none; /* Menos partículas em mobile para performance */
    }
}

/* Suporte para prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .ems-bg-animation * {
        animation: none !important;
        transition: none !important;
    }
}