/* =========================================================
   IZORA — PRACTICE PAGE
   On top of the tokens in styles.css, only the pieces that belong to
   this page: level bar, topic list, report buttons.

   The page is screen-locked: practice.html carries `body.page-fit` and the
   shared fit-* layout from styles.css, the same one the mock exam uses. The
   page itself never scrolls — the header is one line and the two panels split
   what is left of the screen. Nothing here may set a height that grows with
   the content, or the lock breaks and the question slides below the fold.
   ========================================================= */

.practice-id { min-width: 0; }

/* The header is one band across the top: identity on the left, the level bar
   on the right. `flex-end` keeps the level bar on the baseline of the title. */
.practice-head { align-items: flex-end; gap: 22px; padding: 2px 0 14px; }
.practice-head h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(21px, 2.2vw, 28px); letter-spacing: -.03em;
  line-height: 1.05; margin: 0;
}
.practice-head p { margin: 6px 0 0; color: var(--text-2); font-size: 14px; max-width: 56ch; }

/* level bar — shows at a glance which step the student is on */
.levelbar { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.levelbar .lv {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 15px; min-width: 116px;
  display: flex; flex-direction: column; gap: 2px;
  color: var(--text-3); background: transparent;
}
.levelbar .lv b { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 500; }
.levelbar .lv span { font-size: 14.5px; color: var(--text-2); }
.levelbar .lv.done { border-color: var(--m-strong); color: var(--m-strong); }
.levelbar .lv.done span { color: var(--m-strong); }
.levelbar .lv.on {
  border-color: var(--brand); background: var(--tint); color: var(--brand);
}
.levelbar .lv.on span { color: var(--text); }

/* The question takes the wider share; the map is a companion, not a second
   thing to read. Both are as tall as the screen allows and no taller. */
.practice-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(0, .55fr);
  gap: 18px;
}
@media (max-width: 1240px) { .practice-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, .4fr); } }

/* ---------- the question panel ----------
   `.fit-panel .qstage` (styles.css) already scrolls inside itself. What is
   added here is the action row: «Növbəti sual» (and the button that ends the
   round) is stuck to the bottom edge of the panel. With a short question the
   footer is down there anyway; with a long one the student can read on and the
   button is still where they left it — they never scroll to look for it.
   The shadow only shows when something has scrolled under the row. */
.practice-grid .qstage { padding: 20px 26px 0; }
.practice-grid .qfoot { margin-top: auto; display: block; padding-top: 16px; }
.practice-grid .qact,
.practice-grid .res-act {
  position: sticky; bottom: 0; z-index: 1;
  margin-top: 16px; padding: 12px 0 18px;
  background: var(--panel);
  box-shadow: 0 -16px 20px -16px var(--panel);
}

/* =========================================================
   PHONE
   At 360×640 the header block filled a whole screen and the first
   question started at 684px — the student saw no question at all when
   the page opened. Here the intro text gets tighter and the level bar
   turns from three large cards into a single row.
   ========================================================= */
@media (max-width: 680px) {
  .practice-head { gap: 16px; padding: 4px 0 18px; }
  .practice-head h1 { font-size: 25px; line-height: 1.08; }
  .practice-head p { font-size: 14px; line-height: 1.5; margin-top: 10px; }
  .practice-head .sync-note { margin-top: 10px; font-size: 13px; }

  /* levels: the three cards used to stack. Now they sit on one row in
     equal shares — the current step is visible at a glance. */
  .levelbar { width: 100%; margin-left: 0; gap: 6px; flex-wrap: nowrap; }
  .levelbar .lv { flex: 1 1 0; min-width: 0; padding: 8px 10px; }
  .levelbar .lv b { font-size: 10px; letter-spacing: .06em; }
  .levelbar .lv span {
    font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  .sp-side { padding: 16px 16px 4px; }
  .tl-row { grid-template-columns: minmax(0, 1fr) 62px 46px; gap: 10px; }
}

/* footer of the question panel */
.qsrc {
  margin: 14px 0 0; font-size: 12.5px; color: var(--text-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.res-act { margin-top: 24px; }
.res-note { margin: 12px 0 0; font-size: 13.5px; color: var(--text-3); line-height: 1.6; }
.res-head code { color: var(--brand); font-size: 13.5px; }

/* topic list — the textual counterpart of the map */
.tl-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-3); font-weight: 500;
  padding: 20px 0 9px; border-bottom: 1px solid var(--line-soft); margin-bottom: 8px;
}
.tl-head .mono-tag { margin-left: auto; }
.tl-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 76px 54px;
  align-items: center; gap: 12px; padding: 6px 0; font-size: 14px;
}
.tl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.tl-bar { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.tl-bar i { display: block; height: 100%; border-radius: 3px; transition: width .45s cubic-bezier(.2,.8,.25,1); }
.tl-val {
  text-align: right; font-size: 12.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.tl-row.weak   .tl-bar i { background: var(--m-weak); }
.tl-row.mid    .tl-bar i { background: var(--m-mid); }
.tl-row.strong .tl-bar i { background: var(--m-strong); }
.tl-row.strong .tl-name { color: var(--text); }
.tl-row.locked { opacity: .5; }
.tl-row.locked .tl-val { font-size: 11.5px; }

/* ---------- Knowledge-map panel ----------
   The spiral keeps its size and the topic list takes exactly the height that
   is left, scrolling inside itself. The panel therefore ends where the screen
   ends — it can never push the question down. */
.sp-side { padding: 16px 18px 4px; }
.practice-grid .sp-side { flex: none; }
.practice-grid .sp-side .sp-stage { max-width: 190px; }
.practice-grid #topicList { flex: 1; min-height: 0; max-height: none; }

#topicList {
  padding: 0 18px 18px;
  max-height: 300px; overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
#topicList::-webkit-scrollbar { width: 7px; }
#topicList::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

/* where progress is stored — js/practice.js → syncNote() */
.practice-head .sync-note { margin-top: 12px; font-size: 13.5px; color: var(--text-3); min-height: 20px; }
.practice-head .sync-note.cloud::before { content: "● "; color: var(--m-strong); }
.practice-head .sync-note.error { color: var(--m-weak); }
.sync-note .linkish {
  background: none; border: 0; padding: 0; font: inherit; color: var(--brand);
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
/* A link inside a sentence was 20px tall — hard to hit with a finger.
   Vertical padding does not affect the line box, so the text stays put
   while the touch target grows. */
@media (pointer: coarse) {
  .sync-note .linkish { padding: 12px 4px; margin: 0 -4px; }
}

/* =========================================================
   QUESTION TYPES — js/practice.js (choice · pick · open)
   ========================================================= */

/* passage — above a reading question; a long text scrolls inside itself so
   the question and the options stay on screen */
.qpassage {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  margin: 0 0 18px; background: var(--tint);
}
.qpassage summary {
  cursor: pointer; padding: 10px 14px;
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3);
}
.qpassage-body {
  padding: 0 16px 14px; max-height: min(320px, 34vh); overflow: auto; overscroll-behavior: contain;
  white-space: pre-line; font-size: 15.5px; line-height: 1.62; color: var(--text-2);
}

/* numbered / lettered list — with the book's own keys (1. 2. · a) b)) */
.qkeyed { list-style: none; margin: 0 0 18px; padding: 0; font-size: 16px; line-height: 1.55; color: var(--text-2); }
.qkeyed li { display: flex; gap: 10px; padding: 2px 0; }
.qkeyed .qkey { flex: none; min-width: 22px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.qkeyed.right { padding-left: 14px; border-left: 2px solid var(--line-soft); }

/* multiple choice — the .opt look, with a checkbox */
.pick-opt { cursor: pointer; }
.pick-opt input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--brand); }
.pick-opt:has(input:checked) { border-color: var(--brand); background: var(--tint); }
.pick-opt.correct { border-color: var(--m-strong); background: var(--wash-strong); }
.pick-opt.wrong { border-color: var(--m-weak); background: var(--wash-weak); }
.opt-t { min-width: 0; overflow-wrap: anywhere; }
/* KaTeX: long formulas scroll inside their own line instead of widening the page */
.qtext .katex-display, .opt-t .katex-display { overflow-x: auto; overflow-y: hidden; }
.qtext .katex, .opt-t .katex, .qkeyed .katex { font-size: 1.05em; }

/* code block (informatics: Python listings, spreadsheet formulas).
   `white-space: pre` and no wrapping are the point — a Python line that wraps or
   loses its indentation is a different program. Long lines scroll sideways
   inside the block instead of widening the page. */
.qcode {
  margin: 10px 0; padding: 11px 13px; border: 1px solid var(--line-soft); border-radius: 8px;
  background: var(--tint); overflow-x: auto; overscroll-behavior-x: contain;
  font-size: 14px; line-height: 1.5; color: var(--text);
}
.qcode code {
  display: block; white-space: pre; tab-size: 4;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
.opt-t .qcode, .qkeyed .qcode { margin: 4px 0; font-size: 13px; }
.opt-t .qcode:first-child, .qkeyed .qcode:first-child { margin-top: 0; }
.opt-t .qcode:last-child, .qkeyed .qcode:last-child { margin-bottom: 0; }
@media (max-width: 560px) { .qcode { font-size: 13px; } .opt-t .qcode, .qkeyed .qcode { font-size: 12px; } }
.qcheck { margin-top: 14px; }
.qhint-inline { margin: 12px 0 0; font-size: 13.5px; color: var(--text-3); }

/* type the answer */
.open-form { display: flex; gap: 10px; flex-wrap: wrap; }
.open-input {
  flex: 1 1 260px; min-width: 0; font: inherit; font-size: 16px; color: var(--text);
  background: transparent; border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 12px 18px;
}
.open-input:focus { outline: none; border-color: var(--brand); }
.qright { margin: 0 0 14px; font-size: 15px; color: var(--text-2); }

/* more than 6 levels (a subject stepped by book order — English has 19
   sections): the cards do not fit, so only numbers show, plus the name of
   the current level */
.levelbar.many { gap: 5px; max-width: 100%; }
.levelbar.many .lv { min-width: 0; padding: 6px 9px; align-items: center; }
.levelbar.many .lv span { display: none; }
.levelbar.many .lv.on { padding: 6px 12px; }
.levelbar.many .lv.on span { display: block; font-size: 13px; white-space: nowrap; }
@media (max-width: 680px) {
  .levelbar.many { flex-wrap: wrap; }
  .levelbar.many .lv { flex: 0 0 auto; }
}

/* =========================================================
   SHORT SCREEN — a laptop is often 1440×760, not 1440×900
   The screen-locked layout has nowhere to give, so the header and the map give
   instead: the spiral shrinks and the sync line drops out. The question keeps
   its size — it is the thing being read.
   ========================================================= */
@media (max-height: 800px) and (min-width: 1081px) {
  /* css/practice.css is loaded by practice.html only, so a bare `.fit-wrap`
     rule here cannot reach the exam page. */
  .fit-wrap { padding-bottom: 12px; }
  .practice-head { padding: 0 0 10px; }
  /* Where progress is stored is the same sentence every time — on a short
     screen those two lines belong to the question. */
  .practice-head .sync-note { display: none; }
  .practice-grid .sp-side { padding: 10px 18px 0; }
  .practice-grid .sp-side .sp-stage { max-width: 138px; }
  /* (below 721px the spiral is hidden outright — css/spiral.css) */

  /* The question, its options and the explanation after the answer have to
     share ~460px. Everything loses a few pixels of air; the question text and
     the options stay at a size that is still comfortable to read. */
  .practice-grid .qstage { padding: 14px 24px 0; }
  .practice-grid .qcue { margin-bottom: 10px; padding: 4px 12px; font-size: 12px; }
  .practice-grid .qtext { font-size: 16.5px; margin-bottom: 12px; }
  .practice-grid .options { gap: 7px; }
  .practice-grid .opt { padding: 9px 16px; font-size: 14.5px; }
  .practice-grid .qfoot { padding-top: 10px; }
  .practice-grid .verdict { margin-bottom: 9px; }
  .practice-grid .explain { padding-left: 13px; }
  .practice-grid .explain p { font-size: 13.5px; line-height: 1.45; }
  .practice-grid .qsrc { margin-top: 9px; font-size: 11.5px; }
  .practice-grid .qact,
  .practice-grid .res-act { margin-top: 10px; padding: 10px 0 14px; }
}

/* =========================================================
   NARROW SCREEN — the lock is off (css/styles.css, max-width:1080px)
   The page scrolls normally there, so everything that only makes sense inside
   a fixed-height panel is undone: a footer pinned to the bottom of a panel
   that is now as tall as its content would follow the student down the page.
   ========================================================= */
@media (max-width: 1080px) {
  /* the columns and the panel spacing are already undone by the shared
     max-width:1080px block in css/styles.css */
  .practice-grid .qstage { padding: 22px 20px 24px; }
  .practice-grid .qfoot { margin-top: 22px; padding-top: 0; }
  .practice-grid .qact,
  .practice-grid .res-act {
    position: static; padding: 0; background: none; box-shadow: none;
  }
  .practice-grid #topicList { flex: none; max-height: 340px; }
}
