/* 此刻之痕｜人物專訪頁（/then-now/cases/）。手機優先。
 *
 * HTML 由 tools/then-now-cases/build.mjs 產生；改完這支重跑 build，?v= 會自動換成檔案雜湊。
 * 字級與欄寬跟 build.mjs 的 LIMITS 是一組的：內文每段 ≤18 字、大字引言 ≤13 字要在 360px 寬擠得進一行，
 * 桌機一行內文 ≤26 字要在 --measure 內。改字級、字距、邊距前先算過這兩件事。
 */

@font-face {
  font-family: "Helvetica Now Display";
  src: url("/then-now/fonts/HelveticaNowDisplay-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Helvetica Now Display";
  src: url("/then-now/fonts/HelveticaNowDisplay-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --paper: #f4efe7;
  --paper-deep: #ebe3d6;
  --ink: #2a211a;
  --text: #463a30;
  --muted: #6e6156;
  --line: rgba(42, 33, 26, 0.16);
  --accent: #a2785c;
  --accent-ink: #7d5a44;
  --serif: "Noto Serif TC", "Songti TC", "Noto Serif CJK TC", "PMingLiU", serif;
  /* 小字 UI 用系統黑體就好，不另外載入網頁字型。 */
  --sans: "PingFang TC", "Noto Sans CJK TC", "Microsoft JhengHei", sans-serif;
  --en: "Helvetica Now Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* 內文字級：360px → 15px、390px → 16px、415px 以上 17px。 */
  --fs: clamp(15px, 4.1vw, 17px);
  --gutter: clamp(20px, 6.4vw, 40px);
  /* 文字欄：手機是扣掉邊距的寬度，桌機最多 28 個內文字寬（26 字＋字距）。 */
  --col: min(100% - 2 * var(--gutter), calc(var(--fs) * 28));
}

/* 360px 以下（iPhone SE 第一代的 320px 等）：縮字，讓 18 字的內文、13 字的大字引言仍然一行。 */
@media (max-width: 359px) {
  :root {
    --fs: 13.5px;
    --gutter: 18px;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body.cs {
  background: var(--paper);
  color: var(--text);
  font-family: var(--serif);
  font-size: var(--fs);
  font-weight: 400;
  line-height: 2.05;
  letter-spacing: 0.06em;
  line-break: strict;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(42, 33, 26, 0.08);
}

h1,
h2 {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* <picture> 只是 AVIF／WebP 的外包裝，版面上當作不存在，樣式照舊寫在 img 上 */
picture {
  display: contents;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* 開場的導覽疊在照片底色上，焦點框跟著字色走才看得見。 */
.cs-hero a:focus-visible {
  outline-color: currentColor;
}

.en {
  font-family: var(--en);
  letter-spacing: 0.06em;
}

/* ---- 閱讀進度（捲動動畫，不支援就不顯示） ---- */
.cs-progress {
  display: none;
}

@supports (animation-timeline: scroll()) {
  .cs-progress {
    display: block;
    position: fixed;
    inset: 0 0 auto;
    z-index: 20;
    height: 2px;
    background: var(--accent);
    transform-origin: 0 50%;
    animation: cs-progress linear both;
    animation-timeline: scroll(root block);
    pointer-events: none;
  }
}

@keyframes cs-progress {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* ---- 開場 ---- */
.cs-hero {
  background: var(--backdrop, var(--paper-deep));
  color: var(--on-backdrop, var(--ink));
}

.cs-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--gutter) 14px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.08em;
}

.cs-bar a {
  display: flex;
  align-items: center;
  min-height: 44px;
}

.cs-bar__brand {
  gap: 10px;
}

.cs-mark {
  flex: none;
  width: 16px;
  aspect-ratio: 300 / 420.67;
  background: currentColor;
  -webkit-mask: url("/then-now/assets/naiss-mark.svg") center / contain no-repeat;
  mask: url("/then-now/assets/naiss-mark.svg") center / contain no-repeat;
}

.cs-bar__index {
  gap: 0.7em;
}

.cs-bar__index .en {
  font-size: 12px;
  letter-spacing: 0.04em;
}

.cs-bar__index i {
  font-style: normal;
  opacity: 0.5;
  margin: 0 0.15em;
}

.cs-hero__img img {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 68svh;
  object-fit: cover;
  object-position: 50% 30%;
}

.cs-hero__copy {
  background: var(--paper);
  color: var(--ink);
  padding: 2.3em var(--gutter) 0;
}

.cs-hero__copy > * {
  width: min(100%, calc(var(--fs) * 28));
  margin-inline: auto;
}

.cs-kicker {
  display: flex;
  align-items: center;
  gap: 0.9em;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.24em;
  color: var(--muted);
}

.cs-kicker::before {
  content: "";
  flex: none;
  width: 28px;
  height: 1px;
  background: var(--accent);
}

.cs-kicker .en {
  letter-spacing: 0.08em;
}

.cs-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.75rem;
  row-gap: 0.4rem;
  margin-top: 0.7rem;
  line-height: 1;
}

.cs-name__en {
  font-weight: 500;
  font-size: clamp(2.8rem, 14.5vw, 5.4rem);
  letter-spacing: -0.005em;
}

.cs-name__zh {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15em;
  letter-spacing: 0.32em;
}

.cs-name__zh--big {
  font-size: 2.3em;
  letter-spacing: 0.18em;
}

/* 個人頁開場：名字右邊放醫美項目＋主治醫師，靠右、底對齊名字；放不下就換到名字下面 */
.cs-id {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.6rem 1rem;
}

/* 字色跟名字走（開場底色每人不同，Kerry 是深灰底白字） */
.cs-meta {
  margin-left: auto;
  padding-bottom: 0.15em;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: 0.08em;
  text-align: right;
  opacity: 0.82;
}

.cs-meta > span {
  display: block;
}

/* 選擇器要比上面的 .cs-meta > span 強，不然會被蓋回 block、logo 一個一行 */
.cs-meta > .cs-meta__treat--logo {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0 0.75em;
}

/* 「Dr.」和姓名之間只隔一個半形空格（.cs-meta 的字距不套在這裡，不然空格前後各多一點） */
.cs-meta__dr {
  letter-spacing: 0;
}

.cs-meta a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}

.cs-lede {
  margin-top: 1.5em;
  /* 大字 1.5em，但不超過「欄寬 ÷ --lede-w 個字」，手機上一行 --lede-w 個字仍放得下。
     個人頁一律用 16（2026-10-01 使用者要求八個人的開場引言字級都跟 KURT 一樣），目錄頁的標題用 13。 */
  font-size: min(1.5em, (100vw - 2 * var(--gutter)) / (var(--lede-w, 13) * 1.08));
  font-weight: 600;
  line-height: 1.62;
  letter-spacing: 0.05em;
}

.cs--case .cs-lede {
  --lede-w: 16;
}

.ln {
  display: block;
}

/* 標點字寬（render.mjs 包的 span）：
 * .pt       」』）緊接 。，等標點時改半形，不然中間空出將近一個字；
 * .pt--open 行首的「『（ 半形並懸掛到欄外，字才會和下一行對齊。置中的結語、預告卡片不懸掛。 */
.pt {
  font-feature-settings: "halt";
}

.pt--open {
  margin-inline-start: -0.5em;
}

.cs-end .pt--open,
.cs-next__line .pt--open,
.cs-cards__line .pt--open {
  margin-inline-start: 0;
}

/* 文字還沒到的頁（@pending）：名字下面一行說明。 */
.cs-note {
  margin-top: 1.4em;
  font-size: 0.94em;
  line-height: 2;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* ---- 正文：詩的節奏 ---- */
.cs-story {
  padding: 3.4em 0 4.5em;
}

.cs-story > *,
.cs-end > * {
  width: var(--col);
  margin-inline: auto;
}

/* 內文一段＝一個呼吸；段與段之間空一行多一點。 */
.st {
  margin-top: 2em;
}

.st strong {
  font-weight: 600;
  color: var(--ink);
}

/* 大字引言：字大、行距鬆、前後大量留白。margin 用的 em 是引言自己的字級。 */
.q {
  margin-top: 2.1em;
  font-size: 1.5em;
  font-weight: 600;
  line-height: 1.62;
  letter-spacing: 0.05em;
  color: var(--ink);
}

.q + .st,
.q + .qa,
.m + .st {
  margin-top: 3.2em;
}

.m {
  margin-top: 2em;
  font-size: 1.2em;
  line-height: 1.8;
  letter-spacing: 0.05em;
  color: var(--ink);
}

/* 引出句（句子沒說完，以「——」「：」「，」收尾）和接著把它說完的引言或粗體貼近。 */
.st--lead + .q {
  margin-top: 0.55em;
}

.st--lead + .m {
  margin-top: 0.7em;
}

.st--lead + .st {
  margin-top: 0.9em;
}

.cs-story > :first-child {
  margin-top: 0;
}

/* Clover 的問答：題號＋題目，小字、上面一條細線。 */
.qa {
  margin-top: 5.2em;
  padding-top: 1.2em;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.875em;
  line-height: 1.75;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.qa__n {
  display: block;
  margin-bottom: 0.35em;
  font-family: var(--en);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--accent-ink);
}

.qa + * {
  margin-top: 1.9em;
}

.cs-story > .qa:first-child {
  margin-top: 1em;
}

/* 大停頓：一條短短的直線。 */
.cs-story > hr.pause,
.cs-end > hr.pause {
  width: 1px;
  height: 44px;
  margin-top: 4.4em;
  border: 0;
  background: var(--accent);
  opacity: 0.7;
}

hr.pause + * {
  margin-top: 4.4em;
}

/* ---- 照片 ---- */
.ph {
  margin-top: 3.9em;
  overflow: hidden;
}

.ph + * {
  margin-top: 3.9em;
}

.ph img {
  width: 100%;
  background: var(--paper-deep);
}

.cs-story > .ph--wide,
.cs-end > .ph--wide {
  width: 100%;
}

.cs-story > .ph--left,
.cs-story > .ph--right,
.cs-end > .ph--left,
.cs-end > .ph--right {
  width: 86%;
}

.cs-story > .ph--left,
.cs-end > .ph--left {
  margin-left: 0;
  margin-right: auto;
}

.cs-story > .ph--right,
.cs-end > .ph--right {
  margin-left: auto;
  margin-right: 0;
}

.cs-story > .ph--pair,
.cs-end > .ph--pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: calc(100% - 16px);
}

@media (min-width: 640px) {
  .cs-story > .ph--wide,
  .cs-end > .ph--wide {
    width: min(960px, 100% - 2 * var(--gutter));
  }

  .cs-story > .ph--left,
  .cs-story > .ph--right,
  .cs-end > .ph--left,
  .cs-end > .ph--right {
    width: min(520px, 72%);
  }

  /* 平板：往文字欄外側推出去一點，不貼到視窗邊。 */
  .cs-story > .ph--left,
  .cs-end > .ph--left {
    margin-left: max(var(--gutter), (100% - var(--col)) / 2 - 110px);
  }

  .cs-story > .ph--right,
  .cs-end > .ph--right {
    margin-right: max(var(--gutter), (100% - var(--col)) / 2 - 110px);
  }

  .cs-story > .ph--pair,
  .cs-end > .ph--pair {
    width: min(640px, 100% - 2 * var(--gutter));
    gap: 12px;
  }
}

/* ---- 淡入（捲動動畫；不支援或要求減少動態就直接顯示） ---- */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    [data-rv] {
      animation: cs-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 80%;
    }

    .ph[data-rv] {
      animation-range: entry 0% entry 30%;
    }

    .ph[data-rv] img {
      animation: cs-settle linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 55%;
    }
  }
}

@keyframes cs-rise {
  from {
    opacity: 0;
    transform: translateY(1.1rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes cs-settle {
  from {
    transform: scale(1.06);
  }
  to {
    transform: none;
  }
}

/* ---- 結尾：那你呢？ ---- */
.cs-end {
  padding: 5.6em 0 6em;
  background: var(--paper-deep);
  text-align: center;
}

.cs-end > .q:first-child,
.cs-end > .m:first-child {
  margin-top: 0;
}

.cs-end .q + .m {
  margin-top: 1.3em;
}

/* ---- 下一位＋八個人 ---- */
.cs-more {
  padding: 4.2em var(--gutter) 0;
}

.cs-more > * {
  max-width: 560px;
  margin-inline: auto;
}

.cs-next {
  display: grid;
  grid-template-columns: 34% 1fr;
  align-items: end;
  gap: 1.1em;
  padding-bottom: 2.6em;
  border-bottom: 1px solid var(--line);
}

.cs-next__img,
.cs-grid__img,
.cs-cards__img {
  display: block;
}

.cs-next__img img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.cs-next__body {
  display: block;
  min-width: 0;
}

.cs-next__k {
  display: flex;
  gap: 0.8em;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.cs-next__k .en {
  letter-spacing: 0.06em;
}

.cs-next__name {
  display: block;
  margin: 0.3em 0 0.55em;
  font-size: clamp(1.8rem, 8.5vw, 2.6rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: 0;
  color: var(--ink);
}

/* 下一位的開場引言預告：保留詩的斷行，最多三行，多的補刪節號。 */
.cs-next__line {
  display: block;
  font-size: 0.86em;
  line-height: 1.75;
  color: var(--text);
}

.cs-next__line .ln:nth-child(n + 4),
.cs-cards__line .ln:nth-child(n + 4) {
  display: none;
}

.cs-next__line .ln:nth-child(3):not(:last-child)::after,
.cs-cards__line .ln:nth-child(3):not(:last-child)::after {
  content: "⋯";
}

.cs-next__arrow {
  margin-left: auto;
  font-family: var(--en);
  font-size: 1.3rem;
  line-height: 1;
  letter-spacing: 0;
  color: var(--ink);
  transition: transform 0.4s var(--ease);
}

.cs-next:hover .cs-next__arrow {
  transform: translateX(4px);
}

.cs-more__title {
  display: flex;
  justify-content: space-between;
  margin-top: 2.4em;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.24em;
  color: var(--muted);
}

.cs-more__title .en {
  letter-spacing: 0.08em;
}

.cs-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 8px;
  margin-top: 1.1em;
}

.cs-grid a {
  display: block;
}

.cs-grid__img img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  transition: opacity 0.3s;
}

.cs-grid a[aria-current] .cs-grid__img {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.cs-grid__no,
.cs-grid__name {
  display: block;
  line-height: 1.3;
}

.cs-grid__no {
  margin-top: 0.7em;
  font-size: 11px;
  color: var(--muted);
}

.cs-grid__name {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--ink);
}

/* ---- 頁尾 ---- */
.cs-foot {
  margin-top: 4em;
  padding: 3em var(--gutter) calc(2.6em + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  text-align: center;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.9;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.cs-foot__logo {
  display: block;
  width: 72px;
  aspect-ratio: 497.03 / 513.24;
  margin: 0 auto 1.4em;
  background: var(--ink);
  -webkit-mask: url("/then-now/assets/logotype.svg") center / contain no-repeat;
  mask: url("/then-now/assets/logotype.svg") center / contain no-repeat;
}

.cs-foot .en {
  letter-spacing: 0.06em;
}

.cs-foot__links {
  display: flex;
  justify-content: center;
  gap: 1.8em;
  margin-top: 0.8em;
}

.cs-foot__links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 5px;
}

/* ---- 目錄頁 ---- */
.cs-hero--index .cs-hero__copy {
  background: transparent;
  padding-bottom: 2.8em;
}

.cs-index {
  padding: 2.8em var(--gutter) 0;
}

.cs-cards {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.4em 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.cs-cards a {
  display: block;
}

.cs-cards__img img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.cs-cards__no {
  display: block;
  margin-top: 0.9em;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.cs-cards__name {
  display: block;
  margin-top: 0.2em;
  line-height: 1.3;
  color: var(--ink);
}

.cs-cards__name .en {
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.cs-cards__name .zh {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.cs-cards__line {
  display: block;
  margin-top: 0.6em;
  font-size: 0.78em;
  line-height: 1.75;
  color: var(--text);
}

/* 目錄頁卡片：做過的醫美項目 */
.cs-cards__tag {
  display: block;
  margin-top: 0.55em;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
}

/* 贊助品牌換成 logo（then-now 首頁贊助單位那組 SVG，build 時內嵌、填色用項目的字色） */
.cs-cards__tag--logo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.75em;
  margin-top: 0.5em;
}

/* logo 的 SVG 上下有留白，字母高約框高的四成；手機 20px 時字母和旁邊卡片的文字項目差不多大 */
.cs-logo {
  --h: 20px;
  display: block;
  flex: none;
  width: calc(var(--h) * var(--r));
  height: var(--h);
  overflow: visible;
}

@media (min-width: 640px) {
  .cs-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 3em 20px;
  }

  .cs-cards__tag--logo {
    margin-top: 0.35em;
  }

  .cs-logo {
    --h: 24px;
  }
}

@media (min-width: 900px) {
  .cs-cards {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---- 手機第一屏：照片、名字、開場引言的前兩行都要在 iPhone Safari 的可視範圍（約 390×664）內 ---- */
@media (max-width: 899px) {
  .cs--case .cs-hero__img img {
    max-height: 56svh;
  }

  .cs--case .cs-hero__copy {
    padding-top: 1.5em;
  }

  /* 頂列已經有「此刻之痕 03/08」，手機不再重複一行 kicker。 */
  .cs--case .cs-kicker {
    display: none;
  }

  .cs--case .cs-name {
    margin-top: 0;
  }

  .cs--case .cs-lede {
    margin-top: 1.05em;
  }
}

/* ---- 軟斷行：只在手機斷 ---- */
@media (min-width: 600px) {
  br.sb {
    display: none;
  }
}

/* ---- 桌機開場（捲動模式）：左文右圖，整塊用照片的底色；翻頁模式的封面在最後另外排 ---- */
@media (min-width: 900px) {
  html:not(.bk) .cs--case .cs-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min(46vw, 80svh);
    grid-template-rows: auto 1fr;
    min-height: 100svh;
  }

  html:not(.bk) .cs--case .cs-bar {
    grid-column: 1;
    grid-row: 1;
  }

  html:not(.bk) .cs--case .cs-hero__img {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  html:not(.bk) .cs--case .cs-hero__img img {
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
  }

  html:not(.bk) .cs--case .cs-hero__copy {
    grid-column: 1;
    grid-row: 2;
    align-self: end;
    padding: 0 clamp(2rem, 5vw, 5rem) 10svh;
    background: transparent;
    color: var(--on-backdrop, var(--ink));
  }

  html:not(.bk) .cs--case .cs-hero__copy > * {
    margin-inline: 0;
  }

  html:not(.bk) .cs--case .cs-hero .cs-kicker {
    color: inherit;
  }

  /* 棚拍背景有漸層，照片左緣淡進底色，不留一條接縫。 */
  html:not(.bk) .cs--case .cs-hero__img img {
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12%);
    mask-image: linear-gradient(90deg, transparent 0, #000 12%);
  }

  /* 桌機詩行短、集中在欄的左半：右靠的照片和文字左緣齊，左靠的明確往外推。 */
  .cs-story > .ph--right,
  .cs-end > .ph--right {
    margin-left: calc((100% - var(--col)) / 2);
    margin-right: auto;
  }

  .cs-story > .ph--left,
  .cs-end > .ph--left {
    margin-left: max(var(--gutter), (100% - var(--col)) / 2 - 200px);
  }

  html:not(.bk) .cs-bar {
    padding-inline: clamp(2rem, 5vw, 5rem);
  }
}

/* ================================================================
 * 翻頁模式（html.bk）
 * 頁首的小段 script 在 JS 能跑時加上 .bk，book.js 把內容切成一頁一頁（.bk-page）疊在 .bk-book 裡，
 * 組好之後加 .bk-ready。組好之前只露封面，不閃出整篇長文；組不起來四秒後退回捲動模式。
 * ================================================================ */
html.bk,
html.bk body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html.bk body {
  background: var(--paper-deep);
}

html.bk main {
  height: 100%;
}

html.bk:not(.bk-ready) .cs-story,
html.bk:not(.bk-ready) .cs-end,
html.bk:not(.bk-ready) .cs-more,
html.bk:not(.bk-ready) .cs-foot {
  display: none;
}

/* 捲動模式的淡入動畫在翻頁模式不用 */
html.bk [data-rv],
html.bk .ph[data-rv] img {
  animation: none !important;
}

/* 閱讀進度改成第幾頁／共幾頁，由 book.js 設 scaleX */
html.bk .cs-progress {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  width: min(100%, 560px);
  height: 2px;
  margin: 0 auto;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
  animation: none;
  transition: transform 0.5s var(--ease);
  pointer-events: none;
}

/* 書：手機全螢幕；平板、桌機是置中的一頁（最寬 560px）。 */
.bk-book {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: min(100%, 560px);
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
}

@media (min-width: 600px) {
  .bk-book {
    box-shadow: 0 0 70px rgba(42, 33, 26, 0.16);
  }
}

.bk-pages {
  position: absolute;
  inset: 0;
  /* 單指手勢全部交給 book.js（翻頁），雙指縮放留給瀏覽器 */
  touch-action: pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
}

.bk-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  visibility: hidden;
  padding: calc(env(safe-area-inset-top, 0px) + 52px) var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 76px);
  background: var(--paper);
  outline: none;
}

.bk-page.is-under {
  visibility: visible;
  z-index: 1;
}

.bk-page.is-cur {
  visibility: visible;
  z-index: 2;
}

.bk-page.is-turn {
  visibility: visible;
  z-index: 3;
}

/* 內容不滿一頁時垂直置中，滿了就從上面排 */
.bk-inner {
  width: 100%;
  margin-block: auto;
}

.bk-inner > * {
  width: min(100%, calc(var(--fs) * 28));
  margin-inline: auto;
}

.bk-inner > :first-child {
  margin-top: 0;
}

/* 平板、桌機一頁比較寬、詩行短，整塊依最長的一行置中，不要全擠在左半邊 */
@media (min-width: 600px) {
  .bk-page--text .bk-inner {
    width: fit-content;
    max-width: 100%;
  }

  .bk-page--text .bk-inner > * {
    width: auto;
  }
}

/* 封面：開場照填滿、名字與開場引言在下 */
html.bk .cs-hero {
  display: flex;
  flex-direction: column;
  height: 100%;
}

html.bk .cs-hero__img {
  flex: 1 1 auto;
  min-height: 0;
}

html.bk .cs-hero__img img {
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: auto;
  object-fit: cover;
  object-position: 50% 28%;
  -webkit-mask-image: none;
  mask-image: none;
}

html.bk .cs-hero__copy {
  flex: none;
  padding: 1.4em var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 72px);
  background: var(--paper);
  color: var(--ink);
}

html.bk .cs-kicker {
  display: none;
}

html.bk .cs-name {
  margin-top: 0;
}

html.bk .cs-lede {
  margin-top: 1em;
}

.bk-page--cover {
  padding: 0;
  background: var(--backdrop, var(--paper));
  color: var(--on-backdrop, var(--ink));
}

.bk-page--cover .bk-inner {
  width: 100%;
  height: 100%;
  margin: 0;
}

.bk-page--cover .bk-inner > * {
  width: 100%;
}

/* 照片頁：一張一頁，完整呈現不裁切 */
.bk-page--photo {
  padding-inline: 0;
}

.bk-page--photo .bk-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  margin: 0;
}

.bk-page--photo .bk-inner > .ph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: visible;
}

.bk-page--photo .ph img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: none;
}

.bk-page--photo .bk-inner > .ph--pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 8px;
  padding-inline: 8px;
}

.bk-page--photo .ph--pair figure,
.bk-page--photo .ph--pair img {
  height: auto;
  max-height: 100%;
}

/* 「那你呢？」 */
.bk-page--end {
  background: var(--paper-deep);
  text-align: center;
}

.bk-page--end .pt--open {
  margin-inline-start: 0;
}

/* 最後一頁：下一位、八人目錄、頁尾；放不下就在頁內上下捲 */
.bk-page--last {
  overflow-y: auto;
  touch-action: pan-y pinch-zoom;
  padding-top: calc(env(safe-area-inset-top, 0px) + 40px);
}

.bk-page--last .bk-inner {
  margin-block: 0 auto;
}

.bk-page--last .cs-more {
  padding: 0;
}

.bk-page--last .cs-foot {
  margin-top: 3em;
  padding: 2.4em 0 0;
}

/* ---- 翻頁：摺過來的紙背、兩側陰影（位置由 book.js 用 transform 設） ---- */
.bk-flap,
.bk-cast,
.bk-drop {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
}

.bk-book.is-turning .bk-flap,
.bk-book.is-turning .bk-cast,
.bk-book.is-turning .bk-drop {
  visibility: visible;
}

/* 紙背：左緣是翻起來的頁邊（亮），右緣是摺線（暗） */
.bk-flap {
  z-index: 5;
  width: 100%;
  transform-origin: 0 0;
  background: linear-gradient(90deg, #ece5d9 0%, #f6f1e8 42%, #fbf8f3 76%, #e6ddd0 92%, #cfc5b5 100%);
}

/* 紙背投在目前這頁上的影子（在翻起的頁邊左側） */
.bk-cast {
  z-index: 4;
  left: -40px;
  width: 40px;
  background: linear-gradient(90deg, rgba(42, 33, 26, 0), rgba(42, 33, 26, 0.16));
}

/* 摺線右側、落在下一頁上的影子 */
.bk-drop {
  z-index: 2;
  width: 64px;
  background: linear-gradient(90deg, rgba(42, 33, 26, 0.3), rgba(42, 33, 26, 0.08) 45%, rgba(42, 33, 26, 0));
}

/* ---- 頁碼、上下頁、捲動閱讀 ---- */
.bk-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto auto auto 1fr;
  align-items: center;
  height: 60px;
  padding-inline: var(--gutter);
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

.bk-nav > * {
  pointer-events: auto;
}

/* 最後一頁可以在頁內往下捲，頁碼列墊一層紙色，不疊在頁尾的字上 */
.bk-book[data-page="last"] .bk-nav {
  background: linear-gradient(to top, var(--paper) 70%, rgba(244, 239, 231, 0));
}

.bk-count {
  min-width: 5.2em;
  text-align: center;
  letter-spacing: 0.1em;
}

/* 封面還沒翻過之前，頁碼的位置顯示「滑動翻頁」，右箭頭輕輕往右推 */
.bk-count.is-hint {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.bk-count.is-hint + .bk-next span {
  animation: bk-nudge 1.6s var(--ease) infinite;
}

@keyframes bk-nudge {
  0%,
  60%,
  100% {
    transform: none;
  }
  30% {
    transform: translateX(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bk-count.is-hint + .bk-next span {
    animation: none;
  }
}

.bk-prev,
.bk-next {
  display: grid;
  place-items: center;
  width: 40px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--en);
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
}

.bk-prev:disabled,
.bk-next:disabled {
  opacity: 0.22;
  cursor: default;
}

.bk-prev:focus-visible,
.bk-next:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

/* 左「目錄」、右「捲動閱讀」 */
.bk-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  white-space: nowrap;
  color: var(--ink);
}

.bk-tool--index {
  justify-self: start;
}

.bk-tool--mode {
  justify-self: end;
  color: var(--muted);
}

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

/* 閱讀模式切換：只在 JS 能跑時出現，翻頁模式顯示「捲動閱讀」、捲動模式顯示「翻頁閱讀」 */
.cs-view {
  display: none !important;
}

html.js.bk .cs-view--scroll,
html.js:not(.bk) .cs-view--book {
  display: inline-flex !important;
}

/* ---- 小圖示（目錄、捲動、翻頁） ---- */
.cs-ico {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- 捲動模式的底部工具列：滑到哪裡都能回目錄、改成翻頁閱讀 ---- */
.cs-dock {
  display: none;
}

html:not(.bk) .cs-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: calc(52px + env(safe-area-inset-bottom, 0px));
  padding: 0 max(var(--gutter), (100% - 640px) / 2) env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--line);
  background: rgba(244, 239, 231, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

html:not(.bk) body.cs--case {
  padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
}

.cs-dock__tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink);
}
