:root {
  --chp-navy: #0b1f3a;
  --chp-navy-dark: #071527;
  --chp-gold: #f5c518;
  --chp-cream: #f4f2ee;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--chp-navy-dark);
  color: var(--chp-cream);
}

.hidden { display: none !important; }

/* --- Mensajes flash --- */

.chp-flashes {
  position: fixed;
  top: 16px;
  inset-inline: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100% - 32px));
  margin-inline: auto;
}

.chp-flash {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  transition: opacity 0.4s ease;
}

.chp-flash.is-saliendo { opacity: 0; }

.chp-flash-error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.chp-flash-info {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

.chp-login-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

/* --- Panel izquierdo: escenario con logo flotante --- */

.chp-login-left {
  position: relative;
  width: 52%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 120px 32px 64px;
  background: radial-gradient(ellipse 90% 70% at 50% 45%, #16335a 0%, var(--chp-navy) 50%, var(--chp-navy-dark) 100%);
  --mx: 0;
  --my: 0;
}

.chp-login-sweep {
  position: absolute;
  bottom: -10%;
  width: 40%;
  height: 130%;
  transform-origin: 50% 100%;
  filter: blur(14px);
  pointer-events: none;
  animation: chp-fade-in 2s ease both;
}
.chp-login-sweep--left {
  left: 0;
  background: linear-gradient(to top, rgba(245, 197, 24, 0.26), rgba(245, 197, 24, 0) 75%);
  clip-path: polygon(44% 100%, 56% 100%, 100% 0, 0 0);
  animation-name: chp-fade-in, chp-sweep-l;
  animation-duration: 2s, 9s;
  animation-iteration-count: 1, infinite;
  animation-timing-function: ease, ease-in-out;
}
.chp-login-sweep--right {
  right: 0;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 75%);
  clip-path: polygon(44% 100%, 56% 100%, 100% 0, 0 0);
  animation-name: chp-fade-in, chp-sweep-r;
  animation-duration: 2s, 11s;
  animation-iteration-count: 1, infinite;
  animation-timing-function: ease, ease-in-out;
}

.chp-login-particles,
.chp-login-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform: translate(calc(var(--mx) * 40px), calc(var(--my) * 40px));
  transition: transform 0.5s cubic-bezier(.22, .61, .36, 1);
}

.chp-login-particle {
  position: absolute;
  bottom: -20px;
  left: var(--chp-p-left, 50%);
  width: var(--chp-p-size, 3px);
  height: var(--chp-p-size, 3px);
  border-radius: 50%;
  background: var(--chp-p-color, var(--chp-gold));
  box-shadow: 0 0 10px var(--chp-p-color, var(--chp-gold));
  animation: chp-particle-float var(--chp-p-dur, 14s) linear var(--chp-p-delay, 0s) infinite;
}

.chp-login-star {
  position: absolute;
  top: var(--chp-s-top, 50%);
  left: var(--chp-s-left, 50%);
  width: 7px;
  height: 7px;
  background: #ffe3a3;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: chp-twinkle var(--chp-s-dur, 3.5s) ease-in-out var(--chp-s-delay, 0s) infinite;
}

.chp-login-bunting {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 80px;
  animation: chp-drop 1.2s cubic-bezier(.2, .9, .3, 1.2) 0.2s both;
  pointer-events: none;
}
.chp-login-bunting__linea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 36px;
}
.chp-login-bunting__flags {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 0 2%;
}
.chp-login-flag {
  display: block;
  width: clamp(16px, 2.2vw, 28px);
  height: clamp(22px, 3vw, 38px);
  margin-top: var(--chp-f-y, 2px);
  background: var(--chp-f-color, var(--chp-gold));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  animation: chp-swing var(--chp-f-dur, 3s) ease-in-out var(--chp-f-delay, 0s) infinite;
}

.chp-login-eyebrow {
  position: absolute;
  top: 64px;
  left: 28px;
  width: min(270px, 46vw);
  height: auto;
  z-index: 3;
  animation: chp-fade-up 0.8s ease 0.4s both;
}

.chp-login-orbit-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translate(calc(var(--mx) * -26px), calc(var(--my) * -26px));
  transition: transform 0.5s cubic-bezier(.22, .61, .36, 1);
}

.chp-login-orbit {
  position: relative;
  width: min(480px, 84vw);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: chp-fade-in 1.2s ease 0.3s both;
}
.chp-login-orbit__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px dashed rgba(245, 197, 24, 0.3);
  animation: chp-spin 60s linear infinite;
}
.chp-login-orbit__ring--inner {
  inset: 12%;
  border: 1px solid rgba(244, 242, 238, 0.12);
  border-style: solid;
  animation: chp-spin-reverse 40s linear infinite;
}
.chp-login-orbit__dot {
  position: absolute;
  top: -5px;
  left: 50%;
  margin-left: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chp-gold);
  box-shadow: 0 0 14px var(--chp-gold);
}
.chp-login-orbit__glow {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 197, 24, 0.22), rgba(245, 197, 24, 0) 68%);
  filter: blur(10px);
  animation: chp-glow-pulse 5s ease-in-out infinite;
}

.chp-login-logo-float { position: relative; animation: chp-bob 7s ease-in-out infinite; }
.chp-login-logo-float img {
  display: block;
  width: min(340px, 62vw);
  height: auto;
  filter: drop-shadow(0 14px 34px rgba(0, 0, 0, 0.5));
}
.chp-login-logo-fallback {
  display: block;
  font-size: clamp(56px, 8vw, 88px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--chp-gold);
  line-height: 1;
}

.chp-login-divider {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  animation: chp-fade-up 0.9s ease 0.8s both;
}
.chp-login-divider__linea {
  display: block;
  width: 40px;
  height: 1px;
  background: linear-gradient(to right, rgba(245, 197, 24, 0), var(--chp-gold));
  transform-origin: right;
  animation: chp-grow 1s ease 1.1s both;
}
.chp-login-divider__linea--r {
  background: linear-gradient(to left, rgba(245, 197, 24, 0), var(--chp-gold));
  transform-origin: left;
}
.chp-login-divider__texto {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--chp-gold);
}

.chp-login-tagline {
  margin: 14px 0 0;
  max-width: 360px;
  font-size: 15px;
  font-weight: 300;
  line-height: 1.6;
  color: rgba(244, 242, 238, 0.72);
  animation: chp-fade-up 0.9s ease 1s both;
}

/* --- Panel derecho: tarjeta de vidrio --- */

.chp-login-right {
  position: relative;
  width: 48%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  overflow: hidden auto;
  background: linear-gradient(160deg, var(--chp-navy) 0%, var(--chp-navy-dark) 70%);
}
.chp-login-right::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(244, 242, 238, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.chp-login-right::after {
  content: "";
  position: absolute;
  top: -20%;
  right: -20%;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 197, 24, 0.12), rgba(245, 197, 24, 0) 65%);
  animation: chp-glow-pulse 7s ease-in-out infinite;
  pointer-events: none;
}

.chp-login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  padding: 44px 36px 32px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(22, 51, 90, 0.78), rgba(7, 21, 39, 0.82));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(244, 242, 238, 0.1);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(244, 242, 238, 0.08);
  text-align: center;
  /* Sin "opacity: 0" fijo: el fill-mode "both" ya la oculta durante la
     demora. Con opacity fija, si el celular tiene las animaciones
     desactivadas (prefers-reduced-motion) la tarjeta quedaba invisible. */
  animation: chp-card-in 1s cubic-bezier(.2, .8, .2, 1) 0.3s both;
}

.chp-login-accent {
  position: absolute;
  top: 0;
  left: 36px;
  right: 36px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--chp-gold), #ffe3a3, var(--chp-gold));
  background-size: 200% 100%;
  animation: chp-accent-slide 5s linear infinite;
}

.chp-login-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid rgba(245, 197, 24, 0.4);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: rgba(245, 197, 24, 0.06);
  color: var(--chp-cream);
  animation: chp-fade-up 0.7s ease 0.6s both;
}
.chp-login-badge__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chp-gold);
  animation: chp-pulse-ring 2.2s ease-out infinite;
}

.chp-login-title {
  margin: 18px 0 6px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--chp-cream);
  animation: chp-fade-up 0.7s ease 0.7s both;
}
.chp-login-subtitle {
  margin: 0 0 30px;
  font-size: 14px;
  font-weight: 300;
  color: rgba(244, 242, 238, 0.7);
  animation: chp-fade-up 0.7s ease 0.8s both;
}

.chp-login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
}

.chp-login-field.f1 { animation: chp-fade-up 0.7s ease 0.9s both; }
.chp-login-field.f2 { animation: chp-fade-up 0.7s ease 1s both; }

.chp-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(244, 242, 238, 0.75);
}

.chp-input-group { position: relative; display: block; }
.chp-input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  transform: none;
  color: var(--chp-gold);
  opacity: 0.8;
  pointer-events: none;
}
.chp-input {
  width: 100%;
  box-sizing: border-box;
  height: 52px;
  padding: 0 16px 0 44px;
  border-radius: 14px;
  border: 1px solid rgba(244, 242, 238, 0.14);
  background: rgba(10, 18, 34, 0.6);
  color: var(--chp-cream);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.chp-input:focus {
  border-color: var(--chp-gold);
  box-shadow: 0 0 0 4px rgba(245, 197, 24, 0.15);
  background: rgba(10, 18, 34, 0.85);
}
.chp-input::placeholder { color: rgba(244, 242, 238, 0.35); }
.chp-input-group.has-toggle .chp-input { padding-right: 52px; }

.chp-input-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  margin-top: -20px;
  transform: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(244, 242, 238, 0.6);
  cursor: pointer;
  transition: all 0.2s ease;
}
.chp-input-toggle:hover {
  color: var(--chp-gold);
  background: rgba(245, 197, 24, 0.1);
}

.chp-login-forgot {
  display: block;
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--chp-gold);
  cursor: help;
  transition: color 0.2s ease;
}
.chp-login-forgot:hover { color: #ffe3a3; }

.chp-login-submit {
  position: relative;
  overflow: hidden;
  margin-top: 6px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(120deg, var(--chp-gold) 0%, #ffe3a3 50%, var(--chp-gold) 100%);
  background-size: 200% 100%;
  color: var(--chp-navy-dark);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 14px 30px -12px rgba(245, 197, 24, 0.7);
  transition: background-position 0.5s ease, transform 0.2s ease, box-shadow 0.25s ease;
  animation: chp-fade-up 0.7s ease 1.1s both;
}
.chp-login-submit:hover {
  background-position: 100% 0;
  transform: translateY(-2px);
  box-shadow: 0 20px 40px -14px rgba(245, 197, 24, 0.85);
}
.chp-login-submit:active { transform: translateY(0) scale(0.98); }
.chp-login-submit .chp-sheen {
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: chp-sheen 3.4s ease-in-out infinite;
  pointer-events: none;
}
.chp-login-submit__label { position: relative; }
.chp-login-submit svg { position: relative; width: 16px; height: 16px; }

.chp-login-back {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid rgba(244, 242, 238, 0.08);
  display: flex;
  justify-content: center;
  animation: chp-fade-in 0.8s ease 1.3s both;
}
.chp-login-back a {
  font-size: 13px;
  color: rgba(244, 242, 238, 0.6);
  transition: color 0.2s ease;
}
.chp-login-back a:hover { color: var(--chp-gold); }

@keyframes chp-fade-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes chp-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes chp-card-in { from { opacity: 0; transform: translateY(30px) rotateX(12deg) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes chp-sweep-l { 0%, 100% { transform: rotate(-34deg); } 50% { transform: rotate(-10deg); } }
@keyframes chp-sweep-r { 0%, 100% { transform: rotate(34deg); } 50% { transform: rotate(10deg); } }
@keyframes chp-swing { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes chp-drop { from { transform: translateY(-120%); } to { transform: translateY(0); } }
@keyframes chp-particle-float { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-110vh) scale(1); opacity: 0; } }
@keyframes chp-twinkle { 0%, 100% { opacity: .15; transform: scale(.6); } 50% { opacity: 1; transform: scale(1); } }
@keyframes chp-spin { to { transform: rotate(360deg); } }
@keyframes chp-spin-reverse { to { transform: rotate(-360deg); } }
@keyframes chp-glow-pulse { 0%, 100% { opacity: .55; transform: scale(1); } 50% { opacity: .95; transform: scale(1.06); } }
@keyframes chp-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes chp-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes chp-accent-slide { from { background-position: 0% 0; } to { background-position: 200% 0; } }
@keyframes chp-sheen { 0% { transform: translateX(-160%) skewX(-18deg); } 55%, 100% { transform: translateX(320%) skewX(-18deg); } }
@keyframes chp-pulse-ring { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 197, 24, .45); } 50% { box-shadow: 0 0 0 12px rgba(245, 197, 24, 0); } }
@keyframes chp-spin-loading { to { transform: rotate(360deg); } }

/* Celular vertical y también horizontal (poca altura): una sola columna,
   la mascota arriba en una franja corta y el formulario debajo con scroll. */
@media (max-width: 768px), (max-height: 500px) {
  .chp-login-shell { flex-direction: column; }
  .chp-login-left { width: 100%; min-height: 0; height: clamp(220px, 36vh, 320px); padding: 64px 24px 24px; }
  .chp-login-right { width: 100%; min-height: auto; flex: 1; padding: 28px 20px max(40px, env(safe-area-inset-bottom)); overflow: hidden; }
  .chp-login-orbit { width: min(280px, 64vw, 60vh); }
  .chp-login-logo-float img { width: min(220px, 50vw, 44vh); }
  .chp-login-eyebrow { display: none; }
  .chp-login-tagline { display: none; }
  .chp-login-divider { display: none; }
  .chp-login-card { padding: 2rem 1.5rem; border-radius: 22px; }
  .chp-login-accent { left: 24px; right: 24px; }
  .chp-input { font-size: 16px; } /* 16px evita que iOS haga zoom al enfocar */
}

@media (max-width: 420px) {
  .chp-login-right { padding: 20px 14px 32px; }
  .chp-login-card { padding: 1.75rem 1.1rem 1.5rem; }
  .chp-login-title { font-size: 28px; margin-top: 14px; }
  .chp-login-subtitle { margin-bottom: 22px; }
  .chp-login-badge { font-size: 10px; letter-spacing: 0.16em; }
  .chp-login-flag { width: 14px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .chp-login-sweep, .chp-login-particle, .chp-login-star, .chp-login-bunting, .chp-login-flag,
  .chp-login-orbit__ring, .chp-login-orbit__glow, .chp-login-logo-float, .chp-login-divider__linea,
  .chp-login-card, .chp-login-accent, .chp-login-badge__dot, .chp-login-submit .chp-sheen, .chp-login-right::after,
  .chp-login-field, .chp-login-badge, .chp-login-title, .chp-login-subtitle, .chp-login-submit, .chp-login-back,
  .chp-login-orbit, .chp-login-divider, .chp-login-tagline, .chp-login-eyebrow {
    animation: none;
  }
}
