/* Loader 3D com Cuboide - CSS isolado */
:root {
  --size: 120;
  --coefficient: 1px;
  --timeline: 2.6s;
  --delay: 0.65s;
  --rotation-y: -24;
  --rotation-x: 28;
  --color-one: #3a0ca3;
  --color-two: #4361ee;
  --color-three: #4cc9f0;
}

#loader-bg {
  position: fixed;
  z-index: 9999;
  inset: 0;
  background: #121621;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s, background 0.3s;
}

:not([data-theme="dark"]) #loader-bg {
  background: #f0f4fa;
}

[data-theme="dark"] #loader-bg {
  background: #121621;
}

/* Garante que o loader não afete o body ou outros elementos */
body {
  /* Mantém o estilo original do body */
}

#loader-bg *,
#loader-bg *:after,
#loader-bg *:before {
  box-sizing: border-box;
  transform-style: preserve-3d;
}

#loader-bg .scene {
  position: relative;
  transform: translate3d(0, 0, 100vmin) rotateX(calc(var(--rotation-y, 0) * 1deg)) rotateY(calc(var(--rotation-x, 0) * 1deg)) rotateX(0deg);
  transform-origin: 50% 50%;
  animation: loader-scale var(--timeline) var(--delay) infinite linear;
}

@keyframes loader-scale {
  0%, 10% {
    transform: translate3d(0, 0, 100vmin) rotateX(calc(var(--rotation-y, 0) * 1deg)) rotateY(calc(var(--rotation-x, 0) * 1deg)) rotateX(0deg) scaleX(1) scaleY(1);
  }
  35%, 100% {
    transform: translate3d(0, 0, 100vmin) rotateX(calc(var(--rotation-y, 0) * 1deg)) rotateY(calc(var(--rotation-x, 0) * 1deg)) rotateX(0deg) scaleX(0.5) scaleY(0.5);
  }
}

#loader-bg .shadow {
  width: calc(var(--size) * var(--coefficient));
  position: absolute;
  bottom: 0;
  aspect-ratio: 1;
  transform-origin: 50% 50%;
  background: hsl(210 80% 50% / 0.2);
  transform: rotateX(90deg) translate3d(0, 0, calc((var(--size) * (var(--coefficient) * -0.5)) - 1px)) scale(0.96);
  animation: squish-squosh var(--timeline) var(--delay) infinite, fade var(--timeline) var(--delay) infinite;
  background: black;
}

#loader-bg .loader {
  --depth: var(--size);
  --color: var(--color-one, #8338EC);
  width: calc(var(--depth) * var(--coefficient));
  aspect-ratio: 1;
  transform-origin: 50% 50%;
  animation: squish-squosh var(--timeline) var(--delay) infinite;
}

#loader-bg .spinner {
  animation: spin var(--timeline) var(--delay) infinite;
}

#loader-bg .jumper {
  animation: jump var(--timeline) var(--delay) infinite;
}

@keyframes squish-squosh {
  0%, 50%, 60% {
    scale: 1 1 1;
  }
  10%, 35% {
    scale: 1.2 0.8 1.2;
  }
  25% {
    scale: 0.8 1.2 0.8;
  }
  70% {
    scale: 1 1 2;
  }
  80% {
    scale: 2 1 2;
  }
  90%, 100% {
    scale: 2 2 2;
  }
}

@keyframes fade {
  0%, 10%, 40%, 50%, 60%, 100% {
    opacity: 1;
  }
  25% {
    opacity: 0.5;
  }
}

@keyframes spin {
  0%, 10% { 
    rotate: 0deg; 
  }
  30%, 100% { 
    rotate: -360deg; 
  }
}

@keyframes jump {
  0%, 10%, 35%, 50% {
    translate: 0 0;
  }
  25% {
    translate: 0 -150%;
  }
}

/* Cuboid boilerplate code */
#loader-bg .cuboid {
  width: 100%;
  height: 100%;
  position: relative;
}

#loader-bg .cuboid__side {
  background: var(--color);
  position: absolute;
}

#loader-bg .cuboid__side:nth-of-type(1) {
  --b: 1.1;
  height: calc(var(--depth, 20) * var(--coefficient));
  width: 100%;
  top: 0;
  transform: translate(0, -50%) rotateX(90deg);
}

#loader-bg .cuboid__side:nth-of-type(2) {
  --b: 0.9;
  --color: var(--color-three, #FF006E);
  height: 100%;
  width: calc(var(--depth, 20) * var(--coefficient));
  top: 50%;
  right: 0;
  transform: translate(50%, -50%) rotateY(90deg);
}

#loader-bg .cuboid__side:nth-of-type(3) {
  --b: 1;
  width: 100%;
  height: calc(var(--depth, 20) * var(--coefficient));
  bottom: 0;
  transform: translate(0%, 50%) rotateX(90deg);
}

#loader-bg .cuboid__side:nth-of-type(4) {
  --b: 1;
  --color: var(--color-three, #FF006E);
  height: 100%;
  width: calc(var(--depth, 20) * var(--coefficient));
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%) rotateY(90deg);
}

#loader-bg .cuboid__side:nth-of-type(5) {
  --b: 1;
  --color: var(--color-two, #3A86EF);
  height: 100%;
  width: 100%;
  transform: translate3d(0, 0, calc(var(--depth, 20) * (var(--coefficient) * 0.5)));
  top: 0;
  left: 0;
}

#loader-bg .cuboid__side:nth-of-type(6) {
  --b: 1.2;
  height: 100%;
  width: 100%;
  transform: translate3d(0, 0, calc(var(--depth, 20) * (var(--coefficient) * -0.5))) rotateY(180deg);
  top: 0;
  left: 0;
}

/* Responsivo */
@media (max-width: 480px) {
  #loader-bg .scene {
    zoom: 0.6;
  }
}

/* Esconde o loader quando não visível */
#loader-bg.hide {
  opacity: 0;
  pointer-events: none;
} 