/* features.css — practice navigator, filters, settings, leaderboard privacy,
   subject access, announcements, Reading Library, and scrolling fixes. */

/* ───────── Scrolling: sidebar, reviews, sticky bars ───────── */
/* The section/settings sidebar scrolls on its own, so its last item is always reachable. */
/* The sidebar is a fixed-height column: brand on top, the account chip at the
   bottom, and the section list in between is the one element that scrolls.
   overscroll-behavior stops wheel/touch scrolling from chaining into the page,
   so scrolling the list never moves the open review. */
.sidebar{height:100vh;height:100dvh;overflow:hidden;min-height:0}
.side-nav{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;margin:0 -.4rem;padding:0 .4rem .4rem;scrollbar-gutter:stable}
.side-nav:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.sidebar .side-brand,.sidebar .user-chip{flex:none}
.nav-item[hidden]{display:none}
@media(max-width:860px){
  .sidebar{padding-bottom:calc(1rem + env(safe-area-inset-bottom))}
}
/* Two-pane admin editors (Manage Questions, Pages): the left list/settings
   panel is capped to the viewport under the sticky top bar and scrolls on its
   own; scrolling it never moves the question being reviewed on the right. */
@media(min-width:881px){
  .manage .q-list{display:flex;flex-direction:column;max-height:calc(100vh - 88px - 1rem);max-height:calc(100dvh - 88px - 1rem)}
  .manage .q-list-head{flex:none}
  .manage .q-list-body{flex:1 1 auto;min-height:0;max-height:none}
}
@media(min-width:881px){ .manage .q-list-body{overscroll-behavior:contain} }
/* Dialogs: the body is the scroller (header and actions stay visible); the
   page behind cannot scroll while one is open, and the lock is tied to the
   dialog being in the DOM, so closing it can never leave the page stuck. */
html:has(body > .ft-modal-back){overflow:hidden}
.ft-modal{max-height:calc(100vh - 2rem);max-height:calc(100dvh - 2rem);min-height:0}
.ft-modal-head,.ft-modal-foot{flex:none}
.ft-modal-body{flex:1 1 auto;min-height:0;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.ft-modal-back{overscroll-behavior:contain}
/* A question review inside a dialog flows as one column in the dialog's own
   scroller, so passage, choices, key, explanation and actions are all reachable. */
.ft-modal-body .bb.bb-inline .bb-work.split,.ft-modal-body .bb.bb-inline .bb-work.single{max-height:none;min-height:0}
.ft-modal-body .bb.bb-inline .bb-work.split .bb-pane{max-height:none;overflow:visible}
/* Sticky top bar never hides a heading or focused control. */
html{scroll-padding-top:84px;scroll-padding-bottom:84px}
.explain{overflow-wrap:anywhere}
.explain .explain-body{font-size:.9rem;color:var(--ink2);line-height:1.6}
.explain .explain-body p{margin-bottom:.5rem}
.q-passage,.q-prompt,.ct{overflow-wrap:anywhere}
.q-passage .mathseg-block,.explain .mathseg-block,.q-prompt .mathseg-block{max-width:100%}
/* Review: on desktop the passage and question panes scroll independently;
   everything (passage, choices, key, explanation) stays reachable. */
/* The grid rows grow with their content, so the cap goes on each pane (the
   old cap on the container plus overflow:hidden clipped long passages). */
.bb.bb-inline{overflow:visible}
.bb.bb-inline .bb-work.split{max-height:none;min-height:0;align-items:start}
.bb.bb-inline .bb-work.split .bb-pane{max-height:min(72vh,760px);overflow:auto;overscroll-behavior:auto}
.bb.bb-inline .bb-work.split .bb-divider{align-self:stretch}
.bb.bb-inline .bb-work.single{max-height:min(72vh,760px)}
@media(max-height:720px) and (min-width:761px){ .bb.bb-inline .bb-work.split .bb-pane,.bb.bb-inline .bb-work.single{max-height:calc(100vh - 140px)} }
/* Phones: one predictable reading flow — no nested scroll boxes in reviews. */
@media(max-width:760px){
  .bb.bb-inline .bb-work.split,.bb.bb-inline .bb-work.single{max-height:none;overflow:visible;display:block}
  .bb.bb-inline .bb-pane,.bb.bb-inline .bb-work.split .bb-pane{overflow:visible;max-height:none}
  .ft-table-wrap{max-height:none}
  .ft-modal{max-height:calc(100dvh - 2rem)}
  .ft-modal-body{overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
}

/* ───────── Practice navigator (Full Mock look) ───────── */
.pq,.pq-pop{--bb-bg:var(--panel);--bb-ink:var(--ink);--bb-line:var(--border2);--bb-blue:#3B5BDB}
.pq{position:relative;padding-bottom:.5rem}
.pq-label{font-family:var(--disp);font-weight:700;font-size:1rem;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pq-save{display:inline-flex;align-items:center;gap:.35rem;font-size:.8rem;color:var(--ink3);font-weight:600}
.pq-save .dot{width:8px;height:8px;border-radius:50%;background:var(--gold);animation:pqpulse 1s infinite}
.pq-save .dot.bad{background:var(--red);animation:none}
.pq-save.retry{color:var(--red)}
@keyframes pqpulse{50%{opacity:.35}}
@media (prefers-reduced-motion:reduce){.pq-save .dot{animation:none}}
.pq-bar{position:sticky;bottom:0;z-index:20;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:.6rem;margin-top:1rem;padding:.65rem .8rem calc(.65rem + env(safe-area-inset-bottom));background:var(--panel2);border:1px solid var(--border2);border-radius:var(--r2);box-shadow:var(--shadow)}
.pq-bar #pqPrev{justify-self:start}
.pq-bar>.bb-btn:last-child{justify-self:end}
.pq-bar .bb-btn:disabled{opacity:.4;cursor:not-allowed;filter:none}
.pq-bar .bb-btn,.pq-bar .bb-qpill{min-height:44px}
/* Numbered picker: anchored above the footer on desktop, a sheet on phones. */
.pq-layer{position:fixed;inset:0;z-index:130;pointer-events:none}
.pq-scrim{position:absolute;inset:0;pointer-events:auto;background:transparent}
.pq-pop{--bb-blue:#3B5BDB;position:fixed;display:flex;flex-direction:column;pointer-events:auto;background:var(--panel);border:1px solid var(--border2);border-radius:var(--r2);box-shadow:var(--shadow);overflow:hidden}
.pq-pop-head{display:flex;align-items:center;gap:.8rem;padding:.8rem 1rem;border-bottom:1px solid var(--border);flex:none}
.pq-pop-title{display:flex;flex-direction:column;min-width:0;flex:1}
.pq-pop-title b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pq-pop-grid{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;display:grid;grid-template-columns:repeat(auto-fill,minmax(46px,1fr));gap:.6rem;padding:1rem 1rem .9rem;scroll-padding:.9rem}
.pq-pop-grid .bb-cell{min-width:0;height:42px;font-size:.86rem}
.pq-legend{flex:none;margin:0;padding:.6rem 1rem .75rem;border-top:1px solid var(--border)}
.pq-layer.sheet .pq-scrim{background:rgba(0,0,0,.5)}
.pq-layer.sheet .pq-pop{left:0;right:0;bottom:0;width:auto;max-height:min(80dvh,640px);border-radius:var(--r2) var(--r2) 0 0;border-bottom:0;padding-bottom:env(safe-area-inset-bottom)}
.bb-cell.locked{opacity:.4}
.bb-cell.picked{border-style:solid;border-color:var(--bb-blue)}
.bb-cell:focus-visible,.bb-btn:focus-visible,.bb-qpill:focus-visible,.choice:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
.bb-mark.on{color:var(--red)}
.bb-mark.on .ic{fill:var(--red)}
.linkish{color:var(--accent);font-weight:700;text-decoration:underline;padding:0;background:none}

/* ───────── Filters ───────── */
.pf-panel{display:grid;gap:.9rem}
.pf-group{border:1px solid var(--border);border-radius:var(--r);padding:.7rem .85rem}
.pf-group legend,.pf-group summary{font-size:.74rem;text-transform:uppercase;letter-spacing:.07em;color:var(--ink3);font-weight:700;padding:0 .3rem}
.pf-group summary{cursor:pointer;padding:.2rem 0}
.pf-opts{display:flex;flex-wrap:wrap;gap:.4rem;margin-top:.35rem}
.pf-opt{display:inline-flex;align-items:center;gap:.45rem;padding:.42rem .7rem;border:1.5px solid var(--border2);border-radius:100px;font-size:.86rem;cursor:pointer;min-height:38px}
.pf-opt.on{border-color:var(--accent);background:var(--accent-soft);color:var(--accent);font-weight:600}
.pf-opt input{accent-color:var(--accent);width:16px;height:16px}
.pf-skilldom{margin-top:.6rem}.pf-skilldom>b{font-size:.82rem}
.pf-chips{display:flex;flex-wrap:wrap;gap:.4rem;align-items:center;margin:.9rem 0 .2rem}
.pf-chip{display:inline-flex;align-items:center;gap:.3rem;padding:.3rem .6rem;border-radius:100px;background:var(--accent-soft);color:var(--accent);font-size:.8rem;font-weight:600}
.pf-chip .ic{width:12px;height:12px}
.pf-none{margin:.8rem 0 .2rem}
.pf-actions{display:flex;justify-content:space-between;align-items:center;gap:.8rem;flex-wrap:wrap;margin-top:1rem}
.pf-edit{margin-top:.6rem}.pf-edit>summary{cursor:pointer;font-weight:600;color:var(--ink2);padding:.3rem 0}
.qb-domlinks{display:flex;flex-wrap:wrap;gap:.35rem;margin:.6rem 0}
/* Question Bank landing: subject + domain cards, header actions */
.qb-head{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem;flex-wrap:wrap}
.qb-head .page-head{margin-bottom:1.2rem;flex:1 1 320px}
.qb-actions{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;padding-top:.35rem}
.qb-actions #qbCont:empty{display:none}
.qb-badge{display:inline-grid;place-items:center;min-width:1.25rem;height:1.25rem;padding:0 .3rem;border-radius:100px;background:var(--accent);color:var(--accent-ink);font-size:.72rem;font-weight:700}
.qb-cont-meta{font-family:var(--mono);font-size:.74rem;opacity:.85}
.qb-applied{display:flex;flex-wrap:wrap;gap:.4rem;align-items:center;margin:-.4rem 0 1.2rem}
.pf-chip.static{cursor:default}
.qb-subject{margin-bottom:1.8rem}
.qb-subhead{display:flex;align-items:center;gap:.8rem;margin-bottom:.8rem}
.qb-subhead .badge-ic{margin:0;flex:none}
.qb-subtitle{flex:1;min-width:0}
.qb-subtitle h2{font-family:var(--disp);font-size:1.3rem;font-weight:800;letter-spacing:-.01em}
.qb-dom{display:flex;flex-direction:column;cursor:pointer}
.qb-dom.empty{cursor:default;opacity:.7}
.qb-dom-go{position:absolute;inset:0;z-index:1;border-radius:inherit;background:transparent}
.qb-dom-go:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
.qb-dom:has(.qb-dom-go:hover:not(:disabled)){transform:translateY(-3px);border-color:var(--accent)}
.qb-dom-foot{display:flex;justify-content:space-between;align-items:flex-end;margin-top:auto}
.qb-dom-filter{position:relative;z-index:2;display:grid;place-items:center;width:34px;height:34px;border-radius:9px;border:1px solid var(--border);color:var(--ink3);background:var(--panel)}
.qb-dom-filter:hover,.qb-dom-filter:focus-visible{color:var(--accent);border-color:var(--accent)}
/* Filters: popover (desktop) / bottom sheet (phones) */
.qbf-layer{position:fixed;inset:0;z-index:120;pointer-events:none}
.qbf-scrim{position:absolute;inset:0;pointer-events:auto;background:transparent}
.qbf{position:fixed;display:flex;flex-direction:column;pointer-events:auto;background:var(--panel);border:1px solid var(--border2);border-radius:var(--r2);box-shadow:var(--shadow);overflow:hidden}
.qbf-head{display:flex;align-items:center;gap:.7rem;padding:.75rem 1rem;border-bottom:1px solid var(--border)}
.qbf-head b{font-family:var(--disp);font-size:1.05rem}
.qbf-head .umeta{margin-left:auto}
.qbf-body{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:.9rem 1rem;display:grid;gap:.8rem;align-content:start}
.qbf-body .pf-panel{gap:.7rem}
.qbf-body .pf-group{padding:.55rem .7rem}
.qbf-body .pf-opt{min-height:34px;padding:.32rem .62rem;font-size:.84rem}
.qbf-shuffle{justify-self:start}
.qbf-empty{display:flex;gap:.45rem;align-items:flex-start;padding:.6rem .75rem;border-radius:var(--r);background:var(--red-soft);color:var(--ink);font-size:.86rem}
.qbf-foot{display:flex;gap:.45rem;align-items:center;padding:.7rem 1rem calc(.7rem + env(safe-area-inset-bottom));border-top:1px solid var(--border);background:var(--panel2)}
.qbf-foot .spacer{flex:1}
.qbf-layer.sheet .qbf-scrim{background:rgba(0,0,0,.5)}
.qbf-layer.sheet .qbf{left:0;right:0;bottom:0;top:auto;width:auto;max-height:min(88dvh,760px);border-radius:var(--r2) var(--r2) 0 0;border-bottom:0}
.qb-list{list-style:none;display:grid;gap:.45rem;margin-top:1rem}
.qb-row{display:grid;grid-template-columns:2.2rem minmax(0,1fr) auto auto;gap:.8rem;align-items:center;width:100%;text-align:left;padding:.8rem 1rem;background:var(--panel);border:1px solid var(--border);border-radius:var(--r)}
.qb-row:hover,.qb-row:focus-visible{border-color:var(--accent)}
.qb-n{font-family:var(--mono);color:var(--ink3);font-size:.82rem}
.qb-main{display:flex;flex-direction:column;gap:.15rem;min-width:0}
.qb-prev{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.qb-st{font-size:.74rem;font-weight:700;color:var(--ink3)}.qb-st.incorrect{color:var(--red)}.qb-st.correct{color:var(--mint)}
@media(max-width:600px){.qb-row{grid-template-columns:1.8rem minmax(0,1fr)}.qb-row .pill,.qb-st{grid-column:2}}
.qb-pager{display:flex;justify-content:center;align-items:center;gap:.8rem;margin:1.2rem 0}
.pc-panel .pc-row{display:flex;justify-content:space-between;gap:1rem;align-items:center;flex-wrap:wrap;padding:.6rem 0;border-top:1px solid var(--border)}
.pc-panel .pc-row:first-of-type{border-top:0}
.pc-acts{display:flex;gap:.4rem;align-items:center}
.rush-avail{text-align:center;margin-top:.9rem;font-size:.9rem;color:var(--ink2)}

/* ───────── Settings ───────── */
.settings-grid .panel{margin-bottom:1rem}
.st-switch{display:flex;gap:.7rem;align-items:flex-start;cursor:pointer}
.st-switch input{width:20px;height:20px;margin-top:.15rem;accent-color:var(--accent);flex:none}
.st-note{display:flex;gap:.55rem;align-items:flex-start;padding:.7rem .85rem;border-radius:var(--r);background:var(--panel2);border:1px solid var(--border);font-size:.88rem;margin:.6rem 0}
.st-err{color:var(--red);font-size:.88rem;min-height:1.2em;margin:.4rem 0}

/* ───────── Leaderboard ───────── */
.lb-search{min-width:200px}
.lb-hidden td{opacity:.75}
.lb-super{padding:.6rem .8rem;border-radius:var(--r);background:var(--gold-soft);font-size:.88rem;margin:.4rem 0 .8rem}
.lb-wrap{max-height:none}

/* ───────── Subject access ───────── */
.ax-classes{display:grid;gap:.6rem}
.ax-class{display:flex;flex-wrap:wrap;gap:.7rem;align-items:center;padding:.6rem .7rem;border:1px solid var(--border);border-radius:var(--r)}
.ax-class>b{min-width:140px}
.ax-editor{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin:.6rem 0}
@media(max-width:640px){.ax-editor{grid-template-columns:1fr}}
.ax-col{border:1px solid var(--border2);border-radius:var(--r);padding:.8rem}
.ax-area{display:flex;gap:.5rem;align-items:center;padding:.35rem 0 .35rem 1.6rem}
.ax-area input{width:18px;height:18px;accent-color:var(--accent)}
.ax-area:has(input:disabled){opacity:.5}
.ax-conflicts{padding:.7rem .85rem;border-radius:var(--r);background:var(--red-soft);margin:.6rem 0}
.ax-conflicts ul{margin:.4rem 0 0 1.1rem;display:grid;gap:.3rem}
.ax-warn td{background:var(--red-soft)}

/* ───────── Announcements & reading view ───────── */
.an-list{display:grid;gap:.6rem}
.an-card{display:flex;flex-direction:column;gap:.3rem;text-align:left;width:100%;padding:1rem 1.1rem;background:var(--panel);border:1px solid var(--border);border-radius:var(--r2)}
.an-card.unread{border-color:var(--accent)}
.an-title{font-weight:700;font-size:1.02rem;display:flex;align-items:center;gap:.45rem}
.an-dot{width:9px;height:9px;border-radius:50%;background:var(--accent);display:inline-block}
.an-prev{color:var(--ink2);font-size:.9rem}
.reader{max-width:68ch;margin:0 auto;padding-bottom:2rem}
.reader h1{font-family:var(--disp);font-size:clamp(1.6rem,4.5vw,2.3rem);line-height:1.15;margin:.3rem 0 .6rem}
.reader-body{font-family:Georgia,'Times New Roman',serif;font-size:clamp(1.06rem,2.6vw,1.18rem);line-height:1.78;margin:1.2rem 0}
.reader-body p{margin-bottom:1.05em}
.reader-hit{background:color-mix(in srgb,var(--gold) 22%,transparent);border-radius:4px;box-shadow:0 0 0 4px color-mix(in srgb,var(--gold) 22%,transparent)}
.reader-q{border-top:1px solid var(--border);padding-top:1.2rem;margin-top:1.2rem}
.reader-q h2{font-family:var(--disp);font-size:1.2rem;margin-bottom:.6rem}
.reader-support{border-left:3px solid var(--gold);padding:.4rem .8rem;margin:.4rem 0;font-family:Georgia,serif}
.reader-admin{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin:.4rem 0}
.lib-tools{display:flex;gap:.6rem;flex-wrap:wrap}.lib-tools input{flex:1;min-width:200px}
.lib-grid{list-style:none;display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:.8rem}
.lib-card{display:flex;flex-direction:column;gap:.4rem;text-align:left;width:100%;height:100%;padding:1.1rem;background:var(--panel);border:1px solid var(--border);border-radius:var(--r2)}
.lib-card:hover,.lib-card:focus-visible{border-color:var(--accent)}
.lib-topic{font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:var(--accent);font-weight:700}
.lib-title{font-family:var(--disp);font-weight:700;font-size:1.1rem}
.lib-prev{color:var(--ink2);font-size:.9rem;line-height:1.5}

/* ───────── Limits & Access: per-student subject access ───────── */
.ax-panel .ax-h{font-family:var(--disp);font-size:1.05rem;margin:1.3rem 0 .6rem}
.ax-pick{display:flex;gap:.8rem;flex-wrap:wrap;align-items:flex-end;margin:.8rem 0}
.ax-pick .field{flex:1 1 320px;max-width:520px;margin:0}
.ax-student{border:1px solid var(--border2);border-radius:var(--r2);padding:1rem;background:var(--panel2)}
.ax-who{display:flex;justify-content:space-between;gap:1rem;flex-wrap:wrap;margin-bottom:.8rem}
.ax-eff{display:flex;flex-direction:column;align-items:flex-end;gap:.25rem;text-align:right}
@media(max-width:640px){.ax-eff{align-items:flex-start;text-align:left}}
.ax-grid{width:100%;border-collapse:collapse;min-width:420px}
.ax-grid th,.ax-grid td{padding:.55rem .7rem;border-bottom:1px solid var(--border);text-align:left;vertical-align:middle}
.ax-grid thead th{font-size:.74rem;text-transform:uppercase;letter-spacing:.06em;color:var(--ink3)}
.ax-grid tbody th{font-weight:600}
.ax-master th,.ax-master td{background:var(--panel)}
.ax-cb input{width:20px;height:20px;accent-color:var(--accent);cursor:pointer}
.ax-cb input:disabled{opacity:.45;cursor:not-allowed}
.ax-switch{display:inline-flex;align-items:center;gap:.5rem;cursor:pointer;font-weight:700}
.ax-switch input{position:absolute;opacity:0;width:1px;height:1px}
.ax-knob{width:40px;height:22px;border-radius:100px;background:var(--border2);position:relative;transition:background .15s;flex:none}
.ax-knob::after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .15s}
.ax-switch input:checked+.ax-knob{background:var(--accent)}
.ax-switch input:checked+.ax-knob::after{transform:translateX(18px)}
.ax-switch input:focus-visible+.ax-knob{outline:3px solid var(--accent);outline-offset:2px}
.ax-actions{display:flex;gap:.6rem;align-items:center;flex-wrap:wrap;margin-top:.8rem}
.ax-status{font-size:.88rem;font-weight:600;display:inline-flex;gap:.35rem;align-items:center}
.ax-status.ok{color:var(--mint)}.ax-status.err{color:var(--red)}.ax-status.busy{color:var(--ink3)}
.ax-tools{display:flex;gap:.8rem;align-items:center;flex-wrap:wrap;margin-bottom:.6rem}
.ax-tools input{flex:1;min-width:200px;max-width:360px;padding:.55rem .8rem;background:var(--panel2);border:1px solid var(--border2);border-radius:var(--r);color:var(--ink);font:inherit;font-size:.9rem}
.ax-table-wrap{max-height:none}
.ax-table tr[hidden]{display:none}
