/* ============================================================
   TOEIC ENGINE — 章節頁專用樣式（chapters/*.html only）
   ============================================================ */

header.hero{
  border-bottom:1px solid var(--line-strong);
  padding:38px 0 26px;
  margin-bottom:6px;
}
h1{
  font-size:28px;
  font-weight:900;
  margin:10px 0 6px;
  letter-spacing:.01em;
}
.sub{color:var(--ink-soft); font-size:15px; margin:0;}

/* ---------- legend / part-of-speech chips ---------- */
.legend{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
  margin:22px 0 10px;
}
@media (max-width:640px){ .legend{grid-template-columns:repeat(2,1fr);} }

.legend button{
  all:unset;
  cursor:pointer;
  border:1px solid var(--line-strong);
  background:var(--card);
  padding:12px 10px;
  text-align:left;
  position:relative;
}
.legend button::before{
  content:"";
  position:absolute; top:6px; left:6px;
  width:6px; height:6px;
  border-top:1.5px solid currentColor;
  border-left:1.5px solid currentColor;
  opacity:.5;
}
.legend button .tag{
  font-family:"IBM Plex Mono", monospace;
  font-size:11px;
  font-weight:600;
  letter-spacing:.06em;
}
.legend button .cn{font-weight:700; font-size:14.5px; margin-top:3px; display:block;}
.legend button[data-part="noun"]{color:var(--noun);}
.legend button[data-part="verb"]{color:var(--verb);}
.legend button[data-part="adj"]{color:var(--adj);}
.legend button[data-part="adv"]{color:var(--adv);}
.legend button.active{background:currentColor;}
.legend button.active .tag, .legend button.active .cn{color:var(--paper);}
.legend button.active::before{border-color:var(--paper); opacity:.9;}

.part-detail{
  border:1px solid var(--line-strong);
  background:var(--card);
  padding:18px 20px;
  margin-bottom:26px;
  display:none;
}
.part-detail.show{display:block;}
.part-detail h3{margin:0 0 8px; font-size:16px;}
.part-detail .words{
  display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 14px;
}
.word-chip{
  font-family:"IBM Plex Mono", monospace;
  font-size:12.5px;
  padding:3px 9px;
  border:1px solid currentColor;
}
.ex-line{margin:6px 0; font-size:14.5px;}
.ex-line .clickable-word{
  cursor:pointer;
  border-bottom:1.5px dotted currentColor;
}
.ex-line .tag-flip{
  display:inline-block;
  font-family:"IBM Plex Mono", monospace;
  font-size:10.5px;
  padding:0 5px;
  margin-left:3px;
  border:1px solid currentColor;
  vertical-align:2px;
}

/* ---------- generic section ---------- */
section.block{margin:40px 0;}
.block h2{
  font-size:18px; font-weight:900; margin:0 0 4px;
  display:flex; align-items:baseline; gap:8px;
}
.block h2 .idx{
  font-family:"IBM Plex Mono", monospace;
  font-size:12px;
  color:var(--ink-soft);
  border:1px solid var(--line-strong);
  padding:1px 6px;
}
.block .lead{color:var(--ink-soft); font-size:14px; margin:0 0 18px;}

.rule-card .rule-title{
  font-family:"IBM Plex Mono", monospace;
  font-size:12px;
  color:var(--ink-soft);
  text-transform:uppercase;
  letter-spacing:.08em;
  margin-bottom:6px;
}
.rule-card .sentence{font-size:15.5px; margin-bottom:12px;}

/* practice grid */
.practice-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}
@media (max-width:640px){ .practice-grid{grid-template-columns:1fr;} }
.p-card .p-num{
  font-family:"IBM Plex Mono", monospace;
  font-size:11px;
  color:var(--ink-soft);
}
.p-card .sentence{font-size:14.5px; margin:6px 0 10px;}

/* situational */
.situ-card .scene-tag{
  display:inline-block;
  font-family:"IBM Plex Mono", monospace;
  font-size:11px;
  letter-spacing:.06em;
  border:1px solid var(--ink-soft);
  color:var(--ink-soft);
  padding:2px 8px;
  margin-bottom:8px;
}

/* ---------- Part 1 圖片題插畫 ---------- */
.part1-scene{
  border:1px solid var(--line-strong);
  background:var(--card);
  margin-bottom:10px;
  overflow:hidden;
}
.part1-scene svg{
  display:block;
  width:100%;
  height:auto;
}

/* ---------- audio play button (Web Speech API) ---------- */
.play-audio-btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-family:"IBM Plex Mono", monospace;
  font-size:12px;
  font-weight:600;
  letter-spacing:.03em;
  color:var(--spark, #C8571A);
  background:var(--spark-bg, #F4E4D8);
  border:1px solid var(--spark, #C8571A);
  padding:5px 12px;
  margin:6px 0 12px;
  cursor:pointer;
}
.play-audio-btn:hover{ filter:brightness(0.97); }
.play-audio-btn:disabled{
  color:var(--ink-soft);
  background:var(--paper-2);
  border-color:var(--line-strong);
  cursor:not-allowed;
}

/* ---------- dialogue / passage script (Part 3 / Part 4) ---------- */
.dialogue-script{
  background:var(--paper);
  border:1px solid var(--line);
  padding:12px 14px;
  margin:8px 0 14px;
  font-size:14px;
  line-height:1.7;
}
.dialogue-line{margin:4px 0;}
.dialogue-line b{
  font-family:"IBM Plex Mono", monospace;
  font-size:12px;
  color:var(--ink-soft);
  margin-right:4px;
}
.doc-block{margin-bottom:12px; padding-bottom:12px; border-bottom:1px dashed var(--line);}
.doc-block:last-child{border-bottom:none; margin-bottom:0; padding-bottom:0;}
.doc-label{
  font-family:"IBM Plex Mono", monospace;
  font-size:11px;
  color:var(--ink-soft);
  text-transform:uppercase;
  letter-spacing:.06em;
  margin-bottom:4px;
}

/* ---------- quiz ---------- */
#quiz-panel{
  border:1px solid var(--line-strong);
  background:var(--card);
  padding:20px 22px;
}
.quiz-progress{
  height:4px; background:var(--paper-2); border:1px solid var(--line-strong);
  margin-bottom:20px; position:relative;
}
.quiz-progress > i{
  display:block; height:100%; background:var(--ink); width:0%;
  transition:width .2s ease;
}
.q-item{
  padding:16px 0;
  border-top:1px solid var(--line);
}
.q-item:first-child{border-top:none; padding-top:0;}
.q-item .q-num{
  font-family:"IBM Plex Mono", monospace;
  font-size:11px;
  color:var(--ink-soft);
}
.q-item .sentence{font-size:15px; margin:4px 0 10px;}

.quiz-submit{
  all:unset;
  cursor:pointer;
  display:block;
  margin:22px auto 0;
  font-family:"IBM Plex Mono", monospace;
  font-weight:600;
  font-size:13.5px;
  letter-spacing:.06em;
  background:var(--ink);
  color:var(--paper);
  padding:10px 26px;
  text-align:center;
}
.quiz-submit:hover{background:var(--ink-soft);}

#quiz-result{
  display:none;
  text-align:center;
  padding:18px 0 6px;
  border-top:1px solid var(--line-strong);
  margin-top:18px;
}
#quiz-result.show{display:block;}
#quiz-result .score{
  font-family:"IBM Plex Mono", monospace;
  font-size:34px;
  font-weight:600;
}
#quiz-result .score small{font-size:15px; color:var(--ink-soft);}
#quiz-result .msg{font-size:13.5px; color:var(--ink-soft); margin-top:4px;}
