/* ═══════════════════════════════════════
   錢會自己長大嗎？— 給小朋友的投資入門
   字級與行距刻意放大，給國小中低年級閱讀
   ═══════════════════════════════════════ */

:root {
  --bg:      #fdfcf8;
  --surface: #ffffff;
  --text:    #26302a;
  --muted:   #6b7770;
  --line:    #e2e8e2;
  --green:   #2f7d52;
  --green-lt:#4a9d6e;
  --gold:    #c9852c;
  --sky:     #3d7ea6;
  --danger:  #c4523d;
  --radius: 14px;
  --wrap: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #141815;
    --surface: #1d2320;
    --text:    #e7ece8;
    --muted:   #9aa6a0;
    --line:    #2f3833;
    --green:   #6fc294;
    --green-lt:#8ad3aa;
    --gold:    #e0ab5c;
    --sky:     #7fb6d6;
    --danger:  #e08a74;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC",
               -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 19px;
  line-height: 2;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  width: 1.9rem; height: 1.9rem;
  vertical-align: -.45rem;
  margin-right: .4rem;
  image-rendering: pixelated;
}

/* ── Hero ─────────────────────────────── */

.hero {
  background: linear-gradient(165deg, #2f7d52, #4a9d6e 55%, #7cb46b);
  color: #fff;
  padding: 4.5rem 0 4rem;
  text-align: center;
}

.hero .kicker {
  margin: 0 0 .8rem;
  font-size: .8rem;
  letter-spacing: .3em;
  text-indent: .3em;
  opacity: .8;
}

.hero h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2.1rem, 7vw, 3.2rem);
  line-height: 1.3;
  letter-spacing: .03em;
}

.hero .lede { margin: 0; font-size: 1.1rem; line-height: 1.9; opacity: .95; }

/* ── 目錄 ─────────────────────────────── */

.toc {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.toc .wrap {
  display: flex; gap: .3rem;
  overflow-x: auto; scrollbar-width: none;
  padding-top: .5rem; padding-bottom: .5rem;
}
.toc .wrap::-webkit-scrollbar { display: none; }

.toc a {
  flex: none; padding: .3rem .8rem; border-radius: 99px;
  color: var(--muted); font-size: .85rem; text-decoration: none; white-space: nowrap;
}
.toc a:hover { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }

/* ── 區塊 ─────────────────────────────── */

main { padding-bottom: 2rem; }

section { padding: 3.5rem 0 1.5rem; border-bottom: 2px dashed var(--line); }
section:last-child { border-bottom: 0; }

.num {
  margin: 0 0 .3rem;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: color-mix(in srgb, var(--green) 35%, transparent);
}

h2 {
  margin: 0 0 1.5rem;
  font-size: 1.75rem;
  line-height: 1.5;
  letter-spacing: .02em;
  color: var(--green);
}

h3 { font-size: 1.15rem; margin: 0 0 .5rem; line-height: 1.6; }

h3.sub {
  margin: 2.5rem 0 1rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid color-mix(in srgb, var(--green) 25%, transparent);
  color: var(--green);
}

p { margin: 0 0 1.2rem; }

.big {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.85;
}

.lead-out {
  border-left: 4px solid var(--gold);
  padding-left: 1rem;
  font-size: 1.05rem;
}

.note { color: var(--muted); font-size: .92rem; line-height: 1.85; }

/* ── 比喻框 ───────────────────────────── */

.box {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem .5rem;
  margin: 1.75rem 0;
}

.box p:first-child strong { color: var(--green); font-size: 1.05rem; }

.box.danger { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.box.danger p:first-child strong { color: var(--danger); }

.box.grow { border-color: color-mix(in srgb, var(--gold) 50%, transparent); background: color-mix(in srgb, var(--gold) 7%, var(--surface)); }
.box.grow p:first-child strong { color: var(--gold); }

/* ── 兩欄對照 ─────────────────────────── */

.versus {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.75rem 0;
}

.side {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.35rem .8rem;
}

.side.a { border-top: 6px solid var(--gold); }
.side.b { border-top: 6px solid var(--green-lt); }

.side .tag {
  margin: 0 0 .4rem;
  font-size: .78rem;
  letter-spacing: .18em;
  color: var(--muted);
}

.side h3 { color: var(--text); }
.side p { font-size: .98rem; line-height: 1.85; }
.side .name { color: var(--muted); font-size: .92rem; margin-bottom: .4rem; }

/* ── 互動模擬 ─────────────────────────── */

.sim {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.2rem;
  margin: 1.5rem 0;
}

.controls { display: grid; gap: 1.5rem; margin-bottom: 1.75rem; }

.ctrl label {
  display: block;
  margin-bottom: .6rem;
  font-weight: 700;
  font-size: 1.02rem;
  cursor: pointer;
}

.controls output { color: var(--green); font-variant-numeric: tabular-nums; }

.controls input[type=range] {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 2rem;
  margin: 0;
  accent-color: var(--green);
  cursor: pointer;
  touch-action: pan-y;
}

.result {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .7rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .8rem .9rem;
  text-align: center;
}

.stat .label { margin: 0 0 .2rem; font-size: .84rem; color: var(--muted); line-height: 1.6; }
.stat .val { margin: 0; font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.4; }

.stat.hl { background: color-mix(in srgb, var(--green) 12%, transparent); border-color: var(--green); }
.stat.hl .val { color: var(--green); font-size: 1.3rem; }
.stat.warn .val { color: var(--danger); }

.bars { display: grid; gap: .5rem; margin-bottom: 1rem; }

.bar-row { display: flex; align-items: center; gap: .6rem; font-size: .84rem; }
.bar-row .k { flex: none; width: 5.5rem; color: var(--muted); text-align: right; }
.bar-row .t { flex: 1; height: 1.4rem; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-row .f { height: 100%; border-radius: 4px; transition: width .25s ease; }

/* ── 總結 ─────────────────────────────── */

.takeaway { counter-reset: t; list-style: none; padding: 0; margin: 0 0 2rem; }

.takeaway li {
  counter-increment: t;
  position: relative;
  padding: .9rem 1rem .9rem 3.6rem;
  margin-bottom: .7rem;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-size: 1.05rem;
  line-height: 1.8;
}

.takeaway li::before {
  content: counter(t);
  position: absolute; left: 1rem; top: .95rem;
  width: 1.9rem; height: 1.9rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: .95rem;
  font-weight: 800;
}

.final {
  background: color-mix(in srgb, var(--green) 9%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--green) 30%, transparent);
  border-radius: var(--radius);
  padding: 1.6rem 1.5rem .8rem;
  text-align: center;
}

.final .big { color: var(--green); }

/* ── 給爸媽 ───────────────────────────── */

#parents { font-size: .97rem; line-height: 1.9; }
#parents h2 { font-size: 1.4rem; }

/* ── 頁尾 ─────────────────────────────── */

footer {
  border-top: 2px solid var(--line);
  padding: 2.25rem 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.85;
  text-align: center;
}
footer p { margin: 0 0 .5rem; }
footer a { color: var(--green); }
footer .small { font-size: .82rem; opacity: .8; }

a { color: var(--green); }

/* ── 注音 ─────────────────────────────── */

/* 傳統直式注音：符號排在字的右側，聲調再靠右（輕聲置頂） */

ruby {
  display: inline-flex;
  align-items: center;
  vertical-align: baseline;
  line-height: 1;
  ruby-position: inter-character;
}

rt {
  position: relative;
  display: block;
  margin-left: .1em;
  padding-right: .6em;
  font-size: .34em;
  font-weight: 400;
  line-height: 1.06;
  color: var(--muted);
  text-align: left;
  user-select: none;
}

.zy-s {
  display: block;
  writing-mode: vertical-lr;
  text-orientation: upright;
  letter-spacing: -.04em;
}

.zy-t {
  position: absolute;
  right: .02em;
  top: 50%;
  transform: translateY(-45%);
}

/* 輕聲的點放在正上方 */
.zy-t-light {
  right: auto;
  left: 50%;
  top: -.9em;
  transform: translateX(-90%);
}

body.zhuyin-off ruby { display: inline; }
body.zhuyin-off rt { display: none; }

/* ── 注音開關按鈕 ─────────────────────── */

.zy-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  padding: .6rem 1.1rem;
  border: 2px solid var(--green);
  border-radius: 99px;
  background: var(--surface);
  color: var(--green);
  font-family: inherit;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,.16);
  transition: background .15s, color .15s;
}

.zy-toggle:hover { background: var(--green); color: #fff; }

@media (max-width: 34rem) {
  .zy-toggle { right: .7rem; bottom: .7rem; padding: .5rem .9rem; font-size: .86rem; }
}

/* ── 手機 ─────────────────────────────── */

@media (max-width: 34rem) {
  body { font-size: 18px; }
  .hero { padding: 3.25rem 0 2.75rem; }
  section { padding-top: 2.75rem; }
  .versus { grid-template-columns: 1fr; }
  .sim { padding: 1.15rem 1.15rem 1rem; }
  .bar-row .k { width: 4.5rem; font-size: .78rem; }
}
