/* 會考數學判讀練習 [touhou_capmath]
 * 全部規則只作用在 #tcm（練習本體）與 #tcm-zoom（點圖放大的全螢幕層，掛在 body 底下）。
 * 前半段是「防主題干擾」的重設：主題對 button / img / a / h1 / p / ol 等元素下的樣式，
 * 只要我們沒有明講同一個屬性就會滲進來，所以把會被動到的屬性先在 #tcm 裡講死。 */

/* ---------- 防主題干擾 ---------- */
#tcm, #tcm *, #tcm *::before, #tcm *::after { box-sizing: border-box; }
#tcm * {
  font-family: inherit; letter-spacing: normal; text-transform: none; text-shadow: none;
  word-spacing: normal; text-indent: 0; float: none;
}
#tcm div, #tcm span, #tcm p, #tcm li, #tcm b, #tcm small, #tcm label { line-height: inherit; }
#tcm p, #tcm ol, #tcm ul, #tcm li, #tcm details, #tcm summary, #tcm picture { font-size: inherit; }
#tcm img { max-width: 100%; height: auto; border: 0; border-radius: 0; box-shadow: none; padding: 0; margin: 0; opacity: 1; filter: none; }
#tcm a { text-decoration: underline; text-underline-offset: 2px; box-shadow: none; background: none; border: 0; }
#tcm button, #tcm select {
  text-transform: none; letter-spacing: normal; box-shadow: none; text-shadow: none;
  line-height: 1.3; width: auto; height: auto; margin: 0; outline-offset: 2px;
  background-image: none; transform: none; transition: background-color .15s, border-color .15s;
}
#tcm button:focus-visible, #tcm select:focus-visible, #tcm .qimg:focus-visible { outline: 2px solid #2A5A87; }
#tcm ol, #tcm ul { list-style-position: outside; }
#tcm ol { list-style-type: decimal; }
#tcm ul { list-style-type: disc; }
#tcm details { display: block; }
#tcm summary { display: list-item; }
#tcm svg.i { display: inline-block; vertical-align: middle; max-width: none; }
#tcm .card, #tcm .msg, #tcm .weak, #tcm .progress, #tcm .qimg, #tcm .tcm-loading, #tcm .sol { display: block; }
#tcm .opt, #tcm .chip, #tcm .qlist button { text-align: center; }
#tcm .btn { justify-content: center; text-align: center; }
#tcm h1::before, #tcm h1::after, #tcm h2::before, #tcm h2::after, #tcm h3::before, #tcm h3::after { content: none; }

/* ---------- 版面 ---------- */
#tcm {
  --bg:#F6F1E9; --card:#FFFDF9; --ink:#16233d; --ink2:#4a5468; --line:#E4DACB;
  --brand:#a8705c; --brand-dk:#8F5B48; --brand-soft:#F1E4DC;
  --ok:#2F6B45; --ok-bg:#E9F0EA; --err:#C0392B; --err-bg:#F8E9E5;
  --info:#2A5A87; --info-bg:#E8EEF3; --warn:#8A6100; --warn-bg:#F3ECDD;
  font-family: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink); background: var(--bg);
  line-height: 1.65; font-size: 16px; font-weight: 400; text-align: left; -webkit-text-size-adjust: 100%;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 20px 16px 48px; border-radius: 16px;
  min-height: 360px;
}
#tcm .tcm-loading { color: var(--ink2); padding: 40px 0; text-align: center; }
#tcm h1, #tcm h2, #tcm h3 { font-family: "Noto Serif TC", "Songti TC", serif; color: var(--ink); line-height: 1.35; margin: 0; padding: 0; font-weight: 600; border: 0; background: none; }
#tcm h1 { font-size: 26px; } #tcm h2 { font-size: 20px; } #tcm h3 { font-size: 17px; }
#tcm p { margin: .4em 0; padding: 0; color: inherit; }
#tcm .muted { color: var(--ink2); font-size: 14px; }
#tcm .card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 14px 0; }
#tcm .btn { appearance: none; -webkit-appearance: none; border: 1.5px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-size: 16px; font-weight: 500;
  border-radius: 10px; padding: 11px 18px; min-height: 46px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
#tcm .btn:hover, #tcm .btn:focus { background: var(--brand-dk); border-color: var(--brand-dk); color: #fff; }
#tcm .btn.ghost { background: transparent; color: var(--brand-dk); }
#tcm .btn.ghost:hover, #tcm .btn.ghost:focus { background: var(--brand-soft); color: var(--brand-dk); }
#tcm .btn.small { min-height: 38px; padding: 7px 13px; font-size: 15px; }
#tcm .btn[disabled] { opacity: .45; cursor: default; }
#tcm .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#tcm .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
#tcm .chip { appearance: none; -webkit-appearance: none; border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 15px; font-weight: 400; cursor: pointer; min-height: 42px; }
#tcm .chip:hover, #tcm .chip:focus { border-color: var(--brand); background: #fff; color: var(--ink); }
#tcm .chip b { color: var(--brand-dk); font-weight: 500; margin-left: 4px; }
#tcm .chip.on, #tcm .chip.on:hover, #tcm .chip.on:focus { border-color: var(--brand); background: var(--brand); color: #fff; }
#tcm .chip.on b { color: #fff; }
#tcm select { appearance: auto; -webkit-appearance: menulist; font: inherit; font-size: 16px; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); max-width: 100%; min-height: 46px; }
#tcm svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* 題目 */
#tcm .qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
#tcm .progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 6px 0 12px; }
#tcm .progress i { display: block; height: 100%; background: var(--brand); }
#tcm .qimg { display: block; margin: 0 -8px; cursor: zoom-in; position: relative; }
#tcm .qimg img { display: block; width: 100%; height: auto; background: #fff; border-radius: 8px; min-height: 40px; }
#tcm .qimg .zoomtip { display: flex; justify-content: flex-end; gap: 4px; align-items: center; color: var(--ink2); font-size: 13px; margin-top: 4px; }
#tcm .qimg .zoomtip svg { width: 14px; height: 14px; }
#tcm details.passage { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; margin: 0 0 12px; background: #fff; }
#tcm details.passage summary { cursor: pointer; color: var(--brand-dk); font-weight: 500; }
#tcm .opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
#tcm .opt { appearance: none; -webkit-appearance: none; font: inherit; font-size: 20px; font-weight: 700; min-height: 56px; padding: 0 4px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
#tcm .opt:hover:not([disabled]), #tcm .opt:focus:not([disabled]) { border-color: var(--brand); background: #fff; color: var(--ink); }
#tcm .opt.pick-wrong, #tcm .opt.pick-wrong:hover, #tcm .opt.pick-wrong:focus { border-color: var(--err); background: var(--err-bg); color: var(--err); }
#tcm .opt.pick-right, #tcm .opt.pick-right:hover, #tcm .opt.pick-right:focus { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
#tcm .opt.is-answer { border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--ok); }
#tcm .opt[disabled] { cursor: default; opacity: 1; }
#tcm .msg { border-left: 4px solid var(--info); background: var(--info-bg); padding: 10px 12px; border-radius: 6px; margin-top: 12px; color: var(--ink); }
#tcm .msg.ok { border-color: var(--ok); background: var(--ok-bg); }
#tcm .msg.err { border-color: var(--err); background: var(--err-bg); }
#tcm .msg.warn { border-color: var(--warn); background: var(--warn-bg); }
#tcm .msg .t { font-weight: 700; display: flex; gap: 6px; align-items: center; }
#tcm .msg .t svg { width: 18px; height: 18px; }
#tcm .sol ol { margin: 6px 0 0; padding: 0 0 0 1.4em; }
#tcm .sol ul { margin: 4px 0; padding: 0 0 0 1.3em; }
#tcm .sol li { margin: 3px 0; padding: 0; }
#tcm .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#tcm .tag { font-size: 13px; border-radius: 6px; padding: 2px 8px; background: var(--brand-soft); color: var(--brand-dk); }
#tcm .tag.navy { background: #E6E9EF; color: var(--ink); }
#tcm .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
#tcm .lk { color: var(--brand-dk); font-weight: 500; }
#tcm .lk:hover { color: var(--ink); }

/* 結果 */
#tcm .score { font-family: "Noto Serif TC", "Songti TC", serif; font-size: 44px; font-weight: 600; color: var(--ink); line-height: 1; }
#tcm .score small { font-size: 20px; color: var(--ink2); }
#tcm .meter { display: grid; grid-template-columns: 6.5em 1fr 4.2em; gap: 10px; align-items: center; margin: 8px 0; font-size: 15px; }
#tcm .meter .bar { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; display: block; }
#tcm .meter .bar i { display: block; height: 100%; background: var(--ink); }
#tcm .meter .bar i.low { background: var(--brand); }
#tcm .meter .v { text-align: right; font-variant-numeric: tabular-nums; }
#tcm .weak { border-left: 4px solid var(--brand); padding: 8px 12px; margin: 10px 0; background: var(--brand-soft); border-radius: 6px; }
#tcm .weak a { color: var(--brand-dk); font-weight: 500; }
#tcm .qlist { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
#tcm .qlist button { appearance: none; -webkit-appearance: none; font: inherit; font-size: 14px; min-height: 44px; padding: 0 2px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
#tcm .qlist button.r, #tcm .qlist button.r:hover, #tcm .qlist button.r:focus { border-color: var(--ok); color: var(--ok); background: #fff; }
#tcm .qlist button.w, #tcm .qlist button.w:hover, #tcm .qlist button.w:focus { border-color: var(--err); color: var(--err); background: #fff; }

/* 點圖放大（掛在 body 底下，避免祖先元素的 transform 讓 position:fixed 失效） */
#tcm-zoom { position: fixed; inset: 0; background: rgba(22,35,61,.92); z-index: 999999; display: none; overflow: auto; -webkit-overflow-scrolling: touch; }
#tcm-zoom.on { display: block; }
#tcm-zoom img { display: block; background: #fff; margin: 56px auto 24px; max-width: none; height: auto; border: 0; border-radius: 0; box-shadow: none; padding: 0; }
#tcm-zoom button { appearance: none; -webkit-appearance: none; position: fixed; top: 10px; right: 10px; font: 16px/1.3 "Noto Sans TC", system-ui, sans-serif; text-transform: none; letter-spacing: normal;
  border: 0; border-radius: 10px; padding: 9px 14px; margin: 0; min-height: 0; width: auto; background: #fff; color: #16233d; cursor: pointer; box-shadow: none; }
#tcm-zoom button:hover, #tcm-zoom button:focus { background: #F1E4DC; color: #16233d; }
#tcm-zoom .z { position: fixed; top: 10px; left: 10px; display: flex; gap: 8px; }
#tcm-zoom .z button { position: static; }
body.tcm-noscroll { overflow: hidden; }

/* 手機上網站右下角有小助教浮動鈕（約 100px 高），底部多留白，最後一排按鈕與 LINE 連結才不會被蓋住 */
@media (max-width: 520px) {
  #tcm { padding: 14px 12px 104px; border-radius: 12px; }
  #tcm h1 { font-size: 23px; }
  #tcm .card { padding: 14px 12px; }
  #tcm .qimg { margin: 0 -6px; }
  #tcm .opts { gap: 8px; }
}
