/* =========================================================
   Voces en Scroll · Encuesta
   Diseño tipo feed: una pregunta por pantalla, oscuro y vivo,
   con la misma paleta de la presentación.
   ========================================================= */

:root {
  --blue-deep: #173B67;
  --blue-mid: #285F9C;
  --white: #FFFFFF;
  --bg: #F5F7FB;
  --teal: #43C9C0;
  --pink: #F2A1BD;
  --yellow: #EFC66C;
  --lavender: #B8B2F4;

  --top-h: 64px;
  --bar-h: 84px;
  --bar-total: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
  --glass: rgba(255, 255, 255, 0.09);
  --glass-line: rgba(255, 255, 255, 0.24);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--white);
  background: var(--blue-deep);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, textarea { font-family: inherit; }

.icon {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
}

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

/* ---------- Fondo ---------- */
.bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background: linear-gradient(160deg, #173B67 0%, #1b4678 55%, #285F9C 130%);
}
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(70px);
  animation: drift 16s ease-in-out infinite alternate;
}
.b1 { width: 46vmax; height: 46vmax; top: -18vmax; right: -14vmax; background: var(--lavender); opacity: .35; }
.b2 { width: 38vmax; height: 38vmax; bottom: -16vmax; left: -12vmax; background: var(--teal); opacity: .28; animation-delay: -5s; }
.b3 { width: 26vmax; height: 26vmax; top: 42%; left: 58%; background: var(--pink); opacity: .20; animation-delay: -9s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-4vmax, 5vmax) scale(1.12); }
}

/* ---------- Barra superior ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  height: var(--top-h);
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  padding: 0 clamp(16px, 4vw, 40px);
}
.segments { display: flex; gap: 4px; opacity: 0; transition: opacity .4s ease; }
body:not([data-phase="intro"]) .segments { opacity: 1; }
.seg { flex: 1; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.22); overflow: hidden; }
.seg::after {
  content: ""; display: block; height: 100%; width: 0;
  background: var(--teal); border-radius: 5px;
  transition: width .45s ease;
}
.seg.is-done::after { width: 100%; }
.seg.is-current::after { width: 100%; background: var(--white); }
.brand {
  font-size: .8rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

/* ---------- Escenario y pantallas ---------- */
.stage {
  position: fixed; z-index: 1;
  top: var(--top-h); left: 0; right: 0; bottom: 0;
  transition: bottom .3s ease;
}
body[data-phase="asking"] .stage { bottom: var(--bar-total); }

.screen {
  position: absolute; inset: 0;
  display: flex;
  overflow-x: hidden; overflow-y: auto;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(80px);
  transition: opacity .5s ease, transform .5s cubic-bezier(.2, .8, .2, 1), visibility 0s .5s;
}
.screen.is-before { transform: translateY(-80px); }
.screen.is-active {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none;
  transition: opacity .5s ease, transform .5s cubic-bezier(.2, .8, .2, 1), visibility 0s;
}
.screen-inner {
  position: relative; z-index: 1;
  margin: auto; width: min(820px, 100%);
  padding: clamp(14px, 3vw, 36px) clamp(18px, 5vw, 40px);
}

/* Número gigante de fondo */
.ghost {
  position: absolute; z-index: 0; right: 3%; top: 50%;
  transform: translateY(-50%);
  font-size: min(48vw, 440px); font-weight: 900; line-height: 1;
  color: var(--accent, var(--teal)); opacity: .10;
  pointer-events: none; user-select: none;
}
.accent-teal     { --accent: var(--teal); }
.accent-pink     { --accent: var(--pink); }
.accent-yellow   { --accent: var(--yellow); }
.accent-lavender { --accent: var(--lavender); }

.q-kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: .8rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent, var(--teal));
}
.q-kicker::before {
  content: ""; width: 30px; height: 6px; border-radius: 6px; background: var(--accent, var(--teal));
}
.q-title {
  margin: 10px 0 8px;
  font-size: clamp(1.55rem, 4.4vw, 2.9rem);
  font-weight: 800; line-height: 1.12; letter-spacing: -0.02em;
  outline: none;
}
.q-help { margin-bottom: 18px; font-size: 1rem; color: rgba(255, 255, 255, 0.78); max-width: 60ch; }
.q-title:focus, .hero-title:focus { outline: none; }
.q-title + .opts, .q-title + .scale-wrap, .q-title + .matrix, .q-title + .text-wrap { margin-top: 20px; }

/* ---------- Opciones ---------- */
.opts {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}
.opt {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 12px 16px;
  text-align: left; font-size: 1.05rem; font-weight: 600; line-height: 1.3;
  color: var(--white);
  background: var(--glass);
  border: 1.5px solid var(--glass-line);
  border-radius: 18px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease;
}
.opt:hover { border-color: var(--teal); transform: translateY(-2px); }
.opt:active { transform: translateY(0) scale(.99); }
.opt-key {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 9px;
  font-size: .85rem; font-weight: 800;
  border: 1.5px solid var(--glass-line);
  color: rgba(255, 255, 255, 0.85);
}
.opt-label { flex: 1; }
.opt-check { width: 20px; height: 20px; opacity: 0; transform: scale(.4); transition: opacity .18s ease, transform .2s ease; }
.opt[aria-checked="true"] {
  background: var(--teal); border-color: var(--teal); color: var(--blue-deep);
  box-shadow: 0 10px 26px rgba(67, 201, 192, 0.35);
}
.opt[aria-checked="true"] .opt-key { background: var(--blue-deep); border-color: var(--blue-deep); color: var(--white); }
.opt[aria-checked="true"] .opt-check { opacity: 1; transform: scale(1); }
@media (hover: none) { .opt-key { display: none; } }

/* Escala 1 a 5 */
.scale { display: flex; gap: clamp(8px, 2vw, 16px); }
.scale-btn {
  flex: 1; max-width: 92px; aspect-ratio: 1;
  display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 800; color: var(--white);
  background: var(--glass); border: 1.5px solid var(--glass-line);
  border-radius: 50%; cursor: pointer;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease;
}
.scale-btn:hover { border-color: var(--teal); transform: translateY(-3px); }
.scale-btn[aria-checked="true"] {
  background: var(--teal); border-color: var(--teal); color: var(--blue-deep);
  transform: scale(1.1); box-shadow: 0 10px 26px rgba(67, 201, 192, 0.4);
}
.scale-ends {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 12px;
  font-size: .92rem; color: rgba(255, 255, 255, 0.8);
}

/* Matriz */
.matrix { display: grid; }
.mrow {
  display: grid; grid-template-columns: minmax(150px, 1fr) 2fr; gap: 12px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.mrow:last-child { border-bottom: 0; }
.mlabel { font-weight: 700; font-size: 1.02rem; }
.mopts { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  min-height: 44px; padding: 8px 16px;
  font-size: .95rem; font-weight: 700; color: var(--white);
  background: var(--glass); border: 1.5px solid var(--glass-line);
  border-radius: 999px; cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}
.pill:hover { border-color: var(--teal); }
.pill[aria-checked="true"] { background: var(--teal); border-color: var(--teal); color: var(--blue-deep); }

/* Texto libre */
.text-wrap { position: relative; }
.text-area {
  width: 100%; min-height: 150px; padding: 16px 18px; resize: vertical;
  font-size: 1.05rem; line-height: 1.5; color: var(--white);
  background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 18px;
}
.text-area::placeholder { color: rgba(255, 255, 255, 0.55); }
.text-area:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(67, 201, 192, 0.25); }
.text-count { margin-top: 6px; text-align: right; font-size: .85rem; color: rgba(255, 255, 255, 0.7); }

/* ---------- Pantallas de intro y final ---------- */
.hero-title {
  margin: 14px 0 14px;
  font-size: clamp(2.6rem, 8vw, 5.4rem);
  font-weight: 900; line-height: 1; letter-spacing: -0.03em;
}
.hero-title span {
  background: linear-gradient(90deg, var(--teal), var(--lavender) 60%, var(--pink));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero-text { max-width: 56ch; margin-bottom: 20px; font-size: clamp(1.02rem, 1.6vw, 1.2rem); color: rgba(255, 255, 255, 0.92); }
.badges { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  font-size: .92rem; font-weight: 700; color: var(--blue-deep);
  background: var(--accent);
}
.badge .icon { width: 18px; height: 18px; }
.fine { margin-top: 16px; font-size: .88rem; color: rgba(255, 255, 255, 0.72); max-width: 60ch; }
.test-note {
  margin-top: 18px; padding: 12px 16px; border-radius: 14px;
  background: rgba(239, 198, 108, 0.2); border: 1px solid var(--yellow);
  color: var(--white); font-size: .95rem;
}

/* Burbujas decorativas de la intro */
.floaters { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.floater {
  position: absolute; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 18px; font-size: .95rem; font-weight: 700;
  color: var(--blue-deep); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
  animation: float 6s ease-in-out infinite;
}
.floater .icon { width: 18px; height: 18px; }
.f1 { top: 14%; right: 9%; background: var(--yellow); }
.f2 { top: 44%; right: 3%; background: var(--teal); animation-delay: -2s; }
.f3 { bottom: 14%; right: 4%; background: var(--pink); animation-delay: -4s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@media (max-width: 1180px) { .floaters { display: none; } }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 12px 26px;
  font-size: 1.05rem; font-weight: 800;
  border-radius: 999px; border: 1.5px solid transparent; cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease, background-color .2s ease;
}
.btn-primary { background: var(--teal); color: var(--blue-deep); box-shadow: 0 10px 24px rgba(67, 201, 192, 0.4); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(67, 201, 192, 0.55); }
.btn-ghost { background: transparent; color: var(--white); border-color: var(--glass-line); }
.btn-ghost:hover:not(:disabled) { background: var(--glass); }
.btn { white-space: nowrap; }
.btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn.is-busy { pointer-events: none; }

/* ---------- Barra inferior ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  height: var(--bar-total); padding: 0 clamp(14px, 4vw, 40px) env(safe-area-inset-bottom, 0px);
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(15, 42, 76, 0.55);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}
body[data-phase="asking"] .bar { display: flex; }
.step-label { font-size: .9rem; font-weight: 700; color: rgba(255, 255, 255, 0.85); text-align: center; }

/* Aviso */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-total) + 16px); z-index: 20;
  max-width: min(92vw, 480px); padding: 12px 18px; border-radius: 14px;
  background: var(--white); color: var(--blue-deep);
  font-size: .95rem; font-weight: 700; text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  opacity: 0; visibility: hidden; transform: translate(-50%, 10px);
  transition: opacity .3s ease, transform .3s ease, visibility 0s .3s;
}
.toast.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .3s ease, transform .3s ease, visibility 0s; }

/* Campo trampa */
.hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Adaptable ---------- */
@media (max-width: 640px) {
  :root { --bar-h: 76px; }
  .segments { gap: 2px; }
  .opts { grid-template-columns: 1fr; gap: 10px; }
  .opt { min-height: 54px; }
  .scale { gap: 8px; }
  .scale-btn { font-size: 1.25rem; }
  .mrow { grid-template-columns: 1fr; gap: 8px; }
  .btn { padding: 12px 20px; }
  .btn-ghost .btn-text { display: none; }
  .btn-ghost { width: 52px; padding: 0; }
  .step-label { font-size: .82rem; }
  .hero-title { margin-top: 8px; }
}
@media (max-width: 420px) {
  .step-label { display: none; }
  .bar { justify-content: space-between; }
}
@media (max-height: 560px) {
  :root { --bar-h: 64px; --top-h: 52px; }
  .q-title { font-size: 1.5rem; }
  .btn { min-height: 46px; }
}

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