/* LEVEL-TEST-HOW (28 Oct 2026, owner items 13+15): the animated "how it works" diagram and the
   side-space panels (CEFR ladder, sample card, during-test progress, result "what to work on
   next"). New, additive file (includes/level-test-how.php, assets/level-test-how.js). Loads after
   level-test-landing.css. Namespace "vlth" throughout so nothing here can collide with the
   existing "vltl" classes it sits next to.
   Logical properties (inset-inline-*, margin-inline-*, etc.) so this mirrors correctly for the
   RTL pages (he, fa, ar) without a separate [dir="rtl"] copy of every rule. */

.vlth-diagram,
.vlth-rail {
  --vlth-teal: #1e7272;
  --vlth-teal-d: #134f4f;
  --vlth-coral: #f07832;
  --vlth-coral-d: #d4621f;
  --vlth-ink: #15302f;
  --vlth-muted: #4b6261;
  --vlth-soft: #f1f8f7;
  --vlth-line: #d3e6e3;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--vlth-ink);
  box-sizing: border-box;
}
.vlth-diagram *, .vlth-rail *,
.vlth-diagram *::before, .vlth-rail *::before,
.vlth-diagram *::after, .vlth-rail *::after { box-sizing: border-box; }
.vlth-diagram [hidden], .vlth-rail [hidden] { display: none !important; }
.vlth-h {
  font-family: "Poppins", "Nunito", system-ui, sans-serif;
  font-weight: 800;
  color: var(--vlth-teal-d);
}

/* -------------------------------------------------------------- the old static list: hidden once
   the enhanced diagram mounts (no-JS / JS-blocked visitors keep the plain 3-line list, which was
   already there and already translated, as a graceful fallback). */
.vltl-how--enhanced .vltl-steps { display: none; }

/* -------------------------------------------------------------- the stages diagram ------------- */
.vlth-diagram { margin: 14px 0 0; }
.vlth-stages {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.vlth-stage {
  position: relative;
  display: grid;
  /* minmax(0, 1fr), not bare 1fr: without the 0 minimum, a grid track refuses to shrink below
     its content's longest unbroken word (German/Finnish compounds, etc.), which silently pushed
     the whole page wider than the phone viewport and clipped unrelated text at the right edge
     ("Spanis…" — owner screenshot, 28 Oct). This is the fix. */
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 3px 10px;
  padding-bottom: 16px;
  padding-inline-start: 2px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  transition-delay: calc(var(--vlth-d, 0) * 70ms);
}
.vlth-stage.is-in { opacity: 1; transform: translateY(0); }
.vlth-stage:last-child { padding-bottom: 0; }
/* the connecting line, drawn behind the number dot */
.vlth-stage:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 30px;
  bottom: 2px;
  inset-inline-start: 15px;
  width: 2px;
  background: var(--vlth-line);
}
.vlth-stage.is-in:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 30px;
  inset-inline-start: 14px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--vlth-coral);
  animation: vlth-travel 2.4s ease-in-out infinite;
  animation-delay: calc(var(--vlth-d, 0) * 70ms + 0.4s);
}
.vlth-dot {
  /* Spans every content row, however many a stage has (1 to -1, not a hardcoded "1 / 3"): a round
     now carries three lines (title, what it checks, facts), and a fixed 2-row span left column 1
     open on row 3, where grid auto-placement then wrongly dropped the facts line into the 26px
     dot column instead of the text column (owner screenshot, 28 Oct: "6 / preguntas / · / unos /
     1.5 / min" each on its own line). Explicit column placement below on every text line is the
     real, robust fix; this wide span is a second line of defence. */
  grid-row: 1 / -1;
  grid-column: 1;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  background: var(--vlth-soft);
  color: var(--vlth-teal-d);
  border: 2px solid var(--vlth-teal);
  z-index: 1;
  flex-shrink: 0;
  align-self: start;
}
.vlth-stage[data-kind="result"] .vlth-dot { background: var(--vlth-coral); color: #fff; border-color: var(--vlth-coral-d); }
.vlth-stage[data-kind="step0"] .vlth-dot { background: #fff; }
.vlth-t {
  grid-column: 2;
  font-weight: 800;
  font-family: "Poppins", "Nunito", system-ui, sans-serif;
  font-size: 14.5px;
  overflow-wrap: break-word;
}
.vlth-s { grid-column: 2; font-size: 13px; color: var(--vlth-muted); margin: 1px 0 0; line-height: 1.35; overflow-wrap: break-word; }
/* the stage's real facts, written out ("6 questions · about 1.5 min"): no more an unlabeled row
   of dots (owner, 28 Oct: "unlabeled dot grids") */
.vlth-facts {
  grid-column: 2;
  font-size: 12px;
  font-weight: 700;
  color: var(--vlth-teal-d);
  margin-top: 4px;
}
@keyframes vlth-travel {
  0%, 100% { transform: translateY(0); opacity: 0.35; }
  50% { transform: translateY(26px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .vlth-stage { opacity: 1; transform: none; transition: none; }
  .vlth-stage.is-in:not(:last-child)::after { display: none; }
}

/* -------------------------------------------------------------- side rails --------------------- */
/* Mobile and anything under "comfortably wide desktop": both rails render as ordinary blocks,
   stacked after the trust/reviews aside (owner item 13: "on phones it stacks below"; item 15 adds
   small-laptop widths to the same rule — the fixed rails only switch on at 1480px and up, so a
   1366 or 1440 wide laptop window, or a 1512 one with devtools/zoom, never risks the panel sitting
   over the question). */
.vlth-rail {
  margin: 18px 0 0;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--vlth-line);
}
.vlth-rail + .vlth-rail { margin-top: 12px; }
.vlth-rail-h { font-size: 14px; margin: 0 0 8px; }
.vlth-rail-fixed-slot { display: none; } /* placeholder, see JS: the rails move here at wide widths */

/* CEFR ladder */
.vlth-cefr { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.vlth-cefr li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; }
.vlth-cefr-badge {
  display: grid; place-items: center; width: 32px; height: 24px; border-radius: 7px;
  font-weight: 800; font-size: 12px; font-family: "Poppins", "Nunito", sans-serif;
  background: var(--vlth-soft); color: var(--vlth-teal-d);
}
.vlth-cefr-txt { font-size: 13px; color: var(--vlth-muted); line-height: 1.3; padding-top: 2px; }

/* Sample result card (clearly marked as an example, never confusable with a real result) */
.vlth-sample { position: relative; border: 1.5px dashed var(--vlth-line); border-radius: 14px; padding: 14px; margin-top: 4px; }
.vlth-sample-badge {
  position: absolute; top: -10px; inset-inline-end: 10px;
  background: var(--vlth-coral); color: #fff; font-size: 10.5px; font-weight: 800;
  letter-spacing: 0.04em; padding: 3px 9px; border-radius: 999px;
}
.vlth-sample-badge-top {
  background: var(--vlth-coral); color: #fff; font-size: 10.5px; font-weight: 800;
  letter-spacing: 0.04em; padding: 3px 9px; border-radius: 999px; display: inline-block; margin-bottom: 8px;
}
.vlth-sample-row { display: flex; align-items: center; gap: 10px; opacity: 0.9; }
.vlth-sample-badge-level {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--vlth-soft); color: var(--vlth-teal-d); font-weight: 800; font-size: 17px;
  font-family: "Poppins", sans-serif;
}
.vlth-sample-name { font-weight: 700; font-size: 14px; }
.vlth-sample-bars { display: grid; gap: 5px; margin-top: 10px; }
.vlth-sample-bar { height: 6px; border-radius: 4px; background: var(--vlth-soft); overflow: hidden; }
.vlth-sample-bar > span { display: block; height: 100%; background: var(--vlth-teal); border-radius: 4px; }

.vlth-teacher { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--vlth-line); font-size: 13.5px; color: var(--vlth-muted); }
.vlth-teacher-ic { font-size: 18px; line-height: 1; }

/* "What to work on next" (result page) */
.vlth-next { margin-top: 10px; }
.vlth-next-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: 10px; background: var(--vlth-soft); margin-bottom: 7px; font-size: 13.5px;
}

/* During-test progress state ------------------------------------------------------------------- */
.vlth-prog-round { font-family: "Poppins", "Nunito", sans-serif; font-weight: 800; color: var(--vlth-teal-d); font-size: 15px; }
.vlth-prog-sub { font-size: 13px; color: var(--vlth-muted); margin: 3px 0 10px; }
.vlth-prog-bar-row { margin: 8px 0; }
.vlth-prog-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--vlth-muted); margin-bottom: 4px; }
.vlth-prog-bar { height: 8px; border-radius: 6px; background: var(--vlth-soft); overflow: hidden; }
.vlth-prog-bar > span { display: block; height: 100%; background: var(--vlth-teal); border-radius: 6px; transition: width 0.4s ease; }
.vlth-prog-bar.vlth-prog-bar--time > span { background: var(--vlth-coral); }
.vlth-prog-cheer { margin-top: 10px; font-size: 13.5px; font-weight: 700; color: var(--vlth-teal-d); min-height: 18px; }
.vlth-prog-skills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.vlth-prog-skill {
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--vlth-soft); color: var(--vlth-teal-d); opacity: 0.45; transition: opacity 0.3s ease;
}
.vlth-prog-skill.is-seen { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .vlth-prog-bar > span { transition: none; }
}

/* Review grouped by round (result page, non-band campuses only) */
.vlth-round-h {
  font-family: "Poppins", "Nunito", sans-serif; font-weight: 800; font-size: 13px;
  color: var(--vlth-teal-d); text-transform: uppercase; letter-spacing: 0.03em;
  margin: 16px 0 6px; padding-top: 12px; border-top: 1px solid var(--vlth-line);
}
.vlth-round-h:first-child { margin-top: 4px; padding-top: 0; border-top: none; }

/* -------------------------------------------------------------- fixed rails at comfortably wide
   desktop widths only. 760px content + 2 x (230px rail + 48px gutter) ≈ 1316px minimum; 1480px
   leaves real margin so a 1366/1440-wide laptop, or a wider one zoomed in, never gets a rail over
   the question. */
@media (min-width: 1480px) {
  body.vltl-page { position: relative; }
  .vlth-rail-fixed-slot { display: block; }
  .vlth-rail--pinned {
    position: fixed;
    top: 110px;
    width: 236px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    margin: 0;
  }
  .vlth-rail--pinned.vlth-rail--pinned-l { inset-inline-start: max(18px, calc(50% - 760px / 2 - 236px - 34px)); }
  .vlth-rail--pinned.vlth-rail--pinned-r { inset-inline-end: max(18px, calc(50% - 760px / 2 - 236px - 34px)); }
}

/* Compact on phones (owner, 28 Oct): tighter dot, tighter gaps, everything inside the column's
   own width so nothing pushes the page wider than the screen. */
@media (max-width: 480px) {
  .vlth-diagram { margin-top: 10px; }
  .vlth-stage { grid-template-columns: 26px minmax(0, 1fr); gap: 2px 8px; padding-bottom: 13px; }
  .vlth-dot { width: 26px; height: 26px; font-size: 12px; }
  .vlth-stage:not(:last-child)::before { top: 27px; inset-inline-start: 12px; }
  .vlth-stage.is-in:not(:last-child)::after { top: 27px; inset-inline-start: 11px; }
  .vlth-t { font-size: 14px; }
  .vlth-s { font-size: 12.5px; }
  .vlth-rail { padding: 13px; }
}
