/* Movistar Backstage — encore vote, phone.
 *
 * Colours are the real Mistica "movistar" skin tokens (@telefonica/mistica
 * css/movistar.css), not sampled from a mockup:
 *   brand #0066ff · brand-high #005eeb · inverse/on-brand #ffffff
 *   alternative background #fefaf5
 * Radii come from the design rather than Mistica's button token (4px), which
 * is visibly tighter than the drawn pills.
 *
 * FONT: the comps use Movistar's brand face. We don't have the webfont files,
 * so this falls back to the system stack — swap `--font` once they arrive and
 * the whole page follows. */

:root {
  --brand: #0066ff;
  --brand-high: #005eeb;
  --on-brand: #ffffff;
  --alt: #fefaf5;

  /* Fills over the brand blue: the disabled CTA and the option outlines are
     white at low alpha so they sit on blue without a second colour token. */
  --line: rgba(255, 255, 255, 0.55);
  --muted-fill: rgba(255, 255, 255, 0.30);
  --muted-ink: rgba(255, 255, 255, 0.65);

  --radius: 12px;
  --radius-pill: 999px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100dvh;              /* 100vh lies under the phone URL bar */
  background: var(--brand);
  color: var(--on-brand);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  /* The entering view starts translated a full width to the right; without
   * this the phone gets a horizontal scrollbar for the length of the slide. */
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 30rem;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 1.5rem) 1.5rem
           max(env(safe-area-inset-bottom), 1.5rem);
}

/* --- brand ---------------------------------------------------------------- */

.brand { margin-bottom: 2rem; }
.brand img { display: block; height: 2.5rem; width: auto; }

/* --- view plumbing -------------------------------------------------------- */

main { flex: 1; display: flex; flex-direction: column; }

.view { flex: 1; display: flex; flex-direction: column; }
/* MUST outrank `.view { display:flex }`: the `hidden` attribute is only
 * `display:none` in the UA sheet, so an author display rule silently defeats
 * it and every view renders stacked. The screen page shipped exactly that bug. */
.view[hidden] { display: none; }

/* Stage transition: the incoming view slides in from the right.
 *
 * An ANIMATION, not a transition, and only on the entering view — the one
 * leaving is display:none'd the same instant, so the two never overlap and no
 * absolute positioning is needed. A cross-slide would mean stacking both views
 * on top of each other, which breaks the flex column these panels rely on to
 * pin their CTA to the bottom. */
@keyframes view-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.view.enter { animation: view-in 320ms cubic-bezier(0.22, 1, 0.36, 1) both; }
@media (prefers-reduced-motion: reduce) { .view.enter { animation: none; } }

.grow { flex: 1; min-height: 1rem; }
.center { flex: 1; display: flex; align-items: center; justify-content: center; }

/* --- type ----------------------------------------------------------------- */

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.5rem, 12vw, 3.5rem);
  line-height: 0.95;
  font-weight: 800;
  letter-spacing: -0.03em;
}

h2 {
  margin: 0 0 2rem;
  font-size: clamp(1.35rem, 5.5vw, 1.6rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.lede { margin: 0; font-size: 1.05rem; line-height: 1.45; }
.hint { margin: 0 0 1.5rem; text-align: center; font-size: 1.05rem; line-height: 1.35; }
.hint.small { font-size: 0.95rem; opacity: 0.8; margin: 0; }

/* --- spinner (01_spinner) ------------------------------------------------- */

.spinner {
  width: 2.5rem; height: 2.5rem;
  border: 2px solid transparent;
  border-top-color: var(--on-brand);
  border-right-color: var(--on-brand);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }

/* --- countdown ring ------------------------------------------------------- */

.timer { position: relative; width: 5.5rem; height: 5.5rem; margin: 0 auto 1.25rem; }
.timer[hidden] { display: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2; }
.ring-track { stroke: rgba(255, 255, 255, 0.3); }
.ring-arc {
  stroke: var(--on-brand);
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.timer-num {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1;
}
.timer-num b { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-num small { font-size: 0.7rem; opacity: 0.9; margin-top: 0.15rem; }

/* --- song options (03_listado) -------------------------------------------- */

.songs { list-style: none; margin: 0; padding: 0; }
.songs li + li { margin-top: 0.75rem; }

.songs button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 56px;
  padding: 1rem 1.25rem;
  font: inherit;
  font-size: 1rem;
  text-align: left;
  color: var(--on-brand);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

/* Selected: fills white with blue text and a tick — selection only, nothing is
   sent until the CTA is pressed, which is what lets the user change their mind. */
.songs button[aria-pressed="true"] {
  color: var(--brand);
  background: var(--on-brand);
  border-color: var(--on-brand);
}

.songs .tick { width: 1.25rem; height: 1.25rem; flex: none; opacity: 0; }
.songs button[aria-pressed="true"] .tick { opacity: 1; }
.songs .tick path { fill: none; stroke: currentColor; stroke-width: 2.5; }

/* --- CTA ------------------------------------------------------------------ */

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 56px;
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--brand);
  background: var(--on-brand);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

/* As drawn in the comps: a white-alpha wash on blue. Low contrast is the
   intended "inert" signal, and it is backed by the real disabled attribute
   rather than colour alone. */
.cta:disabled { color: var(--muted-ink); background: var(--muted-fill); cursor: default; }

.cta .arrow { width: 1.15rem; height: 1.15rem; flex: none; }
.cta .arrow path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- results (04_Resultados) --------------------------------------------- *
 * Winner takes the full width and everything else is relative to it, per the
 * designer's note — so bars normalise to the max, not to the total. No vote
 * counts: the comps deliberately show none. */

.standings .row + .row { margin-top: 1.5rem; }

.standings .bar {
  height: 1rem;
  width: 0;                        /* animated to target on entry */
  min-width: 0.9rem;
  background: var(--alt);
  border-radius: var(--radius-pill);
  transition: width 900ms cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) { .standings .bar { transition: none; } }

.standings .label { margin-top: 0.6rem; font-size: 1rem; }

/* --- dev tools ------------------------------------------------------------ */

#devtools { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
#devtools[hidden] { display: none; }
#devtools p { margin: 0 0 0.6rem; font-size: 0.8rem; color: var(--muted-ink); }
#devtools code { color: var(--on-brand); }
#devtools button {
  font: inherit; font-size: 0.9rem; min-height: 44px;
  padding: 0.5rem 1rem; color: var(--on-brand);
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer;
}

/* --- preview banner ------------------------------------------------------- *
 * Deliberately not on-brand: it must read as scaffolding, not as part of the
 * design, so nobody mistakes a preview screenshot for the live page. Uses the
 * status-warning step, which clears contrast against dark text. */
#preview-banner {
  margin: -0.5rem -1.5rem 1.5rem;
  padding: 0.6rem 1.5rem;
  background: #fab219;
  color: #262423;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
}
#preview-banner[hidden] { display: none; }
