/* ============================================================
   黃芳誼 Fang-Yi Huang — 個人網站
   設計語言：暖陶土 · 米茶 · 四色章節（源自 Claude Design 定稿
   「黃芳誼 個人網站.dc.html」，實作時保留本站的真實內容與
   漸進增強機制）
   ============================================================ */

:root {
  /* 色盤：米茶 · 奶油紙 · 陶紅 */
  --shell:      #efe7db;   /* 視窗底 */
  --paper:      #f9f0e4;   /* 內容紙面 */
  --sand:       #f3e0c9;   /* 卡片 / 面板 */

  --ink:        #3a2a20;   /* 標題深褐 */
  --ink-soft:   #5c4535;   /* 內文 */
  --ink-mute:   #6b5040;
  --ink-dim:    #7a5a44;
  --ink-faint:  #a2825f;   /* 弱化 / mono 標籤 */

  --terra:      #b3472e;   /* 主色：陶紅 */
  --terra-deep: #8a3f2a;
  --orange:     #c26b1e;   /* 焦橙 */
  --amber:      #d99a2b;   /* 琥珀 */
  --plum:       #9b4a6b;   /* 梅紫 */

  --hair:       #ecdcc2;   /* 細線 */
  --hair-deep:  #e2c99f;
  --pill:       #d9a86a;   /* 藥丸邊框 */
  --tag-border: #e2b988;

  --serif: 'Noto Serif TC', 'Songti TC', serif;
  --sans:  'Noto Sans TC', 'Inter', -apple-system, sans-serif;
  --mono:  'IBM Plex Mono', 'Menlo', monospace;
  --news:  'Newsreader', 'Georgia', serif;

  --ease:     cubic-bezier(.22, .61, .36, 1);
  --ease-ink: cubic-bezier(.19, 1, .22, 1);

  --sheet: 1440px;
  --pad-x: clamp(20px, 4.5vw, 60px);
  /* 滿版關鍵：有色區塊（導覽列、卡片帶、頁尾）延伸到視窗邊緣，
     內容則置中在 --sheet 寬度內。背景填滿螢幕、文字又不會貼邊或過寬。 */
  --edge: max(var(--pad-x), calc((100% - var(--sheet)) / 2));
  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.95;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #e9c89a; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
em { font-family: var(--news); font-style: italic; }

/* 內容置中在 --sheet 內；有色區塊靠 --edge 滿版到視窗邊緣 */
.wrap {
  width: 100%;
  padding-inline: var(--edge);
}

/* ---------- 進場薄紗 ---------- */
.veil {
  position: fixed; inset: 0; z-index: 999;
  background: var(--shell);
  pointer-events: none;
  animation: veil-lift .9s var(--ease-ink) .1s forwards;
}
@keyframes veil-lift { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .veil { display: none; } }

/* ---------- 導覽列 ---------- */
#nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding-inline: var(--edge);
  background: rgba(249, 240, 228, .9);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--hair);
}
#nav.is-scrolled { border-bottom-color: var(--hair-deep); }

.brand {
  display: flex; align-items: baseline; gap: 10px;
}
.brand,
.brand :first-child { font-family: var(--serif); font-weight: 600; font-size: 1.19rem; color: var(--terra); }
.brand .en {
  font-family: var(--mono);
  font-size: .69rem; font-weight: 400;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
}

.navlinks {
  list-style: none; display: flex; align-items: center; gap: 1.65rem;
  margin: 0; padding: 0;
}
.navlinks a {
  font-family: var(--sans);
  font-size: .875rem; font-weight: 400;
  letter-spacing: .02em;
  color: var(--ink-dim);
  position: relative; padding-block: .35em;
  transition: color .3s var(--ease);
}
.navlinks a:hover { color: var(--terra); }
.navlinks a.is-current { color: var(--terra); font-weight: 600; }

.navlinks a.lang {
  font-family: var(--mono);
  font-size: .75rem; letter-spacing: .1em;
  color: var(--terra);
  border: 1px solid var(--pill);
  border-radius: 999px;
  padding: .3em 1em;
}
.navlinks a.lang:hover { background: var(--sand); }

.nav-toggle {
  display: none;
  background: none; border: 0; cursor: pointer;
  width: 32px; height: 24px; padding: 0;
  flex-direction: column; justify-content: space-between;
}
.nav-toggle span {
  display: block; height: 1.5px; width: 100%;
  background: var(--ink);
  transition: transform .4s var(--ease-ink), opacity .3s var(--ease);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(10.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-10.5px) rotate(-45deg); }

/* ---------- Hero（首頁：左文右拱形照片） ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: clamp(32px, 4.5vw, 52px);
  align-items: center;
  padding: clamp(40px, 6vw, 64px) var(--edge) clamp(40px, 5.5vw, 60px);
  min-height: 0;
}

.hero-eyebrow {
  font-family: var(--mono);
  font-size: .75rem; font-weight: 400;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--orange);
  margin: 0;
  animation: rise 1s var(--ease-ink) .35s both;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  /* 上限 3.3rem：中文首行有 9 個字，再大就會在欄寬內折行、
     孤懸單字（設計原型用 62px，其實塞不下自己的標題） */
  font-size: clamp(2.1rem, 4.2vw, 3.3rem);
  line-height: 1.2;
  letter-spacing: .01em;
  margin: 20px 0 22px;
  animation: rise 1.1s var(--ease-ink) .5s both;
}
.hero h1 .accent { color: var(--terra); }

.hero-sub {
  font-size: clamp(1rem, 1.5vw, 1.1rem);
  line-height: 2;
  color: var(--ink-soft);
  max-width: 32em;
  margin: 0;
  animation: rise 1.1s var(--ease-ink) .65s both;
}
.hero-sub .en {
  display: block;
  margin-top: .9rem;
  font-family: var(--news);
  font-style: italic;
  font-size: .92rem;
  color: var(--ink-faint);
}

.hero-cta {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-top: 32px;
  animation: rise 1.1s var(--ease-ink) .8s both;
}
.btn {
  font-size: .875rem; letter-spacing: .02em;
  padding: 12px 26px;
  border-radius: 999px;
  transition: transform .3s var(--ease-ink), box-shadow .3s var(--ease), background .3s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn.solid { background: var(--terra); color: #fff; box-shadow: 0 10px 24px -14px rgba(179, 71, 46, .8); }
.btn.solid:hover { background: #a03e28; }
.btn.line { border: 1px solid var(--pill); color: var(--ink-dim); }
.btn.line:hover { background: var(--sand); }

/* 拱形人像 */
.hero-photo {
  position: relative;
  border-radius: 0;
  overflow: hidden;
  animation: rise 1.2s var(--ease-ink) .55s both;
}
.hero-photo img {
  width: 100%; height: clamp(360px, 42vw, 500px);
  object-fit: cover;
  filter: sepia(.28) saturate(1.15) brightness(1.03);
}
.hero-photo::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(150deg, rgba(217,154,43,.28), rgba(179,71,46,.18) 60%, transparent);
  mix-blend-mode: multiply;
}
/* 沒照片時的暖色佔位 */
.hero-photo:not(:has(img)) {
  background: linear-gradient(150deg, var(--sand), #ecd3b3 60%, #e3c49e);
  min-height: clamp(360px, 42vw, 500px);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-eyebrow, .hero h1, .hero-sub, .hero-cta, .hero-photo { animation: none; }
}

/* ---------- 首頁三卡（研究/著作/教學） ---------- */
.trio {
  background: var(--sand);
  padding: clamp(40px, 5.5vw, 56px) var(--edge);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(24px, 3vw, 36px);
}
.trio a { display: block; padding-top: 20px; border-top: 3px solid var(--terra); }
.trio a:nth-child(2) { border-top-color: var(--amber); }
.trio a:nth-child(3) { border-top-color: var(--plum); }
.trio .no {
  font-family: var(--mono);
  font-size: .69rem; letter-spacing: .16em;
  color: var(--terra);
}
.trio a:nth-child(2) .no { color: var(--orange); }
.trio a:nth-child(3) .no { color: var(--plum); }
.trio h3 {
  font-family: var(--serif);
  font-size: 1.55rem; font-weight: 500;
  margin: 10px 0 12px;
  transition: color .3s var(--ease);
}
.trio a:hover h3 { color: var(--terra); }
.trio p { font-size: .94rem; line-height: 1.85; color: var(--ink-mute); margin: 0; }

/* ---------- 首頁 簡介＋數據 ---------- */
.about-teaser {
  padding: clamp(40px, 5.5vw, 56px) var(--edge);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 4vw, 48px);
  align-items: center;
}
.about-teaser .more {
  display: inline-block; margin-top: 20px;
  font-family: var(--mono);
  font-size: .81rem; letter-spacing: .06em;
  color: var(--terra);
}
.about-teaser .more:hover { text-decoration: underline; text-underline-offset: 4px; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.stat {
  background: var(--sand);
  border-radius: 14px;
  padding: 26px 24px;
}
.stat .n {
  display: block;
  font-family: var(--serif);
  font-size: 2.85rem; font-weight: 500;
  line-height: 1.15;
  color: var(--terra);
}
.stat:nth-child(2) .n { color: var(--orange); }
.stat:nth-child(3) .n { color: var(--amber); }
.stat:nth-child(4) .n { color: var(--plum); }
.stat .l { display: block; font-size: .81rem; color: var(--ink-dim); margin-top: 4px; }

/* ---------- 章節通用 ---------- */
.chapter { padding: clamp(40px, 5.5vw, 56px) 0 20px; }
.chapter > .wrap { padding-inline: var(--edge); }

.sec-index {
  font-family: var(--mono);
  font-size: .69rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--orange);
  margin: 0 0 .8rem;
}
.sec-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 2.6vw, 1.9rem);
  line-height: 1.35;
  margin: 0 0 1.1rem;
}
.sec-title .en {
  display: block;
  font-family: var(--news);
  font-style: italic;
  font-size: .95rem; font-weight: 400;
  letter-spacing: .02em; text-transform: none;
  color: var(--ink-faint);
  margin-top: .5rem;
}
.sec-body { font-size: 1rem; color: var(--ink-soft); margin: 0 0 1.1rem; }
.sec-body:last-of-type { margin-bottom: 1.8rem; }

/* 左右分欄（內頁介紹） */
.split {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: clamp(32px, 4.5vw, 48px);
  align-items: start;
}
.split.rev { grid-template-columns: 1fr 300px; }
.split.rev .col-photo { order: 2; }
.split.lead { margin-bottom: clamp(2.5rem, 4.5vw, 4rem); }
/* 研究頁移除佔位拱形照片後的單欄前言：維持易讀行寬，不撐滿版面 */
.lead-solo { max-width: 860px; margin-bottom: clamp(2.5rem, 4.5vw, 4rem); }

/* 教學頁前言：左側橫幅課堂合照 ＋ 右側文字（圓角矩形，非拱形） */
.teach-lead {
  display: grid;
  grid-template-columns: minmax(320px, 46%) 1fr;
  gap: clamp(28px, 4vw, 48px);
  align-items: center;
  margin-bottom: clamp(2.5rem, 4.5vw, 4rem);
}
.teach-lead .photo {
  border-radius: 0;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  box-shadow: 0 22px 54px -30px rgba(120, 80, 40, .55);
}
.teach-lead .photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: sepia(.16) saturate(1.05);   /* 輕暖調，呼應全站色系 */
}
@media (max-width: 900px) {
  .teach-lead { grid-template-columns: 1fr; }
  .teach-lead .photo { max-width: 520px; }
}

.photo-frame {
  position: relative;
  aspect-ratio: 4 / 5;          /* 直式矩形，無圓角 */
  border-radius: 0;
  overflow: hidden;
  background: linear-gradient(150deg, var(--sand), #ecd3b3 55%, #e3c49e);
}
.photo-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  position: relative; z-index: 1;
  filter: sepia(.24) saturate(1.12);
}
.photo-frame img[src*="portrait"] { object-position: 38% center; }
.photo-veil {
  position: absolute; inset: 0; z-index: 2;
  background: linear-gradient(150deg, rgba(217,154,43,.22), rgba(179,71,46,.14) 60%, transparent);
  mix-blend-mode: multiply;
}
.photo-frame:not(:has(img)) { min-height: 300px; }
.photo-frame:not(:has(img)) .photo-veil { display: none; }

/* 標籤 */
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; padding: 0; margin: 0 0 1.8rem; }
.tags li {
  font-size: .81rem;
  color: var(--terra-deep);
  background: var(--paper);
  border: 1px solid var(--tag-border);
  border-radius: 999px;
  padding: 7px 15px;
}

/* CTA 連結 */
.cta {
  display: inline-flex; align-items: center; gap: .7em;
  font-family: var(--mono);
  font-size: .81rem; letter-spacing: .06em;
  color: var(--terra);
  transition: gap .3s var(--ease);
}
.cta:hover { gap: 1em; text-decoration: underline; text-underline-offset: 5px; }
.cta .arrow { transition: transform .35s var(--ease-ink); }
.cta:hover .arrow { transform: translateX(3px); }
.page-cta { margin: 3rem 0 0; }

/* ---------- 章節群組（清單頁）：彩色頂線 ---------- */
.pub-group { margin-bottom: 3.2rem; }
.pub-group > h3 {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  font-family: var(--serif);
  font-size: 1.5rem; font-weight: 500;
  color: var(--ink);
  margin: 0 0 .4rem;
  border-top: 2px solid var(--terra);
  padding-top: 16px;
}
.pub-group > h3 .en {
  font-family: var(--mono);
  font-size: .69rem; font-weight: 400;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--terra);
}
/* 四色循環 */
.pub-group:nth-of-type(4n+2) > h3 { border-top-color: var(--amber); }
.pub-group:nth-of-type(4n+2) > h3 .en { color: var(--orange); }
.pub-group:nth-of-type(4n+3) > h3 { border-top-color: var(--plum); }
.pub-group:nth-of-type(4n+3) > h3 .en { color: var(--plum); }
.pub-group:nth-of-type(4n+4) > h3 { border-top-color: var(--orange); }
.pub-group:nth-of-type(4n+4) > h3 .en { color: var(--orange); }

/* 清單列：mono 年份 + 內文 */
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub-list li {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 20px;
  padding: 15px 0;
  border-top: 1px solid var(--hair);
}
.pub-list .yr {
  font-family: var(--mono);
  font-size: .81rem;
  color: var(--orange);
  padding-top: .2em;
}
.pub-list p { margin: 0; font-size: .94rem; line-height: 1.8; color: var(--ink-soft); }
.pub-list .venue { color: var(--ink-faint); }
.pub-list a { color: var(--terra); border-bottom: 1px solid var(--tag-border); }
.pub-list a:hover { border-bottom-color: var(--terra); }
/* 標題連結：連到該篇真實文章頁。用內文色＋淡底線，可辨識為連結又不搶戲 */
.pub-list a.ref { color: var(--ink); border-bottom: 1px solid var(--hair-deep); }
.pub-list a.ref:hover { color: var(--terra); border-bottom-color: var(--terra); }

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: .63rem; font-weight: 500;
  letter-spacing: .06em;
  color: var(--terra-deep);
  background: var(--sand);
  border-radius: 5px;
  padding: 2px 7px;
  margin-left: .5em;
  vertical-align: middle;
  white-space: nowrap;
}

/* ---------- 時間軸 / 定義列 ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 24px;
  padding: 15px 0;
  border-top: 1px solid var(--hair);
}
.timeline .when {
  font-family: var(--mono);
  font-size: .81rem;
  color: var(--orange);
  padding-top: .2em;
}
.timeline .what { margin: 0; font-size: .94rem; line-height: 1.75; color: var(--ink-soft); }
.timeline .where {
  display: block;
  font-size: .81rem;
  color: var(--ink-faint);
  margin-top: .3rem;
}

.facts { list-style: none; margin: 0; padding: 0; }
.facts li {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 24px;
  padding: 15px 0;
  border-top: 1px solid var(--hair);
}
.facts .k {
  font-family: var(--mono);
  font-size: .81rem;
  color: var(--plum);
  padding-top: .2em;
}
.facts .v { margin: 0; font-size: .94rem; line-height: 1.75; color: var(--ink-soft); }
.facts .v .sub {
  display: block;
  font-size: .81rem;
  color: var(--ink-faint);
  margin-top: .3rem;
}

/* ---------- 課程卡（教學頁） ---------- */
.course {
  background: var(--sand);
  border-radius: 16px;
  border-top: 3px solid var(--terra);
  padding: 30px 28px;
  margin-bottom: 24px;
}
.course:nth-of-type(2) { border-top-color: var(--amber); }
.course:nth-of-type(3) { border-top-color: var(--plum); }
.course-head {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: .9rem;
}
.course-head h4 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.38rem; font-weight: 500;
}
.course-when {
  font-family: var(--mono);
  font-size: .75rem; letter-spacing: .1em;
  color: var(--orange);
}
.course .note {
  margin: 0 0 .9rem;
  font-family: var(--mono);
  font-size: .72rem; letter-spacing: .1em;
  color: var(--ink-faint);
}
.course .tags { margin-bottom: 1.3rem; }
.course .tags:last-child { margin-bottom: 0; }
.course .tags li { background: var(--paper); }

/* ---------- 聯絡 ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 2.6rem;
}
.contact-item {
  background: var(--sand);
  border-radius: 16px;
  padding: 30px 28px;
}
.contact-item:nth-child(even) {
  background: var(--paper);
  border: 1px solid var(--hair-deep);
}
.contact-item .k {
  display: block;
  font-family: var(--mono);
  font-size: .69rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--terra);
  margin-bottom: .9rem;
}
.contact-item .v { font-size: .97rem; line-height: 1.9; color: var(--ink-soft); }
.contact-item a { border-bottom: 1px solid var(--hair-deep); }
.contact-item a:hover { color: var(--terra); border-bottom-color: var(--terra); }

/* ---------- 頁尾 ---------- */
footer {
  padding: 34px var(--edge);
  border-top: 1px solid var(--hair);
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
}
body > footer { margin-top: 40px; }
/* 內頁頁尾把內容包在 .wrap；footer 本身已有 --edge，避免雙重縮排 */
footer .wrap { padding-inline: 0; }
footer .f-name {
  font-family: var(--serif);
  font-size: .97rem;
  color: var(--terra);
}
footer .f-links { display: flex; gap: 22px; }
footer a {
  font-size: .81rem;
  color: var(--ink-dim);
  transition: color .3s var(--ease);
}
footer a:hover { color: var(--terra); }
footer .f-copy {
  width: 100%;
  font-family: var(--mono);
  font-size: .72rem; letter-spacing: .08em;
  color: var(--ink-faint);
  margin: 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--hair);
}

/* ---------- 內頁頭部 ---------- */
.page-head { padding: clamp(40px, 5.5vw, 56px) 0 0; }
.page-head .wrap { padding-inline: var(--edge); }
.page-head h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.3rem, 4.5vw, 3.25rem);
  line-height: 1.2;
  margin: .9rem 0 1.1rem;
}
.page-head h1 .en {
  display: block;
  font-family: var(--mono);
  font-size: .75rem; font-weight: 400;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--orange);
  margin-top: .8rem;
}
.page-head .lede {
  max-width: 760px;
  margin: 0;
  font-size: clamp(1.05rem, 1.6vw, 1.19rem);
  line-height: 1.9;
  color: var(--ink-soft);
}
.back-link {
  font-family: var(--mono);
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
}
.back-link:hover { color: var(--terra); }
.page-head + section.chapter { padding-top: clamp(28px, 4vw, 44px); }

/* ---------- 捲動揭露 ----------
   內容預設「可見」。只有 <html class="js"> 時才隱藏，改由 IntersectionObserver
   揭露。這個 class 由 <head> 的 inline script 加上，並在 main.js 載入失敗時
   自動移除。

   絕對不要把 .reveal 的 opacity:0 寫在 .js 之外 —— 那會讓內容的可見性依賴
   JavaScript。JS 被擋、載入失敗、或分頁在背景被瀏覽器凍結渲染時，
   整頁就只剩標題（research.html 有 98% 的內容在 .reveal 裡）。 */
.js .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .9s var(--ease-ink), transform .9s var(--ease-ink);
}
.js .reveal.is-in { opacity: 1; transform: none; }
.js .reveal.d1 { transition-delay: .07s; }
.js .reveal.d2 { transition-delay: .14s; }
.js .reveal.d3 { transition-delay: .21s; }
.js .reveal.d4 { transition-delay: .28s; }

@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- 英文版字距（拉丁字母收緊） ---------- */
html[lang="en"] body { line-height: 1.8; }
html[lang="en"] .hero h1,
html[lang="en"] .sec-title,
html[lang="en"] .page-head h1 { letter-spacing: 0; }
html[lang="en"] .hero h1 .zh {
  display: block;
  font-size: clamp(.95rem, 1.7vw, 1.1rem);
  font-weight: 400;
  letter-spacing: .4em;
  color: var(--ink-faint);
  margin-top: 1rem;
}
/* 英文頁的 .en 副標裝的是中文字 —— 不套 Newsreader 斜體（中文斜體很醜） */
html[lang="en"] .sec-title .en,
html[lang="en"] .page-head h1 .en {
  font-family: var(--serif);
  font-style: normal;
  letter-spacing: .3em;
}

/* ---------- 日文版 ----------
   日文用 Noto Serif/Sans JP（漢字字形與 TC 不同：呉・欧・医…都要日式字形）。
   假名與日式漢字若落到 TC 字型會顯得突兀，所以整組覆寫。 */
html[lang="ja"] {
  --serif: 'Noto Serif JP', 'Noto Serif TC', serif;
  --sans:  'Noto Sans JP', 'Noto Sans TC', 'Inter', sans-serif;
}
html[lang="ja"] body { line-height: 1.9; }
/* 日文 hero 標題較長（「制度は一人の生涯に…」），字級收小避免壓到照片 */
html[lang="ja"] .hero h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.9rem);
  letter-spacing: .02em;
  line-height: 1.34;
}
html[lang="ja"] .sec-title { letter-spacing: .02em; }
/* 日文段落不需要為方塊字加額外字距 */
html[lang="ja"] .sec-body,
html[lang="ja"] .lede { letter-spacing: 0; }

/* ---------- 語言切換：兩顆藥丸靠攏成一組 ---------- */
.navlinks a.lang { padding: .28em .8em; }
/* 相鄰的兩個語言 <li> 收窄間距，讓 中｜EN｜日 讀起來像一組開關 */
.navlinks li:has(> a.lang) + li:has(> a.lang) { margin-left: -1.1rem; }

/* ============================================================
   響應式
   ============================================================ */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .hero-photo { order: -1; max-width: 420px; }
  .hero-photo img,
  .hero-photo:not(:has(img)) { height: 340px; min-height: 340px; }
  .trio { grid-template-columns: 1fr; gap: 28px; }
  .about-teaser { grid-template-columns: 1fr; }
  .split, .split.rev { grid-template-columns: 1fr; }
  .split.rev .col-photo { order: 0; }
  .photo-frame { max-width: 420px; }
}

@media (max-width: 760px) {
  .nav-toggle { display: flex; }

  .navlinks {
    /* #nav 是 sticky（形成 containing block 的祖先），absolute 以它定位 */
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: flex-start;
    gap: 0;

    /* 必須完全不透明：半透明背景會讓底下的內文透出來 */
    background: var(--paper);
    border-bottom: 1px solid var(--hair-deep);
    box-shadow: 0 20px 44px -30px rgba(58, 42, 32, .5);
    padding: 10px 20px 24px;

    opacity: 0; visibility: hidden;
    transform: translateY(-10px);
    transition: opacity .35s var(--ease), transform .35s var(--ease-ink), visibility .35s;
  }
  .navlinks.is-open { opacity: 1; visibility: visible; transform: none; }
  .navlinks li { width: 100%; border-bottom: 1px solid var(--hair); }
  .navlinks li:last-child { border-bottom: 0; }
  .navlinks a { display: block; padding: .95em 0; font-size: .94rem; }
  .navlinks a.lang { display: inline-block; }
  /* 手機直排：兩顆語言藥丸各佔一行。用與桌機完全相同的選擇器重置靠攏負邊距
     （特異度相同、順序在後、又在 media query 內，才蓋得過），否則第二顆被拉歪。 */
  .navlinks li:has(> a.lang) + li:has(> a.lang) { margin-left: 0; }
  .navlinks li:not(:has(> a.lang)) + li:has(> a.lang) { padding-top: 1rem; }

  body { font-size: 15.5px; }

  .stats { grid-template-columns: 1fr 1fr; }
  .timeline li, .facts li { grid-template-columns: 1fr; gap: .4rem; }
  .timeline .when, .facts .k { padding-top: 0; }
  .pub-list li { grid-template-columns: 1fr; gap: .35rem; }
  .pub-list .yr { padding-top: 0; }
  .course-head { flex-direction: column; gap: .3rem; }
  .contact-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 430px) {
  .stats { grid-template-columns: 1fr; }
}
