/* 配色、字體與 Nidome 本體（exam-tracker 的 frontend/src/styles.css）一致，改本體配色時這裡要跟著改 */
:root {
  color-scheme: light;
  --bg: #FFF8F1;
  --surface: #FFFFFF;
  --surface-2: #FFF1EE;
  --ink: #4A3B57;
  --muted: #75677F;
  --line: #F3E0DC;
  --half: #C4ECE5;
  --half-ink: #1B5F58;
  --done: #17796E;
  --on-done: #FFFFFF;
  --urgent: #BB2C55;
  --accent: #FFB6CB;
  --on-accent: #4A3B57;
  --shadow: 0 2px 4px rgba(190, 130, 150, .10), 0 8px 24px rgba(190, 130, 150, .12);
  --shadow-lg: 0 4px 8px rgba(190, 130, 150, .10), 0 24px 60px rgba(190, 130, 150, .22);
  --f-body: "Huninn", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --f-mono: "DM Mono", "Huninn", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #231E2E; --surface: #2E2740; --surface-2: #393050; --ink: #F6EFF8; --muted: #BEB1CB; --line: #4A4060;
    --half: #2B6A63; --half-ink: #D3F6F0; --done: #72DCCB; --on-done: #1E1A28;
    --urgent: #FF8FAB;
    --accent: #FF9FBC; --on-accent: #231E2E;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 60px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.7;
  font-synthesis-weight: none; /* 粉圓只有一種字重，不讓瀏覽器模擬粗體 */
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; font-weight: 400; line-height: 1.25; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.label { font-size: 13px; letter-spacing: .12em; color: var(--muted); }

.wrap {
  max-width: 1120px; margin-inline: auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 8px 18px; min-height: 40px; font-size: 15px; text-decoration: none;
  transition: transform .12s ease, border-color .12s ease;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.96); }
.btn.primary {
  background: var(--accent); color: var(--on-accent); border-color: transparent;
  padding: 14px 34px; font-size: 18px; min-height: 54px;
  box-shadow: var(--shadow);
}
.btn.primary:hover { transform: translateY(-2px); }
.btn.primary:active { transform: scale(.97); }
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.note { font-size: 14px; color: var(--muted); }

/* ---------- 頁首 ---------- */
.site-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 20px; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand-mark { display: inline-flex; gap: 3px; align-self: center; }
.brand-mark i { width: 12px; height: 22px; border-radius: 6px; background: var(--half); }
.brand-mark i + i { background: var(--done); }
.brand-name { font-size: 22px; letter-spacing: .04em; }
.brand-sub { font-size: 14px; color: var(--muted); }

/* ---------- 主視覺 ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  align-items: center; gap: 56px;
  padding-block: clamp(32px, 7vw, 88px) clamp(56px, 9vw, 112px);
}
.hero-copy { display: flex; flex-direction: column; gap: 22px; }
.hero h1 { font-size: clamp(44px, 8.4vw, 88px); letter-spacing: .02em; line-height: 1.15; }
/* 「兩輪」底下兩道筆畫：淺的是第一輪，深的是第二輪 */
.twice {
  background:
    linear-gradient(var(--done), var(--done)) left 100% / 100% .09em no-repeat,
    linear-gradient(var(--half), var(--half)) left calc(100% - .16em) / 100% .09em no-repeat;
  padding-bottom: .12em;
}
.lead { font-size: clamp(17px, 2vw, 20px); color: var(--muted); max-width: 30em; }
.hero .cta { margin-top: 10px; }

/* ---------- 示意票卡 ---------- */
.demo { position: relative; }
/* 票卡後面的粉色光暈 */
.demo::before {
  content: ""; position: absolute; inset: -12% -10% -4%; z-index: -1;
  background: radial-gradient(closest-side, var(--accent), transparent);
  opacity: .45; filter: blur(24px);
}
.ticket {
  display: grid; grid-template-columns: 92px minmax(0, 1fr);
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-lg);
  transform: rotate(1.5deg);
}
.stub {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--surface-2); border-radius: var(--r) 0 0 var(--r);
  border-right: 2px dashed var(--line);
}
/* 票根的上下缺口 */
.stub::before, .stub::after {
  content: ""; position: absolute; right: -10px; width: 18px; height: 18px; border-radius: 50%; background: var(--bg);
}
.stub::before { top: -9px; }
.stub::after { bottom: -9px; }
.stub-n { font-size: 30px; line-height: 1.1; color: var(--urgent); }
.stub-l { font-size: 13px; color: var(--urgent); letter-spacing: .1em; }
.ticket-body { padding: 22px 20px 14px 24px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ticket-body h2 { font-size: 28px; }
.prog-text { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--muted); margin-top: 6px; }
.prog-text b { font-weight: 500; color: var(--ink); }
.prog-text > b { font-size: 18px; }
.bar { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; transition: width .35s cubic-bezier(.3, 1.3, .5, 1); }
.bar-half { background: var(--half); }
.bar-done { background: var(--done); }

.topics { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; }
.topic { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; border-top: 1px solid var(--line); }
.topic .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .2s; }
.topic.full .t { color: var(--muted); }
/* 「初｜再」連在一起的膠囊按鈕，樣子與本體相同 */
.seg { display: flex; flex: none; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg:hover { border-color: var(--muted); }
.seg button {
  width: 40px; height: 34px; font-size: 14px; padding: 0;
  border: 0; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button:active { background: var(--surface-2); }
.seg button[data-act="r1"][aria-pressed="true"] { background: var(--half); color: var(--half-ink); }
.seg button[data-act="r2"][aria-pressed="true"] { background: var(--done); color: var(--on-done); border-left-color: transparent; }
.demo-hint { margin-top: 18px; text-align: center; font-size: 14px; color: var(--muted); }

/* ---------- 實際畫面 ---------- */
.shot { padding-block: clamp(40px, 7vw, 80px); text-align: center; }
.shot h2, .closing h2 { font-size: clamp(30px, 5vw, 48px); }
.section-lead { color: var(--muted); max-width: 32em; margin: 14px auto 0; }
.frame {
  margin: clamp(28px, 5vw, 48px) 0 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); overflow: hidden;
}
.frame-bar { display: flex; gap: 7px; padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.frame-bar i { width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.frame-bar i:first-child { background: var(--accent); }
.frame-bar i:last-child { background: var(--half); }
.frame img { display: block; width: 100%; height: auto; }
/* 截圖底部剛好切在清單中間，用漸層淡出收尾；截圖的底色與本站 --bg 相同 */
.frame picture { display: block; position: relative; }
.frame picture::after {
  content: ""; position: absolute; inset: auto 0 0; height: 12%;
  background: linear-gradient(transparent, var(--bg));
}

/* ---------- 功能 ---------- */
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding-block: clamp(40px, 7vw, 80px); }
.feature { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 26px 24px 28px; }
.feature h3 { font-size: 22px; margin: 20px 0 8px; }
.feature p { color: var(--muted); font-size: 15.5px; }
.feature-art { height: 76px; border-radius: 14px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; gap: 8px; }
.chip { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; }
.chip.half { background: var(--half); color: var(--half-ink); }
.chip.done { background: var(--done); color: var(--on-done); }
.count { font-size: 22px; color: var(--urgent); }
/* 同步示意，6 秒一輪：電腦勾初複習 → 訊號傳到手機 → 手機勾再複習 → 訊號傳回電腦。
   三段動畫共用同一個時間軸，改時間點時要一起對 */
.device { width: 54px; height: 38px; border-radius: 7px; border: 2px solid var(--muted); display: grid; place-items: center; }
.device.small { width: 24px; height: 38px; }
.device i { width: 62%; height: 8px; border-radius: 4px; background: var(--line); animation: sync-pc 6s linear infinite; }
.device.small i { animation-name: sync-phone; }
.sync { position: relative; width: 56px; border-top: 2px dashed var(--line); }
.sync::after {
  content: ""; position: absolute; top: -3px; left: 0;
  width: 14px; height: 4px; border-radius: 2px; background: var(--done); opacity: 0;
  animation: sync-signal 6s ease-in-out infinite;
}
@keyframes sync-pc {
  0%, 6% { background: var(--line); }
  10%, 82% { background: var(--half); }
  86%, 96% { background: var(--done); }
  100% { background: var(--line); }
}
@keyframes sync-phone {
  0%, 34% { background: var(--line); }
  38%, 54% { background: var(--half); }
  58%, 96% { background: var(--done); }
  100% { background: var(--line); }
}
@keyframes sync-signal {
  0%, 12% { transform: translateX(0); opacity: 0; }
  15% { transform: translateX(0); opacity: 1; }
  33% { transform: translateX(42px); opacity: 1; } /* 線寬 56px 減掉訊號 14px */
  36%, 60% { transform: translateX(42px); opacity: 0; }
  63% { transform: translateX(42px); opacity: 1; }
  81% { transform: translateX(0); opacity: 1; }
  84%, 100% { transform: translateX(0); opacity: 0; }
}

/* ---------- 名稱由來 ---------- */
.origin { padding-block: clamp(40px, 7vw, 80px); text-align: center; color: var(--muted); }
.origin-word { font-size: clamp(48px, 10vw, 96px); color: var(--ink); line-height: 1.2; letter-spacing: .06em; }
.origin-word span { display: block; font-size: 16px; letter-spacing: .5em; color: var(--muted); margin: 6px 0 18px; padding-left: .5em; }

/* ---------- 結尾 ---------- */
.closing { padding-block: clamp(48px, 8vw, 96px) clamp(64px, 10vw, 120px); text-align: center; }
.closing .cta { flex-direction: column; margin-top: 30px; }
.site-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px;
  padding-block: 22px 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px;
}

/* ---------- 窄螢幕 ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 48px; }
  .demo { max-width: 460px; width: 100%; margin-inline: auto; }
  .features { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .brand-sub { display: none; }
  .ticket { grid-template-columns: 70px minmax(0, 1fr); transform: rotate(1deg); }
  .stub-n { font-size: 24px; }
  .ticket-body { padding: 18px 14px 10px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
