/* ============================================================================
   AOA TEST CENTER — SEARCH THE BANK (screen 08)
   Utility-grade search over the question bank — find any question fast, then
   review it or turn the results into a practice set. NOT a chatbot or tutor.

   Heavy inheritance, little new. Every color/font/radius/shadow/motion value
   comes from test-center-system.css; the question-preview card comes VERBATIM
   from marked-review.css (.mr-card …). This file only adds the genuinely new
   surface: the hero SEARCH FIELD, the restrained MATCH HIGHLIGHT, the REFINE
   disclosure, the "Practice these N" action, and the resting / no-results
   states — plus the mobile (~390px) treatment.

   Discipline carried over: orange is a scalpel, whitespace is generous, motion
   is named, NEVER bright-yellow highlighter, NEVER red on "no results".
   ========================================================================== */

/* The screen reuses the Marked Review shell (.mr-screen / .mr-screen__body) —
   a centered ~720px column so stems stay readable. */
.sb-screen .session-bar { border-bottom: 1px solid var(--line); }

/* ----------------------------------------------------------------------------
   HEADER — eyebrow → heading. Tighter than other screens: the field is the hero.
   -------------------------------------------------------------------------- */
.sb-head { margin-bottom: clamp(18px, 3vw, 26px); }
.sb-eyebrow { margin-bottom: var(--s-3); }
.sb-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.7rem, 3.6vw, 2.3rem);
  line-height: 1.06; letter-spacing: 0.005em; color: var(--ink);
}

/* ----------------------------------------------------------------------------
   THE SEARCH FIELD — the hero. Instrument-grade, NOT a generic rounded box:
   a 2px underline-style field that reads like a panel readout. Leading stroke
   search icon; a clear "×" once there's text; the live count sits to the right.
   -------------------------------------------------------------------------- */
.sb-search { margin-bottom: var(--s-5); }
.sb-search__row {
  display: flex; align-items: center; gap: var(--s-4);
  flex-wrap: wrap;
}
.sb-search__field {
  flex: 1 1 420px; min-width: 0;
  display: flex; align-items: center; gap: var(--s-3);
  height: 60px; padding: 0 var(--s-3) 0 var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);   /* all corners rounded (Chris) */
  transition: border-color var(--brief) var(--ease-calm),
              box-shadow var(--brief) var(--ease-calm),
              background var(--brief) var(--ease-calm);
}
.sb-search__field:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244, 115, 33, 0.15);   /* one clean ring, no doubled box */
  background: var(--surface);
}
.sb-search__icon { flex: none; color: var(--muted); display: flex; transition: color var(--brief) var(--ease-calm); }
.sb-search__field:focus-within .sb-search__icon { color: var(--orange); }
.sb-search__input {
  flex: 1; min-width: 0; height: 100%;
  border: none; outline: none; background: none;
  font-family: var(--font-body); font-size: 1.08rem; font-weight: 400;
  color: var(--ink); letter-spacing: 0;
}
.sb-search__input::placeholder { color: var(--muted); opacity: 0.85; }
/* Suppress the browser's native type=search decorations — we render our own ×. */
.sb-search__input::-webkit-search-cancel-button,
.sb-search__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.sb-search__clear {
  flex: none; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--r-pill); background: none;
  color: var(--muted); cursor: pointer;
  transition: color var(--glance) var(--ease-calm), background var(--glance) var(--ease-calm);
}
.sb-search__clear:hover { color: var(--ink); background: var(--paper); }

/* The live result count — JetBrains Mono, instrument-readout. */
.sb-search__count {
  flex: none;
  font-family: var(--font-mono); font-weight: 500; font-size: 0.82rem;
  color: var(--muted); letter-spacing: 0.02em; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.sb-search__count b { color: var(--ink); font-weight: 500; }

/* Power-user hint under the field — the "/" and Esc shortcuts, very quiet. */
.sb-search__hints {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  margin-top: var(--s-3);
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted);
  letter-spacing: 0.02em;
}
.sb-search__hints .kbd { height: 22px; min-width: 22px; font-size: 0.68rem; }
.sb-hintsep { color: var(--line); }

/* ----------------------------------------------------------------------------
   MATCH HIGHLIGHT — RESTRAINED ember treatment. A deep-orange underline + a
   whisper-soft orange tint behind the word. NEVER a bright-yellow highlighter.
   Used inside the inherited .mr-card__stem.
   -------------------------------------------------------------------------- */
.sb-hl {
  background: var(--orange-soft);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  box-shadow: inset 0 -2px 0 rgba(244,115,33,0.55);
}

/* "matched in …" tag — when the hit was somewhere OTHER than the stem. Mono,
   quiet, sits at the right of the meta line where the marked-time would be. */
.sb-matched {
  margin-left: auto;
  font-family: var(--font-mono); font-weight: 500; font-size: 0.68rem;
  color: var(--muted); letter-spacing: 0.02em; white-space: nowrap;
  padding: 2px var(--s-2);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper);
}
/* The search card's cert prefix in the meta line. */
.mr-card__cert { font-family: var(--font-mono); font-weight: 500; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }
/* Neutral rail for search results — no "why-marked" reason here. */
.mr-card--search { --rail: var(--line); }

/* ----------------------------------------------------------------------------
   REFINE — progressive disclosure. A quiet toggle that expands the inherited
   chip-filter row. Collapsed by default — the field alone is enough for most.
   -------------------------------------------------------------------------- */
.sb-refinebar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.sb-refine-toggle {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-4);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink);
  transition: border-color var(--glance) var(--ease-calm),
              color var(--glance) var(--ease-calm), background var(--glance) var(--ease-calm);
}
.sb-refine-toggle:hover { border-color: var(--orange); color: var(--orange-text); background: var(--orange-soft); } /* label text → AA; border keeps brand */
.sb-refine-toggle svg { flex: none; transition: transform var(--brief) var(--ease-decisive); }
.sb-refine-toggle[aria-expanded="true"] { border-color: var(--orange); color: var(--orange-text); background: var(--orange-soft); } /* persistent state text → AA role */
.sb-refine-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.sb-refine-toggle__n {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--orange); color: var(--ink); /* navy on orange — AA (audit) */
  font-family: var(--font-mono); font-weight: 500; font-size: 0.64rem;
  font-variant-numeric: tabular-nums;
}

/* The disclosure body — inherited height reveal (callout.lift). */
.sb-refine {
  overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--paper);
  margin-bottom: var(--s-5);
  animation: callout-lift var(--beat) var(--ease-cinematic) both;
}
.sb-refine__inner { padding: var(--s-5) var(--s-6); }
.sb-refine__group { margin-bottom: var(--s-5); }
.sb-refine__group:last-child { margin-bottom: 0; }
.sb-refine__label {
  display: block; margin-bottom: var(--s-3);
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sb-refine__chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
/* Reuses the .mr-subj chip language verbatim; adds a checkable/toggle look. */
.sb-refine .mr-subj { min-height: 38px; }
.sb-refine__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); margin-top: var(--s-5); padding-top: var(--s-4);
  border-top: 1px dashed var(--line);
}
.sb-refine__count { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }
.sb-clear {
  background: none; border: none; padding: var(--s-2) 0; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  transition: color var(--glance) var(--ease-calm);
}
.sb-clear:hover { color: var(--orange-text); } /* hover label is text → AA role */
.sb-clear[disabled] { opacity: 0.4; pointer-events: none; }

/* Mastery chips inside refine carry the same dot-color family as the cards. */
.sb-mschip { display: inline-flex; align-items: center; gap: var(--s-2); }
.sb-mschip__dot { flex: none; width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--md, var(--guess)); }
.sb-mschip--strong   { --md: var(--success); }
.sb-mschip--building { --md: var(--guess); }
.sb-mschip--needs    { --md: var(--caution); }

/* ----------------------------------------------------------------------------
   THE "PRACTICE THESE N" ACTION — the sleeper feature. One primary action that
   turns the current result set into a study session. Sits above the list.
   -------------------------------------------------------------------------- */
.sb-action {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-5); flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.sb-action__summary {
  font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted);
  letter-spacing: 0.03em; font-variant-numeric: tabular-nums;
}
.sb-action__summary b { color: var(--ink); font-weight: 500; }
.sb-practice { white-space: nowrap; }

/* ----------------------------------------------------------------------------
   THE LIST — reuses .mr-list (column, gap). Cards enter with checklist.cascade.
   -------------------------------------------------------------------------- */
.sb-list { display: flex; flex-direction: column; gap: var(--s-4); }
/* cascade — first ~8 stagger in; the rest just appear. */
.sb-cascade { opacity: 0; transform: translateY(10px); }
.sb-cascade.is-in {
  opacity: 1; transform: none;
  transition: opacity var(--beat) var(--ease-cinematic), transform var(--beat) var(--ease-cinematic);
}

/* Honest pagination — show the count, lazy-load on demand. No mystery scroll. */
.sb-more {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  margin-top: var(--s-6); padding-top: var(--s-5);
}
.sb-more__note { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.03em; }
.sb-more__btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-5);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink);
  transition: border-color var(--glance) var(--ease-calm), color var(--glance) var(--ease-calm), background var(--glance) var(--ease-calm);
}
.sb-more__btn:hover { border-color: var(--orange); color: var(--orange-text); background: var(--orange-soft); } /* label text → AA; border keeps brand */

/* ----------------------------------------------------------------------------
   RESTING STATE — no query yet. A calm mentor line + suggested-topic chips.
   NOT a floating autocomplete dropdown — tappable chips, in place.
   -------------------------------------------------------------------------- */
.sb-resting { padding: clamp(8px, 2vw, 20px) 0 clamp(20px, 4vw, 36px); }
.sb-resting__lede {
  font-size: clamp(1.02rem, 1.6vw, 1.12rem); line-height: 1.55;
  color: var(--muted); text-wrap: pretty; max-width: 52ch;
  margin-bottom: var(--s-5);
}
.sb-resting__label {
  display: block; margin-bottom: var(--s-4);
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sb-topics { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.sb-topic {
  display: inline-flex; align-items: center; gap: var(--s-3);
  min-height: 48px; padding: 0 var(--s-5);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); cursor: pointer;
  font-family: var(--font-body); font-weight: 500; font-size: 0.96rem;
  color: var(--ink);
  transition: border-color var(--brief) var(--ease-calm),
              background var(--brief) var(--ease-calm), transform var(--tap) var(--ease-decisive);
}
.sb-topic__icon { flex: none; color: var(--muted); display: flex; transition: color var(--brief) var(--ease-calm); }
.sb-topic:hover { border-color: var(--orange); background: var(--orange-soft); }
.sb-topic:hover .sb-topic__icon { color: var(--orange); }
.sb-topic:active { transform: translateY(1px); }
/* ACS-code chips read in mono — they're a reference, not a topic word. */
.sb-topic--code { font-family: var(--font-mono); font-weight: 500; font-size: 0.86rem; letter-spacing: 0.02em; }

/* ----------------------------------------------------------------------------
   NO-RESULTS STATE — calm, NEVER red. Reuses the .mr-empty composition.
   -------------------------------------------------------------------------- */
.sb-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s-4); padding: clamp(32px, 5vw, 52px) var(--s-6);
}
.sb-empty__icon {
  width: 52px; height: 52px; border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); background: var(--paper); border: 1px solid var(--line);
}
.sb-empty__title {
  font-family: var(--font-display); font-weight: 600; font-size: 1.2rem;
  color: var(--ink); letter-spacing: 0.005em; text-wrap: pretty; max-width: 30ch;
}
.sb-empty__title q { font-style: normal; color: var(--orange-text); } /* quoted query is text → AA role */
.sb-empty__body { max-width: 42ch; font-size: 0.98rem; line-height: 1.55; color: var(--muted); text-wrap: pretty; }
.sb-empty__chips { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; margin-top: var(--s-2); }

/* aria-live announcer — visually hidden (count announced ONCE per settle). */
.sb-sr {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ----------------------------------------------------------------------------
   MICROCOPY DECK — the AOA-voice copy for this surface (team review). Reuses
   the Marked Review copy-deck composition verbatim.
   -------------------------------------------------------------------------- */
.sb-copy { padding: clamp(28px, 4vw, 40px); }

/* ============================================================================
   MOBILE (~390px) — co-primary. Driven by an explicit .sb--mobile class so the
   layout renders correctly inside a fixed-width artboard (container, not media).
   The same rules also fire under @media for the real responsive/focus view.
   ========================================================================== */
.sb--mobile.mr-screen { height: 100%; display: flex; flex-direction: column; }
.sb--mobile .mr-screen__body {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  padding: 0; max-width: none; overflow: hidden;
}
/* Search field is full-width and STICKY to the top — always reachable. */
.sb--mobile .sb-stickytop {
  position: sticky; top: 0; z-index: 4;
  background: var(--surface);
  padding: var(--s-4) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.sb--mobile .sb-search { margin-bottom: 0; }
.sb--mobile .sb-search__row { gap: var(--s-3); }
.sb--mobile .sb-search__field { flex: 1 1 100%; height: 54px; }
.sb--mobile .sb-search__count { flex: 1 1 100%; }
.sb--mobile .sb-search__hints { display: none; }
.sb--mobile .sb-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: var(--s-5) var(--s-5) var(--s-6);
}
.sb--mobile .sb-head { margin-bottom: var(--s-4); }
.sb--mobile .sb-title { font-size: 1.5rem; }
/* Refine opens as a bottom sheet. */
.sb--mobile .sb-refinebar { margin-bottom: var(--s-4); }
.sb--mobile .sb-action { margin-bottom: var(--s-4); }
.sb--mobile .sb-list { gap: var(--s-3); }

/* "Practice these N" is sticky-bottom on mobile. */
.sb--mobile .sb-mobilebar {
  flex: none; position: relative; z-index: 4;
  padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(22,19,18,0.06);
}
.sb--mobile .sb-mobilebar .btn-primary { width: 100%; justify-content: center; }

/* The bottom sheet itself — anchored to the artboard, with a scrim. */
.sb-sheet-scrim {
  position: absolute; inset: 0; z-index: 8;
  background: rgba(22,19,18,0.4);
  -webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px);
  animation: fade-in var(--brief) var(--ease-calm);
}
.sb-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-elevated);
  max-height: 86%; display: flex; flex-direction: column;
  animation: sheet-up var(--beat) var(--ease-cinematic) both;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.sb-sheet__grab { width: 36px; height: 4px; border-radius: var(--r-pill); background: var(--line); margin: var(--s-3) auto var(--s-1); flex: none; }
.sb-sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-5) var(--s-4); border-bottom: 1px solid var(--line); flex: none;
}
.sb-sheet__title { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; color: var(--ink); }
.sb-sheet__body { overflow-y: auto; padding: var(--s-5); }

@media (max-width: 640px) {
  .sb-search__row { gap: var(--s-3); }
  .sb-search__field { flex: 1 1 100%; }
  .sb-search__count { order: 3; }
  .sb-action { flex-direction: column; align-items: stretch; }
  .sb-practice { width: 100%; justify-content: center; }
  /* keyboard-shortcut hints are irrelevant on touch — hide via the block that actually
     fires on a phone (the .sb--mobile selector it relied on is never applied). */
  .sb-search__hints { display: none; }
}

/* Per-question CONFIDENCE BADGE — sits in the top-right corner of each search
   card (Chris 2026-06-05). Tells the student where THEY stand on THIS question:
   New (never answered) · Building · Confident · Review. Pill form so it reads as
   a status at a glance; color/soft-bg come from .mr-mastery--<state>. */
.mr-card--search .mr-card__meta { align-items: center; }
.mr-card--search .mr-mastery {
  margin-left: auto; flex: none;
  height: 22px; padding: 0 9px; gap: 5px;
  border-radius: var(--r-pill, 999px);
  background: var(--ms-soft, rgba(107,102,99,.1));
  font-size: 0.64rem;
}
.mr-card--search .mr-mastery svg { width: 12px; height: 12px; }
