﻿/* ============================================================
   江湖來信 · 开场屏
   一切颜色、字号、时长都来自 tokens.css，这里不写死数值。
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--serif);
  background:
    radial-gradient(120% 90% at 34% 26%,
      var(--paper-hi) 0%,
      var(--paper) 44%,
      var(--paper-lo) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── 纸面：水渍与纤维 ──────────────────────────────────── */

.paper {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.wash {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--stain), transparent 68%);
  filter: blur(46px);
  mix-blend-mode: multiply;
  opacity: 0;
  animation: stain var(--dur-stain) var(--ease-ink) forwards;
}

.w1 { width: 62vmax; height: 48vmax; left: -22vmax; top: -20vmax; animation-delay: .1s; }
.w2 { width: 38vmax; height: 44vmax; right: -14vmax; top: 18vh; animation-delay: .35s;
  border-radius: 46% 54% 52% 48% / 48% 46% 54% 52%;
  background:
    radial-gradient(ellipse at 50% 50%,
      rgba(107,92,69,.10) 0%,
      rgba(107,92,69,.16) 56%,
      rgba(107,92,69,.42) 64%,
      rgba(107,92,69,.10) 70%,
      transparent 74%);
  filter: none;
  mix-blend-mode: multiply;
}
.w3 { width: 54vmax; height: 30vmax; left: 22vw; bottom: -18vmax; animation-delay: .55s; }

@keyframes stain {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: .052; transform: scale(1); }
}

.fiber {
  position: absolute;
  inset: -60px;
  background-image: url("img/paper.webp");
  background-size: 512px 512px;
  opacity: .5;
  pointer-events: none;
}

.grain {
  display: none;
  position: absolute;
  inset: -120px;
  mix-blend-mode: multiply;
  opacity: .36;
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'>\
<filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='4' stitchTiles='stitch'/>\
<feColorMatrix type='saturate' values='0'/></filter>\
<rect width='240' height='240' filter='url(%23n)' opacity='0.075'/></svg>");
  background-size: 240px 240px;
  animation: drift var(--dur-drift) linear infinite;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-240px, -240px, 0); }
}

/* ── 装裱角线与书口暗记 ────────────────────────────────── */

.ticks { position: fixed; inset: 18px; pointer-events: none; }
.t {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 0 solid var(--ink-16);
}
.tl { left: 0;  top: 0;    border-left-width: 1px;  border-top-width: 1px; }
.tr { right: 0; top: 0;    border-right-width: 1px; border-top-width: 1px; }
.bl { left: 0;  bottom: 0; border-left-width: 1px;  border-bottom-width: 1px; }
.br { right: 0; bottom: 0; border-right-width: 1px; border-bottom-width: 1px; }

.mark {
  position: fixed;
  top: 38px;
  right: 38px;
  writing-mode: vertical-rl;
  font-family: var(--han);
  font-size: 15px;
  letter-spacing: .42em;
  color: var(--ink-64);
  padding: 14px 8px 18px;
  border: 1px solid var(--ink-16);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--ink-12);
  background: rgba(250, 246, 236, .38);
  opacity: 0;
  animation: fadein 2s var(--ease-ink) 1.4s forwards;
  user-select: none;
}

/* ── 舞台：重心偏左上 ──────────────────────────────────── */

.stage {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: clamp(54px, 8vh, 92px) var(--pad-stage-right) clamp(46px, 6.5vh, 74px) var(--pad-stage-left);
}

.lines { display: grid; place-items: start; }

.intro, .after {
  grid-area: 1 / 1;
  margin: 0;
  max-width: min(680px, 100%);
  transition: opacity .7s var(--ease-ink), transform .7s var(--ease-ink);
}

.intro { display: grid; gap: .52em; }

.l1, .l2 { display: block; }

.l1 {
  font-family: var(--display);
  font-size: var(--fs-open-1);
  line-height: 1.32;
  color: var(--ink);
  opacity: 0;
  animation: rise var(--dur-rise) var(--ease-ink) .25s forwards;
}

.l2 {
  font-family: var(--display);
  font-style: italic;
  font-size: var(--fs-open-2);
  line-height: 1.45;
  color: var(--ink-64);
  opacity: 0;
  animation: rise var(--dur-rise) var(--ease-ink) .5s forwards;
}

/* 起笔的朱砂：只动 transform 与 opacity，不碰 width */
.intro::before {
  content: "";
  display: block;
  width: 36px;
  height: 2px;
  margin-bottom: .9em;
  background: var(--cinnabar);
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  animation: brush var(--dur-brush) var(--ease-ink) .15s forwards;
}

.intro.gone {
  transition-duration: .34s; opacity: 0; transform: translateY(-10px); }

.after {
  font-family: var(--display);
  font-size: var(--fs-after);
  line-height: 1.4;
  color: var(--ink-80);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1s var(--ease-ink), transform 1s var(--ease-ink);
}

.after.in {
  transition-delay: .12s; opacity: 1; transform: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

@keyframes brush {
  from { transform: scaleX(0); opacity: .4; }
  to   { transform: scaleX(1); opacity: 1; }
}

@keyframes fadein { to { opacity: 1; } }

/* 门槛：四件物就摆在这道折痕上，它不是分隔线，是地 */
.shelf { position: relative; width: 100%; }

.threshold {
  position: absolute;
  left: calc(var(--pad-stage-left) * -1);
  bottom: -9px;
  width: 100vw;
  height: 1px;
  background: linear-gradient(90deg, var(--ink-16) 0%, var(--ink-08) 62%, transparent 96%);
  box-shadow: 0 1px 0 var(--crease-light);
  transform: rotate(-.5deg);
  transform-origin: left center;
  opacity: 0;
  animation: fadein 1.6s var(--ease-ink) .65s forwards;
  pointer-events: none;
}

/* ── 四件物：摆出来的，不是排出来的 ────────────────────── */

.things {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  opacity: 0;
  animation: rise 1.2s var(--ease-ink) .7s forwards;
}

/* 四件物摊开占满整条纸面，靠大小与角度制造不平齐 */

/* 抖动放在图上、不放在字上：四行小字因此能对齐在同一基线 */
a.thing { text-decoration: none; color: inherit; }

.thing {
  transform: translateY(var(--dy, 0)) scale(var(--s, 1));
  appearance: none;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .7s var(--ease-ink), transform .7s var(--ease-ink);
}

.thing svg {
  transform: translateY(var(--dy, 0)) rotate(var(--rot, 0deg)) scale(var(--s, 1));
  transform-origin: 50% 100%;
  transition: transform .7s var(--ease-ink), opacity .5s var(--ease-ink);
  width: clamp(116px, 8.8vw + 66px, 190px);
  height: auto;
  display: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
  filter: url(#ink);
  transition: opacity .5s var(--ease-ink);
}

/* 笔锋轻重 + 压纸的暗影 */
.thing svg .heavy   { stroke-width: 2.3;  color: var(--ink); }
.thing svg .whisper { stroke-width: 1.05; opacity: .72; }
.thing svg .fade    { opacity: .58; stroke-width: 1.35; }
.thing svg .fade2   { opacity: .34; stroke-width: 1.1; }

.thing svg .ground {
  fill: var(--ink-08);
  stroke: none;
  opacity: 0;
  animation: fadein 1.2s var(--ease-ink) 1.4s forwards;
}

.thing svg path,
.thing svg circle {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw var(--dur-draw) var(--ease-ink) forwards;
}

.thing:nth-child(1) svg path,
.thing:nth-child(1) svg circle { animation-delay: .95s; }
.thing:nth-child(2) svg path,
.thing:nth-child(2) svg circle { animation-delay: 1.10s; }
.thing:nth-child(3) svg path,
.thing:nth-child(3) svg circle { animation-delay: 1.25s; }
.thing:nth-child(4) svg path,
.thing:nth-child(4) svg circle { animation-delay: 1.40s; }

@keyframes draw { to { stroke-dashoffset: 0; } }

/* 名字只在你选中之后才出现 */
.tag {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-tag);
  color: var(--ink-64);
  white-space: nowrap;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  opacity: .4;
  transform: none;
  transition: opacity .45s var(--ease-ink), transform .45s var(--ease-ink),
              border-color .45s var(--ease-ink), color .45s var(--ease-ink);
}

.thing:hover,
.thing:focus-visible { color: var(--ink); outline: none; }

.thing:hover svg,
.thing:focus-visible svg {
  transform: translateY(calc(var(--dy, 0px) - 6px)) rotate(var(--rot, 0deg)) scale(var(--s, 1));
}

.thing:hover .tag,
.thing:focus-visible .tag {
  opacity: 1;
  transform: none;
  color: var(--ink-80);
  border-bottom-color: var(--cinnabar);
}

/* 选了一件，其余三件退到暗处 */
.things.picked .thing { opacity: .13; pointer-events: none; }

.things.picked .thing svg { transform: translateY(var(--dy, 0)) rotate(var(--rot, 0deg)) scale(.92); }

.things.picked .thing.is-picked { opacity: 1; }

.things.picked .thing.is-picked svg {
  transform: translateY(calc(var(--dy, 0px) - 6px)) rotate(var(--rot, 0deg)) scale(var(--s, 1));
}

.things.picked .thing.is-picked .tag {
  opacity: 1;
  transform: none;
  color: var(--ink-80);
  border-bottom-color: var(--cinnabar);
}

/* ── start over：纸上一行小字，不是按钮 ────────────────── */

.again {
  position: fixed;
  left: var(--pad-stage-left);
  bottom: 48px;
  appearance: none;
  background: none;
  border: 0;
  padding: 6px 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-tag);
  color: var(--ink-40);
  cursor: pointer;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .7s var(--ease-ink), transform .7s var(--ease-ink), color .3s;
}

.again.in { opacity: 1; transform: none; }
.again:hover, .again:focus-visible { color: var(--ink-80); outline: none; }

/* ── 朱砂方印：有刀口、盖得略歪 ────────────────────────── */

.seal {
  position: fixed;
  right: clamp(26px, 4.4vw, 60px);
  bottom: clamp(26px, 4.4vw, 58px);
  width: clamp(36px, 2.6vw, 42px);
  aspect-ratio: 1;
  transform: rotate(-3.8deg) scale(1.22);
  mix-blend-mode: multiply;
  opacity: 0;
  animation: press var(--dur-seal) var(--ease-stamp) 2.1s forwards;
  user-select: none;
  pointer-events: none;
}

.seal svg { width: 100%; height: 100%; display: block; overflow: visible; }

.seal-bg    { fill: var(--cinnabar); }
.seal-carve { fill: none; stroke: var(--paper); stroke-width: 1.35; opacity: .86; }
.seal-chip  { fill: var(--paper); }

.seal-char {
  font-family: var(--han);
  font-weight: 600;
  font-size: 24px;
  fill: var(--paper-hi);
  opacity: .93;
}

@keyframes press {
  to { opacity: .9; transform: rotate(-3.8deg) scale(1); }
}

/* ── 窄屏 ──────────────────────────────────────────────── */

@media (max-width: 760px) {
  .ticks { inset: 11px; }
  .mark  { top: 32px; right: 24px; font-size: 12px; letter-spacing: .40em; }

  .stage {
    padding: 82px 26px 148px 28px;
    justify-content: space-between;
    gap: 0;
  }

  .intro, .after { max-width: 19ch; }

  .threshold {
    left: -28px;
    bottom: 22px;
  }

  /* 手机上是双阶散落，不是四格并排 */
  .things {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
    row-gap: 18px;
    width: 100%;
    align-items: end;
  }

  .thing-letter, .thing-lamp, .thing-mirror { margin-right: 0; }

  .thing-letter { justify-self: start; }
  .thing-lamp   { justify-self: center; }
  .thing-mirror { justify-self: center; }
  .thing-river  { justify-self: end; }

  .thing svg { width: clamp(84px, 24vw, 104px); }
  .tag { font-size: 11px; letter-spacing: .15em; }
  .again { left: 28px; bottom: 34px; }
}

@media (hover: none) {
  .tag { opacity: .5; transform: none; }
  .things.picked .thing.is-picked .tag { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .wash { opacity: .052 !important; animation: none; }
  .grain, .l1, .l2, .mark, .threshold, .things, .thing svg .ground { animation: none; opacity: 1; }
  .seal { animation: none; opacity: .9; transform: rotate(-3.8deg) scale(1); }
  .thing svg path, .thing svg circle { animation: none; stroke-dashoffset: 0; }
  .intro::before { transform: scaleX(1); opacity: 1; animation: none; }
  * { transition-duration: .01ms !important; }
}

@media (min-width: 761px) {
  .l1, .l2 { white-space: nowrap; }
}

/* ── 折痕：这封信待会儿要折的地方，不是装饰 ───────────── */

/* 折痕不是一根线，是一道起伏：上沿有纸的亮边，下沿有压在下面的暗影。
   高度只有 22px，靠的是明暗关系，不是描边。 */
.paper::before {
  content: "";
  position: absolute;
  left: -8vw;
  width: 116vw;
  top: 31vh;
  height: 22px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(250, 245, 236, 0.62) 42%,
    var(--ink-08) 54%,
    rgba(23, 19, 14, 0.03) 76%,
    transparent 100%
  );
  /* 真纸的折痕不会顶到两条边，两端要溶进纸里 */
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
  transform: rotate(-0.7deg) scaleY(0.7);
  opacity: 0;
  animation: crease-in 1.9s var(--ease-paper) .45s forwards,
             crease-breathe 18s var(--ease-ink) 2.6s infinite alternate;
  pointer-events: none;
}

@keyframes crease-in {
  from { opacity: 0;   transform: translateY(-5px) rotate(-1.4deg) scaleY(0.36); }
  to   { opacity: 1;   transform: translateY(0)    rotate(-0.7deg) scaleY(0.7); }
}

@keyframes crease-breathe {
  from { opacity: 1;    transform: translateY(0)     rotate(-0.7deg)  scaleY(0.7); }
  to   { opacity: .72;  transform: translateY(1.5px) rotate(-0.62deg) scaleY(0.92); }
}

@media (max-width: 760px) { .paper::before { top: 44vh; } }

@media (prefers-reduced-motion: reduce) {
  .paper::before { animation: none; opacity: 1; transform: rotate(-0.7deg) scaleY(0.7); }
}
/* 照片版：?photo 生效，用图片替掉线稿 */
.obj { display: none; height: var(--h, 140px); width: auto; filter: grayscale(.45) contrast(1.02); }
body.photos .obj { display: block; }
body.photos .thing svg { display: none; }
body.photos .thing { width: auto; }

/* 木刻版：?print */
body.print .obj { display: block; }
body.print .thing svg { display: none; }
body.print .thing { width: auto; }
body.print .obj { filter: contrast(1.06) saturate(.9); }
/* 木刻版：?print */
.obj-pr { display: none; height: var(--h, 190px); width: auto; }
.obj { display: none; }
body.print .obj { display: none; }
body.print .obj-pr { display: block; }
body.print .thing svg { display: none; }
body.print .thing { width: auto; }
/* 速写版：?sketch（默认） */
.obj-sk { display: block; height: var(--h, 255px); width: auto; }
body.sketch .obj, body.sketch .obj-pr { display: none; }
body.sketch .obj-sk { display: block; }
body.line .obj-sk, body.photos .obj-sk, body.print .obj-sk { display: none; }
body.line .thing svg { display: block; }
body.line .obj, body.line .obj-pr { display: none; }
body.sketch .thing svg { display: none; }
body.sketch .thing { width: auto; }

/* ── 错落散置：底线齐、只留一点上下差，批注落在同一条基线上 ── */
.things { align-items: flex-end; }
.thing-letter { transform: translateY(-9px); }
.thing-lamp   { transform: translateY(5px); }
.thing-mirror { transform: translateY(-5px); }
.thing-river  { transform: translateY(2px); }

.marginalia {
  display: block;
  margin: 8px 0 0;
  max-width: 30ch;
  min-height: 34px;
  font-family: var(--display);
  font-style: italic;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-40);
  text-align: left;
  transition: color .5s var(--ease-ink), opacity .5s var(--ease-ink);
}
.thing:hover .marginalia,
.thing:focus-visible .marginalia { color: var(--ink-80); }
.things.picked .thing:not(.is-picked) .marginalia { opacity: 0; }


/* ── 手机：取消错落、缩小器物、隐藏批注，保证一屏四件 ── */
@media (max-width: 760px) {
  .thing-letter, .thing-lamp, .thing-mirror, .thing-river {
    transform: none !important;
    margin: 0 !important;
  }
  .obj-sk { height: auto !important; max-height: 128px; max-width: min(100%, 158px); }
  .thing { justify-content: center; }
  .marginalia { display: none; }
}


/* ── 中国味回补：压灰、左对齐、汉字暗记、竖乌丝栏 ── */
.obj-sk { filter: grayscale(.35) contrast(1.10); }
.thing-letter .obj-sk {
  -webkit-mask-image: radial-gradient(118% 118% at 50% 46%, #000 56%, transparent 80%);
  mask-image: radial-gradient(118% 118% at 50% 46%, #000 56%, transparent 80%);
}
.thing { text-align: left; align-items: flex-start; }
.han {
  display: inline-block;
  margin-bottom: .28em;
  font-family: var(--han);
  font-size: 12.5px;
  letter-spacing: .12em;
  color: var(--ink-40);
  margin-right: .55em;
}
.cap { display: block; width: 100%; border-left: 1px solid var(--ink-14); padding-left: 10px; text-align: left; }
.tag { display: block; margin-bottom: .34em; }
.marginalia { display: block; }
.mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 16px);
  width: 1px;
  height: min(54vh, 430px);
  background: linear-gradient(180deg, var(--ink-16), transparent 92%);
}




/* 回到门口 */
.backdoor {
  position: fixed;
  left: clamp(18px, 3.2vw, 34px);
  bottom: clamp(14px, 2.6vh, 26px);
  font-family: var(--display);
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--ink-40);
  text-decoration: none;
  opacity: .75;
  transition: opacity .4s var(--ease-ink), color .4s var(--ease-ink);
}
.backdoor:hover { opacity: 1; color: var(--ink-70); }
a.mark { text-decoration: none; color: inherit; }


/* 背景层绝对不能吃点击（伪元素的 pointer-events 不随父级继承，必须单写） */
.bg, .bg::before, .bg::after { pointer-events: none !important; }


/* 隐藏 Netlify 免费版角标（注入元素，选择器多写几个兜底） */
#netlify-badge, .netlify-badge, [data-netlify-badge],
a[href*="netlify.com"][target="_blank"] { display: none !important; }

#nl-badge-frame, #netlify-badge, .netlify-badge { display: none !important; }


/* ── 微交互：平时完全静止，只有指针靠过来才动 ──────────────── */
.thing {
  --mx: 50%; --my: 50%; --rx: 0deg; --ry: 0deg;
  position: relative;          /* 伪元素的定位基准，缺了它光会跑到页面别处 */
  perspective: 620px;
}

.thing .obj-sk {
  transform-origin: 50% 88%;
  transition: transform .5s var(--ease-paper), filter .5s var(--ease-ink);
  will-change: transform;
}

/* 四件物共用的"轻微立体跟随"——只动图，不动字 */
.thing:hover .obj-sk,
.thing:focus-visible .obj-sk {
  transform: rotateX(var(--rx)) rotateY(var(--ry)) translateY(-3px) scale(1.012);
}

/* ① 灯的焰心暖光：暂缓——伪元素的定位基准会随版式变，先把位置算准再加 */

/* ② 镜：一道很淡的反光跟着指针扫过镜面 */
.thing-mirror::after {
  content: ""; position: absolute; inset: 12% 18% 34% 18%;
  border-radius: 50%;
  background: radial-gradient(circle 46px at var(--mx) var(--my),
      rgba(255,252,245,.55) 0%, rgba(248,242,230,.18) 44%, transparent 76%);
  mix-blend-mode: soft-light; opacity: 0; pointer-events: none;
  transition: opacity .4s var(--ease-ink);
}
.thing-mirror:hover::after,
.thing-mirror:focus-visible::after { opacity: 1; }

/* ③ 河：拨水——指针划过时水面被置换，停下就平息 */
.thing-river .obj-sk { filter: url(#river-ripple) grayscale(.3) contrast(1.06); }

/* 底板：触屏上不要有 hover 残留 */
@media (hover: none) {
  .thing-lamp::after, .thing-mirror::after { display: none; }
  .thing:hover .obj-sk { transform: none; }
}



/* 已经装了绫边，四角线不再需要 */
.ticks { display: none !important; }
