/* ========================================
   PRELOADER — Unique Plástica Avançada
   Premium animation with golden accents
   ======================================== */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1a1408 0%, #0d0a04 40%, #000 80%);
  overflow: hidden;
}

/* Animated golden particles / floating lights */
.preloader::before,
.preloader::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.preloader::before {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(197, 169, 116, 0.06) 0%, transparent 70%);
  top: -120px;
  right: -100px;
  filter: blur(60px);
  opacity: 0;
  animation: plFloatOrb1 3s ease-in-out 0.2s infinite alternate, plFadeIn 1.2s ease-out 0.1s forwards;
}

.preloader::after {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(197, 169, 116, 0.05) 0%, transparent 70%);
  bottom: -80px;
  left: -80px;
  filter: blur(50px);
  opacity: 0;
  animation: plFloatOrb2 3.5s ease-in-out 0.5s infinite alternate, plFadeIn 1.5s ease-out 0.3s forwards;
}

/* Central ambient golden glow */
.preloader__glow {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(197, 169, 116, 0.12) 0%, rgba(170, 126, 50, 0.06) 40%, transparent 70%);
  filter: blur(50px);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
  animation: plGlowIn 1.2s ease-out 0.05s forwards, plGlowPulse 3s ease-in-out 1.2s infinite;
}

/* Golden ring behind logo */
.preloader__ring {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 1px solid rgba(197, 169, 116, 0);
  z-index: 1;
  opacity: 0;
  animation: plRingIn 1.2s cubic-bezier(0.23, 1, 0.32, 1) 0.3s forwards, plRingPulse 3s ease-in-out 1.5s infinite;
}

/* Logo */
.preloader__logo {
  width: 180px;
  height: auto;
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: scale(0.7) translateY(10px);
  filter: brightness(1);
  animation: plLogoIn 1s cubic-bezier(0.23, 1, 0.32, 1) 0.15s forwards,
             plLogoPulse 2.8s ease-in-out 1.2s infinite;
}

/* Golden underline */
.preloader__line {
  height: 1px;
  width: 0;
  background: linear-gradient(90deg, transparent, #c5a974 30%, #e2cfa0 50%, #c5a974 70%, transparent);
  margin-top: 28px;
  position: relative;
  z-index: 2;
  opacity: 0;
  animation: plLineIn 0.8s cubic-bezier(0.23, 1, 0.32, 1) 0.6s forwards;
}

/* Shimmer effect on line */
.preloader__line::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(226, 207, 160, 0.9), transparent);
  filter: blur(2px);
  opacity: 0;
  animation: plShimmer 2.2s ease-in-out 1.4s infinite;
}

/* Subtle text "Carregando..." */
.preloader__text {
  position: relative;
  z-index: 2;
  margin-top: 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(197, 169, 116, 0);
  animation: plTextIn 0.8s ease-out 1s forwards, plTextPulse 2s ease-in-out 1.8s infinite;
}

/* Golden dust particles */
.preloader__particles {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.preloader__particle {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(197, 169, 116, 0.6);
  opacity: 0;
}

.preloader__particle:nth-child(1) {
  top: 20%; left: 15%;
  animation: plParticle 3s ease-in-out 0.5s infinite;
}
.preloader__particle:nth-child(2) {
  top: 60%; left: 80%;
  animation: plParticle 3.5s ease-in-out 0.8s infinite;
}
.preloader__particle:nth-child(3) {
  top: 35%; left: 70%;
  animation: plParticle 2.8s ease-in-out 1.1s infinite;
}
.preloader__particle:nth-child(4) {
  top: 75%; left: 25%;
  animation: plParticle 3.2s ease-in-out 0.3s infinite;
}
.preloader__particle:nth-child(5) {
  top: 45%; left: 50%;
  animation: plParticle 3.8s ease-in-out 1.5s infinite;
}
.preloader__particle:nth-child(6) {
  top: 15%; left: 60%;
  animation: plParticle 2.5s ease-in-out 0.7s infinite;
}

/* Curtains */
.preloader__curtain-top,
.preloader__curtain-bottom {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50.5%;
  background: linear-gradient(180deg, #000 0%, #0d0a04 100%);
  z-index: 1;
  transition: transform 0.5s cubic-bezier(0.76, 0, 0.24, 1);
}

.preloader__curtain-top {
  top: 0;
  background: radial-gradient(ellipse at 50% 100%, #1a1408 0%, #0d0a04 40%, #000 80%);
}

.preloader__curtain-bottom {
  bottom: 0;
  background: radial-gradient(ellipse at 50% 0%, #1a1408 0%, #0d0a04 40%, #000 80%);
}

/* Lock scroll */
html.is-loading { overflow: hidden; }
html.is-loading body { overflow: hidden; }

/* ========================================
   EXIT STATE — triggered by .preloader--exit
   ======================================== */

.preloader--exit .preloader__logo {
  animation: plLogoOut 0.3s ease-in forwards;
}

.preloader--exit .preloader__line {
  animation: plLineOut 0.2s ease-in forwards;
}

.preloader--exit .preloader__text {
  animation: plTextOut 0.15s ease-in forwards;
}

.preloader--exit .preloader__glow {
  animation: plGlowOut 0.3s ease-in forwards;
}

.preloader--exit .preloader__ring {
  animation: plRingOut 0.25s ease-in forwards;
}

.preloader--exit .preloader__particle {
  animation: plParticleOut 0.2s ease-in forwards !important;
}

.preloader--exit::before,
.preloader--exit::after {
  animation: plOrbOut 0.2s ease-in forwards !important;
}

.preloader--exit {
  background: transparent;
}

.preloader--exit .preloader__curtain-top {
  transform: translateY(-100%);
  transition-delay: 0.15s;
}

.preloader--exit .preloader__curtain-bottom {
  transform: translateY(100%);
  transition-delay: 0.15s;
}

/* ---- ENTRANCE KEYFRAMES ---- */

@keyframes plFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes plFloatOrb1 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-30px, 20px) scale(1.1); }
}

@keyframes plFloatOrb2 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(20px, -25px) scale(1.05); }
}

@keyframes plGlowIn {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes plGlowPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.15); opacity: 0.8; }
}

@keyframes plRingIn {
  from { opacity: 0; transform: scale(0.5); border-color: rgba(197, 169, 116, 0); }
  to   { opacity: 1; transform: scale(1); border-color: rgba(197, 169, 116, 0.15); }
}

@keyframes plRingPulse {
  0%, 100% { transform: scale(1); border-color: rgba(197, 169, 116, 0.15); }
  50%      { transform: scale(1.08); border-color: rgba(197, 169, 116, 0.08); }
}

@keyframes plLogoIn {
  from { opacity: 0; transform: scale(0.7) translateY(10px); filter: brightness(0.5); }
  to   { opacity: 1; transform: scale(1) translateY(0); filter: brightness(1); }
}

@keyframes plLogoPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50%      { transform: scale(1.03); filter: brightness(1.1); }
}

@keyframes plLineIn {
  from { opacity: 0; width: 0; }
  to   { opacity: 1; width: 140px; }
}

@keyframes plShimmer {
  0%   { left: -80px; opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { left: calc(100% + 80px); opacity: 0; }
}

@keyframes plTextIn {
  from { color: rgba(197, 169, 116, 0); transform: translateY(8px); }
  to   { color: rgba(197, 169, 116, 0.4); transform: translateY(0); }
}

@keyframes plTextPulse {
  0%, 100% { color: rgba(197, 169, 116, 0.4); }
  50%      { color: rgba(197, 169, 116, 0.2); }
}

@keyframes plParticle {
  0%   { opacity: 0; transform: translateY(0) scale(1); }
  25%  { opacity: 0.7; }
  50%  { opacity: 0.3; transform: translateY(-30px) scale(1.5); }
  75%  { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(-60px) scale(0.5); }
}

/* ---- EXIT KEYFRAMES ---- */

@keyframes plLogoOut {
  from { opacity: 1; transform: scale(1); filter: brightness(1); }
  to   { opacity: 0; transform: scale(1.2); filter: brightness(1.5); }
}

@keyframes plLineOut {
  from { opacity: 1; width: 140px; }
  to   { opacity: 0; width: 0; }
}

@keyframes plTextOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-5px); }
}

@keyframes plGlowOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(1.8); }
}

@keyframes plRingOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(1.5); border-color: rgba(197, 169, 116, 0); }
}

@keyframes plParticleOut {
  from { opacity: 0.5; }
  to   { opacity: 0; transform: translateY(-80px) scale(0); }
}

@keyframes plOrbOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ---- RESPONSIVE ---- */
@media screen and (max-width: 479px) {
  .preloader__logo { width: 140px; }
  .preloader__glow { width: 220px; height: 220px; }
  .preloader__ring { width: 160px; height: 160px; }
  .preloader__line { margin-top: 22px; }
  .preloader__text { font-size: 9px; letter-spacing: 3px; }
}
