/* =============================================================================
   Soft Imperio — Capa de experiencia (experience.js)
   Tres piezas de retención: barra de progreso del recorrido, riel de hitos
   (solo escritorio), y el asistente "¿Qué necesitas?" con su recomendación.
   Todo usa los tokens de styles.css: funciona igual en claro y oscuro.
   ============================================================================= */

/* ------------------------------------------ Barra de progreso del recorrido */
.xp-progress {
  position: fixed; inset: 0 0 auto 0; height: 3px;
  z-index: calc(var(--z-sticky) + 2);
  pointer-events: none;
}
.xp-progress i {
  display: block; height: 100%;
  background: var(--brand-strong);
  transform: scaleX(0); transform-origin: 0 50%;
}
[data-theme="dark"] .xp-progress i { background: var(--brand); box-shadow: 0 0 10px oklch(0.72 0.17 156 / 0.55); }

/* ------------------------------------------------ Riel de hitos (escritorio) */
.xp-rail {
  position: fixed; right: clamp(0.7rem, 1.2vw, 1.4rem); top: 50%;
  translate: 0 -50%;
  z-index: var(--z-sticky);
  display: none; flex-direction: column; gap: 0.2rem;
}
@media (min-width: 1200px) and (hover: hover) { .xp-rail { display: flex; } }
.xp-rail button {
  display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem;
  padding: 0.32rem 0.15rem; border: 0; background: none; cursor: pointer;
}
.xp-rail .lbl {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-muted); opacity: 0; translate: 8px 0;
  transition: opacity var(--t) var(--ease-out), translate var(--t) var(--ease-out);
}
.xp-rail .dot {
  flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-strong);
  transition: background-color var(--t), box-shadow var(--t), scale var(--t) var(--ease-out);
}
.xp-rail button:hover .lbl, .xp-rail button.is-cur .lbl { opacity: 1; translate: 0 0; }
.xp-rail button:hover .dot { background: var(--ink-faint); }
.xp-rail button.is-cur .dot {
  background: var(--brand); scale: 1.4;
  box-shadow: 0 0 0 4px oklch(0.69 0.16 156 / 0.18);
}
.xp-rail button:focus-visible { outline: none; border-radius: var(--r-sm); box-shadow: var(--ring); }

/* ------------------------------------------------------- Lienzo de confeti */
.xp-confetti { position: fixed; inset: 0; z-index: calc(var(--z-toast) + 10); pointer-events: none; }

/* ============================================= Asistente "¿Qué necesitas?" */
.quiz {
  display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(2rem, 4vw, 4.5rem); align-items: center;
}
@media (max-width: 1000px) { .quiz { grid-template-columns: 1fr; } }

/* El titular vive en una columna angosta (el 3D ocupa el otro lado): techo
   más bajo que las demás secciones para que no rompa en una palabra por línea */
.quiz__copy h2 { font-size: clamp(1.8rem, 1.1rem + 1.9vw, 3rem); font-weight: 360; letter-spacing: -0.035em; line-height: 1.06; text-wrap: balance; }
.quiz__copy > p { color: var(--ink-muted); margin-top: 0.6rem; max-width: 46ch; }
.quiz__perks { list-style: none; margin-top: 1.4rem; display: grid; gap: 0.55rem; padding: 0; }
.quiz__perks li { display: flex; align-items: center; gap: 0.6rem; font-size: 0.92rem; color: var(--ink-body); }
.quiz__perks li svg { width: 1rem; height: 1rem; color: var(--brand-ink); flex: none; }

/* Escenario del asistente: una sola tarjeta que va cambiando de paso */
.quiz__stage {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-md);
  padding: clamp(1.3rem, 2.4vw, 2.1rem);
  min-height: 21rem; display: flex; flex-direction: column;
  container-type: inline-size;
}
.quiz__stage:empty { display: none; }
.quiz__stage--modal { border: 0; box-shadow: none; padding: 0.2rem 0 0.4rem; min-height: 19rem; }

.quiz__meta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.quiz__count { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-muted); }
.quiz__back {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border: 0; background: none; cursor: pointer; padding: 0.25rem 0.4rem;
  font-size: 0.8rem; font-weight: 600; color: var(--ink-muted); border-radius: var(--r-sm);
  transition: color var(--t);
}
.quiz__back[hidden] { display: none; }
.quiz__back:hover { color: var(--ink); }
.quiz__back:focus-visible { outline: none; box-shadow: var(--ring); }
.quiz__back svg { width: 0.85rem; height: 0.85rem; rotate: 180deg; }

.quiz__meter { height: 4px; border-radius: var(--r-pill); background: var(--surface-2); margin-top: 0.85rem; overflow: hidden; }
.quiz__meter i {
  display: block; height: 100%; border-radius: inherit; background: var(--brand-strong);
  transform-origin: 0 50%; transition: scale 0.5s var(--ease-out);
}
[data-theme="dark"] .quiz__meter i { background: var(--brand); }

/* Cuerpo animado del paso (pregunta o resultado) */
.quiz__body { margin-top: 1.3rem; flex: 1; display: flex; flex-direction: column; }
.qz-anim { transition: opacity 0.3s var(--ease-out), translate 0.3s var(--ease-out), filter 0.3s var(--ease-out); }
.qz-anim.is-out { opacity: 0; translate: 0 -10px; filter: blur(4px); }
.qz-anim.is-in { opacity: 0; translate: 0 14px; filter: blur(4px); transition: none; }

.quiz__q { font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.6rem); font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; }

.quiz__opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.7rem; margin-top: 1.15rem; }
.qz-opt {
  position: relative; text-align: left; cursor: pointer;
  display: flex; align-items: flex-start; gap: 0.8rem;
  padding: 0.95rem 1rem; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface-2); color: inherit; font: inherit;
  transition: border-color var(--t), background-color var(--t), translate var(--t) var(--ease-out), box-shadow var(--t);
}
.qz-opt:hover { border-color: var(--brand); translate: 0 -2px; box-shadow: var(--shadow-sm); }
.qz-opt:focus-visible { outline: none; box-shadow: var(--ring); }
.qz-opt__ic {
  flex: none; width: 2.4rem; height: 2.4rem; border-radius: var(--r);
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--brand-ink);
}
.qz-opt__ic svg { width: 1.15rem; height: 1.15rem; }
.qz-opt__ic .brand-mark__img, .qz-opt__ic img, .qz-opt__ic svg.bg { width: 1.35rem; height: 1.35rem; }
.qz-opt b { display: block; font-size: 0.95rem; font-weight: 650; line-height: 1.25; }
.qz-opt small { display: block; margin-top: 0.2rem; font-size: 0.8rem; color: var(--ink-muted); line-height: 1.35; }
.qz-opt.is-picked { border-color: var(--brand-strong); background: var(--brand-50); }
.qz-opt.is-picked .qz-opt__ic { border-color: var(--brand-strong); color: var(--brand-ink); }
.quiz__opts.is-locked .qz-opt { pointer-events: none; }
.quiz__opts.is-locked .qz-opt:not(.is-picked) { opacity: 0.45; }

/* ----------------------------------------------------- Paso de resultado -- */
.qz-res__badge {
  display: inline-flex; align-items: center; gap: 0.45rem; align-self: flex-start;
  padding: 0.35rem 0.8rem; border-radius: var(--r-pill);
  background: var(--brand-50); color: var(--brand-ink);
  font-size: 0.78rem; font-weight: 700;
}
.qz-res__badge svg { width: 0.95rem; height: 0.95rem; }
/* El resultado se apila por defecto (el escenario suele ser angosto: el 3D
   ocupa media pantalla); con espacio real (ventana del catálogo, pantallas
   muy anchas) pasa a dos columnas mediante container query. */
.qz-res__grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1.1rem; align-items: start; }
@container (min-width: 580px) {
  .qz-res__grid { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: clamp(1.1rem, 2vw, 1.7rem); }
}
.qz-res__card .product-card { max-width: 340px; margin-inline: auto; }
.qz-res__side { display: grid; gap: 0.9rem; align-content: start; }
.qz-res__why { font-size: 0.92rem; line-height: 1.55; color: var(--ink-body); padding: 0.85rem 1rem; border-radius: var(--r); background: var(--surface-2); }
.qz-res__why b { color: var(--ink-strong); }

.qz-alts { display: grid; gap: 0; }
.qz-alts > span { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 0.35rem; }
.qz-alt {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.2rem; border-top: 1px solid var(--border);
  text-decoration: none; color: inherit; transition: background-color var(--t);
}
.qz-alt:hover { background: var(--surface-2); }
.qz-alt .qz-alt__g { flex: none; width: 1.9rem; height: 1.9rem; display: grid; place-items: center; }
.qz-alt b { font-size: 0.9rem; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qz-alt .qz-alt__p { font-size: 0.88rem; font-weight: 700; color: var(--brand-ink); white-space: nowrap; }
.qz-alt .arr { display: inline-flex; color: var(--ink-faint); flex: none; }
.qz-alt .arr svg { width: 0.9rem; height: 0.9rem; }

/* Regalo (empuja a crear cuenta): lenguaje visual de ticket, borde punteado */
.qz-gift {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.8rem 1rem; border: 1px dashed var(--brand-strong); border-radius: var(--r);
  background: var(--brand-50); color: var(--brand-ink);
  font-size: 0.88rem; line-height: 1.45; text-decoration: none;
  transition: translate var(--t) var(--ease-out), box-shadow var(--t);
}
a.qz-gift:hover { translate: 0 -2px; box-shadow: var(--shadow-sm); }
.qz-gift svg { flex: none; width: 1.05rem; height: 1.05rem; }
.qz-gift svg:last-child { margin-left: auto; }

.qz-res__foot { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.2rem; }
.quiz__again {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 0; background: none; cursor: pointer; padding: 0.4rem 0.5rem;
  font-size: 0.85rem; font-weight: 600; color: var(--ink-muted); border-radius: var(--r-sm);
  transition: color var(--t);
}
.quiz__again:hover { color: var(--ink); }
.quiz__again:focus-visible { outline: none; box-shadow: var(--ring); }
.quiz__again svg { width: 0.9rem; height: 0.9rem; }

/* ------------------------------------ Invitación al asistente (catálogo) --- */
.quiz-invite {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.2rem; margin-bottom: 1.5rem;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-xs);
}
.quiz-invite__ic {
  flex: none; width: 2.6rem; height: 2.6rem; border-radius: var(--r);
  display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-ink);
}
.quiz-invite__ic svg { width: 1.2rem; height: 1.2rem; }
.quiz-invite__t { flex: 1; min-width: 220px; }
.quiz-invite__t b { display: block; font-size: 0.98rem; }
.quiz-invite__t span { display: block; margin-top: 0.15rem; font-size: 0.86rem; color: var(--ink-muted); }

/* Panel del asistente cuando abre como ventana (catálogo) */
.modal__panel--quiz { width: min(680px, 100%); }

/* ------------------------------------------------ Ruleta "Gira y gana" -----
   Mismo lenguaje 3D minimalista que las cajas del hero: plato blanco con
   grosor, inclinado en perspectiva, sombras suaves tintadas y aguja de marca. */
.modal__panel--wheel { width: min(430px, 100%); }
.wheel-body { justify-items: center; text-align: center; }
.wheel { position: relative; width: min(310px, 76vw); perspective: 900px; }
.wheel__tilt { transform: rotateX(14deg); }
.wheel__pin {
  position: absolute; left: 50%; top: -6px; translate: -50% 0; z-index: 2;
  width: 0; height: 0; border: 12px solid transparent; border-top: 18px solid var(--brand-strong);
  filter: drop-shadow(0 3px 3px oklch(0.24 0.05 255 / 0.35));
}
.wheel__disc {
  position: relative; aspect-ratio: 1; border-radius: 50%;
  border: 10px solid var(--surface); outline: 1px solid var(--border);
  /* Grosor del plato (canto inferior) + sombra al piso, tintada hacia navy */
  box-shadow:
    0 9px 0 -1px color-mix(in oklch, var(--surface) 78%, var(--ink) 14%),
    0 26px 38px oklch(0.24 0.06 255 / 0.18),
    0 8px 14px oklch(0.24 0.06 255 / 0.10);
  /* 8 casilleros de 45°: premiados (verde marca) alternados con neutros */
  background: conic-gradient(from -22.5deg,
    var(--brand-strong) 0 45deg,  var(--surface-2) 0 90deg,
    var(--brand-strong) 0 135deg, var(--surface-2) 0 180deg,
    var(--brand-strong) 0 225deg, var(--surface-2) 0 270deg,
    var(--brand-strong) 0 315deg, var(--surface-2) 0 360deg);
}
/* Brillo de domo: luz suave arriba, como los biseles de las cajas del hero */
.wheel__disc::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: radial-gradient(120% 88% at 50% 10%, rgba(255, 255, 255, 0.26), transparent 52%);
}
.wheel__disc.is-spin { transition: transform 4.2s cubic-bezier(0.12, 0.84, 0.1, 1); }
.wheel__lab {
  position: absolute; inset: 0; display: flex; justify-content: center;
  padding-top: 1.15rem; rotate: calc(var(--i) * 45deg);
  font-weight: 800; font-size: 1.05rem; color: var(--on-brand); pointer-events: none;
}
.wheel__lab--miss { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); padding-top: 1.45rem; }
.wheel__hub {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: 3.2rem; height: 3.2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 10px oklch(0.24 0.05 255 / 0.18), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  color: var(--brand-ink);
}
.wheel__hub svg { width: 1.2rem; height: 1.2rem; }
.wheel__foot { display: grid; gap: 0.7rem; justify-items: center; width: 100%; }
.wheel__note { font-size: 0.8rem; color: var(--ink-muted); max-width: 34ch; }
.wheel-won__t { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--brand-ink); }
.wheel-won__t svg { width: 1.1rem; height: 1.1rem; }
.wheel-code {
  display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer;
  padding: 0.65rem 1.1rem; border: 1px dashed var(--brand-strong); border-radius: var(--r);
  background: var(--brand-50); color: var(--brand-ink); font: inherit;
  transition: translate var(--t) var(--ease-out), box-shadow var(--t);
}
.wheel-code:hover { translate: 0 -2px; box-shadow: var(--shadow-sm); }
.wheel-code:focus-visible { outline: none; box-shadow: var(--ring); }
.wheel-code code { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 600; letter-spacing: 0.06em; }
.wheel-code svg { width: 0.95rem; height: 0.95rem; }

/* Píldora flotante de la ruleta (abajo-izquierda; WhatsApp vive a la derecha):
   mini ruleta girando + un llamado de atención breve cada tantos segundos. */
.wheel-fab {
  position: fixed; left: clamp(0.9rem, 2vw, 1.6rem); bottom: clamp(0.9rem, 2.5vh, 1.6rem);
  z-index: var(--z-sticky); display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1.15rem; border-radius: var(--r-pill); cursor: pointer; font: inherit;
  font-size: 0.9rem; font-weight: 750; color: var(--brand-ink);
  background: var(--surface); border: 2px solid var(--brand-strong); box-shadow: var(--shadow-md);
  transition: translate var(--t) var(--ease-out), box-shadow var(--t);
  animation: wheel-fab-nudge 7s 3s infinite;
}
.wheel-fab:hover { translate: 0 -2px; box-shadow: var(--shadow-lg); }
.wheel-fab:focus-visible { outline: none; box-shadow: var(--ring); }
.wheel-fab.is-won { animation: none; border-color: var(--border-strong); }
/* Mini ruleta: mismos casilleros que la grande, girando despacio */
.wheel-fab__mini {
  flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: conic-gradient(from -22.5deg,
    var(--brand-strong) 0 45deg,  var(--surface-2) 0 90deg,
    var(--brand-strong) 0 135deg, var(--surface-2) 0 180deg,
    var(--brand-strong) 0 225deg, var(--surface-2) 0 270deg,
    var(--brand-strong) 0 315deg, var(--surface-2) 0 360deg);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-xs);
  animation: wheel-mini-spin 9s linear infinite;
}
.wheel-fab.is-won .wheel-fab__mini { animation: none; }
@keyframes wheel-mini-spin { to { rotate: 360deg; } }
/* Salto doble breve al final de cada ciclo: llama la mirada sin ser cansón */
@keyframes wheel-fab-nudge {
  0%, 86%, 100% { transform: translateY(0); }
  89% { transform: translateY(-5px); }
  92% { transform: translateY(0); }
  95% { transform: translateY(-3px); }
  98% { transform: translateY(0); }
}

/* Empujón en el pago: "gira antes de pagar" (lo pinta ui.js si aún no giró) */
.pay-cup__wheel {
  display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer;
  border: 0; background: none; padding: 0.3rem 0.2rem; font: inherit;
  font-size: 0.85rem; font-weight: 600; color: var(--brand-ink); border-radius: var(--r-sm);
}
.pay-cup__wheel:hover { text-decoration: underline; }
.pay-cup__wheel:focus-visible { outline: none; box-shadow: var(--ring); }
.pay-cup__wheel svg { width: 0.95rem; height: 0.95rem; }

/* --------------------------------------------------- Movimiento reducido --- */
@media (prefers-reduced-motion: reduce) {
  .qz-anim, .qz-anim.is-out, .qz-anim.is-in { transition: none; opacity: 1; translate: none; filter: none; }
  .quiz__meter i { transition: none; }
  .qz-opt, .qz-gift, .xp-rail .lbl, .xp-rail .dot { transition: none; }
  .wheel-fab, .wheel-fab__mini { animation: none; }
  .wheel__disc.is-spin { transition: none; }
}
