/* ============================================================================
   基底 —— reset / 版面骨架 / 排版 / 通用元件
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* 錨點跳轉時不要被吸頂 header 蓋住標題 */
  scroll-padding-top: 88px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-grad) no-repeat fixed, var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  /* CJK 與拉丁混排時,標點與西文之間自動留縫 */
  text-spacing-trim: space-first;
}

/* 宣紙纖維:feTurbulence 的 data URI,~500 bytes,零額外請求。
   固定在視窗上(不隨內容捲動)⇒ 是「紙」而不是「貼在內容上的圖層」。 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23f)' opacity='0.055'/%3E%3C/svg%3E");
}

img, svg, video { max-width: 100%; height: auto; }

a {
  color: var(--accent-text);
  text-decoration-color: var(--gold-hairline);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
  transition: color 0.15s, text-decoration-color 0.15s;
}
a:hover { color: var(--red); text-decoration-color: currentColor; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--gap-xl) 0;
}

::selection { background: var(--accent-glow); }

/* 鍵盤使用者的跳過導覽連結 */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; }

/* ── 裝裱金框(來源:super-reversi2 ornate.css 的 .panel-ornate)──────────
   雙 background + border-box 漸層邊框 = 四角鎏金、兩側收斂成細線;
   ::before 是內襯的那道金髮絲。純 CSS,不需要 9-slice 貼圖。 */
.panel-ornate {
  position: relative;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(135deg, var(--gold) 0%, var(--line) 22%, var(--line) 78%, var(--gold) 100%) border-box;
}
.panel-ornate::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid var(--gold-hairline);
  border-radius: calc(var(--r-lg) - 6px);
  pointer-events: none;
}

/* ── 硃砂印章字(來源:ornate.css 的 .seal-char)────────────────────── */
.seal-char {
  display: inline-block;
  font-family: var(--font-display);
  color: var(--red);
  border: 1.5px solid var(--red);
  border-radius: var(--r-sm);
  padding: 0 5px;
  font-size: 0.82em;
  line-height: 1.35;
  vertical-align: 0.06em;
}

/* ── 通用按鈕 ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--gold-text);
  background: #a8322610;
  border: 1px solid var(--gold);
  border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px #8a6a2f1f;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn:hover { color: var(--text); border-color: var(--line-gold); background: #a8322622; }
.btn:active { background: #a8322633; }

/* 觸控裝置:44px 最小點擊目標(Apple HIG / WCAG AAA)。
   `pointer: coarse` 不吃桌面滑鼠 ⇒ 桌面逐 px 零影響。 */
@media (pointer: coarse) {
  .btn, .nav-link, .badge, .tag-chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
