/* 候補頁：方向 A 暖手帳（數值與 src/ui/colors.ts、tokens.ts 一致）。內文系統字；芫荽只給主標；數字 Nunito。 */
:root {
  --bg: #fbf7f2;
  --surface: #fffdf9;
  --surface-pressed: #f3ebe1;
  --ink: #2e2622;
  --muted: #6b5d54;
  --line: #e2d5c5;
  --line-strong: #cdbca9;
  --accent: #b4534a;
  --accent-pressed: #9a443c;
  --on-accent: #ffffff;
  --accent-tint: #f6e8e3;

  --font-body: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --font-title: 'Iansui', var(--font-body);
  --font-num: 'Nunito', var(--font-body);

  /* 字級最多 5 種、字重 2 種 */
  --fs-1: 32px;
  --fs-2: 20px;
  --fs-3: 17px;
  --fs-4: 15px;
  --fs-5: 12px;
  /* 邀請碼大字（只用在邀請頁） */
  --fs-code: 48px;
  --fw-regular: 400;
  --fw-bold: 700;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-12: 48px;
  --gutter: 24px;

  --r-card: 20px;
  --r-btn: 16px;
  --r-pill: 999px;
}

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

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

/* 元件的 display 規則不能蓋過 hidden 屬性 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-3);
  font-weight: var(--fw-regular);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul,
dl,
fieldset,
legend {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.num {
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
}

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

.skip {
  position: absolute;
  left: var(--s-4);
  top: -64px;
  padding: var(--s-3) var(--s-4);
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-btn);
  z-index: 10;
}
.skip:focus {
  top: var(--s-4);
}

.icon {
  width: 24px;
  height: 24px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 版面 ---------- */
.site-header,
main,
.site-footer {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.site-header {
  display: flex;
  align-items: center;
  min-height: 56px;
}

/* 頁首字標（定稿 logo，高 28px；最小 24px，見 assets/design/logo/final/README.md） */
.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  white-space: nowrap;
}
.brand img {
  display: block;
  height: 28px;
  width: auto;
}

/* 頁尾的字標＋「開發團隊」 */
.footer-brand img {
  height: 24px;
  width: auto;
  vertical-align: middle;
}

/* 品牌名稱與「開發團隊」不拆行 */
.nowrap {
  white-space: nowrap;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding-bottom: var(--s-12);
}

.hero-art {
  display: flex;
  justify-content: center;
}

.hero-art img {
  width: 200px;
  height: 200px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}

h1 {
  font-family: var(--font-title);
  font-weight: var(--fw-regular);
  font-size: var(--fs-1);
  line-height: 1.4;
  letter-spacing: 0.02em;
}

/* 手寫底線：整頁只有這一處 */
.mark {
  position: relative;
  display: inline-block;
}
.scribble {
  position: absolute;
  left: -4%;
  bottom: -8px;
  width: 108%;
  height: 14px;
  overflow: visible;
  fill: none;
  stroke: var(--accent);
  stroke-width: 3px;
  stroke-linecap: round;
}
.scribble path {
  vector-effect: non-scaling-stroke;
}

.lead {
  color: var(--muted);
  font-size: var(--fs-3);
}
.br-wide {
  display: none;
}

/* ---------- 卡片、按鈕、欄位 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--s-6);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 52px;
  padding: 0 var(--s-6);
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  font: inherit;
  font-weight: var(--fw-bold);
  text-decoration: none;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
/* 連結做成的按鈕（邀請頁的「先加入候補」）：滑過時字不要變成強調色 */
.btn-primary:hover {
  background: var(--accent-pressed);
  color: var(--on-accent);
}
.btn-primary:active {
  background: var(--accent-pressed);
}
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover,
.btn-secondary:active {
  background: var(--surface-pressed);
}
.btn[disabled] {
  cursor: default;
}
.btn .icon {
  width: 20px;
  height: 20px;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}
[data-state='submitting'] .spinner {
  display: inline-block;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.field label {
  font-size: var(--fs-4);
  font-weight: var(--fw-bold);
}
input[type='email'],
input[type='text'] {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input[type='email']:focus-visible,
input[type='text']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
input[aria-invalid='true'] {
  border-color: var(--accent);
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  min-height: 44px;
  font-size: var(--fs-4);
}
.consent input,
.opt input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}
.consent input {
  margin-top: var(--s-1);
}
.consent label {
  padding-top: 0;
}
.consent a {
  font-weight: var(--fw-bold);
}

/* 驗證框平常不顯示（interaction-only）；沒出現時把它上方的間距收掉，出現時正常排版 */
.turnstile-slot[data-visible='false'] {
  margin-top: calc(-1 * var(--s-4));
}
.survey-form .turnstile-slot[data-visible='false'] {
  margin-top: calc(-1 * var(--s-6));
}

.status {
  font-size: var(--fs-4);
}
.status:empty {
  display: none;
}
.status.is-error {
  color: var(--accent);
  font-weight: var(--fw-bold);
}

/* ---------- 候補表單 ---------- */
/* 驗證框固定 300px 寬，卡片左右內距用 20 才放得下（393 寬手機：345 − 40 = 305） */
.waitlist {
  padding: var(--s-6) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.waitlist-fields {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.waitlist .btn {
  width: 100%;
}
.waitlist[data-state='success'] .waitlist-fields,
.waitlist[data-state='success'] .status {
  display: none;
}
.success {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  font-size: var(--fs-2);
  font-weight: var(--fw-bold);
  line-height: 1.5;
}
.success .icon {
  margin-top: var(--s-1);
  color: var(--accent);
}

/* ---------- 問卷 ---------- */
.survey {
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}
.survey-title {
  font-size: var(--fs-2);
  font-weight: var(--fw-bold);
  line-height: 1.5;
}
.survey[data-from='waitlist'] .survey-title {
  display: none;
}
.survey-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}
.q {
  border: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.q legend {
  display: flex;
  gap: var(--s-2);
  font-weight: var(--fw-bold);
  line-height: 1.5;
  margin-bottom: var(--s-3);
}
.q-no {
  flex: none;
  min-width: 24px;
  color: var(--accent);
}
.hint {
  font-weight: var(--fw-regular);
  color: var(--muted);
}
.options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.opt {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: var(--fs-4);
  cursor: pointer;
}
.opt:hover {
  background: var(--surface-pressed);
}
.opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.opt:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.opt input:focus-visible {
  outline: none;
}
.q-error {
  color: var(--accent);
  font-size: var(--fs-4);
  font-weight: var(--fw-bold);
}
.q.is-missing .options {
  padding-left: var(--s-3);
  border-left: 2px solid var(--accent);
}
.survey-form > .btn {
  width: 100%;
}

.done {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.done-title {
  font-size: var(--fs-2);
  font-weight: var(--fw-bold);
}
.share {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.share input {
  font-size: var(--fs-4);
  color: var(--muted);
}

/* ---------- 長這樣 ---------- */
.preview {
  border-top: 1px solid var(--line-strong);
  padding: var(--s-8) 0 var(--s-12);
}
.preview h2 {
  font-family: var(--font-title);
  font-weight: var(--fw-regular);
  font-size: var(--fs-1);
  line-height: 1.4;
  margin-bottom: var(--s-6);
}
.preview-scroll {
  overflow-x: auto;
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 var(--gutter);
  overscroll-behavior-x: contain;
}
.preview img {
  display: block;
  width: 680px;
  max-width: none;
  height: auto;
}

/* ---------- 功能 ---------- */
.features {
  border-top: 1px solid var(--line-strong);
  padding: var(--s-8) 0 var(--s-12);
}
.feature-list {
  display: grid;
  gap: var(--s-6);
}
.feature {
  display: flex;
  gap: var(--s-4);
}
.feature-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}
.feature h3 {
  font-size: var(--fs-2);
  font-weight: var(--fw-bold);
  line-height: 1.4;
  margin-bottom: var(--s-1);
}
.feature p {
  color: var(--muted);
}
.tag {
  display: block;
  font-size: var(--fs-4);
  font-weight: var(--fw-regular);
  color: var(--muted);
}

/* ---------- 只填問卷入口、頁尾 ---------- */
.survey-only {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-6);
  margin-bottom: var(--s-12);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-card);
}
.survey-only p {
  color: var(--muted);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-6);
  padding-top: var(--s-6);
  padding-bottom: var(--s-8);
  border-top: 1px solid var(--line);
  font-size: var(--fs-4);
  color: var(--muted);
}
.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* ---------- 隱私說明 ---------- */
.doc {
  padding-bottom: var(--s-12);
}
.doc h1 {
  margin: var(--s-4) 0 var(--s-6);
}
.doc-list {
  display: grid;
  gap: var(--s-4);
}
.doc-item {
  padding: var(--s-4) 0;
  border-top: 1px solid var(--line);
}
.doc-item dt {
  font-weight: var(--fw-bold);
  margin-bottom: var(--s-1);
}
.doc-item dd {
  margin: 0;
  color: var(--ink);
}
.back {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  font-size: var(--fs-4);
  text-decoration: none;
}

/* ---------- 邀請頁（D-054） ---------- */
main.invite {
  max-width: 528px;
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  padding-bottom: var(--s-12);
}
.invite-art {
  display: flex;
  justify-content: center;
}
.invite-art img {
  width: 160px;
  height: 160px;
}
.invite h1 {
  text-align: center;
}
.invite-code {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  text-align: center;
}
.invite-label {
  font-size: var(--fs-4);
  color: var(--muted);
}
/* 邀請碼：6 位數字（D-057），顯示成「123 456」；等寬數字、大字。萬一放不下才在字元之間換行 */
.code {
  max-width: 100%;
  font-family: var(--font-num);
  font-weight: var(--fw-bold);
  font-size: var(--fs-code);
  line-height: 1.2;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  user-select: all;
}
.invite-code .btn {
  width: 100%;
}
.invite-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.invite-steps li {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
}
.step-no {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-4);
}
.step-title {
  font-weight: var(--fw-bold);
}
.step-note {
  font-size: var(--fs-4);
  color: var(--muted);
}
.invite-store {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
/* 商店按鈕的位置：還沒上架，用虛線框寫「App 即將開放」，不能點 */
.store-soon {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-btn);
  color: var(--muted);
  font-weight: var(--fw-bold);
}
.invite-note {
  font-size: var(--fs-4);
  color: var(--muted);
  text-align: center;
}

/* ---------- 桌機 ---------- */
@media (min-width: 768px) {
  :root {
    --fs-1: 44px;
    --fs-code: 56px;
    --gutter: 40px;
  }
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
    column-gap: var(--s-12);
    padding-top: var(--s-6);
  }
  .hero-art {
    order: 2;
    position: sticky;
    top: var(--s-8);
  }
  .hero-art img {
    width: 360px;
    height: 360px;
  }
  .hero-copy {
    order: 1;
  }
  .br-wide {
    display: inline;
  }
  .waitlist {
    max-width: 480px;
  }
  .feature-list {
    grid-template-columns: 1fr 1fr;
    column-gap: var(--s-12);
    row-gap: var(--s-8);
  }
  .share {
    flex-direction: row;
  }
  .doc {
    max-width: 720px;
  }
  .preview-scroll {
    overflow: visible;
    margin: 0;
    padding: 0;
  }
  .preview img {
    width: 100%;
    max-width: 100%;
  }
}
