/* 宿寫 InnPen：共用品牌樣式（亮色／暗色兩套主題）
   主題由 <html data-theme="light|dark"> 控制：預設跟隨系統，作者按過切換鈕後以 localStorage('innpen-theme') 為準。
   元件裡只能用下面的語意化變數，不要寫死色碼，兩套主題才會一起正確。
   字型宣告在 /css/fonts.css（由 scripts/build-font.mjs 產生）。 */

:root {
  /* 兩套主題共用 */
  --primary: #f97316;
  --primary-hover: #ea5b18;
  /* 主要按鈕的底色：#F97316 配白字對比不足，按鈕改用 logo 原色 #EA5B18，20px 粗體白字達大字標準 */
  --primary-fill: #ea5b18;
  --primary-fill-hover: #d14e10;
  --secondary: #1780c3;
  --accent: #46bbbe;           /* 第二主色：進度、完成、AI 相關狀態 */
  --accent-soft: rgba(70, 187, 190, 0.15);
  --on-photo: rgba(0, 0, 0, 0.55); /* 疊在照片上的按鈕底 */

  --font-body: "Nunito", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-display: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
  --radius: 12px;
  --radius-pill: 9999px;
  /* lucide triangle-alert：警告用圖示表達，不另加顏色，才不會跟橘色連結或主要按鈕混淆 */
  --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}

/* 亮色（也是沒有設定 data-theme 時的預設） */
:root,
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #faf7f3;
  --surface: #ffffff;
  --surface-2: #f3eee7;
  --border: #e8e0d6;
  --border-dashed: #d5ccc0;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --link: #c2410c;             /* 規範的 #EA5B18 在白底對比不足，同色系加深到 5.2 倍 */
  --error: #b42318;
  --glow: none;
  color-scheme: light;
}

/* 暗色：暖炭黑，對齊 lakeze.com 官網 */
:root[data-theme="dark"] {
  --bg: #141414;
  --bg-soft: #1a1a1a;
  --surface: #1f1f1f;
  --surface-2: #262626;
  --border: #2c2c2c;
  --border-dashed: #3a3a3a;
  --text: #f5f5f5;
  --text-muted: #b5b5b5;
  --link: #f97316;
  --error: #ff9f8a;
  --glow: radial-gradient(ellipse at 70% 20%, rgba(249, 115, 22, 0.1), transparent 55%);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--glow);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums; /* 數字等寬，額度與張數更新時不跳動 */
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

::selection { background: var(--accent-soft); color: var(--text); }

a { color: var(--link); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid var(--secondary); outline-offset: 3px; }

[hidden] { display: none !important; }

.wrap { max-width: 40rem; margin: 0 auto; padding: 0 20px; }

/* 虛線分隔：InnPen 的簽名元素（母品牌人客多用實線）。用背景畫，才能固定 6px 線段、6px 間距 */
.dash-bottom, .dash-top, .dash-y { background-repeat: no-repeat; }
.dash-bottom { background-image: repeating-linear-gradient(90deg, var(--border-dashed) 0 6px, transparent 6px 12px); background-size: 100% 1px; background-position: bottom; }
.dash-top { background-image: repeating-linear-gradient(90deg, var(--border-dashed) 0 6px, transparent 6px 12px); background-size: 100% 1px; background-position: top; }
.dash-y {
  background-image:
    repeating-linear-gradient(90deg, var(--border-dashed) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(90deg, var(--border-dashed) 0 6px, transparent 6px 12px);
  background-size: 100% 1px, 100% 1px;
  background-position: top, bottom;
}

/* 頁首：logo 與主題切換鈕 */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; }
.masthead .brand { display: inline-flex; align-items: center; }
.masthead .brand img { display: block; height: 32px; width: auto; }
.masthead .tools { display: flex; align-items: center; gap: 12px; min-width: 0; }
.masthead .who { color: var(--text-muted); font-size: 14px; overflow-wrap: anywhere; text-align: right; }
/* logo 依主題與螢幕寬度切換：亮色用彩色字標、暗色用反白字標，手機窄螢幕只放圖標 */
.logo-dark, .logo-mark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (max-width: 639px) {
  .logo-light, .logo-dark, :root[data-theme="dark"] .logo-dark { display: none !important; }
  .masthead .brand .logo-mark { display: block !important; height: 28px; }
}

.theme-toggle {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; padding: 0;
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background-color 0.2s ease-out, color 0.2s ease-out, border-color 0.2s ease-out;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* 標題：頁面主標用明體 900，其他標題用黑體 */
h1 {
  font-family: var(--font-display); font-weight: 900; line-height: 1.2; letter-spacing: 0.02em;
  font-size: clamp(1.9rem, 7vw, 2.6rem); margin: 28px 0 8px; text-wrap: balance;
}
h2 { font-size: 1.15rem; font-weight: 700; line-height: 1.4; margin: 36px 0 8px; text-wrap: balance; }

.lead { margin: 0 0 20px; color: var(--text-muted); }
.fine { color: var(--text-muted); font-size: 14px; }

/* 按鈕：一律膠囊形。主要（橘）一個畫面只放一顆 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 20px; border-radius: var(--radius-pill);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: background-color 0.2s ease-out, border-color 0.2s ease-out, color 0.2s ease-out, transform 0.1s ease-out;
}
.btn:hover { border-color: var(--border-dashed); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
/* 20px 粗體屬於大字，白字在 #EA5B18 上達到大字的對比標準 */
.btn-primary {
  width: 100%; min-height: 56px; font-size: 20px;
  background: var(--primary-fill); border-color: var(--primary-fill); color: #fff;
}
.btn-primary:hover { background: var(--primary-fill-hover); border-color: var(--primary-fill-hover); }
/* 暫時不能用的主要按鈕：拿掉橘色，不讓橘色出現在做不到的動作上；仍可點開說明 */
.btn-primary[aria-disabled="true"],
.btn-primary[aria-disabled="true"]:hover {
  background: var(--surface-2); border-color: var(--border); color: var(--text-muted);
}
.btn-small { min-height: 40px; padding: 6px 16px; font-size: 15px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-danger { color: var(--error); }

.icon-btn {
  width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center; padding: 0;
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer;
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* 提示框 */
.notice {
  margin: 16px 0 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-muted); font-size: 15px;
}
.notice strong { color: var(--text); }
/* 擋下時的提醒：虛線框（InnPen 簽名）加警告圖示，不另加顏色 */
.notice.is-warn { border: 1px dashed var(--text-muted); color: var(--text); padding-left: 42px; position: relative; }
.notice.is-warn::before {
  content: ""; position: absolute; left: 14px; top: 15px; width: 18px; height: 18px;
  background: currentColor; -webkit-mask: var(--icon-alert) center / contain no-repeat; mask: var(--icon-alert) center / contain no-repeat;
}
.notice.is-error { border-color: var(--error); color: var(--text); }
/* 狀態提示（AI 分析、草稿已儲存、照片準備好了）：藍綠邊線與淡藍綠底 */
.notice.is-status { background: var(--accent-soft); border: 0; border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; color: var(--text); }

.error-text { color: var(--error); }

/* 說明視窗：被擋下時說清楚原因與下一步 */
dialog {
  width: min(28rem, calc(100vw - 32px)); padding: 24px 22px 20px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { margin: 0 0 8px; font-size: 1.3rem; }
dialog p { margin: 0 0 12px; color: var(--text-muted); }
dialog .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }
dialog .actions .btn { min-width: 6rem; }

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