/* fundo dinamico desenha manchas de luz desfocadas que flutuam devagar e acompanham a rolagem da pagina */

/* contexto proprio no body deixa o fundo acima da cor da pagina e abaixo de todo o conteudo */
body {
    isolation: isolate;
}

.fundo-dinamico {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.fundo-dinamico span {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.22;
    will-change: transform, translate;
    transition: translate 0.4s ease-out;
    animation: fundo-flutuar 28s ease-in-out infinite alternate;
}

.fundo-dinamico span:nth-child(1) {
    top: -180px;
    left: -140px;
    width: 560px;
    height: 560px;
    background: #2d9ce5;
    /* azul comeca no topo e termina no fundo da tela: deslocamento = altura da tela - 200px */
    translate: 0 calc(var(--rolagem, 0) * (100vh - 200px));
}

.fundo-dinamico span:nth-child(2) {
    right: -160px;
    bottom: -200px;
    width: 500px;
    height: 500px;
    background: #7c5cff;
    /* lilas comeca no fundo e termina no topo da tela */
    translate: 0 calc(var(--rolagem, 0) * (100px - 100vh));
    animation-duration: 34s;
    animation-delay: -8s;
}

.fundo-dinamico span:nth-child(3) {
    top: 38%;
    left: 52%;
    width: 380px;
    height: 380px;
    background: #22d3ee;
    opacity: 0.14;
    translate: calc(var(--rolagem, 0) * -260px) calc(var(--rolagem, 0) * -120px);
    animation-duration: 40s;
    animation-delay: -16s;
}

/* no modo escuro as manchas brilham um pouco mais sobre o azul noite */
html[data-tema="escuro"] .fundo-dinamico span { opacity: 0.32; }
html[data-tema="escuro"] .fundo-dinamico span:nth-child(3) { opacity: 0.2; }

@keyframes fundo-flutuar {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(90px, 70px) scale(1.12); }
    100% { transform: translate(-70px, 110px) scale(0.94); }
}

/* telas de acesso ja possuem fundo decorativo proprio */
body:has(.acesso-fundo) .fundo-dinamico { display: none; }

@media (max-width: 600px) {
    .fundo-dinamico span { filter: blur(60px); }
    .fundo-dinamico span:nth-child(1) { width: 340px; height: 340px; translate: 0 calc(var(--rolagem, 0) * (100vh + 20px)); }
    .fundo-dinamico span:nth-child(2) { width: 300px; height: 300px; translate: 0 calc(var(--rolagem, 0) * (-100vh - 100px)); }
    .fundo-dinamico span:nth-child(3) { width: 240px; height: 240px; }
}

/* movimento reduzido pelo botao do cabecalho ou pelo sistema deixa o fundo parado */
html[data-movimento="reduzido"] .fundo-dinamico span { animation: none; translate: none !important; transition: none; }

@media (prefers-reduced-motion: reduce) {
    html:not([data-movimento="normal"]) .fundo-dinamico span { animation: none; translate: none !important; }
}

/* botao reduzir movimento torna animacoes e transicoes do site instantaneas */
html[data-movimento="reduzido"] *,
html[data-movimento="reduzido"] *::before,
html[data-movimento="reduzido"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

/* icone do botao ganha um risco quando o movimento esta reduzido */
.movimento-alternar .movimento-risco { display: none; }
.movimento-alternar[aria-pressed="true"] .movimento-risco { display: inline; }
.movimento-alternar[aria-pressed="true"] { color: #2d9ce5; border-color: rgba(45, 156, 229, 0.5); }
html[data-tema="escuro"] .movimento-alternar { color: #c8cfe0; }
html[data-tema="escuro"] .movimento-alternar[aria-pressed="true"] { color: #7cc0f2; }
