/* ==========================================================
   我的敘事觀點地圖｜設計系統
   色彩 / 字級 / 間距 / 圓角 / 按鈕 / 卡片 / 互動狀態
   ========================================================== */

:root {
  /* 色彩 */
  --paper: #F8F4EB;      /* 暖米白：底色 */
  --ink: #453F37;        /* 深咖啡：主要文字 */
  --olive: #777D62;      /* 橄欖綠：輔助線與裝飾 */
  --olive-deep: #5A6044; /* 橄欖深色：小字（對比足夠） */
  --clay: #BD7555;       /* 陶土橘：強調、進度條、裝飾 */
  --linen: #EBE3D5;      /* 淺亞麻：卡片與分隔 */
  --soft: #6B6358;       /* 次要文字 */

  /* 字級 */
  --font-serif: "Noto Serif TC", "Noto Serif CJK TC", "Songti TC", serif;
  --font-sans: "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", sans-serif;
  --fs-body: 17px;
  --fs-small: 14px;
  --fs-h1: 30px;
  --fs-h2: 23px;
  --fs-statement: 22px;

  /* 間距（4px 基準） */
  --sp-1: 8px;
  --sp-2: 12px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
  --gutter: 16px;

  /* 圓角與陰影 */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --shadow: 0 1px 0 rgba(69, 63, 55, .06), 0 8px 24px -16px rgba(69, 63, 55, .35);

  /* 動效 */
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.75;
  letter-spacing: .02em;
  overflow-x: hidden;
}

h1, h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
}

p { margin: 0; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--sp-4) var(--gutter) 56px;
  outline: none;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 8px; top: -60px;
  background: var(--ink); color: var(--paper);
  padding: 8px 14px; border-radius: 8px; z-index: 10;
}
.skip:focus { top: 8px; }

:focus-visible {
  outline: 3px solid var(--clay);
  outline-offset: 3px;
}

/* ---------- 品牌區 ---------- */

.brand { text-align: center; margin: var(--sp-4) 0 var(--sp-5); }
.brand .en {
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--clay);
  font-weight: 500;
  text-transform: uppercase;
}
.brand .title { font-size: var(--fs-h1); margin-top: var(--sp-1); }
.brand .sub { color: var(--soft); margin-top: 6px; font-size: 15px; }

.title { outline: none; }

/* ---------- 插畫 ---------- */

.fox { display: block; margin: 0 auto; }
.fox svg { display: block; width: 100%; height: auto; }
.fox-hero { width: min(72%, 300px); margin-top: var(--sp-4); animation: rise .9s var(--ease) both; }
.fox-small { width: 120px; margin: var(--sp-5) auto 0; opacity: .95; }
.fox-result { width: 150px; margin: 0 auto var(--sp-2); }
.result .fox-result + .brand { margin-top: 0; }

/* ---------- 按鈕 ---------- */

.btn {
  appearance: none;
  min-height: 48px;
  min-width: 44px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .2s var(--ease), color .2s var(--ease), transform .1s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: rgba(69, 63, 55, .06); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: transparent; }

.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: #3a342d; }
.btn.secondary { background: var(--linen); border-color: var(--olive-deep); }
.btn.secondary:hover { background: #e2d8c6; }
.btn.ghost { border-color: var(--olive); color: var(--olive-deep); }
.btn.text {
  border-color: transparent;
  color: var(--soft);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.btn.wide { width: 100%; max-width: 360px; }

.actions { display: flex; justify-content: center; margin-top: var(--sp-5); }

/* ---------- 歡迎 / 說明 ---------- */

.welcome { text-align: center; padding-top: var(--sp-2); }
.welcome .guide {
  margin-top: var(--sp-4);
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--olive-deep);
}

.intro { text-align: center; padding-top: var(--sp-2); }
.intro .kicker { font-size: var(--fs-small); color: var(--soft); letter-spacing: .08em; }
.intro .title { font-size: 28px; margin-top: var(--sp-3); }
.intro .lead { margin-top: var(--sp-4); }
.intro .tip {
  margin: var(--sp-4) auto 0;
  max-width: 420px;
  font-family: var(--font-serif);
  color: var(--olive-deep);
  font-size: 16px;
}
.intro .meta { margin-top: var(--sp-4); font-size: var(--fs-small); color: var(--soft); }

.legend {
  list-style: none;
  padding: 0;
  margin: var(--sp-4) auto 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
}
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .sym { font-size: 20px; font-weight: 700; color: var(--clay); }

/* ---------- 作答 ---------- */

.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--sp-2) 0;
}
.quiz-top .site { font-family: var(--font-serif); font-size: 16px; color: var(--soft); }
.quiz-top .count {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 500;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--linen);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--clay);
  border-radius: 999px;
  transition: width .35s var(--ease);
}

.q-card {
  margin-top: var(--sp-4);
  background: #fffdf8;
  border: 1px solid var(--linen);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-4);
  box-shadow: var(--shadow);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.q-label {
  font-size: var(--fs-small);
  color: var(--olive-deep);
  text-align: center;
  margin-bottom: var(--sp-3);
}
.q-text {
  font-family: var(--font-serif);
  font-size: var(--fs-statement);
  line-height: 1.7;
  text-align: center;
  outline: none;
}

.options {
  border: 0;
  padding: 0;
  margin: var(--sp-4) 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}

.opt {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 128px;
  padding: 14px 6px;
  border: 1.5px solid #cfc4af;
  border-radius: var(--r-md);
  background: #fffdf8;
  cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), transform .1s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.opt:hover { border-color: var(--olive); }
.opt:active { transform: scale(.99); }
.opt input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  pointer-events: none;
}
.opt .sym {
  font-size: 44px;
  line-height: 1;
  font-weight: 700;
  color: var(--olive-deep);
  text-align: center;
}
.opt .opt-text { font-size: 17px; font-weight: 500; line-height: 1.3; text-align: center; }
.opt:focus-within {
  outline: 3px solid var(--clay);
  outline-offset: 3px;
}
.opt.is-selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  box-shadow: 0 6px 18px -12px rgba(69, 63, 55, .8);
}
.opt.is-selected .sym { color: var(--clay); }
.opt .chk.is-hidden,
.hint.is-hidden { visibility: hidden; }
.opt .chk {
  font-size: 12px;
  padding: 1px 8px;
  margin-top: 2px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
}

.hint {
  margin-top: var(--sp-3);
  text-align: center;
  color: var(--soft);
  font-size: var(--fs-small);
  min-height: 1.75em;
}

.q-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}
.q-nav .btn { flex: 1; max-width: 220px; }

/* ---------- 結果 ---------- */

.result .brand { margin-top: var(--sp-2); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  appearance: none;
  position: relative;
  font: inherit;
  color: var(--ink);
  background: #fffdf8;
  border: 1.5px solid var(--linen);
  border-radius: var(--r-md);
  padding: 14px 8px 12px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  text-align: center;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.stat:hover { border-color: var(--olive); }
.stat-label { font-size: 15px; font-weight: 500; }
.stat-num {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-tag {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  white-space: nowrap;
}
.stat.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.stat.is-active .stat-tag { background: var(--clay); }

.detail {
  margin-top: var(--sp-5);
  background: #fffdf8;
  border: 1px solid var(--linen);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow);
}
.detail h2 { font-size: var(--fs-h2); }
.detail .note {
  font-size: var(--fs-small);
  color: var(--olive-deep);
  margin-top: 4px;
}

.chapter-list {
  list-style: none;
  padding: 0;
  margin: var(--sp-3) 0 0;
}
.chapter-list li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: var(--sp-2);
  align-items: baseline;
  padding: 12px 0;
  border-top: 1px solid var(--linen);
}
.chapter-list li:first-child { border-top: 0; }
.ch-no {
  font-size: 14px;
  color: var(--olive-deep);
  font-weight: 500;
  white-space: nowrap;
}
.ch-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
}

.empty {
  margin-top: var(--sp-3);
  color: var(--soft);
  text-align: center;
  padding: var(--sp-4) 0;
}

.give-back {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--linen);
}
.give-back h2 { font-size: 20px; margin-bottom: 6px; }

.export {
  margin-top: var(--sp-5);
  display: grid;
  gap: var(--sp-2);
  justify-items: center;
}
.export .btn { max-width: 360px; }
.status {
  min-height: 1.75em;
  font-size: var(--fs-small);
  color: var(--olive-deep);
  text-align: center;
  margin-top: 4px;
}

.restart { display: flex; justify-content: center; margin-top: var(--sp-4); }

/* ---------- 對話框 ---------- */

dialog {
  border: 0;
  border-radius: var(--r-lg);
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  width: min(92vw, 420px);
  box-shadow: 0 24px 60px -20px rgba(69, 63, 55, .55);
}
dialog::backdrop { background: rgba(69, 63, 55, .45); }
.dlg-body { padding: var(--sp-5) var(--sp-4) var(--sp-4); }
.dlg-body h2 { font-size: 22px; margin-bottom: var(--sp-3); }
.dlg-body p + p { margin-top: var(--sp-2); }
.dlg-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: var(--sp-5);
}
.preview-img {
  display: block;
  width: 100%;
  height: auto;
  margin: var(--sp-3) 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--linen);
  background: #fff;
}

/* ---------- 動效偏好 ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 小螢幕（360px 起） ---------- */

@media (max-width: 380px) {
  :root { --fs-h1: 27px; --fs-statement: 20px; }
  .opt { min-height: 116px; padding: 12px 4px; }
  .opt .sym { font-size: 38px; }
  .opt .opt-text { font-size: 16px; }
  .q-card { padding: var(--sp-4) var(--sp-3); }
  .chapter-list li { grid-template-columns: 56px 1fr; }
}

/* ---------- 作答紀錄（可收合） ---------- */

.review {
  margin-top: var(--sp-4);
  background: #fffdf8;
  border: 1px solid var(--linen);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.review summary {
  min-height: 52px;
  padding: 14px var(--sp-4);
  cursor: pointer;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 18px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.review summary::-webkit-details-marker { display: none; }
.review summary::after { content: "展開"; font-family: var(--font-sans); font-size: 14px; font-weight: 500; color: var(--olive-deep); }
.review[open] summary::after { content: "收合"; }
.review-list {
  list-style: none;
  margin: 0;
  padding: 0 var(--sp-4) var(--sp-3);
}
.review-list li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: var(--sp-2);
  align-items: start;
  padding: 14px 0;
  border-top: 1px solid var(--linen);
}
.rv-no {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--olive-deep);
  font-variant-numeric: tabular-nums;
}
.rv-ch { font-size: 13px; color: var(--olive-deep); }
.rv-text { font-family: var(--font-serif); font-size: 17px; line-height: 1.6; }
.rv-ans {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}
.rv-ans b { font-size: 26px; line-height: 1.1; }
.rv-ans small { font-size: 12px; color: var(--soft); }

/* ---------- LINE 內開啟的提示 ---------- */

.line-banner {
  background: #fffdf8;
  border: 1.5px solid var(--clay);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: 15px;
  line-height: 1.6;
}
.line-banner p + p { margin-top: 4px; }
.line-banner-close { margin-top: 4px; padding-left: 0; }
