/* sixteen.: accessibility layer (sprint 4, plan 05; docs/accessibility.md). Loaded last, after every other sheet.
   Overrides only: app.css stays Pace's verbatim copy. Sections: light tokens (AA), focus, reduced motion,
   high-contrast theme, zoom and reflow, phone widths. Token pairs are checked by test/contrast.test.ts. */

/* ---------- light tokens: AA text contrast on every surface ---------- */
/* app.css's muted (#6d6d76), faint (#96969d) and purple (#6f5acb) fall under 4.5:1 on the soft surfaces
   (#efefeb, #ecece6, #efebfc) that pills, segments and kbd use. */
:root{--muted:#5e5e67;--faint:#65656e;--purple:#5f4bbf;--amber:#8a5d1f}
kbd{color:var(--muted)}
.breadcrumb span{color:var(--muted)}

/* ---------- focus: visible on everything that can take it ---------- */
[tabindex]:focus-visible,summary:focus-visible,[role="button"]:focus-visible,[role="radio"]:focus-visible,[role="tab"]:focus-visible,[contenteditable]:focus-visible{outline:3px solid var(--purple);outline-offset:3px}
.skip-link:focus,.skip-link:focus-visible{top:12px;outline:3px solid var(--lime);outline-offset:2px}
/* The test overlay keeps Bluebook's blue ring, including on the focusable passage pane. */
.test-overlay .item-stimulus:focus-visible{outline:none;box-shadow:inset 0 0 0 3px var(--test-blue)}
.pacing-chart .pc-q:focus-visible .pc-hit{stroke-width:3}

/* ---------- reduced motion: the OS setting, or the Settings override (data-motion) ---------- */
@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  *,*::before,*::after{animation-duration:.001ms !important;animation-iteration-count:1 !important;transition-duration:.001ms !important;transition-delay:0s !important;scroll-behavior:auto !important}
}
:root[data-motion="reduce"]{scroll-behavior:auto}
:root[data-motion="reduce"] *,:root[data-motion="reduce"] *::before,:root[data-motion="reduce"] *::after{animation-duration:.001ms !important;animation-iteration-count:1 !important;transition-duration:.001ms !important;transition-delay:0s !important;scroll-behavior:auto !important}
/* The 5-minute alert under reduced motion: a static highlight instead of the flash (overlay.js adds it). */
.test-timer.flash-static{background:#ffe8a3;border-radius:6px;box-shadow:0 0 0 2px var(--test-ink)}

/* ---------- high-contrast theme (Settings > Display > Theme) ---------- */
:root[data-theme="high-contrast"]{
  --bg:#fff;--paper:#fff;--ink:#000;--muted:#2e2e33;--faint:#3d3d42;--line:#6b6b6b;--soft:#f0f0f0;--lime:#d9ef9f;
  --purple:#3a1f9c;--purple-soft:#f1eefc;--green:#0a5a36;--green-soft:#eaf5ec;--red:#8f1d14;--red-soft:#fcecea;--amber:#5e3b00;--amber-soft:#fbf0d5;
  --shadow:none;
  --test-ink:#000;--test-muted:#2e2e33;--test-line:#000;--test-blue:#1c2f9c;--test-blue-soft:#e6eafb;--test-mark:#a3102a;--test-head:#fff;
}
:root[data-theme="high-contrast"] body{background:#fff;color:#000}
:root[data-theme="high-contrast"] .sidebar{background:#fff;border-right:2px solid #000}
:root[data-theme="high-contrast"] .topbar{border-bottom:2px solid #000}
:root[data-theme="high-contrast"] .card{border:2px solid #000}
:root[data-theme="high-contrast"] .button,:root[data-theme="high-contrast"] .segment,:root[data-theme="high-contrast"] .chip,:root[data-theme="high-contrast"] .etag-chip,:root[data-theme="high-contrast"] .drill-tool,:root[data-theme="high-contrast"] .input{border:2px solid #000}
:root[data-theme="high-contrast"] .segment.active,:root[data-theme="high-contrast"] .segment[aria-pressed="true"]{background:#000;color:#fff}
:root[data-theme="high-contrast"] .pill{border:1px solid currentColor}
:root[data-theme="high-contrast"] .nav a{color:#000}
:root[data-theme="high-contrast"] .nav a.active{background:#000;color:#fff}
:root[data-theme="high-contrast"] main a:not(.button):not(.chip),:root[data-theme="high-contrast"] .test-overlay a,:root[data-theme="high-contrast"] .text-button{text-decoration:underline;text-underline-offset:3px}
:root[data-theme="high-contrast"] :focus-visible{outline:4px solid #000 !important;outline-offset:3px !important;box-shadow:0 0 0 7px #fff !important}
:root[data-theme="high-contrast"] .answer{border-width:2px;border-color:#000}
:root[data-theme="high-contrast"] .answer.selected{box-shadow:inset 0 0 0 3px var(--purple)}
:root[data-theme="high-contrast"] .test-overlay .item .answer.selected{box-shadow:0 0 0 3px var(--test-blue)}
:root[data-theme="high-contrast"] .test-overlay .item .answer.eliminated{opacity:1}
:root[data-theme="high-contrast"] .test-head::after,:root[data-theme="high-contrast"] .test-qbar,:root[data-theme="high-contrast"] .test-foot{border-color:#000}
:root[data-theme="high-contrast"] .grid-q.unanswered{border:2px dashed #000}
:root[data-theme="high-contrast"] kbd{color:#000;background:#fff;border-color:#000}
:root[data-theme="high-contrast"] .toast{background:#000;color:#fff;border:2px solid #fff}

/* ---------- zoom and reflow ---------- */
/* Test overlay: under 900 CSS px (a laptop at 150 percent zoom and up) the passage stacks above the question
   and the whole item scrolls as one; the header wraps instead of clipping, and the timer stays in view. */
@media (max-width:900px){
  .test-overlay .item-test.item-split{display:block;height:auto}
  .test-item-host,.test-overlay .item-test{height:auto}
  .test-overlay .item-test.item-split .item-stimulus{height:auto;border-right:0;border-bottom:4px solid #e6e6e6;overflow:visible}
  .test-overlay .item-test.item-split .item-question{height:auto;overflow:visible}
  .test-head{grid-template-columns:minmax(0,1fr) auto;column-gap:12px;row-gap:4px}
  .test-head-left{grid-column:1;grid-row:1 / span 2;align-self:center}
  .test-head-center{grid-column:2;grid-row:1;flex-direction:row;justify-content:flex-end;gap:8px}
  .test-head-right{grid-column:2;grid-row:2;justify-content:flex-end;flex-wrap:wrap;gap:2px}
  .test-title{white-space:normal}
  .test-directions{top:auto;left:12px;right:12px;width:auto;max-height:calc(100% - 24px)}
}
/* Short viewports (200 percent zoom on a 900 px tall window is 450 CSS px): tighter chrome, more room for the item. */
@media (max-height:560px){
  .test-head{padding-top:6px;padding-bottom:8px}
  .test-foot{padding-top:6px;padding-bottom:6px}
  .test-notice{top:12px}
  .grid-popover{max-height:calc(100vh - 120px);overflow:auto}
}
/* Tables scroll inside their own card, never the page. */
.table-scroll,.rs-table-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}

/* ---------- phone widths (app.css's 760 px breakpoint) ---------- */
@media (max-width:760px){
  /* Every nav destination stays reachable: the row scrolls sideways instead of hiding links after the fourth. */
  .nav a:nth-child(n+5){display:flex}
  .nav{scroll-snap-type:x proximity}
  .nav a{min-height:40px}
  /* The plan's done checkmark (plan.css draws it at 30 px) and the admin table's text buttons. */
  .plan-check{width:40px;height:40px}
  .rs-table .text-button{min-height:40px}
  /* Tap targets at least 40 px tall. */
  .button,.button.small,.segment,.chip,.etag-chip,.etag-compact .etag-chip,.drill-tool,.tool-button,.skip-button,.icon-button,.input,select.input,button.emix-row{min-height:40px}
  [data-testid="report-problem"]{min-height:40px;display:inline-flex;align-items:center}
  .chip{padding:8px 12px}
  .text-button.end-session,.review-clear,[data-testid="review-clear"],[data-testid="chat-fresh"]{min-height:40px;display:inline-flex;align-items:center}
  .answer{min-height:48px}
  /* The overlay on phones (R&W mini-modules): header and footer controls get the same 40 px floor. */
  .test-overlay .test-link,.test-overlay .test-tool,.test-overlay .test-mark,.test-overlay .test-abc,.test-overlay .test-pill-button.small,.test-overlay .test-grid-button,.test-overlay .test-nav{min-height:40px}
  .test-overlay .test-link{display:inline-flex;align-items:center}
  .test-overlay .test-qbar{height:auto;min-height:40px}
}
/* Short and narrow (a laptop at 200 percent zoom is 640 x 450 CSS px): the top nav scrolls away instead of
   covering a quarter of the screen. */
@media (max-width:760px) and (max-height:560px){.sidebar{position:static}}
