/* ==========================================================================
   Peret Project · Briefing
   Tokens de diseño en :root. Tema oscuro, acento violeta, plateado del logo.
   ========================================================================== */

:root {
  /* Color */
  --bg: #0b0b0f;
  --surface: #15151c;
  --surface-2: #1c1c25;
  --border: #2a2a36;
  --text: #f2f2f5;
  --muted: #9a9cab;
  --silver: #c9ccd3;
  --accent: #7c5cff;
  --accent-2: #a594ff;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --danger: #ff6b7a;
  --whatsapp: #25d366;

  /* Tipografía */
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-eyebrow: 0.875rem;
  --fs-body: 1rem;
  --fs-field: clamp(1.25rem, 3.6vw, 1.625rem);
  --fs-title: clamp(1.5rem, 4.6vw, 2.25rem);
  --fs-hero: clamp(2rem, 7vw, 3.5rem);

  /* Forma y espacio */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --content-w: 680px;
  --gutter: 20px;

  /* Movimiento */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.5s;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

a {
  color: var(--accent-2);
}

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Fondo: humo animado (guiño al halo del logo) ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg::after {
  /* viñeta para que el centro respire */
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, var(--bg) 85%);
}

.bg__smoke {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: drift 28s ease-in-out infinite alternate;
}

.bg__smoke--1 {
  top: -30vmax;
  left: -20vmax;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.35), transparent 65%);
}

.bg__smoke--2 {
  bottom: -35vmax;
  right: -25vmax;
  background: radial-gradient(circle, rgba(201, 204, 211, 0.12), transparent 65%);
  animation-duration: 34s;
  animation-delay: -10s;
}

.bg__smoke--3 {
  top: 20%;
  left: 40%;
  width: 45vmax;
  height: 45vmax;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.12), transparent 65%);
  animation-duration: 40s;
  animation-delay: -20s;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(8vmax, 6vmax, 0) scale(1.15);
  }
}

/* ---------- Cabecera y progreso ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  padding: calc(var(--space-2) + env(safe-area-inset-top)) var(--gutter) var(--space-2);
  background: linear-gradient(var(--bg) 40%, transparent);
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--silver);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.topbar__brand img {
  width: 36px;
  height: 36px;
}

body[data-screen='welcome'] .topbar__brand {
  visibility: hidden;
}

.progress {
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
}

.progress__bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--silver));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease);
}

/* ---------- Escenario ---------- */

.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(88px + env(safe-area-inset-top)) var(--gutter) calc(96px + env(safe-area-inset-bottom));
}

.screen {
  width: 100%;
  max-width: var(--content-w);
}

.enter-next {
  animation: enter-next var(--dur) var(--ease) both;
}

.enter-prev {
  animation: enter-prev var(--dur) var(--ease) both;
}

@keyframes enter-next {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
}

@keyframes enter-prev {
  from {
    opacity: 0;
    transform: translateY(-40px);
  }
}

.noscript {
  max-width: var(--content-w);
  color: var(--muted);
  text-align: center;
}

/* ---------- Botones ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1.0625rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn svg {
  width: 1.15em;
  height: 1.15em;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 30px -10px rgba(124, 92, 255, 0.7);
}

.btn--primary:hover {
  background: #8c70ff;
}

.btn--primary:disabled {
  opacity: 0.7;
  cursor: progress;
}

.btn--primary.is-loading svg {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--silver);
}

.btn--ghost:hover,
.btn--ghost[aria-pressed='true'] {
  border-color: var(--silver);
  color: var(--text);
}

.btn--link {
  min-height: 44px;
  padding: 0.5rem 0;
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn--link:hover {
  color: var(--text);
}

.btn--whatsapp {
  background: var(--whatsapp);
  color: #062b14;
  box-shadow: 0 8px 30px -10px rgba(37, 211, 102, 0.6);
}

.btn--whatsapp svg {
  fill: currentColor;
  stroke: none;
  width: 1.35em;
  height: 1.35em;
}

.btn--whatsapp:hover {
  background: #3ae27a;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

kbd {
  font-family: inherit;
  font-weight: 600;
  color: var(--silver);
}

/* En táctil no hay atajos de teclado: fuera pistas y letras */
@media (pointer: coarse) {
  .hint--desktop,
  .opt__key {
    display: none;
  }
}

/* ---------- Bienvenida ---------- */

.welcome {
  text-align: center;
}

.welcome__logo {
  /* el PNG tiene mucho margen transparente alrededor del halo */
  width: min(360px, 88vw);
  height: auto;
  margin: -12% auto -9%;
}

.welcome__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.welcome__title span {
  background: linear-gradient(90deg, var(--accent-2), var(--silver));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.welcome__lead {
  max-width: 30rem;
  margin: var(--space-2) auto 0;
  color: var(--muted);
  font-size: 1.125rem;
}

.welcome .actions {
  justify-content: center;
}

.welcome__time {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: var(--space-3) 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.welcome__time svg {
  width: 16px;
  height: 16px;
}

.welcome .btn--link {
  display: block;
  margin: var(--space-1) auto 0;
}

/* ---------- Pregunta ---------- */

.q__eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 var(--space-1);
  color: var(--accent-2);
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.q__num {
  font-family: var(--font-display);
}

.q__arrow {
  color: var(--muted);
}

.q__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.q__title:focus {
  outline: none;
}

.q__req {
  margin-left: 0.2em;
  color: var(--accent-2);
}

.q__help {
  margin: var(--space-1) 0 0;
  color: var(--muted);
}

.q__body {
  margin-top: var(--space-3);
}

.q__error {
  min-height: 1.5em;
  margin: var(--space-1) 0 0;
  color: var(--danger);
  font-size: 0.95rem;
}

.q__error:empty {
  min-height: 0;
}

.shake {
  animation: shake 0.4s var(--ease);
}

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

/* ---------- Campos de texto ---------- */

.field {
  display: block;
  width: 100%;
  padding: 0.5rem 0;
  border: 0;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  background: transparent;
  font-size: var(--fs-field);
  transition: border-color 0.2s;
}

.field::placeholder {
  color: #565867;
}

.field:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.field--area {
  resize: none;
  min-height: 3.2em;
  max-height: 40vh;
  line-height: 1.4;
}

.field--sub {
  margin: var(--space-1) 0 var(--space-1) 3.25rem;
  width: calc(100% - 3.25rem);
  font-size: 1.125rem;
}

.field[type='date'] {
  max-width: 16rem;
}

.field[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.6;
  cursor: pointer;
}

/* ---------- Opciones ---------- */

.options {
  display: grid;
  gap: 0.6rem;
  max-width: 28rem;
}

.options--grid {
  max-width: none;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 52px;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(21, 21, 28, 0.75);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, background-color 0.2s, transform 0.15s var(--ease);
}

.opt:hover {
  border-color: #3d3d4d;
  background: var(--surface-2);
}

.opt:active {
  transform: scale(0.985);
}

.opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.opt__key {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  transition: inherit;
}

.opt__label {
  flex: 1;
}

.opt__check {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--accent-2);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.25s var(--ease);
}

.opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.opt:has(input:checked) .opt__key {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.opt:has(input:checked) .opt__check {
  opacity: 1;
  transform: none;
}

.opt:has(input:focus-visible) {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

/* Casilla de consentimiento */
.opt--consent {
  align-items: flex-start;
  max-width: 36rem;
  padding: 1rem;
}

.opt__box {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.05rem;
  border: 1.5px solid var(--silver);
  border-radius: 6px;
  transition: background-color 0.2s, border-color 0.2s;
}

.opt__box svg {
  width: 16px;
  height: 16px;
  color: #fff;
  stroke-width: 3;
  opacity: 0;
}

.opt--consent:has(input:checked) .opt__box {
  border-color: var(--accent);
  background: var(--accent);
}

.opt--consent:has(input:checked) .opt__box svg {
  opacity: 1;
}

/* Honeypot anti-spam: invisible para personas */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Campo libre bajo las opciones ("¿Alguna más?") */
.extra {
  display: block;
  margin-top: var(--space-3);
}

.extra__label {
  display: block;
  color: var(--silver);
  font-weight: 500;
}

.extra .field {
  font-size: 1.125rem;
}

/* ---------- Navegación inferior ---------- */

.stepper {
  position: fixed;
  right: var(--gutter);
  bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(21, 21, 28, 0.85);
  backdrop-filter: blur(10px);
}

.stepper[hidden] {
  display: none;
}

.stepper__btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 44px;
  border: 0;
  background: none;
  color: var(--silver);
  cursor: pointer;
}

.stepper__btn + .stepper__btn {
  border-left: 1px solid var(--border);
}

.stepper__btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.stepper__btn svg {
  width: 20px;
  height: 20px;
}

/* ---------- Pantalla final ---------- */

.done {
  text-align: center;
}

.done__icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-3);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.4), 0 0 60px -10px var(--accent);
}

.done__icon svg {
  width: 34px;
  height: 34px;
  stroke-width: 2.5;
}

.done__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  line-height: 1.1;
}

.done__title:focus {
  outline: none;
}

.done__lead {
  margin: var(--space-2) auto 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 1.125rem;
}

.done__card {
  margin: var(--space-4) auto 0;
  max-width: 30rem;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(21, 21, 28, 0.8);
}

.done__card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.done__card p {
  margin: var(--space-1) 0 var(--space-3);
  color: var(--silver);
}

.done__card .btn {
  width: 100%;
}

/* ---------- Móvil ---------- */

@media (max-width: 600px) {
  :root {
    --gutter: 16px;
  }

  .stage {
    place-items: start center;
    padding-top: calc(96px + env(safe-area-inset-top));
  }

  body[data-screen='welcome'] .stage,
  body[data-screen='done'] .stage {
    place-items: center;
  }

  .actions .btn--primary {
    flex: 1 1 auto;
  }

  .stepper {
    bottom: calc(var(--space-1) + env(safe-area-inset-bottom));
  }
}

/* ---------- Movimiento reducido ---------- */

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