/* Jowell & Randy 3D — registro. El fondo es el mundo 3D (canvas.world); la UI toma del key visual
   del tour el panel azul con borde magenta, el botón lima con relieve y las gafas 3D rojo/cian.
   Tipografía limpia (Space Grotesk + Inter): la letra inflada del póster NO se usa. */

:root {
  --sky: #2a6fd6;
  --sky-light: #bfe6ff;
  --panel: #1a2fd0;
  --panel-deep: #13209c;
  --rim: #ff2fa8;
  --lime: #d9f24a;
  --lime-deep: #3e9b2a;
  --red: #ff3b3b;
  --cyan: #2fd3ff;
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.78);
  --line: rgba(255, 255, 255, 0.34);
  --error: #ffc2dc;
  --ok: #b8f24a;
  --radius: 14px;
  --gap: 16px;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100svh;
  background: #070b3a; /* negro-azul de TV apagada: se ve mientras la imagen se expande */
  color: var(--text);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-wrap: pretty;
}

h1, h2, p { margin: 0; }
h1, h2 { text-wrap: balance; }
a { color: inherit; }
[hidden], .d-none { display: none !important; }

/* ---------- mundo 3D ---------- */

.world, .world-fallback {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.world { display: block; }
.world-fallback {
  display: none;
  background:
    url("../img/world-poster.webp") center 40% / cover no-repeat,
    radial-gradient(60% 30% at 20% 22%, rgba(255, 255, 255, 0.9), transparent 70%),
    radial-gradient(50% 24% at 78% 14%, rgba(255, 255, 255, 0.85), transparent 70%),
    linear-gradient(180deg, var(--sky), var(--sky-light) 62%, #e08953 62%, #c9653c 82%, #1fc4d8 82%);
}
/* Dither suave del respaldo (el 3D lo hace en su post-proceso): matriz Bayer 8x8 en overlay */
.world-fallback::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAU0lEQVR4nAFIALf/AACBIKEIiSiqAMJA4mHKSOppADCyEJE4uhiZAPJx0lD6edpZAAyNLK4EhSSlAM5M7m3GROZlADy+HJ00thSVAP993l32ddZVOA8fw3HkPukAAAAASUVORK5CYII=") 0 0 / 16px 16px;
  image-rendering: pixelated;
  mix-blend-mode: overlay;
  opacity: 0.22;
}
.no-webgl .world { display: none; }
.no-webgl .world-fallback { display: block; }

/* ---------- pantallas ---------- */

.screen {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 480px);
  padding: 40px clamp(24px, 5vw, 80px);
  pointer-events: none;
}
.screen-content {
  grid-column: 2;
  display: grid;
  align-items: center;
  pointer-events: auto;
}

/* ---------- panel (banner del póster) ---------- */

.patch {
  position: relative;
  width: 100%;
  padding: 36px 34px 32px;
  border: 3px solid var(--rim);
  border-radius: 26px;
  background: linear-gradient(180deg, var(--panel), var(--panel-deep));
  box-shadow: 0 8px 0 #b01e75, 0 30px 60px -18px rgba(10, 20, 80, 0.6);
  text-align: center;
}

/* Wordmark: gafas 3D (desfase rojo/cian), letra limpia */
.wordmark {
  font: 700 clamp(30px, 2.6vw, 40px)/1 var(--font-display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: -2px 0 0 var(--red), 2px 0 0 var(--cyan);
}
.wordmark em { margin: 0 0.18em; font-style: normal; color: var(--lime); }
.wordmark-sm { font-size: clamp(24px, 2vw, 30px); }
.city-sessions { display: block; width: 156px; height: auto; margin: 0 auto 18px; }
.city-sessions-sm { width: 112px; margin: 22px auto 0; opacity: 0.9; }

.event-title {
  margin-top: 18px;
  font: 600 17px/1.3 var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.event-date { margin-top: 6px; color: var(--text-soft); font-size: 15px; }
.event-notice { margin-top: 20px; color: var(--text-soft); font-size: 12px; line-height: 1.5; }

.form-title, .ty-title {
  margin-top: 14px;
  font: 700 26px/1.1 var(--font-display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.ty-title:focus { outline: none; }
.ty-text { margin-top: 12px; color: var(--text-soft); }
.ty-text + .ty-text { margin-top: 8px; }

/* ---------- formulario ---------- */

.form { display: grid; gap: var(--gap); margin-top: 24px; text-align: left; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text-soft); }

.field-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: 400 16px/1 var(--font-body);
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
  appearance: none;
}
.field-input:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.6); }
.field-input:focus { outline: none; border-color: var(--lime); background: rgba(255, 255, 255, 0.12); }
.field-input:disabled { opacity: 0.65; }
.field-input.is-invalid { border-color: var(--error); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.8; cursor: pointer; }

.field-select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23fff' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  text-overflow: ellipsis;
}
.field-select option { background: var(--panel-deep); color: var(--text); }

.field-error { color: var(--error); font-size: 13px; }
.field-error:empty { display: none; }

.phone { display: grid; grid-template-columns: 112px 1fr; gap: 8px; }
.phone-lada { padding-right: 10px; background-image: none; }

.password { position: relative; }
.password .field-input { padding-right: 52px; }
.password-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-soft);
  cursor: pointer;
}
.password-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.password-toggle[aria-pressed="true"] { color: var(--lime); }

.pw-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--text-soft);
}
.pw-rules li { display: flex; align-items: center; gap: 6px; transition: color 0.2s var(--ease); }
.pw-rules li::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  transition: background-color 0.2s var(--ease);
}
.pw-rules li.is-met { color: var(--ok); }
.pw-rules li.is-met::before { background: var(--ok); }

.checks { display: grid; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-soft); cursor: pointer; }
.check a { color: #fff; text-underline-offset: 3px; }
.check input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  background: transparent;
  appearance: none;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.check input:checked { border-color: var(--lime); background: var(--lime); }
.check input:checked::after {
  content: "";
  width: 10px;
  height: 6px;
  border: solid #12360c;
  border-width: 0 0 2px 2px;
  transform: translateY(-1px) rotate(-45deg);
}

/* ---------- botón lima con relieve (etiquetas del póster) ---------- */

.btn {
  display: inline-grid;
  place-items: center;
  width: 100%;
  height: 54px;
  margin-top: 4px;
  border: 2px solid var(--lime-deep);
  border-radius: var(--radius);
  background: var(--lime);
  box-shadow: 0 5px 0 var(--lime-deep);
  color: #12360c;
  font: 700 15px/1 var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), opacity 0.2s var(--ease);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--lime-deep); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--lime-deep); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.screen-ty .btn { margin-top: 24px; }

:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }

/* ---------- preloader: TV sintonizando → encendido CRT ---------- */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 40%, #1a2fd0 0%, #0c1466 70%, #070b3a 100%);
  overflow: hidden;
}
/* Estática tenue + barrido de líneas */
.preloader-noise {
  position: absolute;
  inset: -50%;
  opacity: 0.12;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.4s steps(4) infinite;
}
.preloader::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.preloader-ui { position: relative; display: grid; justify-items: center; gap: 12px; transition: opacity 0.25s var(--ease); }
.preloader-eyebrow, .preloader-label {
  font: 400 12px/1 "Space Mono", ui-monospace, monospace;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}
.preloader-eyebrow .anaglyph { color: var(--lime); }
.preloader-label::after { content: "…"; animation: blink 1s steps(2) infinite; }
.preloader-count {
  font: 400 clamp(84px, 13vw, 150px)/1 "Space Mono", ui-monospace, monospace;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: -4px 0 0 var(--red), 4px 0 0 var(--cyan);
  animation: jitter 2.4s steps(1) infinite;
}
.anaglyph { text-shadow: -2px 0 0 var(--red), 2px 0 0 var(--cyan); }
.preloader-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  background: #fff;
  box-shadow: 0 0 30px 6px rgba(255, 255, 255, 0.75);
  transform: scaleX(0);
}
.is-tuned .preloader-ui, .is-ready .preloader-ui { opacity: 0; transition: none; }
.is-ready .preloader-line { transform: scaleX(1); }
.is-tuned .preloader-line { animation: crt-line 0.45s var(--ease) forwards; }
/* Encendido: el preloader se va de golpe y la imagen del mundo nace de la línea */
.is-ready .preloader { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.12s linear, visibility 0s linear 0.12s; }
.is-ready .world, .is-ready .world-fallback { animation: crt-on 0.8s cubic-bezier(0.2, 0.9, 0.25, 1) both; transform-origin: 50% 50%; }

@keyframes grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-5%, 3%); } 50% { transform: translate(4%, -4%); } 75% { transform: translate(-3%, -2%); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes jitter { 0%, 92% { transform: none; } 94% { transform: translateX(3px) skewX(-4deg); } 96% { transform: translateX(-2px); } }
@keyframes crt-line { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes crt-on {
  0% { transform: scale(1, 0.004); filter: brightness(8) saturate(0); }
  35% { transform: scale(1, 0.004); filter: brightness(6) saturate(0.3); }
  70% { transform: scale(1, 1.03); filter: brightness(1.6) saturate(1.2); }
  100% { transform: none; filter: none; }
}
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- entrada de pantallas (el email espera a que la cámara baje de las nubes) ---------- */

.is-ready .screen:not(.d-none) .patch { animation: rise 0.8s var(--ease) both; }
/* Arranque: ningún panel aparece mientras la imagen se abre (encendido CRT de 0.8 s) */
.is-booting .screen:not(.d-none) .patch { animation-delay: 0.85s; }
.is-booting .screen-email:not(.d-none) .patch { animation-delay: 1.2s; }
.is-loading .screen .patch, .is-tuned .screen .patch { opacity: 0; }

/* ---------- loader del registro ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 16, 70, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.loader-card {
  display: grid;
  justify-items: center;
  gap: 18px;
  max-width: 340px;
  padding: 32px 36px;
  border: 3px solid var(--rim);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 6px 0 #b01e75;
  text-align: center;
}
.loader-stitch { width: 48px; height: 48px; animation: spin 1s linear infinite; }
.loader-stitch circle { fill: none; stroke: var(--lime); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 60 100; }
.loader.is-message .loader-stitch { display: none; }

/* ---------- gracias (desktop): panel centrado arriba, TVs centradas debajo ---------- */

@media (min-width: 992px) {
  .screen-ty { grid-template-columns: minmax(0, 520px); justify-content: center; }
  .screen-ty .screen-content { grid-column: 1; align-items: start; padding-top: 7vh; }
}

/* ---------- registro (desktop): la cámara entra a la TV crema; el panel va centrado sobre la estática ---------- */

@media (min-width: 992px) {
  .screen-form { grid-template-columns: minmax(0, 520px); justify-content: center; }
  .screen-form .screen-content { grid-column: 1; }
}

/* Entrada a la TV: el panel espera a que la cámara llegue; al cruzar el vidrio, barrido de scanlines */
.is-diving .screen:not(.d-none) .patch { opacity: 0; animation: none; }
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px 4px),
    radial-gradient(70% 60% at 50% 50%, rgba(255, 255, 255, 0.35), transparent 70%);
}
.is-crossing body::after { animation: cross 0.26s ease-out both; }
@keyframes cross {
  0% { opacity: 0; transform: scaleY(1.06); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: none; }
}

/* ---------- firmas en las esquinas ---------- */

.marks {
  position: fixed;
  left: clamp(24px, 5vw, 88px);
  right: clamp(24px, 5vw, 88px);
  bottom: 28px;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}
.marks img { display: block; height: auto; }
.marks-jr { width: 128px; opacity: 0.95; filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.35)); }
.marks-partners { display: flex; align-items: center; gap: 22px; opacity: 0.85; filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.35)); }
.marks-amazon { width: 104px; }
.marks-stoyco { width: 58px; }
.is-loading .marks, .is-tuned .marks { opacity: 0; }
.is-ready .marks { animation: rise 0.8s var(--ease) both; }
.is-booting .marks { animation-delay: 1.2s; }

/* ---------- mobile: el mundo arriba, el panel abajo ----------
 * Correo y gracias caben en una pantalla (sin scroll): body en columna de 100svh, el panel se apoya
 * abajo y los logos quedan en el flujo debajo de él; lo que sobra arriba es el mundo 3D.
 * Registro (formulario largo): el panel arranca alto para ver la mayor parte y se scrollea natural;
 * los logos van fijos abajo sobre un degradado y se esconden mientras se escribe (teclado abierto). */

@media (max-width: 991px) {
  body { display: flex; flex-direction: column; }
  .screen {
    flex: 1 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0 16px 12px;
  }
  .screen-content { display: block; padding-top: 10svh; }
  .patch { padding: 22px 20px 20px; border-radius: 22px; }
  .city-sessions { width: 128px; margin-bottom: 12px; }
  .wordmark { font-size: 28px; }
  .wordmark-sm { font-size: 24px; }
  .event-title { margin-top: 12px; font-size: 15px; }
  .event-notice { margin-top: 14px; font-size: 11px; }
  .ty-title { margin-top: 10px; font-size: 22px; }
  .event-notice, .ty-text { text-wrap: balance; }

  .screen-form { justify-content: flex-start; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .screen-form .screen-content { padding-top: 12svh; }

  .marks { position: relative; left: auto; right: auto; bottom: auto; padding: 4px 18px max(14px, env(safe-area-inset-bottom)); }
  .marks-jr { width: 92px; }
  .marks-amazon { width: 78px; }
  .marks-stoyco { width: 46px; }

  body:has(#section-form:not(.d-none)) .marks {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding-top: 28px;
    background: linear-gradient(180deg, transparent, rgba(7, 11, 58, 0.85) 55%);
    transition: opacity 0.2s ease;
  }
  body:has(#section-form:not(.d-none)):has(.field-input:focus, select:focus) .marks { opacity: 0; }
}

/* Teléfonos bajos (SE / barras del navegador abiertas): panel más compacto para que el mundo asome */
@media (max-width: 991px) and (max-height: 600px) {
  .patch { padding: 18px 18px 16px; }
  .city-sessions { width: 104px; margin-bottom: 8px; }
  .wordmark { font-size: 24px; }
  .event-title { margin-top: 8px; font-size: 14px; }
  .form { margin-top: 12px; }
  .event-notice { margin-top: 10px; }
}

@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; }
  .phone { grid-template-columns: 96px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
}
