/* ============================================================
   6.2.0 閱讀頁（reading）樣式
   只使用 style.css 既有 token（surface／border／accent／good／warn），
   深淺色、五種強調色自動跟著全站設定走，不另寫死顏色。
   版面沿用已驗樣品 6.0/ui-samples/reading-620-review.html 的卡片層級與字卡結構；
   本站內容區固定 640px，因此桌面與手機皆為單欄（樣品 960px 雙欄不套用）。
   ============================================================ */

.reading-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.reading-head h2 { margin-bottom: 2px; }
.reading-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}
.reading-source { margin: 0 0 12px; }

/* ---------- 貼上文章 ---------- */
.reading-paste { display: block; }
.reading-title-input,
.reading-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 9px 12px;
}
.reading-title-input { font-size: 0.92rem; margin-bottom: 8px; }
.reading-textarea {
  min-height: 170px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.7;
}
.reading-title-input:focus,
.reading-textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.reading-paste-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.76rem;
  color: var(--muted);
  margin: 6px 0 2px;
}

/* ---------- 考古題清單 ---------- */
.reading-archive-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.reading-year { display: inline-flex; align-items: center; gap: 6px; }
.reading-year select {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 5px 8px;
  font: inherit;
  font-size: 0.85rem;
}
.reading-archive-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.reading-archive-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 11px;
  font: inherit;
  cursor: pointer;
}
.reading-archive-item:hover { background: var(--surface-2); border-color: var(--accent); }
.reading-archive-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.reading-archive-title { font-weight: 600; font-size: 0.9rem; }
.reading-archive-meta { font-size: 0.74rem; color: var(--muted); }
.reading-archive-empty { padding: 8px 0; }

/* ---------- 文章 ---------- */
.reading-article-card { padding: 18px; }
.source-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.source-bar .src-name { color: var(--ink); font-weight: 600; }
.article-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}
.article-title { font-size: 1.1rem; font-weight: 700; line-height: 1.4; }
.article-body {
  font-family: Georgia, "Times New Roman", "Noto Serif TC", serif;
  font-size: 1.02rem;
  line-height: 1.95;
  overflow-wrap: anywhere;
}
.article-body .para { margin: 0 0 1em; white-space: pre-wrap; }
.article-body .para:last-child { margin-bottom: 0; }
.article-body .w {
  display: inline;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 3px;
  padding: 0 1px;
  cursor: pointer;
  text-align: inherit;
}
.article-body .w:hover { background: var(--accent-soft); }
.article-body .w:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.article-body .w.in-book { background: var(--accent-soft); }
.article-body .w.known {
  background: color-mix(in srgb, var(--good) 16%, transparent);
  border-bottom-color: color-mix(in srgb, var(--good) 55%, transparent);
}
.article-body .w.missing {
  border-bottom: 1px dotted var(--warn);
}
.reading-empty { padding: 8px 0; }
.reading-empty p { margin: 0 0 6px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.legend .sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  vertical-align: -1px;
  margin-right: 4px;
}
.legend .sw.hl { background: var(--accent-soft); border: 1px solid var(--accent); }
.legend .sw.known { background: color-mix(in srgb, var(--good) 30%, transparent); border: 1px solid var(--good); }
.legend .sw.miss { background: transparent; border-bottom: 2px dotted var(--warn); border-radius: 0; }

/* ---------- 側欄清單 ---------- */
.reading-side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.reading-side-head h3 { margin: 10px 0 6px; }
.reading-side-head:first-child { margin-top: 0; }
.collect-list { list-style: none; padding: 0; margin: 0; }
.collect-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.collect-item:last-child { border-bottom: 0; }
.collect-item .cw { min-width: 0; }
.collect-item .cw b { display: block; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collect-item .cw span { display: block; font-size: 0.74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collect-item .btn { flex: none; }
.empty { color: var(--muted); font-size: 0.82rem; padding: 8px 0; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 8px; }
.chip { cursor: pointer; font: inherit; }
.confirm-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  padding: 14px;
  margin: 10px 0 0;
}
.confirm-box h4 { font-size: 0.9rem; margin: 0 0 6px; }
.confirm-box p { margin: 0 0 6px; }
.confirm-box .controls { margin: 10px 0 0; }

/* ---------- 查詞浮層：桌面右側面板、手機底部 sheet ---------- */
.reading-word-layer {
  position: fixed;
  inset: 0;
  z-index: 190;
}
.reading-word-layer[hidden] { display: none; }
.reading-word-scrim { position: absolute; inset: 0; background: rgba(20, 20, 18, 0.32); }
.reading-word-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}
.wp-body {
  padding: 14px 16px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}
.wp-word { font-size: 1.45rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.wp-phon { font-size: 0.84rem; color: var(--muted); margin-top: 2px; }
.wp-gloss { font-size: 0.98rem; font-weight: 600; margin-top: 8px; overflow-wrap: anywhere; }
.wp-line { font-size: 0.8rem; color: var(--muted); margin: 6px 0 0; }
.wp-actions { display: grid; gap: 7px; margin: 14px 0 6px; }
.wp-actions .btn { width: 100%; justify-content: flex-start; }
.wp-actions .btn svg { width: 17px; height: 17px; flex: none; }
.wp-note {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  padding: 9px 11px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 12px;
}
.wp-context {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 10px 0 0;
  font-family: Georgia, "Times New Roman", "Noto Serif TC", serif;
  line-height: 1.75;
}
.wp-context mark { background: transparent; color: var(--ink); font-weight: 600; }
.wp-miss {
  border-left: 3px solid var(--warn);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  padding: 9px 11px;
  font-size: 0.84rem;
}
.reading-lex { margin-top: 12px; border-top: 1px solid var(--border-soft); padding-top: 10px; }
.reading-lex summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent);
}
.reading-lex-body { margin-top: 8px; font-size: 0.8rem; line-height: 1.7; }
.reading-lex-body .dict-row { margin: 2px 0; }

@media (max-width: 759px) {
  .reading-article-card { padding: 14px; }
  .article-body { font-size: 0.98rem; line-height: 1.9; }
  .reading-word-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: min(78vh, 640px);
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
  }
  .wp-head { padding: 10px 14px 8px; }
  .wp-body { padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (prefers-reduced-motion: reduce) {
  .reading-word-panel { transition: none; }
}
