/* Pantalla de carga SANMARSA: el logo se arma pieza por pieza */
.cargador {
  --fondo: #0b1530; --cobre: #c4875a; --cobre-claro: #e0ad84; --aire: #8cc4ea; --agua: #74d0e6; --luz: #e2b55a;
  position: fixed; inset: 0; z-index: 200; background: var(--fondo);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(1.6rem, 4vw, 2.6rem);
  padding: max(24px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  overflow: hidden; cursor: pointer;
  transition: clip-path 1s cubic-bezier(.76, 0, .24, 1), visibility 0s 1s;
  clip-path: inset(0 0 0 0);
}
.cargador::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(214, 224, 245, .04) 1px, transparent 1px), linear-gradient(90deg, rgba(214, 224, 245, .04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(60% 60% at 50% 50%, #000, transparent);
}
.cargador.fuera { clip-path: inset(0 0 100% 0); visibility: hidden; }

.cargador__logo { position: relative; width: min(90vw, 980px); aspect-ratio: 1600 / 354; }
.cargador__logo .letra { position: absolute; inset: 0; opacity: 0; animation-duration: .95s; animation-fill-mode: both; animation-timing-function: cubic-bezier(.2, .8, .2, 1); animation-delay: var(--t); }
.cargador__logo .capa { position: absolute; inset: 0; }
.cargador__logo .capa img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.cargador__logo .tapa { position: absolute; inset: 0; background: var(--fondo); }
.cargador__logo .aspa { transform-origin: 56.5% 70.621%; animation: girar 1.1s linear infinite; animation-delay: calc(var(--t) + .5s); }
.cargador__logo .efectos { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.efectos * { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.efectos .fx { opacity: 0; animation: aparecer .6s ease forwards; animation-delay: calc(var(--t) + .75s); }

/* Entradas, una por tipo de pieza */
/* cada pieza: su entrada + un destello de luz en el momento en que "aterriza" */
.cargador__logo .letra { animation-delay: var(--t), calc(var(--t) + var(--golpe, .5s)); animation-duration: .95s, 1.3s; animation-timing-function: cubic-bezier(.2, .8, .2, 1), ease-out; }
.e-izq { animation-name: entraIzq, destello; --golpe: .5s; }
.e-abraza { animation-name: abraza, destello; transform-origin: 23.25% 70.6%; animation-duration: 1.1s, 1.3s; --golpe: .55s; }
.e-baja { animation-name: baja, destello; --golpe: .62s; }
.e-cae { animation-name: cae, destello; animation-duration: 1.05s, 1.3s; --golpe: .63s; }
.e-gira { animation-name: giraEntra, destello; transform-origin: 56.5% 70.62%; animation-duration: 1.1s, 1.3s; --golpe: .85s; }
.e-sube { animation-name: sube, destello; --golpe: .64s; }
.e-instala { animation-name: instala, destello; animation-duration: 1.1s, 1.3s; --golpe: .8s; }
@keyframes destello {
  0% { filter: none; }
  12% { filter: brightness(2.1) drop-shadow(0 0 14px rgba(190, 225, 255, .95)) drop-shadow(0 0 32px rgba(140, 196, 234, .6)); }
  100% { filter: none; }
}
.cargador__lienzo { position: absolute; left: -12%; top: -80%; width: 124%; height: 260%; pointer-events: none; z-index: 3; }
@keyframes entraIzq { from { opacity: 0; transform: translateX(-9%); } to { opacity: 1; transform: none; } }
@keyframes abraza { 0% { opacity: 0; transform: scale(1.45) rotate(-14deg); } 50% { opacity: 1; transform: scale(.9) rotate(3deg); } 70% { transform: scale(1.04) rotate(-1deg); } 85% { transform: scale(.98); } 100% { opacity: 1; transform: none; } }
@keyframes baja { from { opacity: 0; transform: translateY(-34%); } 70% { opacity: 1; transform: translateY(2%); } to { opacity: 1; transform: none; } }
@keyframes cae { 0% { opacity: 0; transform: translateY(-60%); } 60% { opacity: 1; transform: translateY(3%); } 80% { transform: translateY(-1.2%); } 100% { opacity: 1; transform: none; } }
@keyframes giraEntra { from { opacity: 0; transform: rotate(-160deg) scale(.3); } to { opacity: 1; transform: none; } }
@keyframes sube { from { opacity: 0; transform: translateY(36%); } 70% { opacity: 1; transform: translateY(-2%); } to { opacity: 1; transform: none; } }
@keyframes instala { from { opacity: 0; transform: translateY(55%) scaleY(.6); transform-origin: 50% 100%; } to { opacity: 1; transform: none; } }
@keyframes aparecer { to { opacity: 1; } }
@keyframes girar { to { transform: rotate(360deg); } }

/* Efectos de cada sistema (más gruesos y con resplandor para que se note lo que corre por dentro) */
.fx-aire path { stroke: #a9d6f5; stroke-width: 9; stroke-dasharray: 14 22; animation: flujo .7s linear infinite; filter: drop-shadow(0 0 6px rgba(140, 196, 234, .95)) drop-shadow(0 0 14px rgba(140, 196, 234, .5)); }
@keyframes flujo { to { stroke-dashoffset: -36; } }
.fx-agua path { stroke: #8fe3f5; stroke-width: 9; stroke-dasharray: 20 16; animation: flujoAgua .9s linear infinite; filter: drop-shadow(0 0 6px rgba(116, 208, 230, .95)) drop-shadow(0 0 16px rgba(116, 208, 230, .5)); }
@keyframes flujoAgua { to { stroke-dashoffset: -36; } }

.fx-abraza .anillo { stroke: var(--cobre-claro); stroke-width: 6; transform-box: fill-box; transform-origin: center; animation: aprieta 1s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--t) + .3s); filter: drop-shadow(0 0 10px var(--cobre)); }
@keyframes aprieta { from { transform: scale(1.6); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1); opacity: 0; } }
.fx-abraza .tornillo { stroke: #ffd9b0; stroke-width: 6; stroke-dasharray: 40 100; transform-box: fill-box; transform-origin: center; animation: atornilla .7s ease-in-out 3 both; animation-delay: calc(var(--t) + .45s); filter: drop-shadow(0 0 8px var(--cobre)); }
@keyframes atornilla { from { transform: rotate(0); opacity: 1; } to { transform: rotate(720deg); opacity: .3; } }

.fx-ducto path { stroke: #a9d6f5; stroke-width: 9; stroke-dasharray: 5 15; animation: flujo .6s linear infinite; filter: drop-shadow(0 0 6px rgba(140, 196, 234, .9)); }
.fx-ducto .rejilla { stroke: #a9d6f5; stroke-width: 4; transform-box: fill-box; transform-origin: center; animation: soplo 1.2s ease-out infinite; animation-delay: var(--d, 0s); stroke-dasharray: none; filter: drop-shadow(0 0 6px rgba(140, 196, 234, .9)); }
@keyframes soplo { from { transform: scale(1); opacity: 1; } to { transform: scale(2.4); opacity: 0; } }

.fx-luz .cable { stroke: #ffe39c; stroke-width: 9; stroke-dasharray: 70 1100; animation: pulso 1.3s cubic-bezier(.5, 0, .5, 1) infinite; filter: drop-shadow(0 0 8px var(--luz)) drop-shadow(0 0 20px var(--luz)); }
.fx-luz .cable.b { animation-delay: .35s; stroke-dasharray: 60 520; animation-name: pulsoB; }
@keyframes pulso { from { stroke-dashoffset: 1170; } to { stroke-dashoffset: 0; } }
@keyframes pulsoB { from { stroke-dashoffset: 580; } to { stroke-dashoffset: 0; } }
.fx-luz .condulet { stroke: #ffe39c; stroke-width: 6; animation: brillo 1.3s ease-in-out infinite; filter: drop-shadow(0 0 12px var(--luz)); }
.fx-luz .condulet.b { animation-delay: .35s; }
@keyframes brillo { 0%, 100% { opacity: .05; } 45% { opacity: 1; } }

.fx-extractor .viento { stroke: #a9d6f5; stroke-width: 6; stroke-dasharray: 18 12; animation: flujo .45s linear infinite; filter: drop-shadow(0 0 6px rgba(140, 196, 234, .9)); }

.fx-rack .led { stroke: none; animation: parpadeo .9s steps(1) infinite; }
.fx-rack .led.v { fill: #6dffab; filter: drop-shadow(0 0 4px #5fe39a); }
.fx-rack .led.a { fill: #ffd27a; filter: drop-shadow(0 0 4px var(--luz)); }
@keyframes parpadeo { 0%, 100% { opacity: 1; } 50% { opacity: .1; } }

/* el extractor gira más rápido y con estela */
.cargador__logo .aspa { animation-duration: .55s; filter: drop-shadow(0 0 8px rgba(140, 196, 234, .7)); }

/* Lema y avance */
.cargador__lema { margin: 0; font-family: 'Archivo', 'Arial Narrow', Arial, sans-serif; font-stretch: 125%; font-weight: 300; font-size: clamp(.8rem, 1.6vw, 1.05rem); letter-spacing: .5em; color: rgba(226, 233, 247, .85); text-align: center; opacity: 0; animation: lema 1s ease forwards; animation-delay: 2.7s; padding-left: .5em; }
@keyframes lema { from { opacity: 0; letter-spacing: .9em; } to { opacity: 1; letter-spacing: .5em; } }
.cargador__avance { width: min(320px, 70vw); display: flex; flex-direction: column; gap: .7rem; }
.cargador__barra { height: 2px; background: rgba(214, 224, 245, .12); position: relative; overflow: hidden; }
.cargador__barra i { position: absolute; inset: 0; background: linear-gradient(90deg, var(--cobre), var(--cobre-claro)); transform-origin: left; transform: scaleX(0); }
.cargador__datos { display: flex; justify-content: space-between; gap: 1rem; font: 500 .66rem/1 'JetBrains Mono', ui-monospace, Consolas, monospace; letter-spacing: .14em; text-transform: uppercase; color: rgba(226, 233, 247, .55); }
.cargador__datos b { color: var(--cobre-claro); font-weight: 500; font-variant-numeric: tabular-nums; }
.cargador__saltar { position: absolute; bottom: max(22px, env(safe-area-inset-bottom, 0px)); font: 500 .62rem/1 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .16em; text-transform: uppercase; color: rgba(226, 233, 247, .35); }

@media (prefers-reduced-motion: reduce) {
  .cargador__logo .letra, .efectos .fx, .cargador__lema { animation: none !important; opacity: 1; }
  .efectos * { animation: none !important; }
  .cargador__logo .aspa { animation: none; }
}
