/* 晴空海洋底（業主：藍色、深靛藍、白色）；選單與按鈕是半透明深靛藍，動畫畫面與字幕泡泡維持亮底，內容最好讀。
   變數名沿用台北版（--orange＝主色，現在是藍），lib/ 跟台北版同步時比較好對 */
:root {
  --orange: #2f7de1;
  --orange-hi: #6db8ff;
  --orange-deep: #1f5fb8;
  --orange-soft: #dcebfb;
  --navy: #1a2559;
  --night: #0b1438;
  --panel: rgba(14, 26, 72, .74);
  --panel-line: rgba(255, 255, 255, .13);
  --glass: rgba(255, 255, 255, .08);
  --text: #f3f7ff;
  --muted: #b3c3e6;
  --ink: #16213f;
  --red: #e0493d;
  --snap: cubic-bezier(.23, 1, .32, 1);   /* 快起慢收：進場、回饋 */
  --swap: cubic-bezier(.77, 0, .175, 1);  /* 對稱：畫面上的移動 */
  --top-h: 56px;
  --foot-h: 34px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--night); }
/* 桌機：頂列＋版面＋頁尾剛好一個畫面高，頁尾字多換行也不會多出捲軸 */
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
button { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- 背景 ---------- */
.bgscene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.bgshade {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(11, 20, 56,.6) 0, rgba(11, 20, 56,.1) 22%, rgba(11, 20, 56,.08) 60%, rgba(11, 20, 56,.7) 100%);
}
.top, .layout, .foot { position: relative; z-index: 1; }

/* ---------- 頂列 ---------- */
.top {
  height: var(--top-h); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px; background: rgba(11, 20, 56, .55); border-bottom: 1px solid var(--panel-line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand b { font-size: 19px; font-weight: 900; letter-spacing: .04em; white-space: nowrap; }
.brand .en { font-family: "Arial Black", "Noto Sans TC", sans-serif; letter-spacing: .06em; }
.brand .ai { color: var(--orange-hi); }
.brand .dot { font-size: .7em; vertical-align: .12em; margin: 0 .1em; }
.official { font-size: 14px; font-weight: 700; white-space: nowrap; text-decoration: none; }
.official .en { color: var(--orange-hi); margin-left: 4px; }
@media (hover: hover) and (pointer: fine) { .official:hover .en { text-decoration: underline; } }

/* ---------- 版面：左 30%、右 70% ---------- */
.layout {
  display: grid; grid-template-columns: 30% 70%;
  flex: 1; min-height: 0;
}

/* ---------- 左：議題選單 ---------- */
.menu { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--panel-line); background: var(--panel); }
/* 選到的分頁拉寬、顯示全名；沒選到的縮寫（心桃園／怎麼做／闢謠） */
.tabs { display: flex; padding: 12px 12px 0; gap: 6px; }
.tabs button {
  flex: 1 1 0; min-width: 0; border: 0; border-radius: 10px 10px 0 0; padding: 8px 2px; background: var(--glass); cursor: pointer; line-height: 1.3; word-break: keep-all;
  white-space: nowrap; overflow: hidden; /* 拉寬的動畫中全名不先擠成兩行（不然下面的清單會跳一下） */
  font-weight: 700; font-size: 15px; color: var(--muted); transition: flex-grow .25s var(--swap), background-color .2s var(--snap), color .2s var(--snap);
}
.tabs button[aria-selected="true"] { flex-grow: 2.4; background: var(--orange); color: #fff; }
.tabs button .full, .tabs button[aria-selected="true"] .short { display: none; }
.tabs button[aria-selected="true"] .full { display: inline; }
.tabs button .n { display: block; font-weight: 500; font-size: 12px; opacity: .8; } /* 則數放第二行 */
@media (min-width: 821px) and (max-width: 960px) { .tabs button { white-space: normal; } } /* 選單太窄：寧可換行也不要切字 */
.preview-note { margin: 0; padding: 8px 14px; font-size: 12px; background: rgba(255, 214, 102, .14); color: #ffd666; }
.list { list-style: none; margin: 0; padding: 10px 12px 16px; overflow-y: auto; flex: 1; border-top: 3px solid var(--orange); scrollbar-width: thin; scrollbar-color: var(--orange) var(--navy); }
/* Safari 還不支援 scrollbar-color */
.list::-webkit-scrollbar { width: 10px; height: 10px; }
.list::-webkit-scrollbar-track { background: var(--navy); }
.list::-webkit-scrollbar-thumb { background: var(--orange); border-radius: 5px; border: 2px solid var(--navy); }
.list li + li { margin-top: 8px; }
.item {
  width: 100%; display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; text-align: left;
  padding: 8px; border: 1px solid var(--panel-line); border-radius: 12px; background: var(--glass); cursor: pointer;
  transition: border-color .16s var(--snap), background-color .16s var(--snap), transform .12s var(--snap);
}
.item:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) {
  .item:hover { border-color: var(--orange); background: rgba(255, 255, 255, .12); }
}
.item[aria-current="true"] { border-color: var(--orange); background: rgba(47, 125, 225, .25); }
.thumb { width: 96px; height: 72px; border-radius: 8px; object-fit: cover; background: var(--orange-soft); display: block; }
.thumb.fc { object-fit: contain; padding: 4px; } /* 去背貼紙：整張放進來 */
.item .txt { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .t { font-weight: 700; font-size: 15px; line-height: 1.35; }
.item .pre-s { display: none; }
.item .s { font-size: 12.5px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .d { font-size: 11.5px; color: var(--muted); }
.item .draft { align-self: flex-start; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: rgba(255, 255, 255, .14); color: var(--muted); }
.empty { padding: 24px 8px; color: var(--muted); font-size: 14px; line-height: 1.7; }

/* ---------- 右：展演區 ---------- */
/* 標題在左上、操作列在右上；下面是動畫畫面，最下面是娃娃＋拉滿寬的字幕泡泡 */
.stage {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "head ctl" "screen screen" "narr narr";
  min-width: 0; min-height: 0; padding: 14px 20px 12px; gap: 10px 16px; container: stage / inline-size;
}
.stage-head { grid-area: head; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; text-shadow: 0 1px 8px rgba(0, 0, 0, .6); }
.kind-badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 4px; background: var(--orange); color: #fff; text-shadow: none; }
.kind-badge:empty { display: none; }
.kind-badge.factcheck { background: var(--red); }
.topic-title { margin: 4px 0 0; font-size: 24px; font-weight: 900; line-height: 1.3; }
.topic-sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.topic-sub:empty { display: none; }
.source { flex: none; font-size: 13px; color: #9fd0ff; }

.screen { grid-area: screen; position: relative; min-height: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--panel-line); }
.screen:has(.scene:not([hidden])) { background: #fff; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity .3s var(--snap); }
.scene.ready { opacity: 1; }
/* 還沒選議題：畫面透明，看得到背景；字放左上角，不擋背景主體 */
.welcome { position: absolute; left: 24px; top: 20px; right: 24px; font-size: 20px; line-height: 1.8; font-weight: 700; text-shadow: 0 2px 12px rgba(0, 0, 0, .7); }
.welcome p { margin: 0; display: inline-block; padding: 4px 16px; border-radius: 14px; background: rgba(11, 20, 56, .55); } /* 晴空底太亮：字墊一塊深靛藍，藍色強調字才看得清楚 */
.welcome .hl { color: var(--orange-hi); }
.welcome .arrow::before { content: "← "; } /* 選單在左邊；手機版選單在上面，改成 ↑ */

/* ---------- 解說列：娃娃＋字幕＋控制 ---------- */
.narrator { grid-area: narr; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px; }
.doll { --doll-size: 124px; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .45)); }
.bubble {
  position: relative; align-self: stretch; display: flex; align-items: center; color: var(--ink);
  background: #fff; border-radius: 14px; padding: 10px 16px; min-height: 76px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.bubble::before {
  content: ""; position: absolute; left: -8px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  background: #fff; transform: rotate(45deg); border-radius: 2px;
}
.say { position: relative; margin: 0; font-size: 18px; line-height: 1.6; font-weight: 500; max-height: 6.4em; overflow-y: auto; }
.say.swap { animation: say-in .25s var(--snap); }
@keyframes say-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.controls { grid-area: ctl; align-self: end; display: grid; grid-template-columns: auto auto auto auto; gap: 6px; justify-items: stretch; }
.ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 40px; padding: 0 12px;
  border: 1px solid var(--panel-line); border-radius: 10px; background: var(--panel); cursor: pointer; font-size: 14px; font-weight: 700;
  transition: background-color .16s var(--snap), transform .12s var(--snap), opacity .16s var(--snap);
}
.ctl:active:not(:disabled) { transform: scale(.97); }
.ctl:disabled { opacity: .4; cursor: default; }
.ctl svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ctl.play { background: var(--orange); border-color: var(--orange); color: #fff; min-width: 116px; }
.ctl.play .i-play { fill: currentColor; stroke: none; }
.ctl.play .i-pause, .ctl.play[aria-pressed="true"] .i-play { display: none; }
.ctl.play[aria-pressed="true"] .i-pause { display: block; }
.ctl.sound { padding: 0 10px; }
.ctl.sound .i-off, .ctl.sound[aria-pressed="false"] .i-on { display: none; }
.ctl.sound[aria-pressed="false"] .i-off { display: block; }
.ctl.sound[aria-pressed="false"] { opacity: .7; }
.ctl[hidden] { display: none; }
.ctl .shaft { display: none; } /* 展演區窄的時候才出現：‹ › 變成 ← → */
/* 展演區窄（約視窗 1550px 以下、含手機）：上一步／下一步只留 ← →，右上角才放得下，標題不會被擠 */
@container stage (max-width: 900px) {
  .ctl.prev span, .ctl.next span { display: none; }
  .ctl .shaft { display: inline; }
  .ctl.prev svg, .ctl.next svg { width: 22px; height: 22px; }
}
.ctl.yt { grid-column: 1 / -1; color: inherit; text-decoration: none; }
.ctl.yt svg rect { fill: #ff0033; stroke: none; }
.ctl.yt svg path { fill: #fff; stroke: none; }
@media (hover: hover) and (pointer: fine) {
  .ctl:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }
  .ctl.play:hover:not(:disabled) { background: var(--orange-deep); }
}
.dots { grid-column: 1 / -1; display: flex; justify-content: center; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; flex-wrap: wrap; }
.dots button {
  width: 22px; height: 8px; padding: 0; border: 0; border-radius: 99px; background: rgba(255, 255, 255, .25); cursor: pointer;
  transition: background-color .2s var(--snap), transform .2s var(--snap);
}
.dots button[aria-current="step"] { background: var(--orange); transform: scaleX(1.35); }
.dots button.done { background: #9fc7f5; }

.foot {
  min-height: var(--foot-h); display: flex; align-items: center; justify-content: center; gap: 4px 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); border-top: 1px solid var(--panel-line); background: rgba(11, 20, 56, .82); padding: 0 12px;
}
.foot a { color: var(--muted); }
.foot .maker { color: var(--text); font-weight: 700; }

/* ---------- 手機：一頁式（F018）——整頁剛好一個畫面高、不捲動，選單、動畫、娃娃＋字幕、操作列都看得到 ---------- */
/* 由上到下：精簡站名列 → 分頁＋橫向議題列 → 動畫（吃掉剩下的高度）→ 娃娃＋字幕（固定 4 行高）→ 操作列＋圓點 → 兩行頁尾 */
@media (max-width: 820px) {
  body { overflow: hidden; }
  .top { --top-h: 30px; padding: 0 10px; }
  .brand b { font-size: 14px; }
  .official { display: none; }
  .layout { display: flex; flex-direction: column; }
  .menu { flex: none; border-right: 0; border-bottom: 1px solid var(--panel-line); }
  .tabs { padding: 6px 8px 0; gap: 4px; }
  .tabs button { font-size: 13.5px; padding: 6px 2px; }
  .tabs button .n { display: none; }
  .list { display: flex; flex: none; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 6px 8px; scroll-snap-type: x proximity; scrollbar-width: none; }
  .list::-webkit-scrollbar { display: none; }
  .list li { flex: none; width: 152px; scroll-snap-align: start; }
  .list li + li { margin-top: 0; }
  .item { grid-template-columns: 40px 1fr; gap: 6px; height: 46px; padding: 3px 6px 3px 3px; border-radius: 10px; }
  .thumb { width: 40px; height: 38px; border-radius: 7px; }
  .thumb.fc { padding: 2px; }
  .item .t { font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .item .s, .item .d, .item .pre-l { display: none; }
  .item .pre-s { display: inline; color: var(--muted); }
  .empty { padding: 8px; font-size: 13px; }

  /* 標題、副標題議題動畫裡就有，這裡收起來；「看出處」搬到操作列最右邊 */
  .stage {
    flex: 1; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas: "screen screen" "narr narr" "ctl src"; padding: 5px 8px 4px; gap: 5px 6px;
  }
  .stage-head { display: contents; }
  .stage-head > div { display: none; }
  .source {
    grid-area: src; align-self: start; display: inline-flex; align-items: center; height: 38px; padding: 0 8px; border-radius: 10px;
    border: 1px solid var(--panel-line); background: var(--panel); font-size: 12.5px; font-weight: 700; text-decoration: none; text-shadow: none; white-space: nowrap;
  }
  .source[hidden] { display: none; }
  .stage:has(.source[hidden]) .controls { grid-column: 1 / -1; }
  .screen { border-radius: 12px; }
  .welcome { left: 16px; top: 14px; right: 16px; font-size: 17px; }
  .welcome .arrow::before { content: "↑ "; }
  .narrator { gap: 8px; }
  .doll { --doll-size: 60px; }
  .bubble { height: 96px; min-height: 0; padding: 6px 10px; border-radius: 12px; }
  .bubble::before { left: -6px; width: 12px; height: 12px; margin-top: -6px; }
  .say { font-size: 15px; line-height: 1.45; max-height: 100%; } /* 太長 app.js 會縮字（最小 13px），還放不下才捲 */
  .controls { display: flex; flex-wrap: wrap; gap: 5px; align-self: start; }
  .ctl { height: 38px; padding: 0 8px; }
  .ctl.play { flex: 1; min-width: 0; white-space: nowrap; }
  .ctl.yt { padding: 0 8px; }
  .ctl.yt span { display: none; }
  .dots { flex-basis: 100%; margin: 0; gap: 5px; }
  .dots li { display: flex; }
  .dots button { width: 16px; height: 6px; }
  .foot { min-height: 0; padding: 3px 8px; gap: 0 8px; font-size: 10.5px; line-height: 1.4; text-align: center; }
  .foot > :not(.maker):not(.license) { display: none; }
  .foot .license .long { display: none; }
}
@media (min-width: 821px) { .foot .license .short { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .say.swap { animation-name: say-fade; }
  @keyframes say-fade { from { opacity: 0; } to { opacity: 1; } }
}
