/* 2026 馬祖馬拉松報名核對工具
   配色取自賽事宣傳圖的軍綠與磚紅，中性色走花崗岩與海，提示色用老酒琥珀。
   只有橄欖綠是 accent，琥珀與磚紅是語意色（提示、錯誤），不當裝飾用。 */

:root {
  color-scheme: light dark;

  /* 兩個圓角尺度：卡片大、卡片裡的元件小。規則就這一條，不再有第三種。 */
  --r: 10px;
  --r-card: 18px;

  /* 花崗岩與海的冷中性色，刻意避開暖米色 */
  --bg: #eef1ef;
  --surface: #ffffff;
  --surface-sunk: #f4f6f4;
  --surface-sea: #e5ecea;
  --line: #dde1de;
  --line-strong: #b9c0bc;
  --card-line: #e3e7e4;

  /* 背景色面：海在左上、橄欖在右上 */
  --wash-sea: rgba(47, 107, 107, 0.16);
  --wash-accent: rgba(91, 100, 53, 0.13);

  --text-1: #1b201e;
  --text-2: #4e5754;
  /* 這個值卡在 .locked small 疊在海色底上的 4.5:1 門檻，不要再調淡 */
  --text-3: #616966;

  /* 戰備橄欖綠，取自宣傳圖主色 */
  --accent: #5b6435;
  --accent-hover: #4a5229;
  --accent-on: #fbfcfb;
  --accent-soft: rgba(91, 100, 53, 0.12);

  /* 海，只用在鎖定欄位的表面與頂端色帶，不當第二個 accent */
  --sea: #2f6b6b;

  /* 老酒琥珀，用在說明提示 */
  --amber-line: #b8791f;
  --amber-bg: #fdf1dc;
  --amber-text: #4a3512;

  /* 磚紅，取自宣傳圖「再戰」那個紅，降飽和 */
  --error: #9e3324;
  --error-bg: #fdf2f0;
  --error-soft: rgba(158, 51, 36, 0.16);

  /* 陰影帶背景的色相，不用純黑（Section 4.4） */
  --shadow: 0 1px 2px rgba(30, 44, 40, 0.05), 0 10px 30px rgba(30, 44, 40, 0.09),
    0 30px 60px rgba(30, 44, 40, 0.05);

  font-family: system-ui, -apple-system, "Segoe UI", "PingFang TC",
    "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10120f;
    --surface: #1b201d;
    --surface-sunk: #232926;
    --surface-sea: #1d2725;
    --line: #333a36;
    --line-strong: #4a534f;
    --card-line: #2b322e;

    --wash-sea: rgba(95, 163, 163, 0.13);
    --wash-accent: rgba(159, 174, 99, 0.1);

    --text-1: #e8ecea;
    --text-2: #a8b1ad;
    --text-3: #8b9490;

    /* 深色底上的橄欖綠要提亮，按鈕文字改用深色 */
    --accent: #9fae63;
    --accent-hover: #b0bf72;
    --accent-on: #171a12;
    --accent-soft: rgba(159, 174, 99, 0.16);

    --sea: #5fa3a3;

    --amber-line: #d9a441;
    --amber-bg: rgba(217, 164, 65, 0.14);
    --amber-text: #edd6a5;

    --error: #e79683;
    --error-bg: rgba(231, 150, 131, 0.1);
    --error-soft: rgba(231, 150, 131, 0.2);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.42),
      0 30px 60px rgba(0, 0, 0, 0.3);
  }
}

/* ⚠️ 這一行不能刪。app.js 的 show() 用 section.hidden 切換畫面，
   showError() 也用 el.hidden 藏訊息。任何比 [hidden] 更具體的 display
   規則都會蓋掉它，五個畫面就會同時出現。 */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  padding: 2rem 1rem 3rem;
  color: var(--text-1);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;

  /* 海與島的色面。三層徑向漸層疊在底色上，不用圖片，
     捲動時不重繪（背景固定在 body 不是捲動容器）。 */
  background:
    radial-gradient(
      ellipse 80% 55% at 15% -5%,
      var(--wash-sea) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 70% 50% at 95% 8%,
      var(--wash-accent) 0%,
      transparent 55%
    ),
    var(--bg);
  background-attachment: fixed;
}

main {
  max-width: 32rem;
  margin: 0 auto;
}

/* ── 卡片 ───────────────────────────────────────── */

/* 每個畫面都是一張浮在色面上的卡。
   ⚠️ 不能在這裡設 display：section 的顯示狀態由 app.js 的 hidden 控制。 */
main > section {
  padding: clamp(1.5rem, 1.1rem + 1.8vw, 2.25rem);
  background: var(--surface);
  border: 1px solid var(--card-line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
}

/* ── 標頭 ───────────────────────────────────────── */

.masthead {
  text-align: center;
  margin: 0 0 1.5rem;
  padding: 0 0 0.25rem;
}

.masthead .mark {
  width: 44px;
  height: 44px;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.masthead .team {
  margin: 0 0 0.3rem;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 1.2rem + 1.2vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.masthead .purpose {
  margin: 0.25rem 0 0;
  font-size: 0.925rem;
  color: var(--text-2);
}

h2 {
  margin: 0 0 1.25rem;
  font-size: clamp(1.15rem, 1.05rem + 0.4vw, 1.3rem);
  font-weight: 650;
  letter-spacing: -0.005em;
  text-align: center;
}

/* ── 首頁的兩個入口 ─────────────────────────────── */

/* ⚠️ 說明文字放在按鈕外面，不能塞進按鈕裡。app.js 的導覽監聽器讀的是
   event.target.dataset.goto，按鈕內若有子元素，點到子元素就拿不到 goto。 */
.entries {
  display: grid;
  gap: 1rem;
}

.entry {
  padding: 1.25rem;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r);
  text-align: center;
}

.entry-icon {
  width: 34px;
  height: 34px;
  color: var(--sea);
  margin-bottom: 0.6rem;
}

.entry:last-child .entry-icon {
  color: var(--accent);
}

.entry button {
  width: 100%;
  margin: 0;
}

.entry-note {
  margin: 0.7rem 0 0;
  font-size: 0.875rem;
  color: var(--text-2);
}

/* ── 表單 ───────────────────────────────────────── */

label {
  display: block;
  margin-bottom: 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
}

input,
select {
  display: block;
  width: 100%;
  padding: 0.7rem 0.8rem;
  margin-top: 0.4rem;
  /* 16px 是硬底線。再小 iOS Safari 會在聚焦時自動放大整個頁面。 */
  font-size: 1rem;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.4;
  color: var(--text-1);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  appearance: none;
}

select {
  /* 原生下拉的箭頭被 appearance:none 拿掉了，用背景圖補一個回去 */
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 1.1rem) 55%, calc(100% - 0.75rem) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 送出後沒填或有錯的欄位。由 app.js 的 markInvalid 加上，
   使用者一開始輸入就清掉（不是計時器，改了才代表看到了）。
   顏色和 .error 訊息同一個紅，兩者是同一件事的兩個位置。 */
input.is-invalid,
select.is-invalid {
  border-color: var(--error);
  background: var(--error-bg);
  box-shadow: 0 0 0 3px var(--error-soft);
}

/* 出錯時聚焦仍然用紅色，不要跳回綠色讓人以為已經好了 */
input.is-invalid:focus-visible,
select.is-invalid:focus-visible {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-soft);
}

/* 標紅的那一刻閃一下，讓人知道畫面變了。只做一次，不是無限循環。 */
@media (prefers-reduced-motion: no-preference) {
  input.is-invalid,
  select.is-invalid {
    animation: nudge 0.3s ease;
  }
}

@keyframes nudge {
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

input::placeholder {
  color: var(--text-3);
}

/* ── 按鈕 ───────────────────────────────────────── */

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  /* 高度算進來至少 46px，超過 iOS 建議的 44px 觸控目標 */
  padding: 0.72rem 1.35rem;
  border-radius: var(--r);
  border: 1px solid transparent;
  cursor: pointer;
  /* 沒有左右外距：按鈕才能和上面的輸入框切齊，單顆按鈕的完成頁也才會真的置中。
     並排時的間距交給下面的 button + button。 */
  margin: 0 0 0.5rem;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    transform 0.08s ease;
}

/* 並排時才需要間距。第一顆維持切齊左緣。 */
button + button {
  margin-left: 0.5rem;
}

button.primary {
  background: var(--accent);
  color: var(--accent-on);
}

button.primary:hover {
  background: var(--accent-hover);
}

button.secondary {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

button.secondary:hover {
  background: var(--accent-soft);
}

/* 返回類的按鈕。是按鈕不是超連結，但要比主要動作弱一階，
   所以用中性色的淡框，不搶橄欖綠。 */
button.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text-2);
  font-weight: 500;
}

button.ghost:hover {
  border-color: var(--text-3);
  color: var(--text-1);
  background: var(--surface-sunk);
}

/* 按下去要有實體感 */
button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

/* ── 語意色區塊 ─────────────────────────────────── */

.error {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.925rem;
  color: var(--error);
  background: var(--error-bg);
  border-left: 3px solid var(--error);
  border-radius: 0 var(--r) var(--r) 0;
}

/* 說明用，不是錯誤。用老酒琥珀而不是紅色：要夠顯眼讓人一定會讀到，
   但不能讓使用者以為出了問題。也要和 .locked 的海色底區分開。 */
.banner {
  padding: 0.85rem 1rem;
  margin: 0 0 1.25rem;
  border-radius: 0 var(--r) var(--r) 0;
  border-left: 3px solid var(--amber-line);
  background: var(--amber-bg);
  color: var(--amber-text);
  font-size: 0.95rem;
  font-weight: 500;
}

/* 欄位上方的說明。不是錯誤也不是警告，所以不搶 .error 和 .banner 的顏色，
   只比正文淡一點。 */
.hint {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--text-2);
}

/* 姓名與身分證字號。海色底，讀起來像「已驗證的身分」而不是「壞掉的欄位」 */
.locked {
  padding: 1rem;
  margin: 0 0 1.5rem;
  border-radius: var(--r);
  background: var(--surface-sea);
  border: 1px solid var(--line);
  line-height: 1.8;
  font-size: 0.95rem;
  color: var(--text-2);
}

.locked-mark {
  float: right;
  width: 30px;
  height: 30px;
  color: var(--sea);
  opacity: 0.5;
  margin-left: 0.75rem;
}

.locked strong {
  color: var(--text-1);
  font-weight: 650;
}

.locked small {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.825rem;
  color: var(--text-3);
}

/* ── 完成畫面 ───────────────────────────────────── */

#done {
  text-align: center;
}

/* 乾杯。用老酒琥珀，和提示框同一個色系，是全站唯一用琥珀的圖形。 */
.done-mark {
  width: 56px;
  height: 56px;
  color: var(--amber-line);
  margin-bottom: 0.5rem;
}

#done-message {
  margin: 0 auto 1.75rem;
  max-width: 22rem;
  font-size: 1.05rem;
  color: var(--text-2);
}

/* ── 動態 ───────────────────────────────────────── */

/* 換頁時淡入。刻意做得很輕：琥珀提示就在畫面頂端，動畫太重會讓人錯過它。 */
main > section:not([hidden]) {
  animation: enter 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

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

  button:active:not(:disabled) {
    transform: none;
  }
}
