/* ─── Phix · Zepo Intelligence ────────────────────────────────────────────
   Paleta de zepo.ai: navy profundo + azul eléctrico + cian neón (el de la
   camiseta de Phix). Plus Jakarta Sans, como la web de Zepo. El centro de la
   experiencia es Phix: su retrato respira, escucha con anillos de sonar cian
   y se enciende cuando habla. */

:root {
  --navy: #070e34;
  --navy-deep: #0b0e21;
  --navy-soft: #131629;
  --navy-line: #212460;
  --blue: #142cd1;
  --cyan: #7be9e4;
  --ice: #f3f7ff;
  --ice-dim: #9aa7c7;
  --line: rgba(123, 233, 228, 0.16);
  --err: #ff7a8a;
  --font-ui: "Plus Jakarta Sans", sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--navy-deep);
  color: var(--ice);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* atmósfera: glow azul/cian + retícula técnica sutil */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(
      75% 60% at 50% -15%,
      rgba(20, 44, 209, 0.5) 0%,
      transparent 60%
    ),
    radial-gradient(
      50% 45% at 85% 110%,
      rgba(123, 233, 228, 0.12) 0%,
      transparent 55%
    ),
    radial-gradient(
      40% 40% at 8% 95%,
      rgba(20, 44, 209, 0.25) 0%,
      transparent 60%
    ),
    var(--navy-deep);
}
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(123, 233, 228, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(123, 233, 228, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(70% 65% at 50% 40%, black 0%, transparent 100%);
}

.view[hidden] {
  display: none;
}

.view {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--cyan);
}

.avatar {
  display: block;
  object-fit: cover;
}
.avatar-chip {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(
    circle at 50% 35%,
    #1c2b8a 0%,
    var(--navy-soft) 75%
  );
  border: 1px solid var(--line);
  box-shadow: 0 6px 26px rgba(20, 44, 209, 0.45);
}
.avatar--sm {
  width: 100%;
  height: 100%;
  /* la cara ocupa el ~14% superior del PNG: primero translate, después scale */
  transform: scale(2.6) translateY(36%);
}

/* ─── Puerta de acceso ─── */

.gate-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.4rem;
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.gate-title {
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  animation: rise 0.7s 0.08s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.gate-title em {
  font-style: normal;
  background: linear-gradient(100deg, var(--cyan) 20%, #4f6bff 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gate-sub {
  margin-top: 1.2rem;
  max-width: 36rem;
  color: var(--ice-dim);
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.6;
  animation: rise 0.7s 0.16s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.gate-sub strong {
  color: var(--ice);
  font-weight: 700;
}

.code-form {
  margin-top: 2.6rem;
  display: flex;
  gap: 0.7rem;
  align-items: stretch;
  animation: rise 0.7s 0.24s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.code-input {
  width: 16ch;
  padding: 0.95rem 1.1rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  text-indent: 0.25em;
  color: var(--ice);
  background: rgba(19, 22, 41, 0.85);
  border: 1px solid var(--navy-line);
  border-radius: 12px;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.code-input::placeholder {
  color: rgba(154, 167, 199, 0.4);
  letter-spacing: 0.4em;
}
.code-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(123, 233, 228, 0.12);
}

.code-form.is-error .code-input {
  border-color: var(--err);
  animation: shake 0.4s;
}
@keyframes shake {
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(3px);
  }
}

.btn-enter {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.5rem;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(120deg, var(--blue) 0%, #3550f0 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(20, 44, 209, 0.45);
  transition:
    transform 0.15s,
    box-shadow 0.2s,
    filter 0.2s;
}
.btn-enter:hover {
  transform: translateY(-1px);
  filter: brightness(1.12);
  box-shadow: 0 14px 36px rgba(20, 44, 209, 0.55);
}
.btn-enter:active {
  transform: translateY(0);
}
.btn-enter[disabled] {
  opacity: 0.55;
  cursor: wait;
}
.btn-arrow {
  transition: transform 0.2s;
}
.btn-enter:hover .btn-arrow {
  transform: translateX(3px);
}

.gate-error {
  min-height: 1.4rem;
  margin-top: 1rem;
  color: var(--err);
  font-size: 0.92rem;
  font-weight: 600;
}

.gate-foot {
  position: absolute;
  bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ice-dim);
}
.dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cyan);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Conversación ─── */

.stage-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.6rem 2rem;
}

.btn-end {
  padding: 0.55rem 1.2rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ice);
  background: transparent;
  border: 1px solid var(--navy-line);
  border-radius: 999px;
  cursor: pointer;
  transition:
    border-color 0.2s,
    color 0.2s,
    background 0.2s;
}
.btn-end:hover {
  border-color: var(--err);
  color: var(--err);
  background: rgba(255, 122, 138, 0.07);
}

.orb-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.1rem;
}

.presence {
  position: relative;
  width: clamp(190px, 34vmin, 290px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.presence-frame {
  width: 76%;
  height: 76%;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(
    circle at 50% 30%,
    #2440c9 0%,
    #101740 70%,
    var(--navy-deep) 100%
  );
  border: 1px solid rgba(123, 233, 228, 0.35);
  box-shadow:
    0 0 50px rgba(20, 44, 209, 0.55),
    0 0 110px rgba(123, 233, 228, 0.12),
    inset 0 -18px 40px rgba(7, 14, 52, 0.6);
  transition:
    box-shadow 0.4s,
    filter 0.4s;
  animation: breathe 4.6s ease-in-out infinite;
}

.avatar--lg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* encuadre cara + hombros */
  transform: scale(2) translateY(30%);
}

.ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(123, 233, 228, 0.55);
  border-radius: 50%;
  opacity: 0;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.97);
  }
  50% {
    transform: scale(1.02);
  }
}

/* conectando */
.presence[data-state="connecting"] .presence-frame {
  animation: breathe 1.5s ease-in-out infinite;
  filter: saturate(0.5) brightness(0.75);
}

/* escuchando: sonar cian */
.presence[data-state="listening"] .ring {
  animation: sonar 2.4s ease-out infinite;
}
.presence[data-state="listening"] .ring-2 {
  animation-delay: 0.8s;
}
.presence[data-state="listening"] .ring-3 {
  animation-delay: 1.6s;
}
@keyframes sonar {
  0% {
    transform: scale(0.84);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* hablando: Phix se enciende */
.presence[data-state="speaking"] .presence-frame {
  animation: speak 0.6s ease-in-out infinite;
  box-shadow:
    0 0 70px rgba(123, 233, 228, 0.45),
    0 0 160px rgba(20, 44, 209, 0.6),
    inset 0 -18px 40px rgba(7, 14, 52, 0.6);
}
@keyframes speak {
  0%,
  100% {
    transform: scale(0.98);
  }
  35% {
    transform: scale(1.04);
  }
  65% {
    transform: scale(1);
  }
}

.status {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ice-dim);
}
.presence[data-state="speaking"] + .status {
  color: var(--cyan);
}

.stage-foot {
  position: absolute;
  bottom: 2rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ice-dim);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

@media (max-width: 560px) {
  .code-form {
    flex-direction: column;
    width: 100%;
    max-width: 20rem;
  }
  .code-input {
    width: 100%;
    text-align: center;
  }
  .btn-enter {
    justify-content: center;
    padding: 0.9rem 1.4rem;
  }
}
