﻿/* styles.css 里有 body { overflow: hidden }，那是单屏时代的写法，会锁死滚动 */
html { height: auto; overflow-y: auto; }
body {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y proximity;
}

.flow { position: relative; z-index: 3; }
.leaf {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: center;
  scroll-snap-align: start;
}

/* —— 第一页：一句话 + 门外远景 —— */
.leaf-a { padding: 0 clamp(26px, 11vw, 190px); }
.leaf-a .lines { max-width: min(920px, 100%); }

.far {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.far img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 58%;
  opacity: .5;
  filter: grayscale(.12) contrast(.96);
  transition: opacity .9s var(--ease-ink, ease), object-position 1.1s var(--ease-ink, ease);
  -webkit-mask-image: linear-gradient(180deg, transparent 2%, rgba(0,0,0,.22) 26%, #000 56%);
  mask-image: linear-gradient(180deg, transparent 2%, rgba(0,0,0,.22) 26%, #000 56%);
  /* 兜底：就算视频没播，这张纸也一直在极慢地呼吸 */
  animation: far-breathe 48s ease-in-out infinite alternate;
}

@keyframes far-breathe {
  from { transform: scale(1.00); }
  to   { transform: scale(1.035); }
}
@media (prefers-reduced-motion: reduce) { .far img { animation: none; } }


/* 第二页的小字压在岸线上，给一层纸光，别让字糊在山水里 */
.leaf-b .cap { color: var(--ink-60); }
.leaf-b .marginalia { color: var(--ink-50); }
.leaf-b .cap,
.leaf-b .marginalia {
  text-shadow: 0 0 6px var(--paper), 0 0 14px var(--paper), 0 0 22px var(--paper);
}

.cue {
  position: absolute;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  display: grid; justify-items: center; gap: 10px;
  pointer-events: none;
}
.cue i {
  width: 1px; height: 40px;
  background: linear-gradient(180deg, transparent, var(--ink-24));
  animation: cue-drift 3.6s ease-in-out infinite alternate;
}
.cue span {
  font-family: var(--display);
  font-size: 10.5px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--ink-40);
}
@keyframes cue-drift {
  from { transform: translateY(0);   opacity: .35; }
  to   { transform: translateY(9px); opacity: .95; }
}

/* —— 第二页：四件物，大件 —— */
.leaf-b { padding: 0 clamp(20px, 6vw, 96px); }
.leaf-b .things {
  width: 100%;
  justify-content: space-between;
  align-items: flex-end;
}
.leaf-b .thing { transform: none !important; }
.leaf-b .obj-sk {
  height: min(36vh, 330px) !important;
  width: auto;
  max-width: 100%;
}
.leaf-b .shelf { width: 100%; }
.leaf-b .cap { margin-top: 22px; }

@media (max-width: 760px) {
  body { scroll-snap-type: none; }
  .leaf-a { padding: 0 26px; }
  .far { height: 62%; }
  .leaf-b { padding: 0 18px; }
  /* 手机上 2 列会把每件压到 170px，太小；改成一行一件、名在右 */
  .leaf-b .things {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-content: center;
  }
  .leaf-b .thing {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    width: 100%;
  }
  .leaf-b .obj-sk {
    height: auto !important;
    width: 58vw;
    max-width: 250px;
    max-height: none;
  }
  .leaf-b .cap {
    margin: 0;
    text-align: left;
    font-size: 16px;
    line-height: 1.5;
  }
  .leaf-b .marginalia { display: none; }
}


/* 远景的第二层：一段自己流动的水（ComfyUI 图生视频，前后互接的无缝环） */
.far video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 58%;
  opacity: 0;
  filter: grayscale(.12) contrast(.96);
  transition: opacity 1.4s var(--ease-ink, ease), object-position 1.1s var(--ease-ink, ease);
}
body.has-video .far video { opacity: .58; }
body.has-video .far img { opacity: 0; }


body.on-b.has-video .far img { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .far video { display: none; }
  body.has-video .far img { opacity: .5; }
  body.on-b.has-video .far img { opacity: .28; }
}

/* 雾：两层贴图以不同速度横移，山和水都不动 */
.fog {
  position: absolute;
  inset: -18% -34%;
  background-image: url("img/fog.webp");
  background-repeat: repeat;
  background-size: 1400px auto;
  pointer-events: none;
  opacity: .34;
  -webkit-mask-image: linear-gradient(180deg, transparent 33%, #000 41%, #000 60%, transparent 67%);
  mask-image: linear-gradient(180deg, transparent 33%, #000 41%, #000 60%, transparent 67%);
  animation: fog-a 9s ease-in-out infinite alternate;
}
.fog--b {
  opacity: .26;
  background-size: 2100px auto;
  animation: fog-b 13s ease-in-out infinite alternate;
}
@keyframes fog-a { from { transform: translate3d(-22vw,0,0) scale(1.06); } to { transform: translate3d(22vw,0,0) scale(1.06); } } to { transform: translate3d(13vw,0,0); } }

/* 第二页 = 纯纸面：远景与雾整层收回，切图不再和背景打架 */
/* 翻到第二页：两块底逐渐退，不要瞬移 */
.far { transition: opacity 1.1s var(--ease-ink, ease); }
.fog { transition: opacity 1.1s var(--ease-ink, ease); }





/* ── 第二页布局：按 Gemini 数值（近景 380 / 远景 330，间距 38:62:32，纵向 -54/+48/-42/+54） ── */
@media (min-width: 769px) {
  .leaf-b .things {
    justify-content: flex-start;
    align-items: flex-end;
    width: min(94vw, 1382px);
    gap: 0;
  }
  .leaf-b .thing { flex: 0 0 auto; }
  .leaf-b .thing-letter { margin-right: 26px; }
  .leaf-b .thing-lamp   { margin-right: 44px; }
  .leaf-b .thing-mirror { margin-right: 22px; }

  
  
  .leaf-b .thing-lamp   .obj-sk { width: 250px; height: auto; }
  .leaf-b .thing-river  .obj-sk { width: 250px; height: auto; }
  .leaf-b .cap { margin-top: -16px; }
}

/* ── 动效：按 Gemini 数值（14s / 19s，±13vw，0.18→0.62→0.22，只作用在湖腰 36%–64%） ── */
.fog, .fog--b {
  inset: 30% -40% 30% -40% !important;
  background-image: none !important;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%) !important;
  mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%) !important;
}
.fog {
  background: radial-gradient(ellipse 62% 58% at 50% 50%, var(--paper-hi) 0%, rgba(248,242,230,.55) 45%, transparent 78%);
  animation: fog-a 9s ease-in-out infinite alternate;
}
.fog--b {
  background: radial-gradient(ellipse 54% 50% at 50% 50%, var(--paper) 0%, rgba(242,235,221,.45) 48%, transparent 76%);
  animation: fog-b 13s ease-in-out infinite alternate;
}
@keyframes fog-a { from { transform: translate3d(-22vw,0,0) scale(1.06); } to { transform: translate3d(22vw,0,0) scale(1.06); } } to { transform: translate3d(13vw,0,0); } }
@keyframes fog-b { from { transform: translate3d(18vw,0,0) scale(1.02); } to { transform: translate3d(-18vw,0,0) scale(1.02); } } to { transform: translate3d(-11vw,0,0); } }

/* 第一页的核心入口：写一句就是你来的那件事 */
.ask {
  display: flex; align-items: center; gap: 14px;
  justify-content: center;
  width: min(90vw, 760px) !important; max-width: 760px;
  margin: clamp(26px, 4.6vh, 48px) auto 0;
  padding-left: 0; border-left: 0;
}
.ask__label { font-family: var(--serif); font-style: italic; font-size: 0.98rem; color: var(--ink-48); white-space: nowrap; }
.ask__input {
  flex: 1; min-width: 0; background: transparent; border: 0; border-bottom: 1px solid var(--ink-16);
  font-family: var(--serif); font-size: 1.12rem; color: var(--ink); padding: 8px 2px;
}
.ask__input::placeholder { color: var(--ink-40); font-style: italic; }
.ask__input:focus { outline: none; border-bottom-color: var(--cinnabar); }
.ask__go {
  background: transparent; border: 0; cursor: pointer;
  font-family: var(--serif); font-size: 1rem; letter-spacing: .08em; color: var(--cinnabar); padding: 6px 8px;
}
@media (max-width: 560px) { .ask { flex-wrap: wrap; } .ask__label { width: 100%; white-space: normal; } }


/* ── 山腰流云：单向横穿，有明确亮部前缘（比原地往返的噪声更容易被看见） ── */
.fog-cloud {
  position: fixed; left: -20vw; right: -20vw; top: 44%; height: 26vh;
  pointer-events: none; z-index: 1; opacity: .55;
  background-image: linear-gradient(90deg,
      rgba(252,249,242,0) 0%, rgba(252,249,242,.42) 18%,
      rgba(252,249,242,.06) 34%, rgba(252,249,242,0) 50%,
      rgba(23,19,14,.05) 66%, rgba(252,249,242,.30) 82%, rgba(252,249,242,0) 100%);
  background-size: 240% 100%;
  background-repeat: no-repeat;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 42%, #000 58%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 42%, #000 58%, transparent 100%);
  animation: sheen-pass 46s linear infinite;
}
@keyframes sheen-pass { from { background-position: -60% 0; } to { background-position: 160% 0; } }

  18%  { opacity: .74; }
  80%  { opacity: .70; }
  100% { transform: translate3d(85vw, -0.8vh, 0); opacity: 0; }
}

/* 湖面波光先关掉：那排竖条看着像"波"，反而假
.lake-ripple {
  position: fixed; left: 0; right: 0; top: 50%; height: 15vh;
  pointer-events: none; z-index: 1; opacity: .40;
  background-image: repeating-linear-gradient(90deg,
      transparent 0px, rgba(252,249,242,.55) 38px, transparent 86px,
      rgba(23,19,14,.045) 132px, transparent 180px);
  background-size: 360px 100%;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 70%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 70%, transparent 100%);
  animation: water-flow 11s linear infinite;
}
@keyframes water-flow { from { background-position: 0 0; } to { background-position: 360px 0; } }
*/


/* 第二页回到纸面：线稿和山水不搭，封面才要远景 */

body.on-b .mount { opacity: .9; }


/* 写信这一行：让容器真正占满整行，再居中 */
.leaf-a { justify-items: stretch; }
.leaf-a .lines { width: 100%; }
.leaf-a .ask {
  position: relative; left: auto; transform: none;
  width: min(88vw, 760px) !important; max-width: 760px;
  margin-left: auto !important; margin-right: auto !important;
}


/* ── 寄出：整张纸往右上飘走，方向与 reading 页折信落下的起点一致 ── */
body.is-sending .flow {
  pointer-events: none;
  transform: translate3d(34px, -46px, 0) rotate(3deg);
  opacity: 0;
  transition: transform .70s ease, opacity .55s ease;
}

/* ── 从信页返回：不再重播 2 秒开场，0.55s 内就位 ── */
body.is-return .wash,
body.is-return .l1,
body.is-return .l2,
body.is-return .mark,
body.is-return .things,
body.is-return .ask,
body.is-return .cue {
  animation-delay: 0s !important;
  animation-duration: .55s !important;
  transition-delay: 0s !important;
}
body.is-return .fog, body.is-return .fog-cloud {
  position: fixed; left: -20vw; right: -20vw; top: 44%; height: 26vh;
  pointer-events: none; z-index: 1; opacity: .55;
  background-image: linear-gradient(90deg,
      rgba(252,249,242,0) 0%, rgba(252,249,242,.42) 18%,
      rgba(252,249,242,.06) 34%, rgba(252,249,242,0) 50%,
      rgba(23,19,14,.05) 66%, rgba(252,249,242,.30) 82%, rgba(252,249,242,0) 100%);
  background-size: 240% 100%;
  background-repeat: no-repeat;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 42%, #000 58%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 42%, #000 58%, transparent 100%);
  animation: sheen-pass 46s linear infinite;
}
@keyframes sheen-pass { from { background-position: -60% 0; } to { background-position: 160% 0; } }

/* 第二页：背景不消失，只是退后半步，让人看出是同一个院子 */
body.on-b .far { opacity: .30; object-position: 50% 100%; }
body.on-b .fog { opacity: .18; }
body.on-b .fog-cloud {
  position: fixed; left: -20vw; right: -20vw; top: 44%; height: 26vh;
  pointer-events: none; z-index: 1; opacity: .55;
  background-image: linear-gradient(90deg,
      rgba(252,249,242,0) 0%, rgba(252,249,242,.42) 18%,
      rgba(252,249,242,.06) 34%, rgba(252,249,242,0) 50%,
      rgba(23,19,14,.05) 66%, rgba(252,249,242,.30) 82%, rgba(252,249,242,0) 100%);
  background-size: 240% 100%;
  background-repeat: no-repeat;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 42%, #000 58%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 42%, #000 58%, transparent 100%);
  animation: sheen-pass 46s linear infinite;
}
@keyframes sheen-pass { from { background-position: -60% 0; } to { background-position: 160% 0; } }

/* 四件物：铺满整行、底边对齐、垂直居中 */
.leaf-b .shelf { display: flex; align-items: center; justify-content: center; min-height: 74svh; }
.leaf-b .things { width: min(92vw, 1320px); justify-content: space-between; align-items: flex-end; }
.leaf-b .thing { flex: 0 0 auto; }
.leaf-b .cap { margin-top: 16px; }

/* 四件：等高、底边对齐、整行居中（不再上下错落） */
.leaf-b .obj-sk { height: min(34vh, 312px) !important; max-width: min(22vw, 300px); translate: none; scale: none; }
.leaf-b .things { align-items: flex-end; }
.leaf-b .shelf { min-height: 84svh; align-items: center; }
.leaf-b .cap { margin-top: 18px; }

/* 印在纸上，而不是贴上去：正片叠底让亮部吃进纸色，再压一点暖 */
.leaf-b .obj-sk {
  mix-blend-mode: multiply;
  opacity: .96;
  filter: sepia(.10) saturate(.88) contrast(.96);
}

/* 第一页：标题在上三分之一，写信在正中——核心功能占画面中心 */
.leaf-a { position: relative; display: block; }
.leaf-a .lines { position: absolute; left: clamp(26px, 9vw, 150px); top: 17svh; width: min(80vw, 900px); }
.leaf-a .ask {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -34%);
  width: min(86vw, 900px) !important; max-width: 900px !important;
  margin: 0 !important; display: block; text-align: center;
}
.leaf-a .ask__label {
  display: block; font-family: var(--serif); font-style: italic;
  font-size: 1.06rem; color: var(--ink-70); margin-bottom: 18px;
}
.leaf-a .ask__row {
  display: flex; align-items: center; gap: 18px;
  border-bottom: 1px solid rgba(23,19,14,.24); padding-bottom: 14px;
}
.leaf-a .ask__row:focus-within { border-bottom-color: rgba(23,19,14,.46); }
.leaf-a .ask input.ask__input {
  flex: 1 1 auto; min-width: 0; background: transparent; border: 0; outline: none;
  font-family: var(--serif); font-size: 1.62rem; color: var(--ink); padding: 8px 2px;
}
.leaf-a .ask input.ask__input::placeholder { color: var(--ink-45); font-size: 1.42rem; }
.leaf-a .ask .ask__go {
  flex: 0 0 auto; font-family: var(--serif); font-size: 1.18rem; letter-spacing: .10em;
  color: var(--cinnabar); background: transparent; border: 0; cursor: pointer; padding: 8px 12px;
}
.leaf-a .cue { position: absolute; left: 50%; bottom: 6svh; transform: translateX(-50%); }

.leaf-a .ask__hint { margin: 12px 0 0; text-align: center; font-family: var(--serif);
  font-style: italic; font-size: .84rem; color: var(--ink-45); letter-spacing: .01em; }
