/* OPEN PRACTICE: the student's topic chooser.
   ==========================================================================
   Its own stylesheet, and not a block appended to app.css, for one reason:
   app.css is drifted in BOTH deployments (tools/audit_core_drift.py), so a
   block added there would have to be hand-carried into two files that the
   next sync will rewrite anyway. A new file is written once by the sync and
   is identical in all three repos.

   THE HARD PART IS 111 TOPICS ON A 360px PHONE. A flat list of 111 checkboxes
   is roughly eight screens of scrolling with no landmarks, and a student
   looking for "the thing we did Tuesday" has to read all of it. Three things
   stop that:

     1. COLLAPSED BY UNIT. Ten rows to start with, each naming a unit and
        saying how many topics and how many questions are behind it. Nothing
        is expanded until it is asked for.
     2. A FILTER BOX that matches the number OR the words, so "6.12" and
        "chain" both land in one keystroke or two. Matching units open
        themselves while a filter is live and close again when it is cleared.
     3. A STICKY SUMMARY BAR at the bottom holding the running count and the
        Start button, so the student never has to scroll back up to find out
        what they have picked or to begin.

   Everything tappable is var(--tap) tall, which is the site's 48px floor, and
   the variables come from app.css -- this file adds no palette of its own.
   Measured at 360px by tools/audit_open_practice.py. */

.op { margin: 18px 0 0; }

.op-lede { margin: 0 0 12px; color: var(--ink-soft); font-size: 15px;
           line-height: 1.5; }

/* ---- the filter box -------------------------------------------------- */
.op-find {
  width: 100%; min-height: var(--tap);
  padding: 10px 12px;
  font: inherit; font-size: 16px;      /* 16px: anything smaller zooms on iOS */
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.op-find:focus-visible { outline: 3px solid #bcd6f2; outline-offset: 1px; }

/* ---- a unit ---------------------------------------------------------- */
.op-units { margin: 12px 0 0; }

.op-unit { border: 1px solid var(--line); border-radius: var(--radius);
           background: var(--paper); margin: 0 0 8px; overflow: hidden; }

/* The header is a row of two controls, not one control with a checkbox drawn
   inside it: "open Unit 3" and "pick all of Unit 3" are different actions and
   a student must be able to do either without doing the other. */
.op-unit-head { display: flex; align-items: stretch; }

.op-unit-toggle {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px;
  min-height: var(--tap); padding: 9px 10px;
  font: inherit; text-align: left; cursor: pointer;
  background: none; border: 0; color: var(--ink);
}
.op-unit-toggle:focus-visible { outline: 3px solid #bcd6f2; outline-offset: -3px; }
.op-unit-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.op-unit-sub  { color: var(--ink-soft); font-size: 12.5px; }

/* The caret is drawn from the button's own aria-expanded so there is one
   source of truth for "is this open" -- the one a screen reader reads. */
.op-caret { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 4px;
            border-right: 2px solid var(--ink-soft);
            border-bottom: 2px solid var(--ink-soft);
            transform: rotate(45deg); transition: transform .12s ease; }
.op-unit-toggle[aria-expanded="true"] .op-caret { transform: rotate(-135deg);
                                                  margin-top: 8px; }
.op-unit-line { display: flex; align-items: center; gap: 8px; width: 100%; }

.op-unit-all {
  flex: 0 0 auto; min-width: 84px; min-height: var(--tap);
  padding: 0 10px; font: inherit; font-size: 13px; cursor: pointer;
  color: var(--brand); background: var(--sunken);
  border: 0; border-left: 1px solid var(--line);
}
.op-unit-all:focus-visible { outline: 3px solid #bcd6f2; outline-offset: -3px; }
.op-unit-all[disabled] { color: var(--ink-soft); cursor: default; }

.op-unit.on { border-color: var(--brand); }

/* ---- a topic --------------------------------------------------------- */
.op-list { list-style: none; margin: 0; padding: 0;
           border-top: 1px solid var(--line); }
.op-list[hidden] { display: none; }
.op-item { border-bottom: 1px solid #eef0f3; }
.op-item:last-child { border-bottom: 0; }

/* A real <label> around a real checkbox: the whole row is the hit target, the
   checkbox is focusable and space toggles it, and no key handling is written
   by hand. */
.op-row {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 7px 10px; cursor: pointer;
}
.op-row input { flex: 0 0 auto; width: 20px; height: 20px; margin: 0;
                accent-color: var(--brand); }
.op-row input:focus-visible { outline: 3px solid #bcd6f2; outline-offset: 2px; }
.op-text { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
/* THE NUMBER IS NOT DECORATION. Randy: "students can pick the topics BY
   NUMBER AND DESCRIPTION" -- the number is how a student finds the thing
   their teacher just taught, so it leads the line and is not dimmed. */
.op-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.op-name { font-size: 14.5px; }
.op-left { flex: 0 0 auto; font-size: 12px; color: var(--ink-soft);
           font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Thin, but not empty. Said in the row rather than discovered by picking it. */
.op-left.thin { color: #8a5a12; }
.op-item.empty .op-row { cursor: default; opacity: .62; }
.op-item.empty .op-left { color: var(--ink-soft); }
.op-row input[disabled] { cursor: default; }

/* ---- the summary bar ------------------------------------------------- */
/* Sticky, because the alternative on a phone is scrolling back past up to 111
   rows to find out what you have picked or to press Start. */
.op-bar {
  position: sticky; bottom: 0; z-index: 4;
  margin: 10px 0 0; padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  background: var(--sunken);
  border-top: 1px solid var(--line);
}
.op-count { margin: 0 0 8px; font-size: 14px; color: var(--ink); }
.op-count .op-warn { color: #8a5a12; }
.op-actions { display: flex; gap: 8px; }
/* NOWRAP, measured: at 360px "Start practice" broke over two lines beside a
   96px Clear, which made the primary button 88px tall and the bar eat a third
   of the viewport. The label is not shortened -- "Start" alone, under a list
   of topics, reads as "start the list". */
.op-actions .btn { width: auto; flex: 1 1 auto; white-space: nowrap; }
.op-actions .btn.op-clear { flex: 0 0 auto; min-width: 84px; padding: 0 10px; }

.op-none { margin: 10px 0 0; color: var(--ink-soft); font-size: 14px; }

/* ---- finishing an untimed set --------------------------------------- */
/* A set with no clock and no question count has no natural end, so the
   student is given one. Quiet and below the question, never beside Next:
   it is the way out, not the way on. */
.q-finish { margin: 14px 0 0; text-align: center; }
.q-finish button { min-height: var(--tap); }

@media (max-width: 420px) {
  .op-unit-all { min-width: 72px; font-size: 12.5px; }
  .op-name { font-size: 14px; }
}
