/* ============================================================
   一帛入梦 · 一级首页样式
   纯 HTML/CSS/SVG，仅二维动效；手机优先，逐级增强。
   视觉语言沿用 ma+Javas：深色绢底、金/朱砂、grain 噪点、sticky 滚动。
   ============================================================ */

@font-face {
  font-family: "Painting";
  src: url("../fonts/painting-subset.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #0a0908;
  --ink-2: #14110f;
  --deep: #061c23;
  --rice: #e9e2d3;
  --rice-dim: #b8afa0;
  --gold: #b08d4f;
  --gold-dim: #7d6537;
  --cinnabar: #8f3a2c;
  --font-han: "Painting", "Songti SC", "STSong", serif;
  --font-song: "Songti SC", "STSong", serif;
  --font-label: Arial, "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html {
  /* 不用 smooth：跨页面带 hash 返回时，平滑滚动会使初始锚点定位失效（停在顶部）。
     auto 保证二级页返回后准确落位到对应入口。 */
  scroll-behavior: auto;
  scroll-padding-top: 0;
  overflow-x: hidden;
  background: var(--ink);
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--rice);
  font-family: var(--font-song);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: rgba(143, 58, 44, .45); color: var(--rice); }

/* ---------- grain 噪点（内联 SVG，无外部请求） ---------- */
.grain { position: relative; }
.grain::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: .18;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
}

.eyebrow {
  margin: 0;
  font: 400 10px/1.4 var(--font-label);
  letter-spacing: .28em;
  text-transform: uppercase;
  color: rgba(176, 141, 79, .85);
}

.section-heading { text-align: center; margin-bottom: 40px; }
.section-heading h2 {
  margin: 14px 0 0;
  font-family: var(--font-han);
  font-weight: 400;
  font-size: clamp(40px, 11vw, 64px);
  letter-spacing: .16em;
}
.section-heading > p:last-child {
  max-width: 560px;
  margin: 16px auto 0;
  font-size: 13px;
  line-height: 1.9;
  color: var(--rice-dim);
}

/* ============================================================
   固定页眉 / 章节菜单 / 侧轨
   ============================================================ */
.site-header {
  position: fixed;
  z-index: 90;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 20px 18px;
  pointer-events: none;
}
.site-brand, .menu-button, .menu-close { pointer-events: auto; cursor: pointer; }

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-han);
  font-size: 17px;
  letter-spacing: .18em;
}
.seal {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 34px;
  font-size: 19px;
  color: #f2dcc2;
  background: var(--cinnabar);
  border: 1px solid #bc624c;
}

.menu-button, .menu-close {
  font: 400 12px/1 var(--font-song);
  letter-spacing: .2em;
  padding: 8px 4px;
  user-select: none;
}
.menu-toggle { position: fixed; left: -10000px; }

.chapter-overlay {
  position: fixed;
  z-index: 85;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 28px 34px;
  background: rgba(10, 9, 8, .96);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity .5s ease, transform .5s ease, visibility .5s;
  pointer-events: none;
}
.menu-toggle:checked ~ .chapter-overlay {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.chapter-overlay .menu-close { position: absolute; top: 24px; right: 24px; }
.chapter-overlay ol { width: min(720px, 100%); }
.chapter-overlay li a {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: baseline;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.chapter-overlay li span {
  font: 400 10px/1 var(--font-label);
  letter-spacing: .25em;
  color: var(--gold-dim);
}
.chapter-overlay li strong {
  font-family: var(--font-han);
  font-weight: 400;
  font-size: clamp(26px, 7vw, 40px);
  letter-spacing: .12em;
}
.chapter-overlay li small {
  font-size: 11px;
  letter-spacing: .15em;
  color: rgba(184, 175, 160, .6);
}
.chapter-overlay li a:hover strong { color: var(--gold); }

@media (max-height: 500px) {
  .chapter-overlay {
    align-items: start;
    overflow-y: auto;
    padding: 3rem clamp(1rem, 4vw, 1.75rem) .75rem;
  }
  .chapter-overlay .menu-close { top: .8rem; right: 1rem; }
  .chapter-overlay li a {
    min-height: 2.75rem;
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    gap: .65rem;
    padding: .32rem 0;
  }
  .chapter-overlay li strong { font-size: clamp(1.15rem, 5.5svh, 1.6rem); }
}


.chapter-rail { display: none; }

/* ============================================================
   01 序章
   ============================================================ */
.prologue-section { background: var(--ink); }

/* 首屏 */
.hero-scene {
  position: relative;
  height: 100svh;
  min-height: 600px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-bg {
  position: absolute;
  inset: -15%;
  background: linear-gradient(#02161b26, transparent 22%, #031b2012 55%, #03191e99 100%),
    url("../assets/backgrounds/intro.webp") center / cover;
  filter: none;
}
.hero-haze {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, #03141918);
}
.hero-copy {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 0 28px;
  max-width: 680px;
  animation: hero-rise 1.8s ease-out both;
}
.hero-copy h1 {
  margin: 22px 0 0;
  font-family: var(--font-han);
  font-weight: 400;
  font-size: clamp(58px, 16vw, 110px);
  letter-spacing: .18em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .6);
}
.hero-sub {
  margin: 26px 0 0;
  font-size: clamp(15px, 4vw, 19px);
  letter-spacing: .14em;
  line-height: 1.9;
}
.hero-note {
  margin: 22px auto 0;
  font-size: 12px;
  line-height: 1.9;
  color: rgba(192, 196, 182, .75);
  max-width: 460px;
}

.scroll-cue {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
}
.scroll-cue span {
  font-size: 11px;
  letter-spacing: .3em;
  color: rgba(184, 175, 160, .8);
}
.scroll-cue i {
  width: 1px;
  height: 44px;
  background: linear-gradient(to bottom, rgba(176, 141, 79, .8), transparent);
  animation: cue-pulse 1.8s ease-in-out infinite;
}

/* 下沉五段 */
.prologue-shaft {
  position: relative;
  height: 420vh;
  view-timeline-name: --shaft;
  view-timeline-axis: block;
}
.shaft-sticky {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 600px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shaft-image {
  position: absolute;
  inset: 0;
  background: url("../assets/backgrounds/intro.webp") center/cover;
  opacity: .3;
  transform: scale(1.2);
}
.shaft-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(10, 9, 8, .3) 0%, rgba(10, 9, 8, .85) 78%);
}
.shaft-beats {
  position: relative;
  z-index: 5;
  width: min(680px, 88vw);
}
.shaft-beat {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  opacity: 0;
  transform: translateY(22px);
}
.shaft-beat h2 {
  margin: 0;
  font-family: var(--font-han);
  font-weight: 400;
  font-size: clamp(40px, 10vw, 64px);
  color: var(--gold);
}
.shaft-beat p {
  margin: 0;
  font-size: clamp(16px, 4.2vw, 21px);
  line-height: 2;
  letter-spacing: .06em;
}
.beat-1 { opacity: 1; transform: none; }

@supports (animation-timeline: view()) {
  .shaft-image { animation: shaft-zoom 1s linear both; animation-timeline: --shaft; animation-range: cover 0% cover 100%; }
  .shaft-vignette { animation: shaft-dark 1s linear both; animation-timeline: --shaft; animation-range: cover 0% cover 100%; }
  .shaft-beat { animation: shaft-beat 1s ease both; animation-timeline: --shaft; }
  .beat-1 { animation-range: cover 0% cover 20%; }
  .beat-2 { animation-range: cover 18% cover 40%; }
  .beat-3 { animation-range: cover 38% cover 60%; }
  .beat-4 { animation-range: cover 58% cover 80%; }
  .beat-5 { animation-range: cover 78% cover 100%; }
}

@keyframes shaft-zoom {
  from { transform: scale(1.2); filter: blur(0); }
  to { transform: scale(.75); filter: blur(4px); }
}
@keyframes shaft-dark {
  from { background: radial-gradient(ellipse at center, rgba(10,9,8,.3) 0%, rgba(10,9,8,.85) 78%); }
  to { background: radial-gradient(ellipse at center, rgba(10,9,8,.55) 0%, rgba(10,9,8,.95) 78%); }
}
@keyframes shaft-beat {
  0% { opacity: 0; transform: translateY(20px); }
  22%, 68% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-12px); }
}
@keyframes hero-rise {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cue-pulse {
  0%, 100% { opacity: .35; transform: scaleY(.7); transform-origin: top; }
  50% { opacity: 1; transform: scaleY(1); }
}

/* ============================================================
   02 五境入口
   ============================================================ */
.realms-section {
  background: var(--ink);
  padding: 96px 20px 100px;
}
.realms-inner { width: min(1200px, 100%); margin: 0 auto; }

.realm-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.realm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 18px 24px;
  text-align: center;
  background: var(--ink-2);
  border: 1px solid rgba(176, 141, 79, .18);
  transition: transform .5s ease, border-color .5s ease, background .5s ease;
  min-height: 44px;
}
.realm-art {
  width: 100%;
  height: 200px;
  margin: 0 0 12px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  background: rgba(6, 28, 35, .5);
}
.realm-art img {
  max-height: 100%;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .5));
  transition: transform .6s ease;
}
.realm-index {
  font-family: var(--font-han);
  font-size: 22px;
  color: var(--gold);
}
.realm-card strong {
  font-family: var(--font-han);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: .2em;
}
.realm-question {
  font-size: 14px;
  letter-spacing: .08em;
  color: var(--rice-dim);
}
.realm-enter {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: .25em;
  color: var(--gold);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .4s ease, transform .4s ease;
}
.realm-card:hover, .realm-card:focus-visible {
  transform: translateY(-6px);
  border-color: rgba(176, 141, 79, .55);
  background: #181512;
}
.realm-card:hover .realm-art img, .realm-card:focus-visible .realm-art img { transform: scale(1.06); }
.realm-card:hover .realm-enter, .realm-card:focus-visible .realm-enter {
  opacity: 1;
  transform: translateY(0);
}
.realm-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ============================================================
   03 帛画解码推荐
   ============================================================ */
.decode-section {
  background: linear-gradient(180deg, #160b07 0%, #100806 100%);
  padding: 96px 20px 100px;
}
.decode-inner { width: min(960px, 100%); margin: 0 auto; }

.decode-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.decode-card {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(19, 13, 11, .8);
  border: 1px solid rgba(176, 141, 79, .22);
  transition: transform .45s ease, border-color .45s ease, background .45s ease;
}
.decode-card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .5));
}
.decode-no {
  font: 400 11px/1 var(--font-label);
  letter-spacing: .2em;
  color: var(--gold-dim);
}
.decode-q {
  font-family: var(--font-han);
  font-size: clamp(18px, 5vw, 24px);
  letter-spacing: .08em;
}
.decode-go {
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--gold);
  opacity: .65;
}
.decode-card:hover, .decode-card:focus-visible {
  transform: translateX(6px);
  border-color: rgba(176, 141, 79, .6);
  background: #241410;
}
.decode-card:hover .decode-go { opacity: 1; }
.decode-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ============================================================
   04 尾章
   ============================================================ */
.epilogue-section {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--ink);
  padding: 100px 24px;
}
.epilogue-bg {
  position: absolute;
  inset: 0;
  background: url("../assets/backgrounds/heaven.webp") center/cover;
  opacity: .22;
}
.epilogue-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--ink), rgba(10, 9, 8, .55), var(--ink));
}
.epilogue-copy {
  position: relative;
  z-index: 5;
  width: min(620px, 92vw);
  text-align: center;
}
.epilogue-banner {
  width: min(260px, 62vw);
  margin: 0 auto 30px;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .6));
}
.epilogue-copy h2 {
  margin: 0 0 20px;
  font-family: var(--font-han);
  font-weight: 400;
  font-size: clamp(32px, 8vw, 48px);
  letter-spacing: .14em;
}
.epilogue-copy p {
  font-size: 14px;
  line-height: 2.2;
  color: var(--rice-dim);
}
.re-explore {
  display: inline-block;
  margin-top: 34px;
  padding: 12px 30px;
  font-family: var(--font-han);
  font-size: 16px;
  letter-spacing: .2em;
  color: var(--rice);
  border: 1px solid var(--gold);
  transition: background .4s ease, color .4s ease;
}
.re-explore:hover, .re-explore:focus-visible {
  background: var(--gold);
  color: var(--ink);
}
.re-explore:focus-visible { outline: 2px solid var(--rice); outline-offset: 3px; }

/* ============================================================
   响应式：平板（≥700）
   ============================================================ */
@media (min-width: 700px) {
  .site-header { padding: 24px 38px; }
  .realms-section, .decode-section { padding: 110px 32px 120px; }
  .realm-grid { grid-template-columns: repeat(2, 1fr); gap: 22px; }
  .realm-grid li:nth-child(5) { grid-column: 1 / -1; max-width: 50%; justify-self: center; width: 100%; }
  .realm-art { height: 240px; }
  .decode-list { gap: 16px; }
  .decode-card { padding: 18px 24px; }
  .decode-card img { width: 84px; height: 84px; }
}

/* ============================================================
   响应式：桌面（≥1024）
   ============================================================ */
@media (min-width: 1024px) {
  .site-header { padding: 24px 40px; }
  .realms-section, .decode-section { padding: 128px 40px 130px; }
  .realm-grid { grid-template-columns: repeat(5, 1fr); gap: 16px; }
  .realm-grid li:nth-child(5) { grid-column: auto; max-width: none; }
  .realm-art { height: 220px; }
  .realm-card { padding: 20px 14px 26px; }

  /* 桌面侧轨 */
  .chapter-rail {
    position: fixed;
    z-index: 80;
    right: 30px;
    top: 50%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    transform: translateY(-50%);
  }
  .chapter-rail a { display: flex; align-items: center; gap: 10px; }
  .chapter-rail span {
    opacity: 0;
    font-size: 11px;
    letter-spacing: .2em;
    color: var(--rice-dim);
    transition: opacity .4s ease;
  }
  .chapter-rail i {
    width: 16px;
    height: 1px;
    background: rgba(184, 175, 160, .4);
    transition: width .4s ease, background .4s ease;
  }
  .chapter-rail a:hover span { opacity: .8; }
  .chapter-rail a:hover i { width: 30px; background: var(--gold); }

  body:has(#prologue:target) .chapter-rail a[href="#prologue"] span,
  body:has(#realms:target) .chapter-rail a[href="#realms"] span,
  body:has(#decode:target) .chapter-rail a[href="#decode"] span,
  body:has(#epilogue:target) .chapter-rail a[href="#epilogue"] span {
    opacity: 1; color: var(--gold);
  }
  body:has(#prologue:target) .chapter-rail a[href="#prologue"] i,
  body:has(#realms:target) .chapter-rail a[href="#realms"] i,
  body:has(#decode:target) .chapter-rail a[href="#decode"] i,
  body:has(#epilogue:target) .chapter-rail a[href="#epilogue"] i {
    width: 30px; background: var(--gold);
  }
}

/* ============================================================
   减少动态偏好
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .shaft-beat { opacity: 0; }
  .beat-1 { opacity: 1; }
  .realm-enter { opacity: 1; transform: none; }
}

/* 序幕近景沿旧版两侧拨苇的轨迹随滚动退出。 */
.hero-reed {
  position: absolute;
  bottom: -28%;
  max-width: none;
  z-index: 2;
  pointer-events: none;
  filter: none;
}
.hero-reed-left { width: 100%; left: -40%; rotate: 5deg; }
.hero-reed-right { width: 80%; right: -30%; }
@media (max-width: 760px) {
  .hero-reed { bottom: -8%; opacity: .7; }
  .hero-reed-left { width: 180%; left: -85%; }
  .hero-reed-right { width: 150%; right: -75%; }
}
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reed-opening { height: 300svh; view-timeline-name: --reed-opening; }
    .hero-scene { position: sticky; top: 0; min-height: 0; }
    .hero-reed-left { animation: opening-reeds-left linear both; }
    .hero-reed-right { animation: opening-reeds-right linear both; }
    .hero-bg { animation: opening-landscape linear both; }
    .hero-reed, .hero-bg {
      animation-timeline: --reed-opening;
      animation-range: contain 0% contain 100%;
    }
  }
}
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) { .reed-opening { height: 280svh; } }
}
@keyframes opening-landscape {
  from { transform: scale(1); }
  to { transform: scale(1.8) translateY(-8%); filter: none; }
}
@keyframes opening-reeds-left {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-15%, 20%) scale(1.6); }
  100% { transform: translate(-70%, 50%) scale(2.3); }
}
@keyframes opening-reeds-right {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20%, 20%) scale(1.6); }
  100% { transform: translate(80%, 50%) scale(2.4); }
}
