/* 夜景底：百萬夜景在最底層，選單與按鈕是半透明深色；動畫畫面與字幕泡泡維持亮底，內容最好讀 */
:root {
  --orange: #db6a41;
  --orange-hi: #ff8a57;
  --orange-deep: #b8532f;
  --orange-soft: #fbe3d6;
  --navy: #25264a;
  --night: #070c1f;
  --panel: rgba(9, 14, 36, .74);
  --panel-line: rgba(255, 255, 255, .13);
  --glass: rgba(255, 255, 255, .08);
  --text: #eef1ff;
  --muted: #a9b1d6;
  --ink: #1f1d2b;
  --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(7,12,31,.6) 0, rgba(7,12,31,.1) 22%, rgba(7,12,31,.08) 60%, rgba(7,12,31,.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(7, 12, 31, .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: grid; grid-template-columns: 1fr 1fr; padding: 12px 12px 0; gap: 6px; }
.tabs button {
  border: 0; border-radius: 10px 10px 0 0; padding: 10px 0; background: var(--glass); cursor: pointer;
  font-weight: 700; font-size: 16px; color: var(--muted); transition: background-color .2s var(--snap), color .2s var(--snap);
}
.tabs button[aria-selected="true"] { background: var(--orange); color: #fff; }
.tabs button .n { font-weight: 500; font-size: 12px; margin-left: 4px; opacity: .8; }
.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(219, 106, 65, .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 .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: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px 20px 12px; gap: 10px; }
.stage-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; 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: #ffb38f; }

.screen { position: relative; flex: 1; 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; }
/* 還沒選議題：畫面透明，看得到夜景；字放左上角，不擋 101 */
.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; }

/* ---------- 解說列：娃娃＋字幕＋控制 ---------- */
.narrator { display: grid; grid-template-columns: auto 1fr auto; 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 { 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 { 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; } /* 手機版才出現：‹ › 變成 ← → */
.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: #f2b59a; }

.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(7, 12, 31, .82); padding: 0 12px;
}
.foot a { color: var(--muted); }
.foot .maker { color: var(--text); font-weight: 700; }

/* ---------- 手機：選單變成上方橫向捲動的卡片列 ---------- */
@media (max-width: 820px) {
  .top { height: auto; padding: 8px 12px; }
  .brand { flex-direction: column; align-items: flex-start; gap: 3px; }
  .brand b { font-size: 16px; }
  .official { display: none; }
  body { display: block; height: auto; }
  .layout { display: block; height: auto; }
  .menu { border-right: 0; border-bottom: 1px solid var(--panel-line); }
  .list { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 10px 12px 12px; scroll-snap-type: x proximity; }
  .list li { flex: none; width: 168px; scroll-snap-align: start; }
  .list li + li { margin-top: 0; }
  .item { grid-template-columns: 1fr; gap: 6px; height: 100%; align-content: start; }
  .thumb { width: 100%; height: 92px; }
  .stage { padding: 12px 12px 10px; }
  .topic-title { font-size: 20px; }
  .screen { flex: none; aspect-ratio: 16 / 25; } /* 直式畫面＝議題頁的直式版面（640×1000） */
  .welcome { font-size: 17px; }
  .narrator { grid-template-columns: auto 1fr; }
  .doll { --doll-size: 92px; }
  .say { font-size: 16px; }
  .controls { grid-column: 1 / -1; }
  /* 上一步／下一步只留 ← →（按鈕的 aria-label 還是「上一步」「下一步」） */
  .ctl.prev span, .ctl.next span { display: none; }
  .ctl .shaft { display: inline; }
  .ctl.prev svg, .ctl.next svg { width: 22px; height: 22px; }
  .foot { height: auto; padding: 8px 12px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .say.swap { animation-name: say-fade; }
  @keyframes say-fade { from { opacity: 0; } to { opacity: 1; } }
}
