/* ======================================================================
   flashcards.css — vocabulary flashcards across old-HSK volumes.
   Used by flashcards.html (standalone, all six volumes) and by the
   volume shells 1..6/index.html (embedded into the Flashcards tab).
   Builds on common.css. Chinese text sizes off var(--hanzi); English
   text is fixed small. Includes dark-mode + mobile rules.
   ====================================================================== */

/* ---- settings sidebar (right drawer, foldable to a compact gear) ----
   Used by flashcards.html standalone (this file) and relied on by the
   embedded volume shells to restyle their own #sidebar via volume.css. */
#sidebar{position:fixed;top:0;right:0;bottom:0;width:260px;background:var(--card);border-left:1px solid var(--line);z-index:45;display:flex;flex-direction:column;box-shadow:-4px 0 18px rgba(0,0,0,.04);transition:width .22s ease;overflow:hidden}
body.side-collapsed #sidebar{width:0;border-left:0;box-shadow:none;overflow:visible}
body.side-collapsed #sidebar .side-body{display:none}
#sideHead{display:flex;align-items:center;justify-content:space-between;padding:12px;border-bottom:1px solid var(--line);min-height:52px;gap:8px;white-space:nowrap}
#sideHead .st{font-size:14px;font-weight:700;white-space:nowrap;display:flex;align-items:center;gap:7px;min-width:0}
#sideHead .st .gear{font-size:16px}
#sideFold{border:0;background:var(--brand);color:#fff;border-radius:9px;min-width:32px;height:32px;cursor:pointer;font-size:16px;font-weight:700;line-height:1;display:flex;align-items:center;justify-content:center;flex:none;transition:transform .22s ease, background .15s}
#sideFold:hover{background:var(--brand2)}
body.side-collapsed #sideHead{justify-content:flex-start;padding:12px 0;border-bottom-color:transparent}
body.side-collapsed #sideHead .st{display:none}
body.side-collapsed #sideFold{position:fixed;right:14px;bottom:14px;z-index:45;width:38px;height:38px;min-width:38px;border-radius:12px;background:var(--card);color:var(--brand);border:1px solid var(--line);box-shadow:var(--shadow);transform:none;font-size:0}
body.side-collapsed #sideFold::before{content:"\2699";font-size:17px;line-height:1}
body.side-collapsed #sideFold:hover{transform:translateY(-1px);border-color:var(--brand2)}
.side-body{flex:1;overflow-y:auto;overflow-x:hidden;min-width:0;padding:14px}
.side-group{margin-bottom:18px}
.side-group label{display:block;margin-bottom:6px}
.side-row{display:flex;align-items:center;gap:8px;margin:6px 0}
.side-row input[type="range"]{flex:1;min-width:0}
.side-hint{font-size:11px;color:var(--muted);margin-top:4px;line-height:1.4}
.side-val{font-size:13px;color:var(--muted);min-width:35px;text-align:right;white-space:nowrap}
.side-check{display:flex;align-items:center;gap:8px;margin:6px 0;cursor:pointer;font-size:13px}
.side-check input{width:16px;height:16px;cursor:pointer}
#sidebar .seg{display:flex;width:100%}
#sidebar .seg button{flex:1;text-align:center;font-size:13px;padding:8px 6px}
#sidebar select{width:100%;min-width:0;max-width:100%;font-size:13px;padding:7px 8px}
body:not(.side-collapsed)::after{content:"";position:fixed;inset:0;z-index:44;background:rgba(20,22,32,.3)}

/* ---- controls panel ---- */
/* collapsible scope block: the preset is the ordinary case, so the whole thing
   folds away and the picker folds inside it */
.fc-fold{margin:0 0 12px}
.fc-fold-head{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap;cursor:pointer;list-style:none;padding:2px 0}
.fc-fold-head::-webkit-details-marker{display:none}
.fc-fold-head::before{content:"\25B8";color:var(--muted);font-size:11px;transition:transform .12s;align-self:center}
.fc-fold[open]>summary::before{transform:rotate(90deg)}
.fc-fold-title{font-size:13px;font-weight:600}
.fc-fold-note{flex:1;min-width:0;font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fc-fold-body{padding-top:12px}
.fc-scope-row{margin-bottom:14px}
.fc-scope-row label{display:block;margin-bottom:6px}
.fc-scope-row select{width:100%;max-width:560px;font-size:14px;padding:9px 10px}
.fc-scope-hint{font-size:12px;color:var(--muted);margin-top:6px}
.fc-overridden{opacity:.45}
.fc-btns{display:flex;flex-wrap:wrap;gap:10px}
.fc-msg{font-size:13px;color:var(--muted);margin-top:10px}

/* ---- text picker ----
   A lesson is a heading with a tick box that stands for all of its texts, so
   the two levels of choice stay apart: the scope select for whole lessons and
   groups, the tick boxes for the exact texts. */
.fc-pick{margin:0 0 4px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:var(--panel-2,rgba(127,127,127,.04))}
.fc-pick-head{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap;cursor:pointer;list-style:none}
.fc-pick-head::-webkit-details-marker{display:none}
.fc-pick-head::before{content:"\25B8";color:var(--muted);font-size:11px;transition:transform .12s}
.fc-pick[open]>.fc-pick-head::before{transform:rotate(90deg)}
.fc-pick-tools{display:flex;gap:6px;flex:1;min-width:180px;margin-top:10px}
.fc-pick-tools input[type=search]{flex:1;min-width:0;font-size:13px;padding:6px 8px}
.btn.tiny{padding:5px 9px;font-size:12px;line-height:1.2}
.fc-pick-hint{font-size:12px;color:var(--muted);line-height:1.5}
.fc-pick-hint b{color:var(--ink)}
.fc-pick-hint a{color:var(--brand);margin-left:6px}
.fc-pick-list{max-height:340px;overflow:auto;margin-top:8px;padding-right:2px}
.fc-pick-vol+.fc-pick-vol{margin-top:10px;padding-top:10px;border-top:1px solid var(--line)}
.fc-pick-volname{display:block;font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);margin-bottom:4px}
.fc-pick-lesson{border-top:1px solid var(--line)}
.fc-pick-lesson summary{display:flex;align-items:center;gap:8px;padding:5px 2px;cursor:pointer;font-size:13px;list-style:none}
.fc-pick-lesson summary::-webkit-details-marker{display:none}
.fc-pick-lesson summary::before{content:"\25B8";color:var(--muted);font-size:11px;transition:transform .12s}
.fc-pick-lesson[open]>summary::before{transform:rotate(90deg)}
.fc-pick-tick{display:flex;align-items:center}
.fc-pick-tick input{width:15px;height:15px;cursor:pointer;margin:0}
.fc-pick-lname{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fc-pick-count{font-size:11px;color:var(--muted);white-space:nowrap}
.fc-pick-text{display:flex;align-items:center;gap:8px;padding:3px 2px 3px 20px;cursor:pointer;font-size:12.5px}
.fc-pick-text:hover{background:rgba(127,127,127,.07)}
.fc-pick-text input{width:14px;height:14px;cursor:pointer;margin:0;flex:none}
.fc-pick-tid{color:var(--muted);min-width:38px}
.fc-pick-ttitle{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fc-pick-empty{font-size:12px;color:var(--muted);padding:8px 2px}

/* ---- vocabulary detail (mirrors the search page's word + character cards) ---- */
.fc-vocab{margin-top:16px;padding-top:14px;border-top:1px solid var(--line)}
#fcVocab{--fcv-scale:2}
.fcv-loading{font-size:12.5px;color:var(--muted)}
.fcv-wordhead{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.fcv-wword{font-size:calc(var(--fc-hanzi,28px) * .85 * var(--fcv-scale,2));line-height:1.15}
.fcv-wpy{font-size:13px;color:var(--muted)}
.fcv-wm{font-size:13px;flex:1;min-width:160px}
.fcv-title{font-size:11px;letter-spacing:.05em;text-transform:uppercase;color:var(--muted);margin:12px 0 4px}
.fcv-chars{border-top:1px solid var(--line);padding-top:10px}
.fcv-char{background:rgba(127,127,127,.05);border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin-bottom:10px}
.fcv-char .fcv-title{margin-top:10px}
.fcv-head{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}
.fcv-glyph{font-size:calc(var(--fc-hanzi,28px) * var(--fcv-scale,2));line-height:1.15}
.fcv-cmeta{font-size:13px;color:var(--muted)}
.fcv-cdef{font-size:13px}
.fcv-block{margin-top:8px}
.fcv-words{list-style:none;margin:0;padding:0}
.fcv-word{display:flex;gap:8px;align-items:baseline;padding:2px 0;font-size:13px;flex-wrap:wrap}
.fcv-word.on{background:rgba(127,127,127,.14);border-radius:5px;padding-left:5px;margin-left:-5px}
.fcv-w{font-size:calc(16px * var(--fcv-scale,2));line-height:1.2}
.fcv-m{color:var(--ink);flex:1;min-width:140px}
.fcv-none{font-size:12px;color:var(--muted);font-style:italic}
.fcv-sent{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,auto);gap:2px 10px;padding:4px 0;border-top:1px solid var(--line)}
.fcv-sent:first-of-type{border-top:0}
.fcv-zh{font-size:calc(15px * var(--fcv-scale,2));line-height:1.2}
.fcv-side{grid-column:2;grid-row:1;display:flex;gap:6px;align-items:center;justify-content:flex-end}
.fcv-py{font-size:13px;color:var(--muted)}
.fcv-speak{border:1px solid var(--line);background:transparent;color:var(--brand);border-radius:6px;font-size:12px;line-height:1;padding:3px 7px;cursor:pointer;transition:.12s}
.fcv-speak:hover{border-color:var(--brand2);background:var(--hover)}
.fcv-en{grid-column:1 / -1;font-size:12.5px;color:var(--muted)}
.fcv-tok{border-radius:4px;padding:0 1px;cursor:help}
.fcv-tok:hover{background:rgba(123,111,240,.14);outline:1px dotted var(--brand2)}
.fcv-tok-on{background:rgba(123,111,240,.32);outline:1.5px solid var(--brand2);border-radius:4px;padding:0 1px}
.fcv-tok-on:hover{background:rgba(123,111,240,.42)}
.fcv-src{display:inline-block;font-size:11px;line-height:1.5;color:var(--muted);background:rgba(127,127,127,.10);border:1px solid var(--line);border-radius:999px;padding:0 8px;margin-left:8px;vertical-align:baseline;white-space:nowrap}
#fcv-tip{position:fixed;z-index:50;max-width:320px;background:#1f2430;color:#fff;border-radius:8px;padding:7px 10px;font-size:12px;line-height:1.5;box-shadow:0 6px 20px rgba(0,0,0,.28);display:none;pointer-events:none}
#fcv-tip .t-word{font-size:17px;font-weight:700}
#fcv-tip .t-py{color:#b9c2ff;margin-left:6px;font-weight:500;font-size:13px}
#fcv-tip .t-gloss{color:#e8eaf2;margin-top:2px}
@media (max-width:640px){
  .fcv-sent{grid-template-columns:1fr}
  .fcv-side{grid-column:1;grid-row:2;justify-content:flex-start}
}

/* ---- deck stats ---- */
#fcStats{font-size:13px;color:var(--muted);margin-top:12px}
#fcStats b{color:var(--ink)}
.fc-wait{opacity:.7}
.fc-intro{font-size:12px;color:var(--brand);margin-top:6px;padding:5px 9px;border:1px dashed var(--brand);border-radius:8px;display:inline-block;background:rgba(91,84,217,.06)}
.fc-progress{height:8px;background:#edf0f7;border-radius:6px;overflow:hidden;margin-top:8px}
.fc-progress div{height:100%;width:0;background:linear-gradient(90deg,var(--ok),#58c98c);transition:width .25s}
.legend{font-size:12px;color:var(--muted);display:flex;gap:14px;flex-wrap:wrap;margin-top:10px}
.legend .dot{display:inline-block;width:12px;height:12px;border-radius:50%;margin-right:5px;vertical-align:-1px}
.dot.new{background:#d8dce6}
.dot.learning{background:var(--warn)}
.dot.mastered{background:var(--ok)}
.dot.present{background:transparent;border:2px dashed var(--brand)}

/* ---- card ---- */
.fc-card{min-height:220px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;cursor:pointer;padding:20px 12px;position:relative;border-radius:14px;transition:box-shadow .2s, background .2s}
.fc-card:hover{box-shadow:0 8px 26px rgba(31,36,48,.10)}
.fc-card.learning{border:2px solid var(--warn)}
.fc-card.mastered{border:2px solid var(--ok)}
/* introduction phase: a new word handed over, not yet graded */
.fc-card.presenting{border:2px dashed var(--brand);background:rgba(91,84,217,.05)}
.fc-card .idx{position:absolute;top:12px;left:14px;font-size:12px;color:var(--muted);z-index:1}
.fc-card .tag{position:absolute;top:12px;right:14px;font-size:12px;font-weight:600;z-index:1}
.tag.learning{color:var(--warn)}
.tag.mastered{color:var(--ok)}
.tag.new{color:#a5aab8}
.tag.present{color:var(--brand);background:rgba(91,84,217,.12);border-radius:6px;padding:1px 7px}
.fc-speak{position:absolute;top:40px;left:14px;z-index:1;width:34px;height:34px;border-radius:50%;border:1px solid var(--line);background:var(--card);color:var(--brand);font-size:13px;line-height:1;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:.12s}
.fc-speak:hover{border-color:var(--brand2);background:var(--hover)}
.fc-prompt{margin-top:2px;font-weight:700;line-height:1.35;word-break:break-word;max-width:100%}
.fc-prompt.fc-zh{font-size:var(--fc-hanzi,var(--hanzi))}
.fc-prompt.fc-en{font-size:15px;max-width:560px}
/* pinyin sits above the hanzi, the way the textbook reader sets it */
.fc-py{display:block;font-size:.42em;font-weight:400;color:var(--muted);line-height:1.5;margin-bottom:2px;letter-spacing:.02em}
.fc-zh .fc-py{margin-bottom:0}
.fc-sub{font-size:13px;color:var(--muted);margin-top:10px}
#fcHint{font-size:12px;color:#a5aab8;margin-top:18px;min-height:16px}
.fc-answer{margin-top:8px;width:100%}
.fc-answerword{font-weight:700;background:#f0f1fb;border-radius:10px;padding:14px;margin-bottom:6px;line-height:1.4;word-break:break-word;overflow-wrap:anywhere}
.fc-answerword.fc-zh{font-size:var(--fc-hanzi,var(--hanzi))}
.fc-answerword.fc-en{font-size:15px}
.fc-meta{font-size:13px;color:var(--muted)}

/* ---- multiple choice ---- */
.fc-mcq{margin-top:14px}
.fc-mcq-btn{display:flex;align-items:center;gap:10px;width:100%;text-align:left;border:1px solid var(--line);background:var(--card);border-radius:10px;padding:12px 14px;cursor:pointer;margin-bottom:8px;transition:.12s;color:var(--ink)}
.fc-mcq-btn:hover:not(:disabled){border-color:var(--brand2);background:var(--hover)}
.fc-mcq-btn .key{font-size:14px;flex:none}
.fc-mcq-btn .fc-zh{font-size:min(var(--fc-hanzi,var(--hanzi)),48px);font-weight:600;word-break:break-word;overflow-wrap:anywhere}
.fc-mcq-btn .fc-en{font-size:14px;line-height:1.45}
.fc-mcq-btn.right{border-color:var(--ok);background:rgba(47,158,95,.15)}
.fc-mcq-btn.wrong{border-color:var(--bad);background:rgba(192,57,43,.12)}
.fc-mcq-btn .key.right{background:var(--ok);color:#fff}
.fc-mcq-btn .key.wrong{background:var(--bad);color:#fff}
.fc-mcq-btn:disabled{cursor:default}

/* two-column answers: the option asked for, but only once the buttons are wide
   enough that a column still fits a long meaning without wrapping every word */
.fc-mcq.two-col{display:grid;grid-template-columns:1fr 1fr;gap:8px 12px}
.fc-mcq.two-col .fc-mcq-btn{margin-bottom:0}
@media(max-width:560px){
  .fc-mcq.two-col{grid-template-columns:1fr}
  .fc-mcq.two-col .fc-mcq-btn{margin-bottom:8px}
}

/* ---- flip actions ---- */
.actions{display:none;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:18px}
.actions.on{display:flex}
.actions .k,.fc-mcq-btn .key{display:inline-block;min-width:20px;background:rgba(255,255,255,.25);border-radius:5px;padding:0 5px;text-align:center;font-size:12px;font-weight:700}

/* ---- dark overrides ---- */
:root[data-theme="dark"] .fc-progress{background:#232838}
:root[data-theme="dark"] .dot.new{background:#3a4050}
:root[data-theme="dark"] .tag.new,:root[data-theme="dark"] #fcHint{color:var(--muted)}
:root[data-theme="dark"] .fc-answerword{background:rgba(236,238,244,.06)}
:root[data-theme="dark"] .fc-speak{background:var(--card)}

/* ---- small screens ---- */
@media(max-width:640px){
  #sidebar{width:min(300px,88vw)}
  body:not(.side-collapsed) #sidebar{box-shadow:-8px 0 26px rgba(0,0,0,.35)}
  body.side-collapsed #sideFold{width:44px;height:44px;min-width:44px}
  .fc-card{min-height:180px;padding:16px 12px}
  .fc-prompt.fc-zh{font-size:var(--fc-hanzi,var(--hanzi))}
  .fc-mcq-btn .fc-zh{font-size:min(calc(var(--fc-hanzi,var(--hanzi))*.92),40px)}
  .fc-speak{width:40px;height:40px}
  .fc-btns .btn{width:auto;flex:1}
  .actions .btn{width:auto;flex:1}
  .fc-mcq-btn{min-height:50px}
  #sidebar .seg button{min-height:44px}
}