/* ==========================================================
   霧台市集管理系統 · Design System v2
   設計原則：層次、留白、語意色、細節、克制動態
   ========================================================== */

:root {
  /* Brand · 魯凱 × 山林 */
  --c-red-50:  #FDF4F3;
  --c-red-100: #FAE6E3;
  --c-red-200: #F4CDC7;
  --c-red-500: #B74B3D;
  --c-red-600: #8B2A1F;   /* 主色 · 魯凱深紅 */
  --c-red-700: #6D1F18;

  --c-green-50:  #F0F4F1;
  --c-green-100: #DCF4E3;
  --c-green-500: #5A7D5A;
  --c-green-600: #3E5641;  /* 次色 · 森林綠 */
  --c-green-700: #2A3D2C;

  --c-ochre-50:  #FDF9F0;
  --c-ochre-100: #FAF1DC;
  --c-ochre-300: #E8C78E;
  --c-ochre-500: #D4A574;  /* 強調 · 土黃 */
  --c-ochre-700: #A87D4E;

  --c-cream:   #F5EFE3;
  --c-bg:      #FAFAF7;
  --c-surface: #FFFFFF;

  /* Neutral */
  --c-900: #111111;
  --c-800: #1F1F1F;
  --c-700: #374151;
  --c-600: #4B5563;
  --c-500: #6B7280;
  --c-400: #9CA3AF;
  --c-300: #D1D5DB;
  --c-200: #E5E7EB;
  --c-100: #F3F4F6;
  --c-50:  #F9FAFB;

  /* Semantic */
  --c-info:    #0EA5E9;
  --c-warn:    #F59E0B;
  --c-danger:  #EF4444;
  --c-success: #10B981;
  --c-purple:  #8B5CF6;

  /* Shadow system */
  --sh-xs: 0 1px 2px rgba(17,17,17,0.04);
  --sh-sm: 0 1px 3px rgba(17,17,17,0.06), 0 1px 2px rgba(17,17,17,0.04);
  --sh-md: 0 4px 12px rgba(17,17,17,0.06), 0 2px 4px rgba(17,17,17,0.04);
  --sh-lg: 0 10px 30px rgba(17,17,17,0.08), 0 4px 8px rgba(17,17,17,0.04);
  --sh-red: 0 8px 24px rgba(139,42,31,0.20);
  --sh-green: 0 8px 24px rgba(62,86,65,0.20);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography scale */
  --f-display: 36px;
  --f-h1: 26px;
  --f-h2: 19px;
  --f-h3: 15px;
  --f-body: 14px;
  --f-sm: 13px;
  --f-xs: 12px;
  --f-micro: 11px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC",
               "Helvetica Neue", Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-800);
  font-size: var(--f-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.01em;
}

/* Numbers should use tabular figures where relevant */
.mono, .num, .v.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* Typography */
h1 { font-size: var(--f-h1); font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; }
h2 { font-size: var(--f-h2); font-weight: 700; letter-spacing: -0.01em; line-height: 1.4; }
h3 { font-size: var(--f-h3); font-weight: 600; color: var(--c-600); letter-spacing: 0.02em; text-transform: uppercase; }

p { color: var(--c-600); }

a { color: var(--c-red-600); text-decoration: none; transition: color .15s var(--ease-out); }
a:hover { color: var(--c-red-500); }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: var(--s-8) var(--s-6); }
.container-sm { max-width: 620px; margin: 0 auto; padding: var(--s-6) var(--s-5); }

/* Header（工具型頁面用） */
.header {
  background: linear-gradient(135deg, var(--c-red-600) 0%, var(--c-red-500) 100%);
  color: #fff;
  padding: var(--s-6) var(--s-6);
  box-shadow: var(--sh-sm);
  position: relative;
  overflow: hidden;
}
.header::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 95% -10%, rgba(255,255,255,0.12), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(0,0,0,0.15), transparent 40%);
  pointer-events: none;
}
.header > * { position: relative; }
.header h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.header .sub {
  font-size: var(--f-sm);
  opacity: 0.88;
  margin-top: 3px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* Card */
.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-bottom: var(--s-4);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--c-200);
  transition: box-shadow .2s var(--ease-out);
}
.card:hover { box-shadow: var(--sh-md); }
.card h2 {
  font-size: var(--f-h2);
  margin-bottom: var(--s-4);
  color: var(--c-900);
  display: flex;
  align-items: center;
  gap: 6px;
}
.card h3 {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: var(--s-3);
  color: var(--c-500);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: var(--f-body);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: transform .1s var(--ease-out), box-shadow .15s var(--ease-out),
              background .15s var(--ease-out), color .15s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--c-red-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(139,42,31,0.2), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover { background: var(--c-red-500); box-shadow: var(--sh-red); }
.btn-secondary {
  background: var(--c-surface);
  color: var(--c-red-600);
  border: 1.5px solid var(--c-red-600);
}
.btn-secondary:hover { background: var(--c-red-50); }
.btn-ghost {
  background: transparent;
  color: var(--c-600);
}
.btn-ghost:hover { background: var(--c-100); color: var(--c-800); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 15px 24px; font-size: 15px; }

/* Progress steps */
.progress-steps { list-style: none; }
.progress-steps li {
  display: flex;
  align-items: center;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--c-100);
  color: var(--c-500);
  font-size: var(--f-body);
  font-weight: 500;
  transition: color .2s var(--ease-out);
}
.progress-steps li:last-child { border-bottom: none; }
.progress-steps li .step-icon {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  background: var(--c-200);
  color: var(--c-400);
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: var(--s-3);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all .2s var(--ease-out);
}
.progress-steps li.done { color: var(--c-green-600); }
.progress-steps li.done .step-icon {
  background: var(--c-green-600); color: #fff;
  box-shadow: 0 1px 2px rgba(62,86,65,0.3);
}
.progress-steps li.current { color: var(--c-red-600); font-weight: 700; }
.progress-steps li.current .step-icon {
  background: var(--c-red-600); color: #fff;
  box-shadow: 0 0 0 4px rgba(139,42,31,0.12);
  animation: pulse 2.4s ease-in-out infinite;
}
.progress-steps li.locked { color: var(--c-300); }
.progress-steps li.locked .step-icon { background: var(--c-100); color: var(--c-300); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(139,42,31,0.12); }
  50% { box-shadow: 0 0 0 10px rgba(139,42,31,0); }
}

/* Stats grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.stat-box {
  background: linear-gradient(180deg, var(--c-cream) 0%, #F0E8D6 100%);
  padding: var(--s-4);
  border-radius: var(--r-md);
  text-align: center;
  border: 1px solid rgba(212,165,116,0.18);
  transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--sh-sm); }
.stat-box .num {
  font-size: 30px;
  font-weight: 700;
  color: var(--c-red-600);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat-box .lbl { font-size: var(--f-xs); color: var(--c-600); margin-top: 4px; font-weight: 500; }
.stat-box .sub { font-size: 10px; color: var(--c-400); margin-top: 3px; font-weight: 500; letter-spacing: 0.05em; }

/* Table */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--f-body);
}
table th, table td {
  padding: 12px var(--s-3);
  text-align: left;
  border-bottom: 1px solid var(--c-100);
  vertical-align: middle;
}
table th {
  background: var(--c-50);
  font-weight: 600;
  color: var(--c-500);
  font-size: var(--f-micro);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: sticky; top: 0;
  white-space: nowrap;
}
table th:first-child { border-top-left-radius: var(--r-sm); }
table th:last-child { border-top-right-radius: var(--r-sm); }
table tbody tr { transition: background .12s var(--ease-out); }
table tbody tr:hover { background: var(--c-50); }

/* Tags / pills */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: var(--f-micro);
  font-weight: 600;
  background: var(--c-100);
  color: var(--c-700);
  letter-spacing: 0.02em;
}
.tag-local {
  background: var(--c-green-100);
  color: var(--c-green-700);
}
.tag-outside {
  background: var(--c-ochre-100);
  color: var(--c-ochre-700);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: var(--r-full);
  font-size: var(--f-micro);
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* Alerts */
.alert {
  padding: 12px var(--s-4);
  border-radius: var(--r-md);
  margin-bottom: var(--s-4);
  font-size: var(--f-body);
  font-weight: 500;
  display: block;
  line-height: 1.6;
}
.alert-info { background: #E0F2FE; color: #075985; border-left: 3px solid var(--c-info); }
.alert-warn { background: #FEF3C7; color: #854D0E; border-left: 3px solid var(--c-warn); }
.alert-success { background: var(--c-green-100); color: var(--c-green-700); border-left: 3px solid var(--c-success); }
.alert-danger { background: #FEE2E2; color: #991B1B; border-left: 3px solid var(--c-danger); }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--c-200);
  margin-bottom: var(--s-5);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 11px 16px;
  cursor: pointer;
  color: var(--c-500);
  font-weight: 500;
  font-size: var(--f-body);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s var(--ease-out), border-color .12s var(--ease-out);
}
.tab:hover { color: var(--c-700); }
.tab.active {
  color: var(--c-red-600);
  border-bottom-color: var(--c-red-600);
  font-weight: 700;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.filter-bar select, .filter-bar input {
  padding: 9px 12px;
  border: 1px solid var(--c-200);
  border-radius: var(--r-sm);
  font-size: var(--f-body);
  font-family: inherit;
  background: var(--c-surface);
  color: var(--c-700);
  transition: border-color .12s var(--ease-out), box-shadow .12s var(--ease-out);
}
.filter-bar select:focus, .filter-bar input:focus {
  outline: none;
  border-color: var(--c-red-600);
  box-shadow: 0 0 0 3px rgba(139,42,31,0.08);
}
.filter-bar input { min-width: 220px; }

/* Empty state */
.empty {
  text-align: center;
  padding: var(--s-10) var(--s-5);
  color: var(--c-400);
  font-size: var(--f-sm);
}

/* Fade-in on load */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.card, .stat-box, .big-num, .urgent-card { animation: fadeUp .35s var(--ease-out) both; }
.stat-grid .stat-box:nth-child(2) { animation-delay: .04s; }
.stat-grid .stat-box:nth-child(3) { animation-delay: .08s; }
.stat-grid .stat-box:nth-child(4) { animation-delay: .12s; }
.stat-grid .stat-box:nth-child(5) { animation-delay: .16s; }
.stat-grid .stat-box:nth-child(6) { animation-delay: .20s; }

/* ==========================================================
   Tour（新手導覽）+ 沙盒標記
   ========================================================== */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: auto;
  background: transparent;
}
.tour-spotlight {
  position: absolute;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(17, 17, 17, 0.55);
  background: transparent;
  transition: left .3s var(--ease-out), top .3s var(--ease-out),
              width .3s var(--ease-out), height .3s var(--ease-out);
  pointer-events: none;
  display: none;
}
.tour-card {
  position: fixed;
  background: var(--c-surface);
  width: 320px;
  max-width: calc(100vw - 32px);
  padding: 20px;
  border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,0.32), 0 4px 12px rgba(0,0,0,0.18);
  z-index: 10000;
  pointer-events: auto;
  transition: top .3s var(--ease-out), left .3s var(--ease-out);
  border: 1px solid var(--c-200);
}
.tour-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.tour-num {
  background: var(--c-red-600);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--r-full);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.tour-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-900);
  letter-spacing: -0.01em;
}
.tour-desc {
  font-size: 14px;
  color: var(--c-600);
  line-height: 1.75;
  margin-bottom: 16px;
}
.tour-desc strong {
  color: var(--c-red-600);
  font-weight: 700;
}
.tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.tour-skip {
  background: transparent;
  border: none;
  color: var(--c-400);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 6px 4px;
}
.tour-skip:hover { color: var(--c-600); }
.tour-nav { display: flex; gap: 6px; }
.tour-nav button {
  background: var(--c-red-600);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s var(--ease-out);
  white-space: nowrap;
}
.tour-nav .tour-next:hover { background: var(--c-red-500); }
.tour-nav .tour-prev {
  background: var(--c-100);
  color: var(--c-700);
}
.tour-nav .tour-prev:hover { background: var(--c-200); }
.tour-nav .tour-prev:disabled,
.tour-nav button:disabled {
  background: var(--c-100);
  color: var(--c-300);
  cursor: not-allowed;
}

/* 公開 Demo 沙盒標記 */
.sandbox-bar {
  background: linear-gradient(90deg, #FEF3C7 0%, #FDE68A 50%, #FEF3C7 100%);
  background-size: 200% 100%;
  color: #78350F;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 16px;
  text-align: center;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #F59E0B;
  animation: sandboxShimmer 8s linear infinite;
  position: relative;
  z-index: 100;
}
.sandbox-bar a {
  color: #78350F;
  text-decoration: underline;
  margin-left: 8px;
  font-weight: 700;
}
@keyframes sandboxShimmer {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* Mobile */
@media (max-width: 640px) {
  :root { --f-h1: 22px; --f-display: 28px; }
  .container { padding: var(--s-5) var(--s-4); }
  .container-sm { padding: var(--s-5) var(--s-4); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: var(--s-2); }
  .stat-box .num { font-size: 26px; }
  table { font-size: var(--f-sm); }
  table th, table td { padding: 8px; }
  .card { padding: var(--s-5); }
}
