/* 大事關懷 PWA — 共用樣式（前台＋後台）
   字級：html 直接切三個 font-size，不用 CSS 變數（避免踩過的「變數設在 body 對 html 無效」的坑）。 */

html {
  font-size: 18px; /* 基準 A */
}
html.font-large {
  font-size: 21px; /* A+ */
}
html.font-xlarge {
  font-size: 24px; /* A++ */
}

:root {
  --bg: #ffffff;
  --bg-elevated: #f7f5f2;
  --text: #1c1a17;
  --text-secondary: #4a463f;
  --text-muted: #6b665c;
  --border: #ddd7cc;
  --link: #185fa5;
  --hotline-bg: #a32d2d;
  --hotline-text: #ffffff;
  --keypoint-bg: #faeeda;
  --keypoint-border: #ef9f27;
  --keypoint-text: #412402;
  --card-bg: #ffffff;
  --card-border: #e5e0d6;
  --quote-bg: #f4f1ea;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17161a;
    --bg-elevated: #201f24;
    --text: #f1efe9;
    --text-secondary: #cfc9bd;
    --text-muted: #a39c8e;
    --border: #3a3833;
    --link: #7fb2ea;
    --keypoint-bg: #3a2e12;
    --keypoint-border: #ef9f27;
    --keypoint-text: #ffe4b0;
    --card-bg: #201f24;
    --card-border: #37342d;
    --quote-bg: #262420;
  }
}
:root[data-theme="dark"] {
  --bg: #17161a;
  --bg-elevated: #201f24;
  --text: #f1efe9;
  --text-secondary: #cfc9bd;
  --text-muted: #a39c8e;
  --border: #3a3833;
  --link: #7fb2ea;
  --keypoint-bg: #3a2e12;
  --keypoint-border: #ef9f27;
  --keypoint-text: #ffe4b0;
  --card-bg: #201f24;
  --card-border: #37342d;
  --quote-bg: #262420;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a,
button {
  touch-action: manipulation;
}

img {
  max-width: 100%;
}

/* 頂部專線列 */
.hotline-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--hotline-bg);
  color: var(--hotline-text);
}
.hotline-bar a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--hotline-text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  min-height: 48px;
}
.hotline-bar a:active {
  background: rgba(0, 0, 0, 0.15);
}

/* 字級切換 */
.font-switch {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
}
.font-switch button {
  min-width: 48px;
  min-height: 48px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.font-switch button[aria-pressed="true"] {
  border-color: var(--link);
  background: var(--link);
  color: #fff;
}

/* 主題色塊 grid */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding: 0.5rem 1rem 1rem;
}
.topic-tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  min-height: 96px;
  padding: 0.9rem;
  border-radius: 16px;
  color: #ffffff;
  text-decoration: none;
  min-width: 0;
}
.topic-tile .icon {
  width: 28px;
  height: 28px;
}
.topic-tile .title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}
.topic-tile .subtitle {
  font-size: 0.72rem;
  opacity: 0.92;
  line-height: 1.3;
}

.disclaimer {
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
}
.updated-at {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 1rem;
}

/* 第二層：返回列 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  gap: 0.5rem;
}
.topbar .back-link {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  min-height: 48px;
  padding: 0.4rem 0.2rem;
}
.topbar .current-title {
  font-weight: 700;
  font-size: 1rem;
}

.keypoint-box {
  margin: 1rem;
  padding: 1rem;
  border-radius: 12px;
  background: var(--keypoint-bg);
  border: 2px solid var(--keypoint-border);
  color: var(--keypoint-text);
}
.keypoint-box ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}
.keypoint-box li {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.section-heading {
  margin: 1.2rem 1rem 0.6rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.item-card {
  margin: 0 1rem 1rem;
  padding: 1rem;
  border-radius: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
}
.item-card .question {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

/* 摺疊列（Q&A／文章共用）：一開始只看到標題＋箭頭，點了才展開內容，
   避免第一眼就把所有題目的完整文字灑滿整頁。 */
.qa-row {
  margin: 0 1rem 0.6rem;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  overflow: hidden;
}
.qa-row-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  min-height: 48px;
}
.qa-row-summary::-webkit-details-marker {
  display: none;
}
.qa-row-summary::after {
  content: "›";
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.qa-row[open] .qa-row-summary::after {
  transform: rotate(90deg);
}
.qa-row-body {
  padding: 0 1rem 1rem;
}

.sub-heading {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0.8rem 0 0.3rem;
  color: var(--text);
}
.sub-heading:first-child {
  margin-top: 0;
}

.item-card .summary,
.qa-row-body .summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.6rem;
}
.item-card .quote,
.qa-row-body .quote {
  background: var(--quote-bg);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin: 0.6rem 0 0.5rem;
  font-size: 0.92rem;
}
.item-card .quote-note,
.qa-row-body .quote-note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.item-card .sources,
.qa-row-body .sources {
  font-size: 0.78rem;
}
.item-card .sources a,
.qa-row-body .sources a {
  color: var(--link);
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
}

/* 引文＋出處預設收合，只留白話重點摘要一律可見，避免頁面被逐字長引文拉得過長。
   一鍵展開仍可看到完整引文，資訊沒有被拿掉，只是不預設攤開。 */
.quote-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--link);
  min-height: 44px;
  display: flex;
  align-items: center;
  list-style: none;
}
.quote-details summary::-webkit-details-marker {
  display: none;
}
.quote-details summary::before {
  content: "▸";
  margin-right: 0.4rem;
}
.quote-details[open] summary::before {
  content: "▾";
}

/* type: links——資料連結清單 */
.links-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.link-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--bg-elevated);
  text-decoration: none;
  min-height: 48px;
  justify-content: center;
}
.link-label {
  color: var(--link);
  font-weight: 700;
  font-size: 0.95rem;
}
.link-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 影片 lite embed——2 欄縮圖 grid，比逐支滿版堆疊省下約一半垂直空間；
   點了才展開成滿版播放（.playing 讓該格橫跨兩欄）。 */
.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin: 0 1rem 1rem;
}
.video-tile {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  min-width: 0;
}
.video-tile.playing {
  grid-column: 1 / -1;
}
.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  cursor: pointer;
}
.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-wrap .play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-tile.playing .thumb-wrap .play-btn {
  width: 60px;
  height: 60px;
}
.thumb-wrap .play-btn svg {
  width: 18px;
  height: 18px;
  fill: #fff;
  margin-left: 2px;
}
.video-tile.playing .thumb-wrap .play-btn svg {
  width: 26px;
  height: 26px;
}
.video-tile iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
}
.tile-title {
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0.5rem 0.6rem 0.1rem;
  line-height: 1.3;
}
.tile-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin: 0 0.6rem 0.5rem;
}

/* 底部再放一次撥打專線 */
.bottom-hotline {
  margin: 1.5rem 1rem;
  display: block;
  text-align: center;
  background: var(--hotline-bg);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 1rem;
  border-radius: 12px;
  min-height: 48px;
}

/* 後台共用 */
.admin-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.admin-list-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  margin-bottom: 0.6rem;
  background: var(--card-bg);
  cursor: grab;
}
.admin-list-row.dragging {
  opacity: 0.4;
}
.admin-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
}
.form-row {
  margin-bottom: 0.9rem;
}
.form-row label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}
.form-row input[type="text"],
.form-row input[type="url"],
.form-row textarea,
.form-row select {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
.char-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.char-count.over {
  color: #a32d2d;
  font-weight: 700;
}
.field-error {
  color: #a32d2d;
  font-size: 0.8rem;
  margin-top: 0.3rem;
}
.btn {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn.primary {
  background: var(--link);
  border-color: var(--link);
  color: #fff;
}
.btn.danger {
  background: #a32d2d;
  border-color: #a32d2d;
  color: #fff;
}
.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1a17;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 100;
}

.hidden {
  display: none !important;
}

@media (max-width: 380px) {
  .topic-tile .title {
    font-size: 1.05rem;
  }
}
