/* ==========================================================================
   郭捷妤 · 舞者个人网站
   叙事：黑暗 → 破晓 → 绽放。页面背景随滚动由舞台黑过渡到天光白。
   本文件不依赖任何外部资源；字体自托管。
   ========================================================================== */

/* ---------- 自托管字体 ---------- */
@font-face {
  font-family: "LXGW WenKai";
  src: url("assets/fonts/lxgw-wenkai-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Serif SC";
  src: url("assets/fonts/noto-serif-sc-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- 设计变量 ---------- */
:root {
  /* 调色板：取自舞裙的钴蓝、群舞裙的琥珀，以及舞台黑与天光白 */
  --ink-black: #07080c;   /* 幕黑 */
  --ink-navy:  #121a2b;   /* 夜蓝 */
  --dusk:      #2a3547;   /* 破晓前的蓝灰 */
  --mist:      #6f7f93;   /* 雾灰 */
  --day:       #f4f1ea;   /* 天光白 */
  --cobalt:    #2f5fb3;   /* 钴蓝 */
  --amber:     #c8742a;   /* 琥珀 */

  /* 文字 */
  --text-on-dark: #ebe7df;
  --muted-on-dark: #a4acb9;
  --text-on-light: #1d2026;
  --muted-on-light: #5a6372;

  /* 由 app.js 按滚动进度写入的页面底色 */
  --sky: var(--ink-black);

  --font-kai: "LXGW WenKai", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --font-song: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "LXGW WenKai", serif;

  --gutter: clamp(20px, 6vw, 104px);
  --measure: 32em; /* 文字栏宽 */
  color-scheme: dark;
}
html.is-day { color-scheme: light; }

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sky);
  color: var(--text-on-dark);
  font-family: var(--font-song);
  font-size: 17px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; }
figure { margin: 0; }
a { color: inherit; }
::selection { background: var(--cobalt); color: var(--day); }

/* 键盘焦点始终可见 */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
}
html.is-day :focus-visible { outline-color: var(--cobalt); }

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: .5em 1em;
  background: var(--day);
  color: var(--text-on-light);
  z-index: 100;
}
.skip:focus { top: 12px; }

/* ---------- 页眉：固定在左上角的名字 ---------- */
.masthead {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  margin: 0;
  padding: 22px var(--gutter);
  font-family: var(--font-kai);
  line-height: 1.3;
  pointer-events: none;
  color: var(--text-on-dark);
  opacity: 0;                                  /* 序幕期间隐藏 */
  transition: color .6s ease, opacity .9s ease;
}
/* 序幕里已有大字姓名，页眉此时隐藏以免同屏撞名；
   滚过序幕后再淡入，成为长页面里持续的「签名」。
   is-past-prologue 由 app.js 在滚过序幕 70% 高度时加到 <html> 上。 */
html.is-past-prologue .masthead { opacity: 1; }
.masthead__name { margin: 0; font-size: 15px; letter-spacing: .3em; }
.masthead__tag  { margin: .2em 0 0; font-size: 11px; letter-spacing: .4em; opacity: .65; }
html.is-day .masthead { color: var(--text-on-light); }

/* ---------- 左缘光线标尺 ----------
   概念：一束光随滚动向下生长（琥珀 → 钴蓝）。
   两端用 mask 渐隐，避免出现「进度条」式的硬切端点。 */
.light-rail {
  position: fixed;
  top: 0;
  left: 0;
  width: 2px;
  height: 100vh;
  height: 100svh;
  z-index: 40;
  background: rgba(255, 255, 255, .06);
  pointer-events: none;
}
html.is-day .light-rail { background: rgba(29, 32, 38, .1); }
.light-rail__fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, var(--amber), var(--cobalt));
  transform-origin: top;
  transform: scaleY(var(--progress, 0));
  /* 顶端与末端各渐隐 14%，让光束「出现」与「收束」都是柔的 */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
}

/* ---------- 序幕：黑场，唯一一次编排入场 ---------- */
.prologue {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 55%;
  align-items: center;
  /* 序幕图有意向右出血 3vw（让羽化边伸到画面外）。用 overflow-x: clip 裁掉伸出的部分：
     clip 不创建滚动容器、不生成层叠上下文，所以不会把 .prologue__figure 的
     mix-blend-mode: lighten 关进盒子里（这点与 overflow: hidden 不同，务必不要改成 hidden）。
     任何 border-radius / overflow-y 都不要加在这里，会破坏 alpha 羽化。
     实测：1440 宽下 scrollWidth 由 1483 回到 1440，lighten 混合不受影响。 */
  overflow-x: clip;
}
.prologue__figure {
  grid-column: 2;
  justify-self: end;
  align-self: center;
  height: 92vh;
  height: 92svh;
  margin-right: -3vw; /* 轻微出血，让羽化边伸到画面之外 */
  /* 深色段落必须用 lighten：黑场舞台与页面背景取「较亮者」，羽化边才会真正溶入背景。
     数值依据（2026-12-06 Pillow 实测）：舞台照黑场为 (3,5,5)，比页面背景 #0d111b=(13,17,27)
     更黑；normal 会贴出 Δ≈19–22 的纯黑矩形，lighten 则精确抬平到 Δ=0。
     lighten 只抬平「比背景更黑」的像素，对亮部无影响（橙裙亮部两种混合结果一致），
     所以它没有副作用。它必须与「同行」段的近黑背景 #0d111b 配套：背景转亮后 lighten
     就不再能把黑场藏住，段落之间才允许过渡到蓝灰。
     注意：任何祖先若创建独立层叠上下文（isolation/transform/opacity<1/will-change），
     lighten 就只在该上下文内混合，羽化边会重新露出黑边——改样式时务必保留这条约束。 */
  mix-blend-mode: lighten;
}
.prologue__img {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
}
.prologue__text {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  position: relative;
  z-index: 2;
  padding: 0 var(--gutter) 0 var(--gutter);
  margin-top: -4vh;
}
.prologue__title {
  margin: 0;
  font-family: var(--font-kai);
  font-weight: 400;
  font-size: clamp(56px, 8.6vw, 132px);
  line-height: 1.12;
  letter-spacing: .1em;
  color: #f3efe6;
}
.prologue__intro {
  margin: 1.4em 0 0;
  font-family: var(--font-kai);
  font-size: clamp(17px, 1.5vw, 22px);
  letter-spacing: .14em;
  color: var(--muted-on-dark);
}
.prologue__hint {
  margin: 7vh 0 0;
  font-size: 12px;
  letter-spacing: .32em;
  color: var(--muted-on-dark);
  opacity: .7;
}

/* 入场编排：名字逐字对焦浮现，图片从黑里缓缓显影。
   起始态全部写在 @keyframes 的 from 里，元素默认可见——
   没有脚本时不会留下任何被隐藏的内容，也不需要内联脚本。 */
.prologue__char {
  display: inline-block;
  animation: char-in 1.1s cubic-bezier(.2, .65, .2, 1) both;
  animation-delay: calc(.45s + var(--i, 0) * .14s);
}
@keyframes char-in {
  from { opacity: 0; filter: blur(10px); transform: translateY(6px); }
  to   { opacity: 1; filter: blur(0);   transform: none; }
}
/* 未被拆字时（无脚本），名字整体淡入即可 */
.prologue__title:not(.is-split) { animation: fade-in 1.4s ease-out .3s both; }
.prologue__intro { animation: fade-in 1.4s ease-out 1.35s both; }
.prologue__hint  { animation: fade-in 1.6s ease-out 2.3s both; }
.prologue__figure { animation: develop 2.6s ease-out .25s both; }
@keyframes develop { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 章节通用 ---------- */
.chapter {
  position: relative;
  padding: 16vh var(--gutter) 14vh;
}
.chapter__head {
  max-width: var(--measure);
  margin: 0 0 9vh;
}
/* 章节序号：一根线 + 一个汉字数字，章节名交给下方的大标题 */
.chapter__mark {
  display: flex;
  align-items: center;
  gap: 1em;
  margin: 0 0 .9em;
  font-family: var(--font-kai);
  font-size: 15px;
  letter-spacing: .2em;
  color: var(--amber);
}
.chapter__mark::before {
  content: "";
  width: 2.6em;
  height: 1px;
  background: currentColor;
  opacity: .8;
}
.chapter__title {
  margin: 0;
  font-family: var(--font-kai);
  font-weight: 400;
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.35;
  letter-spacing: .12em;
}
.copy {
  max-width: var(--measure);
  margin: 10vh 0 0;
  font-size: clamp(16px, 1.25vw, 19px);
  line-height: 2.05;
  letter-spacing: .04em;
}
.copy p { margin: 0 0 1.1em; }
.copy p:last-child { margin-bottom: 0; }
/* 缩进用外边距而不是内边距，避免挤占 32em 的正文栏宽 */
.copy--indent-1 { margin-left: clamp(0px, 6vw, 96px); }
.copy--indent-2 { margin-left: clamp(0px, 12vw, 192px); }

/* 深色段落的 figure 由 app.js 铺一张 32px 的 lqip 作为「显影起点」。
   必须拉伸铺满且不重复，否则小图会平铺成一格格缩略图。
   lqip 是黑边 jpg，在 mix-blend-mode: lighten 下黑边等于透明，所以不会露出灰框。 */
.prologue__figure,
.duo__item,
.cluster__item {
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: center;
}

/* 滚动浮现：只做透明度与 ≤ 14px 的位移。
   隐藏态只在脚本给元素加上 will-reveal 时才成立，所以无脚本时内容始终可见。
   图片 figure 只淡入不位移：transform 会在过渡期间创建层叠上下文，
   让 lighten 混合短暂失效而露出黑边；文字块保留 14px 的轻微位移。 */
.will-reveal {
  opacity: 0;
  transition: opacity 1.25s ease-out;
  transition-delay: var(--d, 0ms);
}
.copy.will-reveal {
  transform: translateY(14px);
  transition:
    opacity 1.25s ease-out,
    transform 1.25s cubic-bezier(.2, .7, .2, 1);
}
.will-reveal.is-in { opacity: 1; transform: none; }

/* ---------- 一 · 暗场：两图交叠错落 ---------- */
.chapter--dusk,
.chapter--dark { color: var(--text-on-dark); }
.chapter--dusk .chapter__mark,
.chapter--dark .chapter__mark { color: var(--amber); }

.duo {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}
.duo__item {
  /* 深色段落：黑场与页面背景融为一体（理由与约束见 .prologue__figure） */
  mix-blend-mode: lighten;
}
.duo__item img { display: block; width: 100%; height: auto; }
/* 偏左下沉：更大，更低 */
.duo__item--sink {
  grid-area: 1 / 3 / 2 / 8;
  z-index: 1;
  margin-top: 18vh;
}
/* 偏右上浮：更小，更高，压在下沉那张的右上角（重叠约 15%） */
.duo__item--float {
  grid-area: 1 / 6 / 2 / 11;
  z-index: 2;
  justify-self: end;
  width: 80%;
  /* 不加 opacity<1：会在 figure 上创建层叠上下文，给 lighten 混合埋雷 */
}

/* ---------- 二 · 同行：横竖混排，基线不齐 ---------- */
.chapter--dusk {
  /* 顶光：来自舞台上方的一束钴蓝，极淡 */
  padding-bottom: 22vh; /* 与破晓之间留出长长的过渡带 */
  background:
    radial-gradient(ellipse 70% 38% at 68% 6%, rgba(47, 95, 179, .16), transparent 70%);
}
.cluster {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}
.cluster__item {
  /* 深色段落：黑场与页面背景融为一体（理由与约束见 .prologue__figure） */
  mix-blend-mode: lighten;
}
.cluster__item img { display: block; width: 100%; height: auto; }
.cluster__item--beams {
  grid-area: 1 / 1 / 2 / 6;   /* 与群舞交叠约两列 */
  z-index: 1;
  margin-top: 8vh;
  padding-left: 2vw;
}
.cluster__item--ensemble {
  grid-area: 1 / 4 / 2 / 9;
  z-index: 2;
}
.cluster__item--backstage-a {
  grid-area: 1 / 9 / 2 / 13;
  z-index: 3;
  justify-self: end;
  width: 84%;
  margin-top: 26vh;
}
.cluster__item--backstage-b {
  grid-area: 2 / 3 / 3 / 10;
  z-index: 4;
  width: 74%;
  margin-top: -8vh; /* 横幅上提，与第一行的底边轻轻交叠 */
}

/* ---------- 三 · 破晓：冷白，两图并置不等高 ---------- */
.chapter--dawn {
  padding-top: 24vh; /* 标题出现时，背景已经完全亮起来 */
  color: var(--text-on-light);
  /* 晨光：从章节顶部慢慢漫开的一片白 */
  background: linear-gradient(
    to bottom,
    rgba(244, 241, 234, 0) 0%,
    rgba(244, 241, 234, .55) 35%,
    rgba(244, 241, 234, 0) 70%
  );
}
.chapter--dawn .chapter__mark { color: var(--cobalt); }
.dawn {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
  column-gap: 2vw;
}
.dawn__item { /* 浅色段落：不再混合，让羽化边以自身的方式安静地结束 */
  mix-blend-mode: normal;
}
.dawn__item img { display: block; width: 100%; height: auto; }
.dawn__item--wall {
  grid-area: 1 / 2 / 2 / 6;
  z-index: 1;
  margin-top: 12vh;
}
.dawn__item--grass {
  grid-area: 1 / 7 / 2 / 11;
  z-index: 2;
}
.chapter--dawn .copy { color: var(--text-on-light); }
.chapter--dawn .copy--indent-2 { margin-top: 6vh; }

/* ---------- 尾声 ---------- */
.coda {
  position: relative;
  padding: 22vh var(--gutter) 16vh;
  color: var(--text-on-light);
  /* 下面的地平线故意向右伸出画面（right: -10vw），会撑出 39px 的横向滚动区域。
     用 clip 把伸出去的部分裁掉：线在末端本就渐变到透明，裁掉的部分不可见；
     clip 不创建滚动容器，不影响后代定位。实测移动端 scrollWidth 由 429 回到 390。 */
  overflow-x: clip;
}
.coda::before {
  /* 地平线：一根从左缘延伸到画面之外的细线 */
  content: "";
  position: absolute;
  left: var(--gutter);
  right: -10vw;
  top: 14vh;
  height: 1px;
  background: linear-gradient(to right, rgba(29, 32, 38, .28), rgba(29, 32, 38, 0));
}
/* 尾声只有一句短诗（联系方式待本人提供真实邮箱后再加）。
   短句是 h2：既是区块的无障碍标题，也承接原来的 coda-title 锚点。 */
.coda__line {
  margin: 0;
  max-width: 22em;
  font-family: var(--font-kai);
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: .12em;
}

/* ---------- 页脚 ---------- */
.colophon {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  padding: 0 var(--gutter) 32px;
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--muted-on-light);
}
.colophon p { margin: 0; }

/* ---------- 窄屏 ---------- */
@media (max-width: 860px) {
  :root { --gutter: clamp(20px, 7vw, 40px); }
  body { font-size: 16px; }

  .prologue {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    min-height: 100svh;
    padding-top: 14vh;
    align-items: end;
  }
  .prologue__figure {
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
    height: auto;
    width: 86%;
    margin: 0;
  }
  .prologue__img { width: 100%; height: auto; }
  .prologue__text {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    padding-top: 6vh;
    padding-bottom: 10vh;
  }
  .prologue__title { font-size: clamp(52px, 15vw, 84px); }
  .prologue__hint { margin-top: 4vh; }

  .chapter { padding: 12vh var(--gutter) 10vh; }
  .chapter--dusk { padding-bottom: 16vh; }
  .chapter--dawn { padding-top: 16vh; }
  .chapter__head { margin-bottom: 6vh; }

  .duo, .cluster, .dawn { display: block; }
  .duo__item, .cluster__item, .dawn__item { width: 100% !important; margin: 0 !important; padding: 0; }
  .duo__item--sink { width: 82% !important; }
  .duo__item--float { width: 72% !important; margin: -12vh 0 0 auto !important; }
  .cluster__item--beams { width: 70% !important; }
  .cluster__item--ensemble { width: 84% !important; margin: -14vh 0 0 auto !important; }
  .cluster__item--backstage-a { width: 66% !important; margin-top: -6vh !important; }
  .cluster__item--backstage-b { width: 88% !important; margin: 5vh 0 0 auto !important; }
  .dawn__item--wall { width: 74% !important; }
  .dawn__item--grass { width: 78% !important; margin: -10vh 0 0 auto !important; }

  .copy { margin-top: 7vh; }
  .copy--indent-1, .copy--indent-2 { margin-left: 0; }

  .coda { padding: 14vh var(--gutter) 10vh; }
  .coda__line { margin-bottom: 7vh; }
  .colophon { flex-direction: column; gap: .4em; }
}

/* ---------- 减少动态 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .prologue__char,
  .prologue__title,
  .prologue__intro,
  .prologue__hint,
  .prologue__figure {
    animation: none;
    opacity: 1;
    filter: none;
    transform: none;
  }
  .will-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .masthead { transition: none; }
}

/* ---------- 打印 ---------- */
@media print {
  .masthead, .light-rail, .prologue__hint, .skip { display: none; }
  body { background: #fff; color: #000; }
}
