/* =========================================================
   共用樣式系統 — 作品集 / 新聞索引 兩頁共用
   主題透過 body 上的 class 切換少量變數
   ========================================================= */

/* ---------- 字體 ---------- */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Noto+Serif+TC:wght@500;600;700&family=Noto+Sans+TC:wght@300;400;500;600&display=swap');

/* ---------- 設計 Token ---------- */
:root {
  /* 字體族 */
  --font-display: 'Fraunces', 'Noto Serif TC', Georgia, serif;
  --font-body: 'Noto Sans TC', system-ui, -apple-system, sans-serif;

  /* 字級刻度 */
  --fs-hero: clamp(2.8rem, 6vw, 4.6rem);
  --fs-h1: clamp(2rem, 3.4vw, 2.9rem);
  --fs-h2: clamp(1.5rem, 2.2vw, 1.9rem);
  --fs-h3: 1.2rem;
  --fs-body: 1rem;
  --fs-small: 0.85rem;
  --fs-tiny: 0.75rem;

  /* 間距（4 的倍數） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 96px;

  /* 容器 */
  --maxw: 1180px;
  --gutter: clamp(20px, 5vw, 64px);

  /* 過渡 */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 0.5s;

  /* 線條 */
  --line: rgba(26, 24, 20, 0.14);
}

/* ---------- 主題：作品集（預設） ---------- */
.theme-portfolio {
  --bg: #f5f1ea;
  --bg-soft: #efe8dc;
  --ink: #1a1814;
  --ink-soft: #4a443c;
  --muted: #8a8378;
  --accent: #b5563a;
  --accent-soft: rgba(181, 86, 58, 0.12);
  --line: rgba(26, 24, 20, 0.14);
}

/* ---------- 主題：新聞索引 ---------- */
.theme-news {
  --bg: #fafaf7;
  --bg-soft: #f1f0ea;
  --ink: #16202c;
  --ink-soft: #3a4654;
  --muted: #6b7785;
  --accent: #9c3a2e;
  --accent-soft: rgba(156, 58, 46, 0.10);
  --line: rgba(22, 32, 44, 0.13);
}

/* ---------- 基礎重置 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.75;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--accent); color: #fff; }

/* ---------- 容器 ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- 頂部導覽列 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.nav { display: flex; gap: var(--sp-5); }
.nav a {
  font-size: var(--fs-small);
  color: var(--ink-soft);
  position: relative;
  transition: color var(--dur) var(--ease);
}
.nav a::after {
  content: '';
  position: absolute;
  left: 0; bottom: -6px;
  width: 0; height: 1.5px;
  background: var(--accent);
  transition: width var(--dur) var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after { width: 100%; }

/* ---------- 區塊通用 ---------- */
section { padding-block: var(--sp-9); position: relative; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-5);
  margin-bottom: var(--sp-7);
}
.section-num {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  font-size: 1rem;
}
.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-h2);
  margin: 0;
  letter-spacing: -0.01em;
}
.section-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--line), transparent);
}

/* ---------- 漸隱遮罩工具 ---------- */
.fade-y {
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
}
.fade-x {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
}

/* ---------- 佔位圖塊 ---------- */
.ph {
  background:
    linear-gradient(135deg, var(--bg-soft), color-mix(in srgb, var(--accent) 18%, var(--bg-soft)));
  position: relative;
  overflow: hidden;
}
.ph::after {
  content: '圖片佔位';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-style: italic;
  color: color-mix(in srgb, var(--ink) 45%, transparent);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

/* ---------- 按鈕 / 連結 ---------- */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-small);
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 3px;
  transition: gap var(--dur) var(--ease), color var(--dur) var(--ease);
}
.link-arrow:hover { gap: 14px; color: var(--accent); border-color: var(--accent); }
.link-arrow .arr { transition: transform var(--dur) var(--ease); }
.link-arrow:hover .arr { transform: translateX(2px); }

/* ---------- 頁尾 ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding-block: var(--sp-7);
  color: var(--muted);
  font-size: var(--fs-small);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

/* ---------- 滾動揭示動畫 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.in { opacity: 1; transform: none; }

/* ---------- 響應式 ---------- */
@media (max-width: 768px) {
  section { padding-block: var(--sp-8); }
  .nav { gap: var(--sp-4); }
  .nav a { font-size: 0.8rem; }
  .section-head { flex-wrap: wrap; }
  /* 行動端內容置中 */
  .center-m { text-align: center; align-items: center; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
