/* ────────────────────────────────────────────────────────────
   site.css ｜ 共享外殼（幽玄設計系統）
   供 /articles/ 內各頁複用，與 index.html 的內嵌樣式保持一致。
   只放「跨頁共用」的 token 與外殼（nav / footer / fog / 按鈕 / reveal）。
   各區塊專屬樣式請放 article.css。
   ──────────────────────────────────────────────────────────── */

:root {
  color-scheme: dark;
  /* 幽玄 (Yugen) - Deep, mysterious aesthetic */
  --bg-dark: #0e0f14;
  --bg-surface: #161821;
  --bg-elevated: #1f2230;
  --bg-glass: rgba(22, 24, 33, 0.55);
  --surface-rgb: 22, 24, 33;

  /* 霧 (Kiri) - Text colors */
  --text-main: #f0f0f2;
  --text-muted: #8b8f97;
  --text-dim: #4a4d57;
  --text-read: #ccd0d7; /* 長文內文:比 muted 亮,讀起來清楚 */

  /* 靈 (Rei) - Accents */
  --accent-glow: #8e95ac;
  --accent-warm: #d4af37; /* Muted gold */
  --accent-red: #8b2c2c;  /* Subtle crimson */

  --line-rgb: 255, 255, 255;
  --accent-warm-rgb: 212, 175, 55;

  --font-serif: "Noto Serif TC", "Cormorant Garamond", serif;
  --font-sans: "Zen Kaku Gothic New", sans-serif;

  --ease-cinematic: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-dark: #f4f1ea;
  --bg-surface: #ebe7dd;
  --bg-elevated: #fbf9f4;
  --bg-glass: rgba(244, 241, 234, 0.6);
  --surface-rgb: 235, 231, 221;

  --text-main: #2b2a28;
  --text-muted: #615e57;
  --text-dim: #a6a39c;
  --text-read: #3a3834; /* 長文內文:亮色主題下略淺於標題,但仍清楚 */

  --accent-glow: #8e95ac;
  /* 金色加深:亮色主題下小字需達 WCAG 4.5:1 */
  --accent-warm: #7d6a1c;
  --accent-red: #9e3636;

  --line-rgb: 0, 0, 0;
  --accent-warm-rgb: 125, 106, 28;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: var(--bg-dark);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Cinematic Grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Ambient Fog */
.fog-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.fog {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  animation: drift 20s infinite alternate ease-in-out;
}
.fog-1 { width: 60vw; height: 60vw; background: var(--accent-glow); top: -20%; left: -10%; }
.fog-2 { width: 50vw; height: 50vw; background: var(--accent-red); bottom: -10%; right: -10%; animation-delay: -5s; animation-duration: 25s; opacity: 0.08; }
.fog-3 { width: 40vw; height: 40vw; background: var(--accent-warm); top: 40%; left: 30%; animation-delay: -10s; animation-duration: 30s; opacity: 0.05; }

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(5%, 10%) scale(1.1); }
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 300;
  margin: 0;
  letter-spacing: 0.05em;
  text-wrap: balance;
}

a { color: inherit; text-decoration: none; }
a, button { touch-action: manipulation; }

:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  padding: 0.8rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(var(--line-rgb), 0.2);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: translateY(0); }

.wrap {
  width: min(1200px, 88vw);
  margin-inline: auto;
  position: relative;
  z-index: 10;
}

.section {
  padding: clamp(6rem, 15vh, 12rem) 0;
  position: relative;
}

/* ── 導覽列 ───────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 2rem clamp(1.5rem, 5vw, 4rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: padding 0.6s var(--ease-cinematic), background 0.6s var(--ease-cinematic), backdrop-filter 0.6s var(--ease-cinematic);
  mix-blend-mode: difference;
}
:root[data-theme="light"] .nav { mix-blend-mode: normal; }
.nav.scrolled {
  padding: 1rem clamp(1.5rem, 5vw, 4rem);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  mix-blend-mode: normal;
  border-bottom: 1px solid rgba(var(--line-rgb), 0.05);
}
.brand {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  display: flex;
  flex-direction: column;
}
.brand span {
  font-family: var(--font-sans);
  font-size: 0.55rem;
  letter-spacing: 0.4em;
  color: var(--text-muted);
  margin-top: 0.3rem;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.theme-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.4s ease;
}
.theme-btn:hover { color: var(--text-main); }
.theme-btn svg { width: 20px; height: 20px; fill: currentColor; }
:root[data-theme="light"] .theme-btn .moon { display: none; }
:root:not([data-theme="light"]) .theme-btn .sun { display: none; }
.nav-btn {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  border: 1px solid rgba(var(--line-rgb), 0.2);
  padding: 0.6rem 1.5rem;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  transition: background 0.4s ease, color 0.4s ease;
}
.nav-btn:hover {
  background: var(--text-main);
  color: var(--bg-dark);
}

/* ── 按鈕 ─────────────────────────────── */
.btn-group {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.btn-primary {
  background: rgba(var(--accent-warm-rgb), 0.08);
  border: 1px solid rgba(var(--accent-warm-rgb), 0.35);
  color: var(--text-main);
  padding: 1rem 2.5rem;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  transition: background 0.4s var(--ease-cinematic), border-color 0.4s var(--ease-cinematic);
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(var(--line-rgb),0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s var(--ease-cinematic);
}
.btn-primary:hover {
  background: rgba(var(--accent-warm-rgb), 0.16);
  border-color: rgba(var(--accent-warm-rgb), 0.6);
}
.btn-primary:hover::before { transform: translateX(100%); }
.btn-text {
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  position: relative;
  transition: color 0.3s ease;
}
.btn-text::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0%;
  height: 1px;
  background: var(--text-main);
  transition: width 0.4s var(--ease-cinematic);
}
.btn-text:hover { color: var(--text-main); }
.btn-text:hover::after { width: 100%; }

/* ── eyebrow（小標）─────────────────────── */
.eyebrow {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  letter-spacing: 0.3em;
  color: var(--accent-warm);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.eyebrow::before {
  content: "";
  width: 40px;
  height: 1px;
  background: currentColor;
}

/* ── Footer ───────────────────────────── */
footer {
  padding: 3rem 0;
  text-align: center;
  border-top: 1px solid rgba(var(--line-rgb),0.05);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}
footer .footer-links {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
footer .footer-links a {
  color: var(--text-muted);
  transition: color 0.3s ease;
}
footer .footer-links a:hover { color: var(--accent-warm); }

/* ── 動畫 (Cinematic Reveals) ────────────── */
.reveal {
  opacity: 0;
  filter: blur(10px);
  transform: translateY(30px);
  transition: opacity 1.2s var(--ease-cinematic), filter 1.2s var(--ease-cinematic), transform 1.2s var(--ease-cinematic);
}
.reveal.in {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}
.d-1 { transition-delay: 0.1s; }
.d-2 { transition-delay: 0.2s; }
.d-3 { transition-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; filter: none; transform: none; transition: none; }
  .fog { animation: none; }
}

/* ── 回到頂部 ─────────────────────────── */
.to-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 90;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(var(--line-rgb), 0.05);
  border: 1px solid rgba(var(--line-rgb), 0.1);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.4s var(--ease-cinematic), visibility 0.4s var(--ease-cinematic), transform 0.4s var(--ease-cinematic), background 0.4s var(--ease-cinematic), border-color 0.4s var(--ease-cinematic);
  backdrop-filter: blur(10px);
}
.to-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.to-top-btn:hover {
  background: rgba(var(--line-rgb), 0.1);
  border-color: rgba(var(--line-rgb), 0.3);
}
.to-top-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  transition: transform 0.3s ease;
}
.to-top-btn:hover svg { transform: translateY(-3px); }
@media (max-width: 768px) {
  .to-top-btn { bottom: 1.5rem; right: 1.5rem; }
}
