/* ===================== 聽解 Listening (#page-listening, js/listening.js) =====================
   The list and the result / review screens reuse the grammar and reading page's
   classes (css/grammar.css, css/reading.css); this file adds the player, the item
   header, the options and the transcript. */

.listening-card { text-align: left; }
.listening-card h3 { text-align: center; }

/* list */
/* levels not recorded yet (LISTENING_SOON) */
.ls-soon { margin: 4px 0 10px; padding: 8px 12px; border: 2px dashed var(--line); border-radius: 12px;
    font-size: .85rem; color: var(--text-secondary); }
.ls-exam { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; padding: 10px 12px;
    border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-size: .85rem;
    color: var(--text-secondary); cursor: pointer; }
.ls-exam input { margin-top: 3px; accent-color: var(--primary); width: 18px; height: 18px; flex: none; }
.ls-exam b { color: var(--ink, var(--text-main)); }
.ls-types { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0; }
.ls-type { font-size: .7rem; padding: 1px 7px; border-radius: 99px; background: var(--track); color: var(--text-secondary); }

/* item header */
.ls-dots { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.ls-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--track); }
.ls-dot.now { background: var(--primary); }
.ls-dot.ok { background: var(--success, #3b8a5a); }
.ls-dot.no { background: var(--danger, #c0392b); }
/* a long round (Cambridge B2 / C1: 52–56 questions) keeps its dots on one line */
.ls-dots-many { gap: 2px; flex-wrap: nowrap; }
.ls-dots-many .ls-dot { width: 6px; height: 6px; flex: none; }
.ls-kind { text-align: center; font-size: .82rem; font-weight: 700; color: var(--primary); letter-spacing: .04em; margin-top: 4px; }
.ls-how { text-align: center; font-size: .82rem; color: var(--text-secondary); margin: 2px 0 12px; }
/* TOPIK: the paper's Korean instruction above its translation (.ls-how) */
.ls-instr { text-align: center; font-size: .95rem; font-weight: 700; margin: 4px 0 0; word-break: keep-all; }
.ls-instr + .ls-how { margin-top: 0; }
.ls-scene { text-align: center; font-size: 1.02rem; margin: 4px 0 12px; line-height: 1.7; }
.ls-scene-emoji { display: block; font-size: 2.4rem; line-height: 1.2; margin-bottom: 2px; }
.ls-scene-pic .ls-scene-emoji { font-size: 3.4rem; }   /* the "picture" alone, before answering */
/* the drawn pictures (tools/listening/pics.json): a 発話表現 scene, and 課題理解 options that
   each show one quarter of a 2x2 picture */
.ls-scene-emoji[hidden] { display: none; }   /* the fallback while the picture loads fine */
.ls-scene-img { display: block; width: 100%; max-width: 560px; margin: 0 auto 6px; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.ls-opts.pics .option-btn { flex-direction: column; gap: 4px; padding: 8px; min-height: 0; position: relative; }
.ls-opts.pics .ls-n { position: absolute; left: 10px; top: 8px; z-index: 1; background: #fff; color: #2b2724; border: 2px solid #2b2724; border-radius: 8px; padding: 0 7px; line-height: 1.5; }
.ls-pic { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background-color: #fff; }
.ls-pic img { position: absolute; width: 200%; height: 200%; max-width: none; display: block; }   /* HSK pictures set their own size (listeningCellStyle) */
.ls-pic-tx { font-size: .9rem; line-height: 1.6; }
/* HSK (2026-10-30): three pictures in a row; a panel not drawn yet shows its caption; the letters of
   a dialogue-matching picture; printed options with pinyin over the characters */
.ls-opts.pics.pics3 { grid-template-columns: repeat(3, 1fr); }   /* also on phones: three, not 2 + 1 */
.ls-pic-todo { display: flex; align-items: center; justify-content: center; padding: 8px; border: 1px dashed var(--line);
    background: var(--surface-2); color: var(--text-secondary); font-size: .85rem; text-align: center; }
.ls-opts.ls-letters { grid-template-columns: repeat(3, 1fr); }
.ls-opts.ls-letters .option-btn { justify-content: center; font-size: 1.1rem; }
.ls-sheet-pic { margin: 8px 0; }
.ls-zh-opts [lang="zh"], .ls-qtext[lang="zh"], .ls-ja[lang="zh"] { font-family: 'Noto Sans SC', var(--font-sans); line-height: 2.3; }
.ls-zh-opts rt, .ls-qtext[lang="zh"] rt, .ls-ja[lang="zh"] rt { font-size: .5em; }
/* the pictures are drawn black on white; in the dark theme they keep their white paper */
@media (max-width: 560px) {
    .ls-opts.pics { grid-template-columns: 1fr 1fr; }
}
.ls-question { font-size: 1.12rem; padding: 8px 12px; border: 2px dashed var(--line); border-radius: 12px; line-height: 2.1; }
.ls-zh { font-size: .82rem; color: var(--text-secondary); line-height: 1.5; }
.listening-card rt { font-size: .5em; color: var(--text-secondary); }

/* player */
.ls-player { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px;
    border: 2px solid var(--line); border-radius: 16px; background: var(--surface); margin-bottom: 14px; }
.ls-play { width: 84px; height: 84px; border-radius: 50%; border: 2px solid var(--primary-edge); background: var(--primary);
    color: #fff; font-size: 2rem; line-height: 1; box-shadow: 0 4px 0 var(--primary-edge); cursor: pointer; }
.ls-play:active { transform: translateY(4px); box-shadow: none; }
.ls-play:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 0 4px 0 var(--primary-edge); }
.ls-play.playing { animation: ls-pulse 1.2s infinite; }
@keyframes ls-pulse { 50% { opacity: .75; } }
@media (prefers-reduced-motion: reduce) { .ls-play.playing { animation: none; } }
.ls-bar { width: 100%; max-width: 360px; height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.ls-bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.ls-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; font-size: .82rem; color: var(--text-secondary); }
.ls-row .mode-btn.ls-small { width: auto; min-width: 0; flex: none; margin: 0; padding: 5px 11px; font-size: .82rem; min-height: 0; }
.ls-exam-tag { font-size: .75rem; padding: 2px 9px; border-radius: 99px; border: 1.5px solid var(--primary); color: var(--primary); }

/* options */
.ls-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ls-opts.three { grid-template-columns: 1fr 1fr 1fr; }
/* HSK 4–6: four printed options in one row, so a recording with three or four questions still fits
   a 1080p screen (2026-10-30); two a row on phones */
.ls-opts.four { grid-template-columns: repeat(4, 1fr); }
.ls-opts.four .option-btn { padding-left: 8px; padding-right: 8px; flex-wrap: nowrap; line-height: 1.5; }
.ls-opts.four .ls-n { flex: none; }
.ls-opts.two .option-btn { justify-content: center; font-size: 1.1rem; }   /* HSK 7–9 对 / 错 */
.ls-typed { margin-top: 4px; }   /* HSK 7–9 written answers (the box itself is .rdx-short-in, css/reading.css) */
.ls-opts .option-btn { margin: 0; min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; line-height: 1.8; }
.ls-n { font-weight: 700; color: var(--primary); }
.ls-emoji { font-size: 1.15rem; }
.ls-why { font-size: .88rem; line-height: 1.7; padding: 10px 12px; border-left: 3px solid var(--primary);
    background: var(--surface); border-radius: 0 10px 10px 0; margin-top: 6px; }

/* transcript */
.ls-tx { margin-top: 12px; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--surface); }
.ls-tx summary { cursor: pointer; font-weight: 700; font-size: .9rem; }
.ls-line { display: grid; grid-template-columns: 2.6em 1fr auto; gap: 6px; align-items: start; padding: 6px 4px;
    border-bottom: 1px dashed var(--line); border-radius: 8px; transition: background .15s; }
.ls-line:last-of-type { border-bottom: 0; }
.ls-line.playing { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.ls-who { font-size: .76rem; font-weight: 700; padding-top: 7px; color: var(--text-secondary); }
.ls-ja { font-size: 1.08rem; line-height: 2.15; }
.ls-say { border: 0; background: none; font-size: 1.05rem; cursor: pointer; padding: 4px; }
.ls-words { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; padding-top: 8px; border-top: 2px solid var(--line); font-size: .85rem; color: var(--text-secondary); }
.ls-words b { color: var(--ink, var(--text-main)); }

/* result */
.ls-types-result { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; text-align: left; }
.ls-type-box { border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--surface); font-size: .82rem; color: var(--text-secondary); }
.ls-type-box b { display: block; font-size: 1.05rem; color: var(--ink, var(--text-main)); }

/* mock exam: the card on the list, the tag above an item, the answer sheet */
.ls-mock { border: 2px solid var(--primary); border-radius: 14px; padding: 10px 12px 4px; margin: 4px 0 14px;
    background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
/* the mock exam is the last card of the rounds' grid (閱讀 / 聽解 lists), framed in vermilion */
.grammar-item.ls-mock-item { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.ls-mock-note { margin: 8px 2px 0; }
.ls-mock-head { font-size: .95rem; }
.ls-mock-hint { font-size: .8rem; color: var(--text-secondary); margin: 4px 0 8px; line-height: 1.6; }
.ls-mock .grammar-list { margin: 0; }
.ls-mock-tag { text-align: center; font-size: .78rem; font-weight: 700; color: var(--primary); margin-top: 6px; }
.ls-dot.done { background: var(--text-secondary); }
.ls-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; margin: 8px 0 14px; }
.ls-sheet-cell { border: 2px solid var(--line); border-radius: 10px; background: var(--surface); padding: 4px 0;
    font-weight: 700; color: var(--ink, var(--text-main)); cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.ls-sheet-cell i { font-style: normal; font-size: .95rem; }
.ls-sheet-cell.ok i { color: var(--success, #3b8a5a); }
.ls-sheet-cell.no { border-color: var(--danger, #c0392b); }
.ls-sheet-cell.no i { color: var(--danger, #c0392b); }

/* reading time / answer time countdown */
.ls-clock { font-size: .85rem; font-weight: 700; color: var(--primary); display: flex; gap: 8px; align-items: center; }
.ls-clock[hidden] { display: none; }
.ls-clock.urgent { color: var(--danger, #c0392b); }
.ls-skip { border: 1.5px solid var(--line); background: none; border-radius: 99px; padding: 1px 10px; font-size: .75rem;
    color: var(--text-secondary); cursor: pointer; }

/* a picked option before the answers show (mock exam, multi-question items) */
.ls-opts .option-btn.ls-picked { border-color: var(--primary); background: var(--primary-soft); }

/* several questions about one recording */
.ls-q + .ls-q { margin-top: 14px; padding-top: 12px; border-top: 2px dashed var(--line); }
.ls-qlabel { font-size: .82rem; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.ls-qtext { font-size: 1rem; line-height: 2; margin-bottom: 8px; }
/* a printed question (TOPIK): bold, its translation small under it */
.ls-ask { line-height: 1.6; font-weight: 700; word-break: keep-all; }
.ls-ask .ls-zh { font-weight: 400; }
/* TOPIK's printed sentences: the number left of the text, which wraps beside it (a centred
   wrapping row put the number on a line of its own and doubled the button's height) */
.ls-opts.ls-sent .option-btn { flex-wrap: nowrap; justify-content: flex-start; align-items: center; text-align: left; gap: 10px; line-height: 1.5; padding-top: 8px; padding-bottom: 8px; min-height: 48px; }
.ls-opts.ls-sent .ls-n { flex: none; }
.ls-otx { display: block; min-width: 0; word-break: keep-all; }
.ls-opt-tr { display: block; font-size: .78rem; color: var(--text-secondary); font-weight: 400; margin-top: 2px; }
.ls-line-q .ls-ja { font-weight: 700; }
/* 上一題 / 下一題: a clear gap below the options (and the transcript) so they aren't tapped by mistake */
#listening-card .grammar-nav { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (max-width: 560px) {
    .ls-opts, .ls-opts.three, .ls-types-result { grid-template-columns: 1fr; }
    .ls-opts.four { grid-template-columns: 1fr 1fr; }
    .ls-dots { display: none; }          /* the count beside it says the same; the row was too tight */
}

.ls-qtabs { display: none; }   /* phones: all the questions of an item are listed (shown ≥1024px below) */

/* computers: the item's header and player left, its question(s) and options right, the transcript
   under the player once shown — so a question and all its options fit one 1080p screen without
   scrolling (owner's rule, 2026-10-24); phones keep one column in the order head, questions, transcript */
@media (min-width: 1024px) {
    .ls-cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-areas: "head qs" "tx qs";
        grid-template-rows: auto 1fr; column-gap: 28px; align-items: start; }
    .ls-head { grid-area: head; }
    .ls-qs { grid-area: qs; }
    .ls-txw { grid-area: tx; }
    /* a long transcript scrolls inside its box, which ends at the screen's bottom (listeningFitTx) */
    .ls-txw .ls-tx { overflow-y: auto; overscroll-behavior: contain; }
    .ls-cols.ls-tx-right { grid-template-areas: "head qs" "head tx"; grid-template-rows: auto 1fr; }
    .ls-txw .ls-tx > summary { position: sticky; top: -8px; z-index: 1; margin: -8px -12px 0; padding: 8px 12px; background: var(--surface); }
    .ls-cols .ls-scene-img { max-width: 100%; }
    /* answered: the picture a little shorter, so its caption and the player stay on the screen (TOEIC photos) */
    .ls-cols.ls-shown .ls-scene-img { max-height: 290px; width: auto; }
    /* answered with a picture on the left (the transcript moved right): a one-row player — ▶ beside
       the bar — so picture + player + 上一題 / 下一題 fit (HSK 1 picture sheets 983 → ≤ 920px, 2026-11-06) */
    .ls-cols.ls-shown.ls-tx-right .ls-player { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; row-gap: 8px; padding: 10px 14px; }
    .ls-cols.ls-shown.ls-tx-right .ls-play { width: 56px; height: 56px; font-size: 1.4rem; grid-row: 1 / span 3; }
    .ls-cols.ls-shown.ls-tx-right .ls-bar { max-width: none; }
    .ls-cols.ls-shown.ls-tx-right .ls-row { justify-content: flex-start; }
    /* a picture grid: four quarters in a square no taller than the screen allows */
    .ls-qs .ls-opts.pics { max-width: 560px; margin: 0 auto; }
    .ls-shown .ls-qs .ls-opts.pics { max-width: none; }   /* answered: the pictures in one row leave room for the explanation */
    .ls-shown .ls-qs .ls-opts.pics:not(.pics3) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ls-shown .ls-qs .ls-opts.pics .ls-pic-tx { font-size: .8rem; line-height: 1.35; }   /* narrower captions would wrap taller */
    /* four or more questions on one recording (HSK 5–6, LISTENING_Q_PAGED): one at a time, number tabs
       above — the look of the 閱讀 reader's .rd-qtab; phones list them all and hide the tabs */
    .ls-qtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
    .ls-qtab { min-width: 34px; height: 34px; padding: 0 8px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text-secondary); font: inherit; font-weight: 700; cursor: pointer; }
    .ls-qtab.on { border-color: var(--primary); color: var(--primary); }
    .ls-qtab.done { background: var(--track); }
    .ls-qtab.ok { background: var(--success-bg); border-color: var(--success); color: var(--success-text); }
    .ls-qtab.no { background: var(--danger-bg); border-color: var(--danger); color: var(--danger-text); }
    .ls-qtab.on.ok, .ls-qtab.on.no, .ls-qtab.on.done { outline: 2px solid var(--primary); outline-offset: 1px; }
    .ls-q-off { display: none; }
    .ls-qtabs ~ .ls-q .ls-opts.four { grid-template-columns: 1fr 1fr; }   /* one question in view: room for long options */
    /* a matching task's A–H in one view (DELE B2 Tarea 4): four rows of two, a little tighter, so the
       answered item and its 上一題 / 下一題 row fit a 1080p screen (964 → ≤ 920px, 2026-11-06) */
    .ls-qtabs ~ .ls-q .ls-opts.four:has(> .option-btn:nth-child(7)) { gap: 8px; }
    .ls-qtabs ~ .ls-q .ls-opts.four:has(> .option-btn:nth-child(7)) .option-btn { min-height: 44px; line-height: 1.35; padding-top: 6px; padding-bottom: 6px; }
    .ls-q-off + .ls-q, .ls-qtabs + .ls-q { margin-top: 0; padding-top: 0; border-top: 0; }
}
