/* ============================================================
   YAYAKO Studio UI Kit v1.1（2026-07-11）
   canonical：LigeOS 200_Reference/templates/yayako-ui-kit.css
   搭配樣品頁 yayako-ui-kit.html 一起看。

   用法：
   - 新專案直接複製這份，或 <link> 引用
   - 改配色一律動 :root 變數，不要硬寫 hex（阿凱驗收標準）
   - 色票來源：yayako-studio-brand-book.md §3.1（不可自創顏色）
   ============================================================ */

/* ---------- 1. Design Tokens ---------- */
:root {
  /* 色票（對照品牌書，嚴格遵守） */
  --bg:            #0a0a0f;
  --surface:       #12121a;
  --surface-hi:    #191924;   /* 表面再高一層：彈窗、下拉、hover 列 */
  --border:        #1f1f2e;
  --border-hi:     rgba(255, 255, 255, 0.10);  /* 高一層表面用的細邊 */
  --text:          #e6e6f0;
  --text-2:        #8a8aa0;
  --text-3:        #6e7388;

  --primary:       #7c5cff;
  --primary-hi:    #8d70ff;   /* primary hover 亮一階 */
  --glow:          #a78bfa;
  --cyan:          #22d3ee;

  --good:          #51cf66;
  --warn:          #fbbf24;
  --bad:           #ff6b6b;

  /* 主視覺漸層：只准用在 Logo / 首頁 H1 / 工具標題（品牌書原則 3） */
  --gradient-brand: linear-gradient(135deg, #a78bfa 0%, #22d3ee 100%);

  /* 字型 */
  --font-body: "Inter", "Noto Sans TC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* 字級（只用這 5 階，不要自創） */
  --fs-xs:   12px;   /* 時間戳、tag、表頭 */
  --fs-sm:   14px;   /* 輔助文字、按鈕 */
  --fs-base: 16px;   /* 正文 */
  --fs-lg:   20px;   /* 卡片標題、h3 */
  --fs-xl:   28px;   /* 區塊標題、h2 */
  --fs-hero: clamp(32px, 5vw, 44px);  /* 首頁 H1 專用 */

  /* 間距（8px 網格，取值只從這裡拿） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* 圓角 */
  --r-sm:   8px;    /* input 內元素、小徽章 */
  --r-md:   10px;   /* 按鈕、輸入框 */
  --r-lg:   12px;   /* 卡片（品牌書原則 1） */
  --r-full: 999px;  /* 膠囊徽章 */

  /* 陰影與光暈（最多 2 個 glow，品牌書原則 4） */
  --shadow-card:  0 8px 24px rgba(124, 92, 255, 0.15);
  --shadow-btn:   0 4px 16px rgba(124, 92, 255, 0.35);
  --ring:         0 0 0 3px rgba(124, 92, 255, 0.25);

  /* 動畫（品牌書原則 2：輕、慢） */
  --t-hover: 200ms ease;
  --t-enter: 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- 2. 基礎 ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* 頁面背景配方：底色 → 一個大紫光暈 → 極淡點陣網格
   純平一片黑是 AI 寫醜的主因，鋪這三層質感就出來 */
.yk-bg {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 50% -8%, rgba(124, 92, 255, 0.16), transparent 70%),
    radial-gradient(circle, rgba(230, 230, 240, 0.035) 1px, transparent 1px);
  background-size: 100% 100%, 28px 28px;
}

h1, h2, h3 { margin: 0 0 var(--sp-3); line-height: 1.3; font-weight: 700; }
h1 { font-size: var(--fs-hero); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p  { margin: 0 0 var(--sp-4); }

a { color: var(--glow); text-decoration: none; transition: color var(--t-hover); }
a:hover { color: var(--cyan); }

/* 品牌漸層字：只用在 Logo / 首頁 H1 / 工具標題 */
.text-gradient {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.text-2    { color: var(--text-2); }
.text-3    { color: var(--text-3); }
.mono      { font-family: var(--font-mono); }

/* section 小標（青色 + mono + 大寫，工程感） */
.section-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: var(--sp-2);
}

/* ---------- 3. 按鈕（三階制，全部不用漸層） ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 20px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: all var(--t-hover);
  text-decoration: none;
  white-space: nowrap;
}

/* Primary：每個畫面最多 1 個主要動作 */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hi);
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn);
}
.btn-primary:active { transform: scale(0.97); box-shadow: none; }

/* Secondary：次要動作 */
.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--primary);
  background: rgba(124, 92, 255, 0.08);
}

/* Ghost：連結型動作，搭配 → */
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}
.btn-ghost:hover { color: var(--text); }
.btn-ghost .arrow { transition: transform var(--t-hover); }
.btn-ghost:hover .arrow { transform: translateX(3px); }

/* 尺寸 */
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { padding: 14px 28px; font-size: var(--fs-base); }

/* 按下回饋：所有按鈕點下去微縮，放開彈回 */
.btn:active { transform: scale(0.97); }

/* 狀態 */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* 危險動作（刪除等）：secondary 形 + 語意紅 */
.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--bad);
}
.btn-danger:hover {
  border-color: var(--bad);
  background: rgba(255, 107, 107, 0.08);
}

/* ---------- 4. 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: transform var(--t-hover), box-shadow var(--t-hover), border-color var(--t-hover);
}
/* 可點的卡片才加 hover 浮起；純資訊卡不用加 .card-hover */
.card-hover:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 92, 255, 0.4);
  box-shadow: var(--shadow-card);
}

.card-title { font-size: var(--fs-lg); font-weight: 600; margin: 0 0 var(--sp-2); }
.card-desc  { font-size: var(--fs-sm); color: var(--text-2); margin: 0; }

/* KPI / 數字卡 */
.stat-value {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.2;
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}

/* ---------- 5. 表單 ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text); }
.field-hint  { font-size: var(--fs-xs); color: var(--text-3); }

.input,
.select,
.textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  transition: border-color var(--t-hover), box-shadow var(--t-hover);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.input.is-error { border-color: var(--bad); }
.textarea { min-height: 96px; resize: vertical; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8aa0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* 開關（switch）：圓點左＝關、圓點右＝開 */
.switch {
  position: relative;
  width: 44px;
  height: 24px;
  appearance: none;
  background: var(--border);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-hover);
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text);
  transition: transform var(--t-hover);
}
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); background: #fff; }
.switch:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- 6. 徽章與標籤 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  padding: 4px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
}
.badge-live { color: var(--good); border-color: rgba(81, 207, 102, 0.3); }
.badge-soon { color: var(--text-3); }
.badge-beta { color: var(--cyan); border-color: rgba(34, 211, 238, 0.3); }

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  padding: 2px 10px;
  border-radius: var(--r-sm);
}

/* ---------- 7. 表格 ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.table tbody tr { transition: background var(--t-hover); }
.table tbody tr:hover { background: rgba(124, 92, 255, 0.05); }
.table .num { font-family: var(--font-mono); text-align: right; }

/* ---------- 8. 提示訊息 ---------- */
.alert {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: var(--surface);
  font-size: var(--fs-sm);
}
.alert-good { border-left-color: var(--good); }
.alert-warn { border-left-color: var(--warn); }
.alert-bad  { border-left-color: var(--bad); }
.alert-info { border-left-color: var(--cyan); }

/* ---------- 9. 工具類 ---------- */
.divider { border: none; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }

/* 進場淡入（700ms，品牌書原則 2） */
@keyframes yk-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: yk-fade-up var(--t-enter) both; }

/* Logo 呼吸（4.5s 循環） */
@keyframes yk-breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.72; }
}
.breathe { animation: yk-breathe 4.5s ease-in-out infinite; }

/* ---------- 10. 動畫（v1.1 新增） ---------- */

/* 進場逐個淡入：搭配 .fade-up 使用，區塊由上到下依序浮現 */
.d1 { animation-delay: 80ms; }
.d2 { animation-delay: 160ms; }
.d3 { animation-delay: 240ms; }
.d4 { animation-delay: 320ms; }
.d5 { animation-delay: 400ms; }
.d6 { animation-delay: 480ms; }

/* 卡片聚光燈：滑鼠在卡片上移動時，一團紫光跟著滑鼠跑。
   需要搭配一小段 JS 追蹤滑鼠位置（見樣品頁底部 spotlight 片段） */
.card-spotlight { position: relative; overflow: hidden; }
.card-spotlight::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%),
              rgba(124, 92, 255, 0.13), transparent 65%);
  opacity: 0;
  transition: opacity var(--t-hover);
  pointer-events: none;
}
.card-spotlight:hover::before { opacity: 1; }

/* 數字滾動：HTML 加 data-countup="12480"，JS 讓數字從 0 滾上去
   （JS 片段見樣品頁底部 countup） */

/* 按鈕光澤掃過（花俏款，預設不用；要用就在按鈕加 .btn-shine） */
.btn-shine { position: relative; overflow: hidden; }
.btn-shine::after {
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 50%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: skewX(-20deg);
  pointer-events: none;
}
.btn-shine:hover::after { animation: yk-shine 700ms ease; }
@keyframes yk-shine {
  to { left: 130%; }
}

/* 尊重系統「減少動態效果」設定（無障礙） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
