/* One question per screen (run-steps.js): the placement quiz, practice sets and the mistakes
   review. Phone first: the text on top and one question under it, each scrolling on its own;
   Previous, Check answer and Next sit at the bottom, within reach of the thumb. On a wide screen
   the text and the question sit side by side, half and half. Mock tests are not affected.
   On a phone the text can be raised as a drawer over the question (drawer.js; STORY-04.22). */

/* The rows change at once: with Reduce Motion tokens.css gives every change 0.01 ms, long enough for a row to be drawn half way. */
.exam-body.steps { transition: none; }
.steps .questions__in { gap: var(--s4); }
.step-part:empty { display: none; }
/* The heading above already says "Questions 11–16 of 24". */
.step-q .q__range { display: none; }
.step-head { display: flex; align-items: baseline; }
.step-head__title { font-size: var(--fs-l); font-variant-numeric: tabular-nums; }
/* The text's own instruction is small text under its title, not a block of its own. */
.steps .passage__kicker { margin-top: var(--s1); }

/* The text is a raised card (the box of STORY-04.13) with the passage in it: the corner button, the drawer's handle and the
   sheet's shape are on the card, so the text itself never moves. */
.step-card { display: flex; flex-direction: column; overflow: hidden; }
.step-card > .passage { flex: 1 1 auto; border-radius: inherit; }
.step-grip, .step-card > .box-tool { display: none; }

/* The footer: Previous, Check answer, Next, and a thin line along its top for how far along. A bar of 56 px with 44 px buttons. */
.palette--steps { position: relative; min-height: 56px; padding-block: 6px calc(6px + env(safe-area-inset-bottom)); }
.step-line { position: absolute; inset-inline: 0; top: -1px; height: 4px; background: var(--exam-line); }
.step-line > span { display: block; height: 100%; background: var(--ink); }
.step-mid { display: flex; justify-content: center; min-width: 0; }

@media (max-width: 860px) {
  .palette--steps > .btn { width: auto; min-width: 48px; padding: 0 var(--s4); }
  .palette--steps > .btn span:not(.sr) { display: inline; }
  .palette--steps > .step-prev { width: 48px; padding: 0; }
  .step-prev__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .step-mid .btn { padding: 0 var(--s4); }

  /* The question's heading is one slim line, so it and the footer take 81 px together. */
  .exam-body.steps > .questions { padding-top: 6px; }
  .steps .questions__in { gap: var(--s1); }
  .step-head { min-height: 24px; }
  .step-head__title { font: 700 var(--fs-s)/1.4 var(--text); color: var(--ink-2); }

  /* A part with a text to read: the text and the question share the screen half and half, with the bar between them
     ("Hide text", "Read full screen"; dashboard.css also styles a class named .steps, a 12px gap, so the gap is set here). */
  .exam-body.steps.has-text { grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); row-gap: 0; }
  .step-bar { display: flex; align-items: center; justify-content: end; gap: var(--s2); min-height: 52px; padding: var(--s1); }
  .step-bar__title { display: none; min-width: 0; margin-inline-end: auto; font-family: var(--display); font-weight: 700; font-size: var(--fs-l); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Two buttons with a fill and a 2 px ink border (3:1 and more against the bar); "Show question" is the one solid button. */
  .step-bar .btn { flex: none; min-height: 44px; padding: 0 var(--s4); font-family: var(--text); font-size: var(--fs-m); font-weight: 700; white-space: nowrap; }
  .step-bar .btn--exam-plain { --face: var(--exam-fill); --on: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
  .step-bar .btn .i { width: 16px; height: 16px; stroke-width: 2.5; }
  .step-card > .box-tool { display: grid; }
  .steps .passage__in > :first-child { margin-inline-end: var(--s7); }

  /* A recording's card (STORY-04.20) is as tall as its words and the player, up to 46%; exam.css names the passage as the body's
     own child, and here the card holds it. */
  .exam-body.steps:not(.is-single):not(.has-text):has(> .step-card .block-audio) { grid-template-rows: fit-content(46%) minmax(0, 1fr); }

  /* "Hide text" folds the text away and the bar stays with "Show text"; a recording stays, so its plays left stay in view. */
  .exam-body.steps.has-text.is-text-hidden { grid-template-rows: auto auto minmax(0, 1fr); }
  .steps.is-text-hidden > .step-card { grid-row: 1; }
  .steps.is-text-hidden > .step-bar { grid-row: 2; }
  .steps.is-text-hidden > .questions { grid-row: 3; }
  .steps.is-text-hidden > .step-card:not(:has(.block-audio)), .steps.is-text-hidden > .step-card > .box-tool, .steps.is-text-hidden .step-whole { display: none; }
  .steps.is-text-hidden .passage__in > :not(.passage__body), .steps.is-text-hidden .passage__body > :not(.block-audio) { display: none; }
  .steps.is-text-hidden .passage { padding-block: var(--s3); }

  /* The drawer: "Read full screen" raises the text as a sheet over the screen. It has rounded top corners, the elevation
     shadow, a handle and the dimmed question behind it (inert; the 40 px of it above the sheet are the dimming). The bar
     is the sheet's foot: the question's heading and "Show question". */
  .exam-body.steps.is-text-whole { position: relative; grid-template-rows: 40px minmax(0, 1fr) auto; gap: 0; padding: 0; }
  .steps.is-text-whole::after { content: ""; position: absolute; inset: 0; z-index: 5; background: var(--scrim-deep); animation: step-fade 200ms ease-out; }
  .steps.is-text-whole > .questions { grid-area: 1 / 1 / -1 / -1; }
  .steps.is-text-whole > .step-card { grid-area: 2 / 1; z-index: 6; border-radius: var(--r-l) var(--r-l) 0 0; box-shadow: 0 0 0 1px var(--exam-line), var(--float); animation: step-up 220ms ease-out; }
  .exam--plain .steps.is-text-whole > .step-card { box-shadow: 0 0 0 1px var(--exam-line), var(--float); }
  .steps.is-text-whole > .step-bar { grid-area: 3 / 1; z-index: 6; min-height: 60px; padding: var(--s2) var(--s4); background: var(--exam-bg); border-top: 1px solid var(--exam-line); }
  .steps.is-text-whole .step-bar__title { display: block; }
  .steps.is-text-whole .step-toggle { display: none; }
  .steps.is-text-whole .step-grip { position: relative; flex: none; display: grid; place-items: center; height: 44px; }
  .steps.is-text-whole .step-grip::before { content: ""; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); }
  .steps.is-text-whole .passage { padding-top: 0; }
  .steps.is-text-whole .passage__in > :first-child { margin-inline-end: 0; }
  @keyframes step-up { from { transform: translateY(32px); opacity: 0; } }
  @keyframes step-fade { from { opacity: 0; } }
  /* With Reduce Motion the drawer appears at once (the app's global rule would still leave 0.01 ms). */
  @media (prefers-reduced-motion: reduce) {
    .steps.is-text-whole::after, .steps.is-text-whole > .step-card { animation: none !important; transition: none !important; }
  }
}

/* A very narrow phone: the bar's heading stays on one line beside "Show question", smaller and
   with less space around it; only a long range is cut short (a screen reader reads it whole). */
@media (max-width: 359px) {
  .step-bar__title { font-size: var(--fs-m); }
  .step-bar .btn { padding: 0 var(--s3); }
  /* Previous, Check answer and Next side by side without touching, their words whole. */
  .palette--steps > .btn:not(.step-prev), .step-mid .btn { padding: 0 var(--s2); }
}

@media (min-width: 861px) {
  .exam-body.steps:not(.is-single) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .step-bar { display: none; }
  /* The two panes' titles line up: the text's title and the question's heading are one type, one top and one baseline. */
  .steps .passage__in > h1, .step-head__title { margin: 0; font-family: var(--display); font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.015em; }
}

/* Reading practice in practice mode (run-reading.js, pull-up.js; STORY-03.33, O17): the text keeps the room and the
   part's questions sit in a list at the bottom, at peek, half or full height (the panel's height is set in px by
   pull-up.js; the text takes the rest and keeps scrolling). The handle is the bottom row, in thumb reach. */
.exam-main > .exam-body.pu-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; row-gap: 0; }
.exam-body.pu-body .passage { border-inline-end: 0; border-bottom: 0; }
/* The screen and the panel never scroll themselves (a field brought into view would move them): only the text and
   the list scroll. `.palette` is there for the app's messages only (pull-up.js); none of its bar styles apply. */
.exam:has(.pu-body), .exam-body.pu-body { overflow: clip; }
.exam .pu.palette {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-items: stretch; gap: 0; min-height: 0; padding: 0;
  overflow: clip; background: var(--exam-pane); border-top: 2px solid var(--line-strong);
}
.pu__handle {
  display: grid; justify-items: center; gap: var(--s1); width: 100%; min-height: 52px; padding: var(--s2) var(--s4);
  border: 0; border-bottom: 1px solid var(--exam-line); background: var(--exam-bg); color: var(--ink);
  font-family: var(--text); font-size: var(--fs-m); font-weight: 700; line-height: 1.3; touch-action: none; cursor: pointer;
}
.pu__handle:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }
.pu__grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.pu__sum { font-variant-numeric: tabular-nums; }
.pu__list { position: relative; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--s4) var(--s6); }
.pq { position: relative; display: grid; gap: var(--s3); max-width: 720px; margin-inline: auto; padding: var(--s4) 0 var(--s5) var(--s3); }
.pq + .pq { border-top: 1px solid var(--exam-line); }
/* The open question: a bar of ink along its side. */
.pq.is-open::before { content: ""; position: absolute; inset-block: var(--s3); inset-inline-start: 0; width: 3px; border-radius: 2px; background: var(--ink); }
.pq:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pq__state { justify-self: end; min-height: 20px; font-size: var(--fs-s); line-height: 20px; color: var(--ink-2); }
.pq__state[data-state="right"] { color: var(--teal); font-weight: 700; }
.pq__state[data-state="wrong"] { color: var(--coral-ink); font-weight: 700; }
.pq__acts { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2); }
.pq__acts .btn { min-height: 44px; padding: 0 var(--s4); }
.pq__check[hidden] { display: none; }
.pq__next { margin-inline-start: auto; }
.pu__prev { max-width: 720px; margin-inline: auto; padding-top: var(--s4); }
.pu__prev .btn { min-height: 44px; padding: 0 var(--s4); }
/* The card's label: only on a laptop, where the list is the questions card of the split. */
.pu__label { display: none; }
@media (min-width: 861px) {
  .exam-body.pu-body .passage { padding-block: var(--s6) var(--s7); }
  .pu__list { padding-inline: var(--s6); }
  /* The top bar's part buttons do this job on a wide screen. */
  .pu__prev { display: none; }

  /* The laptop split (STORY-04.43; SN Test screens, DECIDED: on a laptop every passage-plus-questions screen is a side-by-side
     split): the text card on the left and the questions card on the right, as the model test's two cards (exam.css
     .exam-body, 11fr 9fr), each scrolling on its own; no handle. pull-up.js drops the panel's own height here. */
  .exam-main > .exam-body.pu-body { grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); grid-template-rows: minmax(0, 1fr); gap: var(--s4); padding: var(--s4); background: var(--exam-pane); }
  .exam-body.pu-body > .passage, .exam .pu.palette {
    border-radius: var(--r-m); background: var(--exam-bg);
    box-shadow: 0 0 0 1px var(--exam-line), 0 2px 4px var(--shade-06), 0 6px 16px var(--shade-08);
  }
  .exam .pu.palette { height: auto; border-top: 0; }
  .exam--plain .exam-body.pu-body > .passage, .exam--plain .pu.palette { box-shadow: 0 0 0 1px var(--exam-line); }
  .pu__handle { display: none; }
  .pu__label {
    display: block; margin: 0; padding: var(--s3) var(--s6); border-bottom: 1px solid var(--exam-line);
    font-size: var(--fs-s); font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums;
  }
}
