/* Página de inicio de NoelyQuest (v10.0.0): lo único público. Gráficos del juego preparados por
   tools/inicio/preparar.py. Sin estilos en línea en el HTML (para una CSP estricta). */

@font-face {
  font-family: "Source Sans 3";
  src: url("/inicio/fuentes/SourceSans3.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: "Silkscreen";
  src: url("/inicio/fuentes/slkscr.ttf") format("truetype");
  font-display: swap;
}

:root {
  --cian: #10abff;
  --cian-suave: rgba(16, 171, 255, 0.35);
  --oro: #f4c45a;
  --texto: #eef3ff;
  --texto-suave: #9fb2d6;
  --error: #ff7a8a;
  --caja: linear-gradient(160deg, rgba(14, 22, 44, 0.92) 0%, rgba(4, 8, 20, 0.96) 100%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #05070d;
  color: var(--texto);
  font-family: "Source Sans 3", system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100dvh;
}

button,
input {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ───── El paisaje ───── */

#escena {
  position: fixed;
  inset: 0;
  overflow: hidden;
  transition: transform 1.1s cubic-bezier(.6, 0, .8, .2), filter 1.1s ease-in;
}

#fondos,
.fondo,
#luces,
#vineta {
  position: absolute;
  inset: 0;
}

.fondo {
  background: center 62% / cover no-repeat;
  opacity: 0;
  transition: opacity 2.6s ease-in-out;
  transform: scale(1.14) translateX(3.5%);
  will-change: transform, opacity;
}

.fondo.activo {
  opacity: 1;
  animation: viaje 13s linear forwards;
}

/* El fondo se desliza despacio: el viaje por los escenarios del juego */
@keyframes viaje {
  from { transform: scale(1.14) translateX(3.5%); }
  to { transform: scale(1.14) translateX(-3.5%); }
}

#luces {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#vineta {
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 35%, rgba(2, 4, 10, 0.55) 100%),
    linear-gradient(to bottom, rgba(2, 4, 10, 0.35) 0%, transparent 22%, transparent 70%, rgba(2, 4, 10, 0.6) 100%);
}

/* ───── El sello de la puerta (el SVG lo dibuja inicio.js) ───── */

/* Tumbado en el suelo: un círculo visto en perspectiva */
#sello {
  position: absolute;
  left: 50%;
  top: 80%;
  width: min(84vw, 660px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) perspective(1100px) rotateX(70deg);
  pointer-events: none;
  opacity: 0.92;
  transition: opacity 0.8s, transform 1.1s cubic-bezier(.5, 0, .7, .4), filter 0.8s;
}

#sello svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

#sello .giro {
  transform-box: view-box;
  transform-origin: 100px 100px;
}

#sello .ext { animation: girar 70s linear infinite; }
#sello .med { animation: girar 46s linear infinite reverse; }
#sello .int { animation: girar 24s linear infinite; }

@keyframes girar {
  to { transform: rotate(360deg); }
}

#sello .halo {
  fill: none;
  stroke: rgba(16, 171, 255, 0.28);
  stroke-width: 4;
}

#sello .linea {
  fill: none;
  stroke: #9fe2ff;
  stroke-width: 0.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#sello .oro .halo { stroke: rgba(244, 196, 90, 0.3); }
#sello .oro .linea { stroke: #ffd98a; }
#sello .punteado { stroke-dasharray: 1.5 4; }

#sello .nucleo {
  fill: url(#sello-nucleo);
  transform-box: view-box;
  transform-origin: 100px 100px;
  animation: pulso 3.2s ease-in-out infinite;
}

#sello .cerradura {
  fill: #0b1030;
  stroke: #ffd98a;
  stroke-width: 1.4;
}

@keyframes pulso {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.18); opacity: 1; }
}

/* El haz de luz que sube del sello */
#haz {
  position: absolute;
  left: 50%;
  bottom: 20%;
  width: min(34vw, 260px);
  height: 74vh;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  pointer-events: none;
  background: radial-gradient(ellipse 50% 100% at 50% 100%, rgba(190, 240, 255, 0.7), rgba(16, 171, 255, 0.22) 45%, transparent 75%);
  mix-blend-mode: screen;
  animation: latir-haz 5s ease-in-out infinite;
  transition: transform 1.1s cubic-bezier(.6, 0, .8, .3), opacity 0.6s;
}

#haz::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 9%;
  height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(to top, rgba(255, 255, 255, 0.8), rgba(190, 240, 255, 0.25) 55%, transparent);
  filter: blur(2px);
}

@keyframes latir-haz {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

/* Paso 2: la puerta responde, el sello brilla más */
body.puerta #sello {
  opacity: 1;
  filter: brightness(1.25) saturate(1.2);
}

/* ───── Portada ───── */

#portada {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(4vh, 16px) 16px 0;
  pointer-events: none;
  transition: opacity 0.7s, transform 0.9s cubic-bezier(.3, .7, .2, 1);
}

#portada h1 {
  margin: 0;
  line-height: 0;
}

#logo {
  width: min(78vw, 640px);
  max-height: 44vh;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 22px rgba(16, 171, 255, 0.35)) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.7));
  animation: flotar 6s ease-in-out infinite;
  transition: width 0.9s cubic-bezier(.3, .7, .2, 1), max-height 0.9s cubic-bezier(.3, .7, .2, 1);
}

@keyframes flotar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.2vh); }
}

#empezar {
  margin-top: min(4vh, 36px);
  pointer-events: auto;
  font-size: clamp(18px, 2.6vh, 24px);
  padding: 0.55em 1.4em 0.55em 1em;
  animation: latido 2.4s ease-in-out infinite;
}

@keyframes latido {
  0%, 100% { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), 0 0 12px var(--cian-suave); }
  50% { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), 0 0 30px rgba(16, 171, 255, 0.65); }
}

.pulsa {
  margin: 1.1em 0 0;
  font-family: "Silkscreen", monospace;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #e6eeff;
  text-shadow: 0 1px 2px #000, 0 0 8px #000, 0 0 14px rgba(0, 0, 0, 0.8);
  animation: parpadeo 1.6s steps(2, jump-none) infinite;
}

.pulsa .tactil {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .pulsa .teclado {
    display: none;
  }

  .pulsa .tactil {
    display: inline;
  }
}

@keyframes parpadeo {
  50% { opacity: 0.25; }
}

/* Paso 2: el logo sube y se hace pequeño, el botón se va */
body.puerta #logo {
  width: min(56vw, 360px);
  max-height: 24vh;
}

body.puerta #empezar,
body.puerta .pulsa {
  opacity: 0;
  pointer-events: none;
  transform: translateY(2vh);
  transition: opacity 0.4s, transform 0.4s;
}

/* ───── Botones (como los del juego: caja oscura con borde cian) ───── */

.boton {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  border: 2px solid var(--cian);
  border-radius: 10px;
  background: var(--caja);
  color: var(--texto);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.5em 1.2em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), 0 0 12px var(--cian-suave);
  transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s, opacity 0.2s;
}

.boton:hover,
.boton:focus-visible {
  outline: none;
  border-color: #7fd6ff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), 0 0 26px rgba(16, 171, 255, 0.7);
}

.boton:active {
  transform: translateY(1px) scale(0.98);
}

.boton:disabled {
  cursor: wait;
  opacity: 0.85;
}

.boton.secundario {
  border-color: rgba(159, 178, 214, 0.5);
  color: var(--texto-suave);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font-weight: 400;
}

/* La moneda del menú del juego como cursor: gira (11 fotogramas) */
.moneda {
  flex: none;
  width: 1.1em;
  height: 1.1em;
  background: url("/inicio/img/moneda.webp") 0 0 / 1100% 100% no-repeat;
  animation: moneda 0.9s steps(10, jump-none) infinite;
}

@keyframes moneda {
  to { background-position: 100% 0; }
}

/* ───── La ventana de entrar ───── */

#ventana {
  position: fixed;
  left: 50%;
  top: 56%;
  width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  animation: abrir 0.55s cubic-bezier(.2, .9, .3, 1.15) both;
}

@keyframes abrir {
  from { opacity: 0; transform: translate(-50%, -40%) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#entrar {
  position: relative;
  padding: 22px 24px 20px;
  border: 3px solid var(--cian);
  border-radius: 14px;
  background: var(--caja);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.75), 0 0 28px var(--cian-suave), inset 0 0 18px rgba(16, 171, 255, 0.12);
  backdrop-filter: blur(3px);
}

/* Brillo que recorre el borde de arriba */
#entrar::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #bfeaff, transparent);
  opacity: 0.8;
}

#entrar h2 {
  margin: 0 0 16px;
  font-size: 21px;
  font-weight: 700;
  text-align: center;
  color: var(--oro);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8), 0 0 14px rgba(244, 196, 90, 0.35);
}

.campo {
  position: relative;
  display: block;
  margin-bottom: 14px;
  padding-left: 26px;
}

.campo .moneda {
  position: absolute;
  left: 0;
  bottom: 9px;
  width: 20px;
  height: 20px;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s, transform 0.2s;
}

.campo:focus-within .moneda {
  opacity: 1;
  transform: none;
}

.etiqueta {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--texto-suave);
  letter-spacing: 0.04em;
}

.campo input {
  width: 100%;
  padding: 9px 12px;
  border: 2px solid rgba(16, 171, 255, 0.35);
  border-radius: 8px;
  background: rgba(2, 6, 16, 0.75);
  color: var(--texto);
  font-size: 17px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.campo input:focus {
  outline: none;
  border-color: var(--cian);
  box-shadow: 0 0 12px var(--cian-suave), inset 0 0 6px rgba(16, 171, 255, 0.2);
}

#aviso {
  min-height: 1.3em;
  margin: 2px 0 10px 26px;
  font-size: 15px;
  color: var(--error);
  text-shadow: 0 1px 2px #000;
}

.acciones {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

#enviar .moneda {
  display: none;
}

#enviar:disabled .moneda {
  display: block;
  animation-duration: 0.35s;
}

#ventana.temblor {
  animation: temblor 0.42s;
}

@keyframes temblor {
  0%, 100% { transform: translate(-50%, -50%); }
  20% { transform: translate(calc(-50% - 10px), -50%); }
  40% { transform: translate(calc(-50% + 9px), -50%); }
  60% { transform: translate(calc(-50% - 6px), -50%); }
  80% { transform: translate(calc(-50% + 4px), -50%); }
}

/* ───── Al entrar: el haz se abre, el sello se desata y la pantalla se rompe en un destello ───── */

#destello {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

body.saliendo #ventana,
body.saliendo #portada {
  opacity: 0;
  transition: opacity 0.35s;
}

body.saliendo #haz {
  transform: translateX(-50%) scaleX(7) scaleY(1.4);
}

body.saliendo #sello {
  transform: translate(-50%, -50%) perspective(1100px) rotateX(70deg) scale(1.5);
  filter: brightness(2.2);
}

body.saliendo #escena {
  transform: scale(1.6) rotate(7deg);
  filter: blur(7px) brightness(1.8);
}

body.saliendo #destello {
  animation: destello 1.15s ease-in forwards;
}

@keyframes destello {
  0% { opacity: 0; background: #fff; }
  55% { opacity: 0.9; background: #fff; }
  100% { opacity: 1; background: #05070d; }
}

/* ───── Mientras se comprueba si ya hay sesión: todo a negro ───── */

body.comprobando #escena,
body.comprobando #portada {
  opacity: 0;
}

#escena,
#portada {
  transition: opacity 1.2s ease, transform 1.1s cubic-bezier(.6, 0, .8, .2), filter 1.1s ease-in;
}

.sin-js {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 24px;
  text-align: center;
  font-size: 18px;
  text-shadow: 0 1px 3px #000;
}

/* ───── Pantallas bajas (móvil en horizontal): en el paso 2 solo la ventana ───── */

@media (max-height: 560px) {
    body.puerta #portada {
    opacity: 0;
  }

  #ventana {
    top: 50%;
  }

  #entrar {
    padding: 14px 18px;
  }

  #entrar h2 {
    margin-bottom: 8px;
    font-size: 18px;
  }

  .campo {
    margin-bottom: 8px;
  }
}

/* Móvil en vertical: la ventana un poco más abajo, bajo el logo */
@media (max-width: 600px) and (min-height: 561px) {
  #ventana {
    top: 54%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fondo.activo,
  #logo,
  #empezar,
  .pulsa,
  #haz,
  #sello .giro,
  #sello .nucleo {
    animation: none;
  }

  .fondo {
    transform: scale(1.05);
  }
}
