/* =========================================================
   OTS Web — Animações e interacções
   Requer: web/js/animacoes.js (para as animações de entrada).
   Sem JavaScript, todo o conteúdo fica visível (nada se perde).
   Com "reduzir movimento" activo no sistema, tudo fica estático.
   ========================================================= */

/* ---- Animações de entrada ao fazer scroll ----
   Uso: <h1 data-ots-anim="fade-up" data-ots-delay="0.2">…</h1>
   Tipos: fade-up · fade · pop · pop-center · slide-l · slide-r · spin-in · drop · wipe · grow · stamp */
.ots-js [data-ots-anim] { opacity: 0; }
.ots-js [data-ots-anim].is-visible {
  opacity: 1;
  animation-duration: var(--ots-dur, 0.7s);
  animation-delay: var(--ots-delay, 0s);
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  animation-iteration-count: 1;   /* a entrada corre uma só vez (ver nota abaixo) */
}
.ots-js [data-ots-anim="fade-up"].is-visible { animation-name: ots-fade-up; }
.ots-js [data-ots-anim="fade"].is-visible    { animation-name: ots-fade; }
.ots-js [data-ots-anim="pop"].is-visible     { animation-name: ots-pop; --ots-dur: 0.55s; transform-origin: left center; }
.ots-js [data-ots-anim="pop-center"].is-visible { animation-name: ots-pop; --ots-dur: 0.55s; transform-origin: center; }
.ots-js [data-ots-anim="slide-l"].is-visible { animation-name: ots-slide-l; }
.ots-js [data-ots-anim="slide-r"].is-visible { animation-name: ots-slide-r; }
.ots-js [data-ots-anim="spin-in"].is-visible { animation-name: ots-spin-in; --ots-dur: 1.3s; }
.ots-js [data-ots-anim="drop"].is-visible    { animation-name: ots-drop; --ots-dur: 0.9s; }
.ots-js [data-ots-anim="wipe"].is-visible    { animation-name: ots-wipe; --ots-dur: 0.6s; transform-origin: left; }
.ots-js [data-ots-anim="grow"].is-visible    { animation-name: ots-grow; --ots-dur: 0.6s; transform-origin: bottom; }
.ots-js [data-ots-anim="stamp"].is-visible   { animation-name: ots-stamp; --ots-dur: 0.5s; }

/* As maquetes inclinadas mantêm a rotação depois de entrar */
.ots-js .ots-mock--main[data-ots-anim].is-visible { animation-name: ots-slide-l-tilt-main; }
.ots-js .ots-mock--side[data-ots-anim].is-visible { animation-name: ots-slide-r-tilt-side; }
.ots-js .ots-mock--card[data-ots-anim].is-visible { animation-name: ots-slide-r-tilt-card; }

@keyframes ots-fade-up { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes ots-fade    { from { opacity: 0; } to { opacity: 1; } }
@keyframes ots-pop     { 0% { opacity: 0; transform: scale(0.5); } 70% { opacity: 1; transform: scale(1.06); } 100% { opacity: 1; transform: scale(1); } }
@keyframes ots-slide-l { from { opacity: 0; transform: translateX(-120px); } to { opacity: 1; transform: none; } }
@keyframes ots-slide-r { from { opacity: 0; transform: translateX(120px); } to { opacity: 1; transform: none; } }
@keyframes ots-spin-in { from { opacity: 0; transform: rotate(-270deg) scale(0.2); } to { opacity: 1; transform: rotate(0) scale(1); } }
@keyframes ots-drop    { 0% { opacity: 0; transform: translateY(-200px) rotate(-12deg); } 70% { opacity: 1; transform: translateY(10px) rotate(-1deg); } 100% { opacity: 1; transform: none; } }
@keyframes ots-wipe    { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes ots-grow    { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes ots-stamp   { 0% { opacity: 0; transform: scale(2.6) rotate(-35deg); } 60% { opacity: 1; transform: scale(0.9) rotate(-14deg); } 100% { opacity: 1; transform: scale(1) rotate(-14deg); } }
@keyframes ots-slide-l-tilt-main { from { opacity: 0; transform: translateX(-120px) rotate(-2deg); } to { opacity: 1; transform: rotate(-2deg); } }
@keyframes ots-slide-r-tilt-side { from { opacity: 0; transform: translateX(120px) rotate(5deg); } to { opacity: 1; transform: rotate(5deg); } }
@keyframes ots-slide-r-tilt-card { from { opacity: 0; transform: translateX(120px) rotate(3deg); } to { opacity: 1; transform: rotate(3deg); } }

/* ---- Movimento contínuo (decorações) ---- */
.ots-float-a { animation: ots-float-a 7s ease-in-out infinite alternate; }
.ots-float-b { animation: ots-float-b 9s ease-in-out infinite alternate; }
.ots-spin-slow { animation: ots-spin 60s linear infinite; }
.ots-bob { animation: ots-bob 4s ease-in-out infinite; }
@keyframes ots-float-a { from { translate: 0 0; } to { translate: 80px -60px; } }
@keyframes ots-float-b { from { translate: 0 0; } to { translate: -70px 70px; } }
@keyframes ots-spin { to { rotate: 360deg; } }
@keyframes ots-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }

/* ---- Pulso no CTA principal (usar num só elemento por página) ---- */
.ots-pulse { animation: ots-pulse 1.6s ease-out infinite; }
@keyframes ots-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.6); }
  70%  { box-shadow: 0 0 0 22px rgba(255, 107, 53, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0); }
}

/* ---- Entrada + movimento contínuo no mesmo elemento ----
   Ex.: notificação com data-ots-anim="pop" e .ots-bob; CTA com "pop-center" e .ots-pulse.
   Sem estas regras, o movimento contínuo (infinite) fazia a entrada repetir-se sem parar e o
   elemento piscava. Aqui a entrada corre uma vez e o movimento contínuo começa a seguir.
   O "pop" mexe em transform e o "bob" em translate: não se anulam um ao outro. */
.ots-js .ots-bob[data-ots-anim].is-visible {
  animation:
    var(--ots-enter, ots-fade) var(--ots-dur, 0.7s) cubic-bezier(0.2, 0.8, 0.2, 1) var(--ots-delay, 0s) 1 both,
    ots-bob 4s ease-in-out calc(var(--ots-delay, 0s) + var(--ots-dur, 0.7s)) infinite;
}
.ots-js .ots-pulse[data-ots-anim].is-visible {
  animation:
    var(--ots-enter, ots-fade) var(--ots-dur, 0.7s) cubic-bezier(0.2, 0.8, 0.2, 1) var(--ots-delay, 0s) 1 both,
    ots-pulse 1.6s ease-out calc(var(--ots-delay, 0s) + var(--ots-dur, 0.7s)) infinite;
}
.ots-js [data-ots-anim="pop"], .ots-js [data-ots-anim="pop-center"] { --ots-enter: ots-pop; }
.ots-js [data-ots-anim="fade-up"] { --ots-enter: ots-fade-up; }
.ots-js [data-ots-anim="fade"] { --ots-enter: ots-fade; }

/* ---- Ondulação ao clicar (adicionada pelo JS a .ots-btn) ---- */
.ots-ripple-host { position: relative; overflow: hidden; }
.ots-ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.25;
  transform: scale(0);
  pointer-events: none;
  animation: ots-ripple 0.6s ease-out forwards;
}
@keyframes ots-ripple { to { transform: scale(2.6); opacity: 0; } }

/* ---- Inclinação suave ao passar o rato (data-ots-tilt) ---- */
[data-ots-tilt] { transition: transform 0.2s ease; transform-style: preserve-3d; will-change: transform; }

/* ---- Acessibilidade: reduzir movimento ---- */
@media (prefers-reduced-motion: reduce) {
  .ots-js [data-ots-anim] { opacity: 1; }
  .ots-js [data-ots-anim].is-visible,
  .ots-float-a, .ots-float-b, .ots-spin-slow, .ots-bob, .ots-pulse, .ots-ripple {
    animation: none !important;
  }
  [data-ots-tilt] { transform: none !important; }
}
