/* ============================================================
   kaihuo 獨有元件
   tokens.css + app.css + screens.css 是共用的設計系統；
   這裡只放那三個檔沒有、屬於這套系統特有功能的樣式：
   行事曆、任務關卡、照片牆、新手導覽、通關密語、統計磚。

   一律使用 tokens.css 的變數，不要再出現寫死的色碼——
   否則深色模式會漏掉這一塊。
   ============================================================ */

/* ── 統計磚（stats-grid）──────────────────────────────────
   app.css 的 .stat-row 是橫向捲動用的；儀表板要的是會換行的格線。 */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  text-align: center;
  box-shadow: var(--sh-1);
}
.stat-card .stat-num,
.stats-grid .stat-num {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.15;
}
.stat-label {
  font-size: 12px;
  color: var(--ink-light);
  margin-top: var(--sp-1);
}

/* ── 任務關卡 ────────────────────────────────────────────── */

.quest-log { margin: var(--sp-3) 0; }
.quest-steps { margin-top: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-1); }
.quest-step {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: 13px; color: var(--ink-mid);
  transition: background var(--dur-fast) var(--ease);
}
.quest-step.done { color: var(--green); }
.quest-step.done .quest-label { text-decoration: line-through; opacity: .75; }
.quest-step.now {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}
/* 手指要點得到——48px 是行動裝置的最小可點區域 */
.quest-step input[type=checkbox] {
  width: 20px; height: 20px; accent-color: var(--green); cursor: pointer; flex-shrink: 0;
}
.quest-mark { width: 18px; text-align: center; flex-shrink: 0; }
.quest-hint { font-weight: 400; }
.quest-go {
  margin-left: auto; color: var(--accent); font-weight: 700;
  text-decoration: none; white-space: nowrap;
}

/* ── 行事曆 ──────────────────────────────────────────────── */

.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: var(--sp-1); margin-bottom: var(--sp-2);
}
.cal-dow {
  text-align: center; font-size: 11px; color: var(--ink-light);
  font-weight: 700; padding: var(--sp-1) 0;
}
.cal-day {
  min-height: 58px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: var(--sp-1);
  font-size: 11px; cursor: pointer; overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.cal-day:hover { border-color: var(--accent); }
.cal-day:active { transform: scale(.97); }
.cal-day.dim { opacity: .35; background: var(--surface-2); }
.cal-day.today { border: 2px solid var(--accent); }
.cal-num { font-weight: 700; font-size: 12px; margin-bottom: 2px; }
.cal-ev {
  border-radius: var(--r-sm); padding: 1px var(--sp-1); margin-bottom: 2px;
  font-size: 10px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-ev-planning, .cal-ev-shopping, .cal-ev-cooking { background: var(--orange-soft); color: var(--orange); }
.cal-ev-review { background: var(--yellow-soft); color: var(--yellow); }
.cal-ev-done { background: var(--green-soft); color: var(--green); }
.cal-ok { font-size: 10px; color: var(--green); font-weight: 700; }

/* ── 照片 ────────────────────────────────────────────────── */

.photo-grid-wrap { flex-basis: 100%; }
.photo-grid { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); align-items: center; }
.photo-thumb { position: relative; width: 76px; height: 76px; }
.photo-grid-lg .photo-thumb { width: 112px; height: 112px; }
.photo-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--r-md); border: 1px solid var(--border-soft);
  display: block; box-shadow: var(--sh-1);
}
.photo-del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: var(--r-full); border: 1px solid var(--border);
  background: var(--surface); color: var(--red);
  font-size: 11px; cursor: pointer; line-height: 1; padding: 0;
  box-shadow: var(--sh-2);
}
.photo-add {
  width: 76px; height: 76px;
  border: 1.5px dashed var(--border); border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer;
  color: var(--ink-light); background: var(--surface-2);
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.photo-add:hover { border-color: var(--accent); color: var(--accent); }
.photo-add.htmx-request { opacity: .4; }

/* ── 新手導覽 ────────────────────────────────────────────── */

.tour-highlight {
  position: relative;
  z-index: 1001 !important;
  box-shadow: 0 0 0 4px var(--accent), 0 0 0 9999px rgba(20, 12, 4, .6) !important;
  border-radius: var(--r-md);
}
.tour-dialog {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--sp-3) + env(safe-area-inset-bottom));
  z-index: 1002;
  width: min(440px, calc(100vw - 24px));
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--sh-4);
  font-size: 14px;
}
.tour-dialog p { margin: var(--sp-2) 0 var(--sp-3); font-size: 13px; line-height: 1.7; color: var(--ink-mid); }
.tour-progress { font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: .08em; margin-bottom: 2px; }
.tour-btns { display: flex; gap: var(--sp-2); }
.tour-btns .btn-ghost { margin-left: auto; }
.tour-resume {
  position: fixed; left: var(--sp-3);
  bottom: calc(var(--tabbar-h) + var(--sp-3) + env(safe-area-inset-bottom));
  z-index: 199;
}
.tour-welcome {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 12, 4, .6);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-4);
}
.tour-welcome-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  padding: var(--sp-6) var(--sp-5);
  max-width: 380px; width: 100%;
  box-shadow: var(--sh-4);
  text-align: center;
}
.tour-welcome-card h2 { font-family: var(--font-serif); font-size: 1.2rem; margin-bottom: var(--sp-2); }
.tour-welcome-card p { font-size: 13px; color: var(--ink-mid); line-height: 1.7; margin-bottom: var(--sp-4); }
.tour-welcome-card .btn { display: block; width: 100%; margin-bottom: var(--sp-2); }

/* ── 登入頁的通關密語 ────────────────────────────────────── */

.gate-field { margin-bottom: var(--sp-3); }

/* ── 統計圖表（傳承儀表板）──────────────────────────────── */

.chart { width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--accent); transition: fill var(--dur-fast) var(--ease); }
.chart .bar:hover { fill: var(--green); }
.chart .bar-empty { fill: var(--surface-3); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .lbl { fill: var(--ink-light); font-size: 10px; font-family: var(--font-sans); }
.chart .val { fill: var(--ink-mid); font-size: 10px; font-weight: 700; font-family: var(--font-serif); }

/* ── QR code 一定要白底才掃得到，不跟著深色走 ───────────── */

.qr-box {
  background: #fff !important;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: inline-block;
}
