/* Foco de pruebas: una pila de casos donde el activo pasa al frente y los demás se repliegan. */
@font-face {
  font-family: Archivo;
  src: url("../../assets/fonts/archivo-latin-400-700.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Big Shoulders Display";
  src: url("../../assets/fonts/big-shoulders-display-latin-900.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}

/* Palette: white, ink, dark green, sage + pale sage, beige and paper. Muted text and lines are the only neutrals. */
:root {
  color-scheme: light;
  --ink: #1e2421;
  --green: #1d322d;
  --sage: #dde5d8;
  --sage-soft: #eef2e9;
  --beige: #fffaf0;
  --paper: #fffef5;
  --mark: #f3e6c8;                                 /* highlight beige, deep enough to read on the sage bubble (user decision 2026-11-18) */
  --muted: #4f6059;
  --line: #cbd3c7;
  --ring: #4f6059cc;
  --hair: #1d322d26;
  --lift: 0 14px 34px #1d322d29, 0 2px 6px #1d322d14;
  --rest: 0 2px 8px #1d322d0f;
  /* motion.js replaces this with a linear() curve simulated from the 260/26 spring */
  --spring: cubic-bezier(.2, .8, .3, 1);
  font-family: Archivo, Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: transparent; }
h1, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button { color: inherit; font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Stage: fills the iframe. Option A (user decision 2026-11-18): pale sage with the 13px dotted grid, the same stage as Pulsos.
   The beige lives in the tiles, question bubbles and chips that sit on the white cards. */
.stage {
  position: absolute;
  inset: 0;
  container-type: size;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: radial-gradient(#1d322d27 .7px, transparent .7px) 0 0 / 13px 13px, var(--sage-soft);
}
.frame {
  --pad-x: 10px; --pad-t: 8px; --pad-b: 10px; --gap-f: 6px;
  --gap: 6px; --gap-c: 6px; --bub: 7px 11px; --chip-h: 28px; --cp: 4px 11px 11px;
  --fs: 12.5px; --fs-sm: 12px; --name: 13px; --title: 15px;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap-f);
  padding: var(--pad-t) var(--pad-x) var(--pad-b);
}

/* Header: title and status slot on the left, the case counter on the right. The title is a small label so the score is the number
   that leads, and so it does not compete with the section heading beside the illustration on the page. The 44px floor keeps the
   header exactly as tall as the heading, so the stack below never moves. */
.top { flex: none; display: flex; align-items: center; gap: 8px; min-block-size: 44px; }
.heading { flex: 1 1 auto; min-inline-size: 0; }
.title { font: 900 var(--title)/1 "Big Shoulders Display", "Arial Narrow", sans-serif; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.slot { display: grid; align-items: center; justify-items: start; min-block-size: 24px; margin-top: 2px; }
.slot > * { grid-area: 1 / 1; }
.sub { color: var(--muted); font-size: var(--fs-sm); line-height: 1.2; white-space: nowrap; }
.score {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  block-size: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--rest);
  white-space: nowrap;
}
.odo, .den { font: 900 21px/1 "Big Shoulders Display", "Arial Narrow", sans-serif; }
.lbl { margin-inline-start: 5px; font-size: var(--fs-sm); font-weight: 600; }
.done { position: absolute; inset: -7px -7px auto auto; display: grid; place-items: center; inline-size: 17px; block-size: 17px; border-radius: 50%; background: var(--green); transform: scale(.7); visibility: hidden; }
.done svg { inline-size: 10px; block-size: 10px; fill: none; stroke: var(--paper); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.stage[data-complete] .score { border-color: var(--green); }
.stage[data-complete] .done { transform: none; visibility: visible; }

/* Round progress: a hairline at 1/4, 2/4, 3/4 and 4/4 of the width, the same fraction as the counter and the open case */
.bar { flex: none; block-size: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; block-size: 100%; background: var(--green); transform-origin: 0 50%; transform: scaleX(var(--p, .25)); }

/* The stack. motion.js measures the fullest case and sets --row (collapsed height) and --open (active height). */
.stack { --row: 46px; --open: 200px; flex: 1 1 0; min-block-size: 0; display: flex; flex-direction: column; justify-content: space-between; gap: var(--gap); }
.case {
  --tile: calc(var(--row) - 10px);
  position: relative;
  isolation: isolate;
  flex: 0 0 var(--row);
  min-block-size: 0;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  transform: scale(.96);
}
.case.is-active { flex-basis: var(--open); transform: none; z-index: 1; }
/* Fading the surface instead of the whole card keeps text above 4.5:1 while the card recedes */
.case::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1px solid var(--line);
  border-radius: inherit;
  background: #fff;
  box-shadow: var(--rest);
  opacity: .72;
}
.case::after { content: ""; position: absolute; inset: 0; z-index: -2; border-radius: inherit; box-shadow: var(--lift); opacity: 0; }
.case.is-active::before { border-color: var(--green); opacity: 1; }
.case.is-active::after { opacity: 1; }

.head {
  position: relative;
  z-index: 1;
  flex: none;
  display: grid;
  grid-template-columns: var(--tile) minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  inline-size: 100%;
  min-block-size: var(--row);
  padding: 0 12px 0 calc((var(--row) - var(--tile)) / 2);
  border: 0;
  border-radius: 11px;
  background: none;
  text-align: left;
}
.tile { display: grid; place-items: center; inline-size: var(--tile); aspect-ratio: 1; border-radius: 8px; background: var(--beige); box-shadow: inset 0 0 0 .5px var(--hair); }
.tile svg { inline-size: 56%; block-size: 56%; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tile .dash { stroke-dasharray: 2.3 2.2; }
.is-active .tile { box-shadow: inset 0 0 0 1.5px var(--green); }
.is-active .tile svg { stroke: var(--ink); }
.meta { min-inline-size: 0; display: grid; gap: 2px; }
.name, .exp { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name { font-size: var(--name); font-weight: 600; line-height: 1.2; }
.is-active .name { font-weight: 700; }
.exp { color: var(--muted); font-size: var(--fs-sm); line-height: 1.25; }

/* Status: an empty ring until the case passes, then a solid dark-green disc that stamps in (full colour from its first frame,
   only its size springs). Every pass looks the same; what each case expects is written in its own line. The three checks use the same ring. */
.state, .tick { position: relative; display: grid; place-items: center; flex: none; aspect-ratio: 1; border: 1.5px solid var(--ring); border-radius: 50%; background: #fff; }
.state { inline-size: 20px; }
.tick { inline-size: 15px; }
.state::before, .tick::before { content: ""; position: absolute; inset: -1.5px; border-radius: 50%; background: var(--green); transform: scale(.7); visibility: hidden; }
.state svg, .tick svg { position: relative; fill: none; stroke: var(--paper); stroke-linecap: round; stroke-linejoin: round; transform: scale(.7); visibility: hidden; }
.state svg { inline-size: 11px; block-size: 11px; stroke-width: 2.4; }
.tick svg { inline-size: 9px; block-size: 9px; stroke-width: 2.8; }
.is-done .state::before, .has-checks .tick::before, .is-done .state svg, .has-checks .tick svg { transform: none; visibility: visible; }

/* Detail: the conversation that opens inside the active card */
.detail { position: relative; z-index: 1; flex: 1 1 0; min-block-size: 0; display: flex; flex-direction: column; overflow: hidden; border-radius: 0 0 11px 11px; }
.content { flex: 1 0 auto; display: flex; flex-direction: column; gap: var(--gap-c); padding: var(--cp); opacity: 0; }
.is-active .content { opacity: 1; }
.q, .a { max-inline-size: 92%; padding: var(--bub); border-radius: 10px; font-size: var(--fs); line-height: 1.38; overflow-wrap: break-word; opacity: 0; transform: translateY(8px); }
.q, .a > span { text-wrap: pretty; }
.q { align-self: flex-end; background: var(--beige); box-shadow: inset 0 0 0 1px var(--line); }
.a { align-self: flex-start; display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 7px; background: var(--sage); }
.a img { display: block; inline-size: 14px; block-size: 14px; margin-top: 2px; }
.has-q .q, .has-a .a { opacity: 1; transform: none; }
/* Context line: the amount the assistant holds. It shows the old figure with the question and counts up to the new one as the answer lands. */
.ctx { align-self: flex-start; display: flex; align-items: center; gap: 5px; margin-inline-start: 2px; color: var(--muted); font-size: var(--fs-sm); line-height: 1.2; opacity: 0; transform: translateY(8px); }
.ctx svg { flex: none; inline-size: 12px; block-size: 12px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.ctx b { color: var(--ink); font-weight: 600; }
.has-q .ctx { opacity: 1; transform: none; }
[data-amount] { font-variant-numeric: tabular-nums; }
/* Highlights look like selected text on a computer (user decision 2026-11-18): a flat beige fill
   tight to the words, no border or outline, following line wraps. It sweeps in left to right
   like a selection; the ink colour never changes and the text never shifts. */
mark {
  color: inherit;
  background-color: transparent;
  background-image: linear-gradient(var(--mark), var(--mark));
  background-repeat: no-repeat;
  background-size: 0% 100%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.has-checks mark { background-size: 100% 100%; }

.checks { margin-top: auto; display: flex; gap: var(--gap-c); }
.chip {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-inline-size: 0;
  min-block-size: var(--chip-h);
  padding: 3px 6px;
  border-radius: 8px;
  background: var(--beige);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: var(--fs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

/* "Ficha actualizada" takes the place of the subtitle and announces the next round */
.update {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  block-size: 24px;
  padding: 0 11px 0 7px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--rest);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  visibility: hidden;
  transform: translateY(6px) scale(.94);
}
.update::after { content: ""; position: absolute; inset: -1px; border: 2px solid var(--green); border-radius: 9px; opacity: 0; pointer-events: none; }
.ico { display: grid; inline-size: 14px; block-size: 14px; }
.ico svg { inline-size: 14px; block-size: 14px; fill: none; stroke: var(--ink); stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.lab { display: grid; }
.lab > span { grid-area: 1 / 1; white-space: nowrap; }
.l2 { opacity: 0; }
.stage[data-update] .update { visibility: visible; transform: none; }
.stage[data-update] .sub { opacity: 0; }
.stage[data-update="rerun"] .l1 { opacity: 0; }
.stage[data-update="rerun"] .l2 { opacity: 1; }
.stage[data-update="rerun"] .ico svg { transform: rotate(360deg); }

/* Motion is declared only while the loop plays, so every static frame (reduced motion, offscreen, hidden tab) is instant */
@media (prefers-reduced-motion: no-preference) {
  .stage[data-playing="true"] .case { transition: flex-basis 620ms var(--spring), transform 620ms var(--spring); }
  .stage[data-playing="true"] .case::before { transition: opacity 360ms ease-out, border-color 240ms ease-out; }
  .stage[data-playing="true"] .case::after { transition: opacity 480ms ease-out; }
  .stage[data-playing="true"] .tile { transition: box-shadow 240ms ease-out; }
  .stage[data-playing="true"] .tile svg { transition: stroke 240ms ease-out; }
  /* A closing card fades its conversation out in its first 110 ms, before the shrinking edge can slice a line of text. */
  .stage[data-playing="true"] .content { transition: opacity 110ms ease-out; }
  .stage[data-playing="true"] .is-active .content { transition: none; }
  /* Bubbles, ticks and highlights ease in; when a round resets they vanish at once, so nothing shrinks or fades out inside an opening card. */
  .stage[data-playing="true"] :is(.has-q .q, .has-a .a, .has-q .ctx) { transition: opacity 240ms ease-out, transform 460ms var(--spring); }
  .stage[data-playing="true"] .state::before,
  .stage[data-playing="true"] .state svg { transition: transform 200ms ease-in, visibility 200ms; }
  .stage[data-playing="true"] .is-done .state::before,
  .stage[data-playing="true"] .is-done .state svg { transition: transform 380ms var(--spring), visibility 380ms; }
  .stage[data-playing="true"] .has-checks .tick::before,
  .stage[data-playing="true"] .has-checks .tick svg { transition: transform 380ms var(--spring) calc(var(--c) * 110ms), visibility 380ms linear calc(var(--c) * 110ms); }
  .stage[data-playing="true"][data-update="rerun"] .case:not(.is-done) .state::before,
  .stage[data-playing="true"][data-update="rerun"] .case:not(.is-done) .state svg { transition-delay: calc(var(--i) * 70ms); }
  .stage[data-playing="true"] .has-checks mark { transition: background-size 340ms ease-out calc(var(--c) * 110ms); }
  .stage[data-playing="true"] .score { transition: border-color 300ms ease-out; }
  .stage[data-playing="true"] .done { transition: transform 200ms ease-in, visibility 200ms; }
  .stage[data-playing="true"][data-complete] .done { transition: transform 420ms var(--spring), visibility 420ms; }
  /* The hairline travels with the card that opens: same duration and curve as .case, started in the same frame */
  .stage[data-playing="true"] .bar i { transition: transform 620ms var(--spring); }
  .stage[data-playing="true"] .update { transition: transform 160ms ease-in, visibility 160ms; }
  .stage[data-playing="true"][data-update] .update { transition: transform 520ms var(--spring), visibility 520ms; }
  .stage[data-playing="true"] .sub { transition: opacity 140ms ease-out 140ms; }
  .stage[data-playing="true"][data-update] .sub { transition: none; }
  /* The label swaps while the chip is on: the old one fades out, then the new one fades in, so two lines never overlap.
     When the chip leaves, the swap waits until it is hidden, so it never flips back on its way out. */
  .stage[data-playing="true"] .lab > span { transition: opacity 0s linear 180ms; }
  .stage[data-playing="true"][data-update] .l1 { transition: opacity 80ms ease-in; }
  .stage[data-playing="true"][data-update] .l2 { transition: opacity 80ms ease-out 80ms; }
  .stage[data-playing="true"][data-update="ficha"] .update::after { animation: ring 1300ms ease-out; }
  .stage[data-playing="true"][data-update="rerun"] .ico svg { transition: transform 700ms cubic-bezier(.215, .61, .355, 1); }
  @keyframes ring {
    from { opacity: .55; transform: scale(1); }
    to { opacity: 0; transform: scale(1.3, 1.8); }
  }
}

/* Sizes follow the stage: 320-399, 400-479 and 480+ wide. motion.js trims --row and fits the fullest case. */
@container (max-width: 339px) {
  .lbl { display: none; }
}
@container (min-width: 400px) {
  .frame { --pad-x: 16px; --pad-t: 10px; --pad-b: 14px; --gap-f: 7px; --gap: 8px; --gap-c: 8px; --bub: 8px 12px; --chip-h: 30px; --cp: 4px 13px 13px; --fs: 13.5px; --fs-sm: 12px; --name: 14px; --title: 16px; }
}
@container (min-width: 480px) {
  .frame { --pad-x: 18px; --pad-t: 12px; --pad-b: 16px; --gap-f: 8px; --gap: 9px; --gap-c: 10px; --bub: 9px 14px; --chip-h: 32px; --cp: 4px 14px 14px; --fs: 14px; --fs-sm: 12.5px; --name: 15px; --title: 17px; }
}
/* Fit levels set by motion.js when the fullest case would not fit the default spacing */
.stage[data-fit="1"] .frame { --bub: 6px 10px; --gap-c: 5px; --chip-h: 26px; --cp: 3px 10px 9px; }
.stage[data-fit="2"] .frame { --bub: 5px 9px; --gap-c: 4px; --chip-h: 24px; --cp: 2px 9px 7px; --gap: 5px; }

/* Text selection in the sage of the homepage buttons (2026-11-18). */
::selection { color: #1e2421; background-color: #dde5d8; }
.a::selection, .a *::selection { color: #fffef5; background-color: #1d322d; } /* the answer bubble is sage */
