:root {
  --linen: #e9e3d8;
  --linen-dark: #ddd5c8;
  --card: #f8f5f0;
  --ink: #3f3633;
  --ink-soft: #7a6c66;
  --mauve: #c4a79c;
  --mauve-dark: #9c7c71;
  --title: #8a6a60;
  --line: #ded3c9;
  --gold: #b08d57;
  --error: #a3473a;
  --serif-display: "Cormorant Garamond", Georgia, serif;
  --serif: "Lora", Georgia, serif;
  --music: "Noto Music", "Segoe UI Symbol", "Apple Symbols", serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);

  /* Medidas fluidas: se adaptan solas entre celular (320px) y escritorio */
  --radius: clamp(16px, 3vw, 22px);
  --gutter: clamp(12px, 4vw, 32px);
  --pad-x: clamp(18px, 6vw, 52px);
  --pad-y: clamp(32px, 6vw, 52px);
  --corner: clamp(46px, 11vw, 74px);
  --field-gap: clamp(18px, 3vw, 24px);
  --tap: 48px; /* alto mínimo cómodo para tocar con el dedo */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
  line-height: 1.55;
  background-color: var(--linen);
  /* Textura de lino sutil */
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.18) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120,100,80,.05) 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at top, #f1ece4 0%, var(--linen) 60%, var(--linen-dark) 100%);
  background-attachment: fixed;
  /* Respeta el notch / bordes redondeados de los celulares */
  padding:
    max(clamp(20px, 5vw, 40px), env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(clamp(24px, 5vw, 44px), env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Animaciones compartidas ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes noteBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ---------- Notas flotantes de fondo ---------- */
.notes-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.bg-note {
  position: absolute;
  bottom: -60px;
  font-family: var(--music);
  color: var(--mauve-dark);
  opacity: 0;
  animation: floatUp linear infinite;
  will-change: transform, opacity;
}
@keyframes floatUp {
  0% { transform: translate(0, 0) rotate(0); opacity: 0; }
  10% { opacity: var(--alpha); }
  50% { transform: translate(var(--sway), -55vh) rotate(var(--spin)); }
  90% { opacity: var(--alpha); }
  100% { transform: translate(0, -115vh) rotate(0); opacity: 0; }
}

.brand, .card, .foot { position: relative; z-index: 1; }

/* Notas que "saltan" al interactuar */
.burst-note {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  font-family: var(--music);
  color: var(--mauve-dark);
  transform: translate(-50%, -50%);
  animation: burstNote .95s var(--ease-out) both;
}
@keyframes burstNote {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); }
}

/* ---------- Logo ---------- */
.brand { display: flex; justify-content: center; margin-bottom: clamp(16px, 4vw, 28px); }

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: .85;
  user-select: none;
  animation: fadeIn .9s var(--ease-out) both;
}

.logo-dg,
.logo-studio {
  font-family: var(--serif-display);
  /* Capa 1: brillo que cruza el logo cada tanto · Capa 2: metal */
  background:
    linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, .95) 50%, transparent 58%),
    linear-gradient(180deg, #ffffff 0%, #cfc4bd 35%, #8c7a72 55%, #e9dfd8 75%, #a8958c 100%);
  background-size: 300% 100%, 100% 100%;
  background-repeat: no-repeat;
  background-position: 150% 0, 0 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 rgba(60, 40, 30, .45)) drop-shadow(0 3px 4px rgba(60, 40, 30, .18));
  animation: shine 7s ease-in-out 1.4s infinite;
}
@keyframes shine {
  0% { background-position: 150% 0, 0 0; }
  28%, 100% { background-position: -50% 0, 0 0; }
}

.logo-dg { font-size: clamp(56px, 15vw, 96px); font-weight: 700; letter-spacing: -2px; }
.logo-studio { font-size: clamp(24px, 6.4vw, 40px); font-weight: 600; margin-top: 2px; }

/* ---------- Tarjeta ---------- */
.card {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -18px rgba(70, 50, 40, .35), 0 2px 6px rgba(70, 50, 40, .08);
  overflow: hidden;  scroll-margin-top: 12px;
  animation: cardIn .8s var(--ease-out) .15s both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

.corner {
  position: absolute;
  width: var(--corner);
  height: var(--corner);
  background: var(--mauve);
  border-radius: 50%;
  opacity: .9;
  pointer-events: none;
}
.corner-tl { top: calc(var(--corner) / -2); left: calc(var(--corner) / -2); }
.corner-tr { top: calc(var(--corner) / -2); right: calc(var(--corner) / -2); }
.corner-bl { bottom: calc(var(--corner) / -2); left: calc(var(--corner) / -2); }
.corner-br { bottom: calc(var(--corner) / -2); right: calc(var(--corner) / -2); }

.card-inner { position: relative; padding: var(--pad-y) var(--pad-x) calc(var(--pad-y) + 4px); }

.title {
  font-family: var(--serif-display);
  font-weight: 500;
  font-size: clamp(28px, 8vw, 48px);
  line-height: 1.1;
  color: var(--title);
  text-transform: uppercase;
  letter-spacing: clamp(.5px, .3vw, 1.5px);
  text-align: center;
  margin: 0;
  overflow-wrap: break-word;
}

/* Onda de sonido que se dibuja bajo el título */
.wave-line {
  display: block;
  width: clamp(110px, 30vw, 160px);
  height: 16px;
  margin: 8px auto 0;
  overflow: visible;
}
.wave-line path {
  fill: none;
  stroke: var(--mauve);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: drawWave 1.6s cubic-bezier(.65, 0, .35, 1) .7s forwards;
}
@keyframes drawWave { to { stroke-dashoffset: 0; } }

.subtitle {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: clamp(1.5px, .6vw, 3px);
  font-size: clamp(10px, 2.6vw, 11.5px);
  color: var(--ink-soft);
  margin: 6px 0 clamp(14px, 3vw, 20px);
}

.intro {
  font-style: italic;
  text-align: center;
  color: var(--ink-soft);
  font-size: clamp(14px, 3.6vw, 15.5px);
  margin: 0 0 clamp(20px, 4vw, 28px);
}

/* ---------- Progreso: pentagrama ---------- */
.progress { margin-bottom: clamp(20px, 4vw, 30px); }

.staff {
  --line-gap: 7px;
  position: relative;
  height: calc(var(--line-gap) * 4 + 1px);
  margin: 18px 0 0;
  /* Las 5 líneas del pentagrama */
  background: repeating-linear-gradient(180deg, var(--line) 0 1px, transparent 1px var(--line-gap));
}

.clef {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-52%);
  font-family: var(--music);
  font-size: 46px;
  line-height: 1;
  color: var(--title);
}

/* Cabezal que avanza como una barra de reproducción */
.staff-play {
  position: absolute;
  left: 38px; /* empieza después de la clave de sol */
  top: -6px;
  bottom: -6px;
  width: calc(var(--to, 26%) - 38px);
  border-right: 2px solid var(--mauve);
  background: linear-gradient(90deg, transparent 0%, rgba(196, 167, 156, .10) 50%, rgba(196, 167, 156, .26) 100%);
  border-radius: 0 3px 3px 0;
  transition: width .7s var(--ease-out);
  pointer-events: none;
}

.staff-note {
  position: absolute;
  left: var(--x);
  top: var(--y);
  margin: -13px 0 0 -9px;
  font-family: var(--music);
  font-size: 26px;
  line-height: 1;
  color: var(--ink-soft);
  opacity: .25;
  transition: opacity .4s ease, color .4s ease;
}
.staff-note.is-current {
  opacity: 1;
  color: var(--mauve-dark);
  animation: noteBob 1.6s ease-in-out infinite;
}
.staff-note.is-played { opacity: 1; color: var(--title); }
.staff-note.just-played { animation: notePop .55s var(--ease-bounce); }
@keyframes notePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.5) rotate(-8deg); }
  100% { transform: scale(1); }
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.progress-label {
  margin: 0;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Ecualizador: se mueve mientras la persona escribe */
.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.eq i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--mauve);
  transform-origin: bottom;
  transform: scaleY(.25);
  transition: transform .3s ease;
}
.eq i:nth-child(2) { transform: scaleY(.45); }
.eq i:nth-child(3) { transform: scaleY(.3); }
.eq i:nth-child(4) { transform: scaleY(.55); }
.eq.is-playing i { animation: eqBar .9s ease-in-out infinite; }
.eq.is-playing i:nth-child(2) { animation-delay: -.6s; animation-duration: .8s; }
.eq.is-playing i:nth-child(3) { animation-delay: -.3s; animation-duration: 1s; }
.eq.is-playing i:nth-child(4) { animation-delay: -.75s; animation-duration: .7s; }
.eq.is-playing i:nth-child(5) { animation-delay: -.15s; animation-duration: .95s; }
@keyframes eqBar {
  0%, 100% { transform: scaleY(.2); }
  50% { transform: scaleY(1); }
}
.eq-light i { background: rgba(255, 255, 255, .9); }

/* ---------- Secciones ---------- */
.section-title {
  font-family: var(--serif);
  font-size: clamp(13.5px, 3.6vw, 15.5px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: clamp(.8px, .3vw, 1.5px);
  line-height: 1.35;
  color: var(--title);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin: 0 0 clamp(18px, 4vw, 24px);
}
.section-title::before {
  content: "♪";
  display: inline-block;
  margin-right: 8px;
  font-family: var(--music);
  color: var(--mauve);
}
.step.is-active .section-title::before { animation: noteBob 2.4s ease-in-out infinite; }

/* Transición entre secciones según la dirección */
.step.enter-next { animation: slideFromRight .5s var(--ease-out) both; }
.step.enter-prev { animation: slideFromLeft .5s var(--ease-out) both; }
@keyframes slideFromRight {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}
@keyframes slideFromLeft {
  from { opacity: 0; transform: translateX(-28px); }
  to { opacity: 1; transform: none; }
}

/* Los campos aparecen en cascada, como las notas de un arpegio */
.step.is-active > .field,
.step.is-active > .note {
  animation: fadeIn .55s var(--ease-out) both;
}
.step.is-active > :nth-child(3) { animation-delay: .05s; }
.step.is-active > :nth-child(4) { animation-delay: .10s; }
.step.is-active > :nth-child(5) { animation-delay: .15s; }
.step.is-active > :nth-child(6) { animation-delay: .20s; }
.step.is-active > :nth-child(7) { animation-delay: .25s; }

/* ---------- Campos ---------- */
.field { margin: 0 0 var(--field-gap); border: 0; padding: 0; min-width: 0; }

label,
.label,
legend {
  display: block;
  font-size: clamp(15px, 3.8vw, 16px);
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  padding: 0;
  margin-bottom: 6px;
  transition: color .25s ease;
}

.sublabel { font-size: 13px; color: var(--ink-soft); font-weight: 400; margin-bottom: 4px; }
.req { color: var(--mauve-dark); }

/* La pregunta que se está respondiendo toma el color de la marca */
.field:focus-within > label,
.field:focus-within > .label,
.field:focus-within .sublabel { color: var(--title); }

.hint {
  font-size: clamp(13px, 3.4vw, 13.5px);
  font-style: italic;
  line-height: 1.45;
  color: var(--ink-soft);
  margin: -2px 0 8px;
}

input[type="text"],
input[type="email"],
input[type="number"],
textarea {
  display: block;
  width: 100%;
  min-height: var(--tap);
  font: inherit;
  /* 16px como mínimo: evita que el iPhone haga zoom al tocar un campo */
  font-size: 16px;
  color: var(--ink);
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .2s, box-shadow .3s, background-color .3s;
}

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

textarea { resize: vertical; min-height: 110px; line-height: 1.5; }

input:focus,
textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--mauve-dark);
  box-shadow: 0 0 0 3px rgba(196, 167, 156, .28), 0 6px 18px -10px rgba(156, 124, 113, .55);
}

.field.has-error input,
.field.has-error textarea { border-color: var(--error); }
.field.has-error { animation: shake .4s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
.field-msg { color: var(--error); font-size: 13.5px; margin: 6px 0 0; animation: fadeIn .3s ease both; }

/* Filas de dos campos (nombre/apellido, edad/ocupación) */
.row { display: flex; gap: 12px; }
.col-age { flex: 0 0 104px; min-width: 0; }
.col-grow { flex: 1 1 0; min-width: 0; }

/* Opciones tipo "pastilla" */
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { margin: 0; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdfa;
  font-size: 15px;
  font-weight: 400;
  text-align: center;
  line-height: 1.3;
  transition: background .25s, border-color .25s, color .25s, box-shadow .25s;
}
.choice input:checked + span {
  background: var(--mauve);
  border-color: var(--mauve-dark);
  color: #fff;
  box-shadow: 0 6px 14px -8px rgba(156, 124, 113, .9);
}
.choice span.pop { animation: pillPop .45s var(--ease-bounce); }
@keyframes pillPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgba(196, 167, 156, .45); }

.note {
  margin-top: 8px;
  padding: clamp(14px, 3.5vw, 18px) clamp(14px, 4vw, 20px);
  border-left: 3px solid var(--gold);
  background: #f3ece2;
  border-radius: 0 10px 10px 0;
}
.note h3 {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--title);
}
.note p { margin: 0; font-size: clamp(13.5px, 3.5vw, 14.5px); color: var(--ink-soft); }

/* ---------- Navegación ---------- */
.nav {
  display: flex;
  gap: 12px;
  margin-top: clamp(24px, 5vw, 34px);
}
.nav .btn-primary { margin-left: auto; }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 16px;
  letter-spacing: .5px;
  min-height: var(--tap);
  padding: 12px 30px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  touch-action: manipulation;
  transition: background .2s, border-color .2s, color .2s, box-shadow .25s, transform .12s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .75; cursor: progress; }

.btn-primary {
  background: var(--mauve-dark);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(110, 80, 70, .8);
}
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn:focus-visible { outline: 2px solid var(--mauve-dark); outline-offset: 3px; }

.btn-icon {
  display: inline-block;
  font-family: var(--music);
  transition: transform .3s var(--ease-bounce);
}
.btn-text { display: inline-flex; align-items: center; gap: 8px; }
.btn-loading { display: none; align-items: center; gap: 10px; }
.btn.is-loading .btn-text { display: none; }
.btn.is-loading .btn-loading { display: inline-flex; }

/* El efecto hover solo en equipos con mouse (en celulares queda "pegado") */
@media (hover: hover) {
  .btn-primary:hover { background: #876659; box-shadow: 0 12px 22px -10px rgba(110, 80, 70, .9); }
  .btn-primary:hover .btn-icon { transform: translateY(-3px) rotate(-12deg); }
  .btn-ghost:hover { border-color: var(--mauve); color: var(--ink); }
  .btn-ghost:hover .btn-icon { transform: translateX(-3px); }
  .choice:hover span { border-color: var(--mauve); }
}

.form-error {
  margin: 20px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f6e3df;
  color: var(--error);
  font-size: 14.5px;
  animation: fadeIn .3s ease both;
}

/* ---------- Final: disco girando ---------- */
.done { text-align: center; animation: fadeIn .5s ease both; }
.done:focus { outline: none; }
.done p { margin: 0 0 14px; overflow-wrap: anywhere; }
.done-title::before { display: none; }

.vinyl {
  position: relative;
  width: 128px;
  height: 128px;
  margin: 4px auto 24px;
  animation: vinylIn .8s var(--ease-out) both;
}
.vinyl-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    conic-gradient(from 30deg, transparent 0 12%, rgba(255,255,255,.14) 16%, transparent 22% 62%, rgba(255,255,255,.10) 66%, transparent 72%),
    repeating-radial-gradient(circle, #2c2523 0 2px, #3b3230 2px 3px);
  box-shadow: 0 10px 24px -8px rgba(60, 40, 30, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: spin 3.2s linear infinite;
}
.vinyl-label {
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--card) 0 7%, var(--mauve) 8% 100%);
  color: #fff;
  font-family: var(--serif-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vinyl-note {
  position: absolute;
  top: 10%;
  font-family: var(--music);
  font-size: 20px;
  color: var(--mauve-dark);
  opacity: 0;
  animation: vinylNote 3s ease-out infinite;
}
.vinyl-note.n1 { left: 88%; animation-delay: .6s; }
.vinyl-note.n2 { left: -6%; animation-delay: 1.6s; }
.vinyl-note.n3 { left: 70%; animation-delay: 2.5s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes vinylIn {
  from { opacity: 0; transform: scale(.6) rotate(-90deg); }
  to { opacity: 1; transform: none; }
}
@keyframes vinylNote {
  0% { opacity: 0; transform: translate(0, 10px) rotate(0); }
  20% { opacity: .9; }
  100% { opacity: 0; transform: translate(10px, -46px) rotate(20deg); }
}

.closing {
  margin-top: 24px !important;
  font-style: italic;
  font-weight: 600;
  color: var(--title);
}

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.foot {
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 22px;
  padding: 0 8px;
}

[hidden] { display: none !important; }

/* ---------- Celulares ---------- */
@media (max-width: 560px) {
  /* Nombre y apellido, uno debajo del otro */
  .row-wrap { flex-direction: column; }

  /* Botones grandes que ocupan el ancho: "Siguiente" más ancho que "Anterior" */
  .nav .btn { flex: 1 1 0; padding-left: 16px; padding-right: 16px; }
  .nav .btn-primary { flex-grow: 2; margin-left: 0; }

  .progress-meta { justify-content: center; }
  .staff { margin-top: 26px; }
  .clef { font-size: 38px; }
  .staff-note { font-size: 23px; }
}

/* Celulares muy angostos (iPhone SE, Android chicos) */
@media (max-width: 380px) {
  .row { flex-direction: column; }
  .col-age { flex-basis: auto; max-width: 140px; }
  .choices { flex-direction: column; }
  .choice span { justify-content: flex-start; border-radius: 12px; }
}

/* Celular acostado o pantallas bajitas: logo más chico para dejar lugar al formulario */
@media (max-height: 520px) and (orientation: landscape) {
  .brand { margin-bottom: 12px; }
  .logo-dg { font-size: 48px; }
  .logo-studio { font-size: 22px; }
}

/* Pantallas grandes */
@media (min-width: 1200px) {
  .card { max-width: 760px; }
}

/* Quien tiene activado "reducir movimiento" en su equipo ve todo estático */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
  }
  .notes-bg, .burst-note, .vinyl-note { display: none; }
  .wave-line path { stroke-dashoffset: 0; }
}
