/*
 * Animación del acceso (22-nov-2026, pedido de César): la «A» blanca al centro del panel naranja y dos anillos de iconos
 * (js/auth-orbit.js) girando despacio en sentidos contrarios. El estado del ingreso vive en #authScreen[data-login]:
 *   work = verificando (la «A» late) · ok = entró (la «A» se vuelve una esfera blanca con un check verde) · bad = falló (la esfera
 *   se sacude; el mensaje escrito sigue siendo el que explica el error).
 * En celular el panel no se muestra: ahí el check aparece en el botón «Entrar» (al final del archivo).
 * Qué no debe hacer: pintar el panel ni la tipografía del saludo (auth-screen.css) ni tocar el formulario.
 * Depende de tokens.css.
 */
/* Verde del check de «entró» (el mismo del formulario de planes al editar, 22-nov-2026): del claro al oscuro. */
.auth-screen {
  --auth-ok-from: #7fd83a;
  --auth-ok-to: #4c9f1c;
}

/* La zona de la animación: es la fila del medio de la escena, entre el nombre y el saludo. La órbita se dibuja del tamaño que quepa en
   ella (container query), así que nunca toca el texto y crece o se achica con la pantalla. */
.auth-orbit {
  position: relative;
  display: grid;
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  margin-left: var(--auth-gutter);
  place-items: center;
  container-type: size;
  pointer-events: none;
}

/* El disco es el cuadrado de la órbita; todas las medidas salen de su tamaño. */
.auth-orbit__disc {
  --orbit-size: min(84cqw, 84cqh);
  --core-size: calc(var(--orbit-size) * 0.31);
  --chip-size: calc(var(--orbit-size) * 0.15);
  --chip-size-in: calc(var(--orbit-size) * 0.12);
  position: relative;
  width: var(--orbit-size);
  height: var(--orbit-size);
}

.auth-orbit__halo {
  position: absolute;
  inset: 23%;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 255 255 / 30%), transparent 70%);
  animation: auth-orbit-breathe 6s ease-in-out infinite;
}

/* Cada anillo gira de un lado y sus iconos giran al contrario, para que se queden derechos. */
.auth-orbit__ring {
  position: absolute;
  inset: 0;
  animation: auth-orbit-spin 44s linear infinite;
}

.auth-orbit__ring--in {
  inset: 17%;
  animation: auth-orbit-spin-back 32s linear infinite;
}

.auth-orbit__chip {
  position: absolute;
  display: grid;
  width: var(--chip-size);
  height: var(--chip-size);
  margin: calc(var(--chip-size) / -2);
  place-items: center;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: calc(var(--chip-size) * 0.3);
  color: var(--as-text-inverse);
  background: rgb(255 255 255 / 18%);
  box-shadow:
    inset 0 1px rgb(255 255 255 / 50%),
    0 8px 18px -10px rgb(110 30 0 / 65%);
  animation: auth-orbit-spin-back 44s linear infinite;
}

.auth-orbit__ring--in .auth-orbit__chip {
  width: var(--chip-size-in);
  height: var(--chip-size-in);
  margin: calc(var(--chip-size-in) / -2);
  border-color: rgb(255 255 255 / 40%);
  border-radius: calc(var(--chip-size-in) * 0.3);
  background: rgb(255 255 255 / 12%);
  animation: auth-orbit-spin 32s linear infinite;
}

.auth-orbit__chip svg {
  width: 48%;
  height: 48%;
}

/* Centro: la «A» blanca y, encima, la esfera del check (escondida hasta que se entra). */
/* La «A» flota sobre el agua: sube y baja despacio; en el punto más bajo «toca» el agua y nace una onda (js/auth-water.js lee el
   ciclo de esta animación, por eso su nombre y su duración de 4,2 s no deben cambiar sin cambiar BOB_MS allí). */
.auth-orbit__core {
  position: absolute;
  inset: 0;
  width: var(--core-size);
  height: var(--core-size);
  margin: auto;
  animation: auth-orbit-bob 4.2s ease-in-out infinite;
}

@keyframes auth-orbit-bob {
  0%,
  100% {
    transform: translateY(-6%);
  }
  50% {
    transform: translateY(3%);
  }
}

.auth-orbit__logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgb(110 30 0 / 35%));
  animation: auth-orbit-in 0.9s ease-out both;
}

.auth-orbit__wave {
  position: absolute;
  inset: -4px;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 50%;
  opacity: 0;
  animation: auth-orbit-wave 5s ease-out infinite;
}

.auth-orbit__sphere {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--as-surface);
  box-shadow: 0 16px 32px -12px rgb(90 25 0 / 60%);
  opacity: 0;
  transform: scale(0);
}

.auth-orbit__sphere svg {
  width: 72%;
  height: 72%;
}

.auth-orbit__sphere path {
  fill: none;
  stroke: url('#authOkGradient') var(--auth-ok-to);
  stroke-width: 11;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

/* Estados del ingreso. */
.auth-screen[data-login='work'] .auth-orbit__logo {
  animation: auth-orbit-pulse 1s ease-in-out infinite;
}

.auth-screen[data-login='ok'] .auth-orbit__logo {
  animation: auth-orbit-hide 0.35s ease-in forwards;
}

.auth-screen[data-login='ok'] .auth-orbit__sphere {
  animation: auth-orbit-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

.auth-screen[data-login='ok'] .auth-orbit__sphere path {
  animation: auth-orbit-tick 0.45s 0.3s ease-out forwards;
}

.auth-screen[data-login='ok'] .auth-orbit__wave {
  border-width: 2px;
  border-color: rgb(255 255 255 / 80%);
  animation: auth-orbit-wave 0.9s 0.25s ease-out forwards;
}

.auth-screen[data-login='bad'] .auth-orbit__core {
  animation: auth-orbit-shake 0.45s;
}

.auth-screen[data-login='bad'] .auth-orbit__logo {
  animation: none;
}

@keyframes auth-orbit-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes auth-orbit-spin-back {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes auth-orbit-breathe {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

@keyframes auth-orbit-in {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
}

/* El único aro (22-nov-2026): sale de la «A» y se desvanece al llegar a los iconos de afuera (el núcleo mide 0,31 del disco). */
@keyframes auth-orbit-wave {
  from {
    opacity: 0.9;
    transform: scale(0.85);
  }
  to {
    opacity: 0;
    transform: scale(3.3);
  }
}

@keyframes auth-orbit-pulse {
  50% {
    opacity: 0.8;
    transform: scale(1.1);
  }
}

@keyframes auth-orbit-hide {
  to {
    opacity: 0;
    transform: scale(0.6);
  }
}

@keyframes auth-orbit-pop {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes auth-orbit-tick {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes auth-orbit-shake {
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

/* Quien pide menos movimiento ve todo quieto y el check de una vez, sin rebote ni onda. */
@media (prefers-reduced-motion: reduce) {
  .auth-orbit__core,
  .auth-orbit__halo,
  .auth-orbit__ring,
  .auth-orbit__chip,
  .auth-orbit__wave,
  .auth-orbit__logo {
    animation: none;
  }

  .auth-screen[data-login='ok'] .auth-orbit__logo {
    opacity: 0;
  }

  .auth-screen[data-login='ok'] .auth-orbit__sphere,
  .auth-screen[data-login='ok'] .auth-orbit__sphere path {
    animation: none;
    opacity: 1;
    transform: none;
    stroke-dashoffset: 0;
  }
}

/* Celular: no hay panel naranja; el botón «Entrar» se vuelve verde con un check (una forma, no solo color). */
@media (max-width: 840px) {
  .auth-screen[data-login='ok'] #loginSubmit {
    font-size: 0;
    border-color: transparent;
    background: linear-gradient(135deg, var(--auth-ok-from), var(--auth-ok-to));
    box-shadow:
      0 8px 18px color-mix(in srgb, var(--auth-ok-to) 30%, transparent),
      inset 0 1px rgb(255 255 255 / 25%);
  }

  .auth-screen[data-login='ok'] #loginSubmit > span {
    display: none;
  }

  .auth-screen[data-login='ok'] #loginSubmit::before {
    width: 16px;
    height: 8px;
    border-bottom: 3px solid var(--as-text-inverse);
    border-left: 3px solid var(--as-text-inverse);
    content: '';
    transform: translateY(-2px) rotate(-45deg);
  }
}
