/* CMS-motion · Pantalla de carga (lienzo Claude Design CMS-034).
   Toma logo, nombre, frase y colores de la franja del sitio desde el CMS.
   Cada escena es un bloque [data-scene=…]; sumar una propuesta = su bloque
   aquí y su nombre en LOADER_SCENES (src/cargador.tsx). */
.site-loader {
  display: none;
}
.cms-intro body {
  overflow: hidden;
}
.cms-intro .site-loader {
  --sl-ink: var(--brand, var(--site-color, #1d4e57));
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: hidden;
  cursor: pointer;
  color: #13262b;
  background: #fff;
}
/* CMS-050: el fondo de la carga es opaco desde el primer cuadro (antes entraba
   con un fundido y se alcanzaba a ver la página detrás). Solo el contenido entra suave. */
.cms-intro .site-loader .sl-card {
  animation: sl-in 260ms ease-out both;
}
.sl-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.sl-card p {
  margin: 0;
}
.sl-logo {
  object-fit: contain;
}
.sl-weave,
.sl-progress,
.sl-agua,
.sl-lluvia,
.sl-segs,
.sl-marea-texto,
.sl-lluvia-texto {
  display: none;
}

/* ── Escena «franja»: La franja se teje ─────────────────────────────── */
[data-scene="franja"] .sl-logo {
  width: auto;
  max-width: min(260px, 70vw);
  height: 116px;
}
[data-scene="franja"] .sl-name {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: #51656a;
}
[data-scene="franja"] .sl-frase {
  font-family: var(--display, inherit);
  font-size: clamp(34px, 6vw, 48px);
  font-weight: 800;
  line-height: 1;
  color: var(--sl-ink);
  text-wrap: balance;
}
.sl-bars {
  display: none;
}
[data-scene="franja"] .sl-bars {
  display: flex;
  align-items: flex-end;
  gap: clamp(8px, 1.2vw, 10px);
  height: clamp(72px, 10vw, 96px);
  margin-top: 18px;
}
[data-scene="franja"] .sl-bars i {
  display: block;
  width: clamp(16px, 2vw, 22px);
  height: 100%;
  border-radius: 11px;
  background: var(--c);
  transform-origin: bottom;
  animation: sl-eq 1.1s ease-in-out infinite alternate;
}
.sl-bars i:nth-child(2) { animation-delay: -0.18s; }
.sl-bars i:nth-child(3) { animation-delay: -0.36s; }
.sl-bars i:nth-child(4) { animation-delay: -0.54s; }
.sl-bars i:nth-child(5) { animation-delay: -0.72s; }
.sl-bars i:nth-child(6) { animation-delay: -0.9s; }
.sl-msgs {
  display: none;
}
[data-scene="franja"] .sl-msgs {
  display: block;
  position: relative;
  width: min(520px, 100%);
  height: 28px;
  font-size: 18px;
  font-weight: 600;
  color: #3e5257;
}
[data-scene="franja"] .sl-msgs span {
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: sl-msg 3.6s infinite;
}
.sl-msgs span:nth-child(2) { animation-delay: 1.2s !important; }
.sl-msgs span:nth-child(3) { animation-delay: 2.4s !important; }
[data-scene="franja"] .sl-loading,
[data-scene="franja"] .sl-note {
  display: none;
}
/* Salida: las seis columnas de la franja suben y se llevan la carga. */
[data-scene="franja"] .sl-weave {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  pointer-events: none;
}
[data-scene="franja"] .sl-weave i {
  background: var(--c);
  transform: scaleY(0);
  transform-origin: bottom;
}
[data-scene="franja"].is-leaving {
  animation: sl-bg-out 1000ms linear forwards;
}
[data-scene="franja"].is-leaving .sl-card {
  animation: sl-card-out 320ms ease-in forwards;
}
[data-scene="franja"].is-leaving .sl-weave i {
  animation: sl-weave 1000ms cubic-bezier(0.7, 0, 0.3, 1) forwards;
}
.sl-weave i:nth-child(2) { animation-delay: 60ms !important; }
.sl-weave i:nth-child(3) { animation-delay: 120ms !important; }
.sl-weave i:nth-child(4) { animation-delay: 180ms !important; }
.sl-weave i:nth-child(5) { animation-delay: 240ms !important; }
.sl-weave i:nth-child(6) { animation-delay: 300ms !important; }

/* ── Escena «neutral»: logo, tarjeta y texto. Sirve en cualquier sitio. ─ */
[data-scene="neutral"] {
  background: #f4f6f5;
}
[data-scene="neutral"] .sl-progress {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 35%;
  background: var(--sl-ink);
  animation: sl-progress 1.6s ease-in-out infinite;
}
[data-scene="neutral"] .sl-card {
  width: min(380px, 100%);
  box-sizing: border-box;
  padding: 32px 28px;
  border: 1px solid #e5e9e8;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 48px -28px rgba(19, 38, 43, 0.35);
  animation: sl-rise 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
[data-scene="neutral"] .sl-logo {
  width: auto;
  max-width: 200px;
  height: 76px;
}
[data-scene="neutral"] .sl-name {
  font-size: 18px;
  font-weight: 700;
}
[data-scene="neutral"] .sl-frase {
  display: none;
}
[data-scene="neutral"] .sl-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #3e5257;
}
.sl-loading i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 3px;
  border-radius: 50%;
  background: var(--sl-ink);
  animation: sl-dot 1.2s ease-in-out infinite;
}
.sl-loading i:nth-child(2) { animation-delay: 0.15s; }
.sl-loading i:nth-child(3) { animation-delay: 0.3s; }
[data-scene="neutral"] .sl-note {
  font-size: 13px;
  color: #5b6e72;
}
.sl-loading,
.sl-note {
  display: none;
}
[data-scene="neutral"].is-leaving {
  animation: sl-fade-out 360ms ease forwards;
}
[data-scene="neutral"].is-leaving .sl-card {
  animation: sl-card-out 300ms ease forwards;
}

@keyframes sl-in {
  from {
    opacity: 0;
  }
}
@keyframes sl-eq {
  from {
    transform: scaleY(0.25);
  }
  to {
    transform: scaleY(1);
  }
}
@keyframes sl-msg {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  6%,
  28% {
    opacity: 1;
    transform: none;
  }
  34%,
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}
@keyframes sl-weave {
  0% {
    transform: scaleY(0);
  }
  45%,
  55% {
    transform: scaleY(1) translateY(0);
  }
  100% {
    transform: scaleY(1) translateY(-100%);
  }
}
@keyframes sl-bg-out {
  0%,
  50% {
    background-color: #fff;
  }
  51%,
  100% {
    background-color: transparent;
  }
}
@keyframes sl-card-out {
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}
@keyframes sl-progress {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(300%);
  }
}
@keyframes sl-dot {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.15);
  }
}
@keyframes sl-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes sl-fade-out {
  to {
    opacity: 0;
  }
}

/* ── Escena «marea» (Guaitecas): la marea sube y baja con los colores de la
   franja; el escudo flota. Al salir, la capa baja y destapa el sitio. ─── */
[data-scene="marea"] {
  place-items: start center;
  padding-top: clamp(72px, 14vh, 120px);
}
[data-scene="marea"] .sl-agua {
  display: block;
  position: absolute;
  inset: 0;
  transform: translateY(80%);
  animation: sl-sube 6s ease-in-out infinite;
}
.sl-ola {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 200%;
  background: var(--c);
  /* Cresta de ola como máscara: el color sale de la franja del sitio. */
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 60' preserveAspectRatio='none'%3E%3Cpath d='M0 30 Q180 0 360 30 T720 30 T1080 30 T1440 30 V60 H0 Z'/%3E%3C/svg%3E")
      0 0 / 50% clamp(36px, 6vw, 60px) repeat-x,
    linear-gradient(#000 0 0) 0 clamp(35px, calc(6vw - 1px), 59px) / 100% 100%
      no-repeat;
  animation: sl-olas linear infinite;
}
.sl-ola:nth-child(1) { height: 100%; opacity: 0.9; animation-duration: 9s; }
.sl-ola:nth-child(2) { height: 92%; opacity: 0.85; animation-duration: 6s; }
.sl-ola:nth-child(3) { height: 84%; opacity: 0.8; animation-duration: 4.5s; }
[data-scene="marea"] .sl-logo {
  width: auto;
  max-width: min(260px, 70vw);
  height: clamp(96px, 13vw, 120px);
  filter: drop-shadow(0 10px 14px rgba(19, 38, 43, 0.18));
  animation: sl-flota 3s ease-in-out infinite;
}
[data-scene="marea"] .sl-name,
[data-scene="lluvia"] .sl-name {
  font-size: clamp(11px, 1.2vw, 13px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: #51656a;
}
[data-scene="marea"] .sl-frase {
  font-family: var(--display, inherit);
  font-size: clamp(36px, 6vw, 52px);
  font-weight: 800;
  line-height: 1;
  color: var(--sl-ink);
  text-wrap: balance;
}
[data-scene="marea"] .sl-marea-texto {
  display: block;
  font-size: clamp(16px, 1.6vw, 18px);
  color: #3e5257;
  text-wrap: balance;
}
[data-scene="marea"].is-leaving {
  animation: sl-baja 700ms cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

/* ── Escena «lluvia» (Lluvia de luz, alternativa): gotas de colores, un
   rayo amarillo y un destello sobre un cielo claro del color del sitio. ─ */
[data-scene="lluvia"] {
  background: color-mix(in oklab, var(--civic-5, var(--sl-ink)) 12%, white);
}
[data-scene="lluvia"] .sl-lluvia {
  display: block;
  position: absolute;
  inset: 0;
}
.sl-gota {
  position: absolute;
  top: -90px;
  width: 3px;
  border-radius: 3px;
  opacity: 0.8;
  background: var(--c);
  animation: sl-cae linear infinite;
}
.sl-rayo {
  position: absolute;
  right: 16%;
  top: 7%;
  width: clamp(70px, 9vw, 120px);
  height: auto;
  opacity: 0;
  animation: sl-destello 2.4s ease-out infinite;
}
.sl-destello {
  position: absolute;
  inset: 0;
  background: #fffbe6;
  opacity: 0;
  animation: sl-destello 2.4s ease-out infinite;
}
[data-scene="lluvia"] .sl-card {
  width: min(520px, 100%);
  box-sizing: border-box;
  padding: clamp(28px, 4vw, 40px) clamp(22px, 4vw, 44px) clamp(24px, 3vw, 34px);
  border-radius: clamp(22px, 3vw, 28px);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 30px 60px -30px rgba(19, 38, 43, 0.35);
}
[data-scene="lluvia"] .sl-logo {
  width: auto;
  max-width: min(240px, 60vw);
  height: clamp(76px, 9vw, 96px);
}
[data-scene="lluvia"] .sl-frase {
  font-family: var(--display, inherit);
  font-size: clamp(30px, 4.5vw, 40px);
  font-weight: 800;
  line-height: 1.05;
  color: var(--sl-ink);
  text-wrap: balance;
}
[data-scene="lluvia"] .sl-segs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin-top: 10px;
}
.sl-segs i {
  height: 8px;
  border-radius: 4px;
  background: #e6ecea;
  overflow: hidden;
}
.sl-segs b {
  display: block;
  height: 100%;
  background: var(--c);
  transform: scaleX(0);
  transform-origin: left;
  animation: sl-llena 4.2s ease-in-out infinite;
}
.sl-segs i:nth-child(2) b { animation-delay: 0.35s; }
.sl-segs i:nth-child(3) b { animation-delay: 0.7s; }
.sl-segs i:nth-child(4) b { animation-delay: 1.05s; }
.sl-segs i:nth-child(5) b { animation-delay: 1.4s; }
.sl-segs i:nth-child(6) b { animation-delay: 1.75s; }
[data-scene="lluvia"] .sl-lluvia-texto {
  display: block;
  font-size: 16px;
  color: #3e5257;
}
[data-scene="lluvia"].is-leaving {
  animation: sl-lluvia-out 650ms ease forwards;
}

/* CMS-050: la marea sube como mucho hasta el 72 % de la altura. La tarjeta
   (escudo, frase y texto) termina entre el 61 % y el 68 % en celular, tableta y
   escritorio; antes subía hasta el 44 % y, si la carga duraba, tapaba el texto. */
@keyframes sl-sube {
  0%,
  100% {
    transform: translateY(80%);
  }
  70% {
    transform: translateY(72%);
  }
}
@keyframes sl-olas {
  to {
    transform: translateX(-50%);
  }
}
@keyframes sl-flota {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-10px) rotate(2deg);
  }
}
@keyframes sl-baja {
  to {
    transform: translateY(100%);
  }
}
@keyframes sl-cae {
  to {
    transform: translateY(calc(100vh + 120px));
  }
}
@keyframes sl-destello {
  0%,
  84%,
  100% {
    opacity: 0;
  }
  86% {
    opacity: 0.8;
  }
  89% {
    opacity: 0.15;
  }
  92% {
    opacity: 0.6;
  }
}
@keyframes sl-llena {
  0% {
    transform: scaleX(0);
  }
  20%,
  80% {
    transform: scaleX(1);
  }
  100% {
    transform: scaleX(0);
  }
}
@keyframes sl-lluvia-out {
  30% {
    filter: brightness(1.25);
  }
  to {
    opacity: 0;
    transform: scale(1.03);
  }
}

/* Movimiento reducido: sin barras que bailan, sin tejido; un fundido. */
@media (prefers-reduced-motion: reduce) {
  .site-loader *,
  .site-loader {
    animation: none !important;
  }
  [data-scene="franja"] .sl-msgs span:first-child {
    opacity: 1;
  }
  [data-scene="neutral"] .sl-progress {
    width: 60%;
  }
  [data-scene="marea"] .sl-agua {
    transform: translateY(76%);
  }
  .sl-gota,
  .sl-rayo,
  .sl-destello {
    display: none;
  }
  .sl-segs b {
    transform: none;
  }
  .site-loader.is-leaving {
    opacity: 0;
    transition: opacity 150ms linear;
  }
}

/* CMS-050 r5 · Progreso real de la carga (letras, avisos y fotos listas). */
.sl-real {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 2;
  height: 4px;
  width: 100%;
  background: var(--civic-0, var(--sl-ink));
  transform-origin: left;
  transform: scaleX(var(--sl-real, 0));
  transition: transform 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  .sl-real {
    transition: none;
  }
}
