/* ================================================================
   IndianTyping.com — training.css
   Loaded only on $page_type = 'training' (/typing-training/).

   .page-wrap and .content-section are RE-DECLARED here on purpose. They live
   in tool.css, which this page type does not load, and a page using a class no
   loaded stylesheet defines is the exact defect that made the games page
   render full-bleed (0fb822b) and left the Hindi test with no text on mobile
   (2ac0086). tools/css-contract-test.js gates this.

   Tokens only — --r-*, --font*, --ease. Never restate a literal a token
   already holds (see tools/design-token-test.js).
================================================================ */

.page-wrap {
  max-width: var(--tool-max);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 32px) 24px 80px;
}

.content-section {
  margin-top: 48px;
}
.content-section h2 {
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--text-1); margin: 28px 0 10px;
}
/* max-width caps the MEASURE, not the section. Without it these paragraphs
   ran the full 1052px of the page wrap — about 94 characters a line on a
   desktop screen, where the eye starts losing its place on the return sweep.
   68ch is the value course.css already uses for the same supporting-content
   role, so this is closing an inconsistency rather than introducing a number.
   Headings, tables and the drill UI are untouched. */
.content-section p, .content-section li {
  font-size: 15px; line-height: 1.7; color: var(--text-2); max-width: 68ch;
}
.content-section ul { margin: 10px 0 0 20px; }
.content-section a { color: var(--brand); text-decoration: underline; }

/* ── header ─────────────────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 800; letter-spacing: -0.025em; line-height: 1.2;
  color: var(--text-1); margin-bottom: 6px;
}
.page-header h1 .hi { color: var(--brand); }
.page-header .sub { font-size: 15px; color: var(--text-2); line-height: 1.6; }

/* ── hero metric: most improved key ─────────────────────────────── */
.tr-hero {
  display: flex; align-items: center; gap: 18px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 22px; margin-bottom: 20px;
}
.tr-hero-val {
  font-family: var(--mono);
  font-size: 40px; font-weight: 800; line-height: 1;
  color: var(--brand); min-width: 62px; text-align: center;
  /* Fixed width + tabular figures: this number changes between drills and
     must not shove the label sideways when it does. */
  font-variant-numeric: tabular-nums;
}
.tr-hero-label { font-size: 14px; color: var(--text-2); line-height: 1.5; }

/* ── level selector ─────────────────────────────────────────────── */
/* .tr-levels became a WRAPPER on 2026-08-03 (rail + hint). The flex row moved
   down to .tr-levels-rail; leaving `display:flex` here would have laid the
   hint out as a sixth button beside the five levels. */
.tr-levels      { margin-bottom: 18px; }
.tr-levels-rail { display: flex; flex-wrap: wrap; gap: 8px; }
.tr-levels-hint {
  font-size: 12.5px; color: var(--text-3); margin: 8px 0 0;
}
.tr-level {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; min-height: 44px;   /* touch target */
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-2);
  font-size: 14px; font-weight: 600;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease),
              opacity 0.2s var(--ease);
}
.tr-level:hover { border-color: var(--border-strong); color: var(--text-1); }
.tr-level.is-active {
  border-color: var(--brand); color: var(--brand); background: var(--brand-dim);
}

/* ── the ladder ─────────────────────────────────────────────────────
   Locked levels stay visible, focusable and labelled: the rail IS the
   progression, and a rail that hides its own future is just a shorter rail.
   `cursor: not-allowed` rather than `pointer-events: none` — the click has
   to arrive for weak-key-training.js to explain why it was refused. */
.tr-level.is-locked {
  opacity: 0.45; filter: grayscale(1); cursor: not-allowed;
}
.tr-level.is-locked:hover { opacity: 0.6; border-color: var(--border); }
.tr-level.is-done:not(.is-active) { border-color: var(--green, #17853f); }
.tr-lock { font-size: 12px; }

@keyframes tr-unlock {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(232, 66, 10, 0.55); }
  35%  { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(232, 66, 10, 0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(232, 66, 10, 0); }
}
.tr-level.is-unlocking {
  animation: tr-unlock 1000ms cubic-bezier(0.22, 1, 0.36, 1) 2;
  border-color: var(--brand); color: var(--brand);
}

/* Clicking a locked level: a short shake, so the refusal is felt as well as
   announced. The explanation still goes to #trainStatus and .tr-adaptive. */
@keyframes tr-refuse {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}
.tr-level.is-refused { animation: tr-refuse 240ms ease; }

/* ── the no-history gate ────────────────────────────────────────────
   ONE action. A visitor with no typing data has exactly one useful next
   step, and a panel offering three would be hiding it. */
.tr-empty {
  padding: 44px 32px; margin-bottom: 26px; text-align: center;
  border: 1.5px solid var(--border); border-radius: var(--r-xl);
  background: var(--surface);
}
.tr-empty-icon  { font-size: 40px; line-height: 1; margin-bottom: 12px; }
.tr-empty-title { font-size: 22px; font-weight: 800; margin: 0 0 10px; }
.tr-empty-copy {
  font-size: 15px; color: var(--text-2); margin: 0 auto 22px;
  max-width: 56ch; line-height: 1.65;
}
.tr-empty-cta   { display: inline-flex; }
.tr-empty-note  { font-size: 13px; color: var(--text-3); margin: 16px 0 0; }

/* ── a completed drill that opened the next level ───────────────────── */
.tr-unlocked {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; margin: 4px 0 0;
  border-radius: 999px; background: rgba(232, 66, 10, 0.10);
  font-size: 13.5px; font-weight: 600; color: var(--brand);
}
.tr-ov-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; flex-wrap: wrap; margin-top: 6px;
}
.tr-ov-next {
  min-height: 44px; padding: 0 18px;
  border: 1.5px solid var(--brand); border-radius: var(--r-md);
  background: transparent; color: var(--brand);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.tr-ov-next:hover { background: var(--brand-dim); }

/* ── drill surface ──────────────────────────────────────────────── */
.tr-surface {
  position: relative;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 24px; margin-bottom: 16px;
}
.tr-adaptive {
  font-size: 13px; color: var(--text-3); margin-bottom: 14px;
  line-height: 1.5;
}
.tr-prompt {
  font-family: var(--mono); font-size: 20px; line-height: 2;
  letter-spacing: 0.04em; color: var(--text-3);
  word-break: break-word; user-select: none;
  min-height: 80px;      /* reserved: text length varies per level and the
                            surface must not resize under the typist */
  margin-bottom: 16px;
}
.tc { transition: color 0.08s linear; }
.tc-ok  { color: var(--text-1); }
.tc-bad { color: var(--red); background: var(--red-dim); border-radius: 2px; }
.tc-cur { background: var(--brand-dim); border-radius: 2px; color: var(--text-1); }

.tr-input {
  width: 100%; min-height: 52px;
  padding: 14px 16px;
  font-family: var(--mono); font-size: 16px;
  color: var(--text-1); background: var(--surface-2);
  border: 1.5px solid var(--border); border-radius: var(--r-md);
}
.tr-input:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
.tr-input:disabled { opacity: 0.6; }

/* ── live metrics ───────────────────────────────────────────────── */
.tr-stats { display: flex; gap: 26px; margin-top: 16px; flex-wrap: wrap; }
.tr-stat-v {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  color: var(--text-1);
  /* Tabular figures so a rising WPM cannot nudge the next metric while
     someone is typing. */
  font-variant-numeric: tabular-nums;
  min-width: 3ch; display: inline-block;
}
.tr-stat-l {
  display: block; font-size: 11px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-3);
}

/* ── overlay ────────────────────────────────────────────────────── */
.tr-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 20px;
  background: var(--surface); border-radius: var(--r-lg);
}
.tr-ov-title { font-size: 19px; font-weight: 800; color: var(--text-1); }
.tr-ov-copy  { font-size: 14px; color: var(--text-2); max-width: 44ch; }
.tr-res { display: flex; gap: 26px; }
.tr-res strong {
  display: block; font-family: var(--mono); font-size: 26px; color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.tr-res span {
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3);
}
.btn-start {
  min-height: 44px; padding: 12px 26px;
  background: var(--brand); color: #fff;
  border-radius: var(--r-md); font-size: 15px; font-weight: 700;
}

/* ── keyboard heat map ──────────────────────────────────────────── */
.tr-keyboard { margin: 20px 0 8px; }
.tk-row { display: flex; justify-content: center; gap: 5px; margin-bottom: 5px; }
.tk-key {
  width: 34px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-3);
}
/* Confidence bands. Colour is never the ONLY signal — each key carries a
   title and aria-label stating its accuracy in words. */
.tk-none   { opacity: 0.45; }
.tk-low    { border-style: dashed; }
.tk-weak   { background: var(--red-dim);   color: var(--red);   border-color: var(--red); }
.tk-ok     { background: var(--amber-dim); color: var(--amber); border-color: var(--amber); }
.tk-strong { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.tk-key.is-target { outline: 2px solid var(--brand); outline-offset: 1px; }
.tr-legend {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  font-size: 12px; color: var(--text-3); margin-top: 10px;
}

/* ── progress panel ─────────────────────────────────────────────── */
.tr-progress {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-top: 20px;
}
.tr-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-md); padding: 14px 16px;
}
.tr-card-v {
  font-family: var(--mono); font-size: 20px; font-weight: 700;
  color: var(--text-1); font-variant-numeric: tabular-nums;
}
.tr-card-l {
  font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3); margin-top: 2px;
}
.tr-weak-list { font-family: var(--mono); letter-spacing: 0.2em; }

/* ── reserved ad space ──────────────────────────────────────────────
   Below the drill and below the progress panel, never between the prompt and
   the input. Fixed height so a unit loading late cannot shift the surface
   under someone mid-drill. */
.tr-adslot { min-height: 90px; margin: 28px 0; }

@media (max-width: 640px) {
  .page-wrap  { padding-left: 16px; padding-right: 16px; }
  .tr-prompt  { font-size: 17px; letter-spacing: 0.02em; }
  .tr-stats   { gap: 18px; }
  .tk-key     { width: 26px; height: 32px; font-size: 11px; }
  .tr-hero-val { font-size: 32px; min-width: 50px; }
}

/* Motion is suppressed; STATE is not. The locked opacity and greyscale stay,
   because they encode which levels are shut rather than decorating them. */
@media (prefers-reduced-motion: reduce) {
  .tc, .tr-level { transition: none; }
  .tr-level.is-unlocking,
  .tr-level.is-refused { animation: none; }
}
