:root {
  color: #22302f;
  background: #f2f0e8;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-synthesis: none;
  --red: #9f4a45;
  --ink: #203130;
  --paper: #f5f0d9;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; overflow-x: hidden; }
button, a { color: inherit; }
button { font: inherit; }
body.locked { overflow: hidden; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: .18;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.17'/%3E%3C/svg%3E");
}

.archive-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 47% 12%, rgba(255,255,255,.98), transparent 30%),
    linear-gradient(90deg, rgba(93,111,103,.02) 1px, transparent 1px),
    #f2f0e8;
  background-size: auto, 7px 7px, auto;
  position: relative;
}

.site-header {
  height: 74px;
  border-bottom: 1px solid rgba(37,52,50,.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3.3vw;
  letter-spacing: .15em;
  position: relative;
  z-index: 2;
}
.brand { font-family: Georgia, serif; font-size: 15px; font-weight: 700; text-decoration: none; letter-spacing: .18em; }
.brand span { display: block; margin-top: 4px; font-size: 6px; letter-spacing: .36em; font-weight: 400; }
.index-counter { text-align: right; font-family: "Special Elite", monospace; font-size: 7px; line-height: 1.7; }
.index-counter span, .index-counter b { display: block; }
.index-counter b { letter-spacing: .22em; }

.hero { min-height: calc(100vh - 116px); display: grid; grid-template-columns: 29% 71%; align-items: center; padding: 2vh 3.3vw 4vh; }
.intro { align-self: center; max-width: 335px; transform: translateY(-2vh); }
.section-code { color: var(--red); font-family: "Special Elite", monospace; font-size: 8px; letter-spacing: .12em; margin-bottom: 27px; }
.intro h1 { margin: 0; font-weight: 500; font-size: clamp(35px, 3vw, 58px); letter-spacing: .06em; line-height: 1; }
.intro h2 { font-size: 11px; letter-spacing: .15em; margin: 13px 0 0; font-weight: 500; }
.intro p { font-size: 9px; line-height: 2.1; margin: 33px 0 37px; letter-spacing: .05em; max-width: 300px; }
.browse-cue { display: flex; align-items: center; gap: 10px; font-family: "Special Elite", monospace; font-size: 7px; letter-spacing: .18em; }
.browse-cue i { border: 1px solid #61716e; width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; font-style: normal; transition: transform .3s; }
.intro:hover .browse-cue i { transform: rotate(-45deg); }

.file-stack {
  height: min(62vw, 720px);
  min-height: 500px;
  position: relative;
  pointer-events: none;
  perspective: 1250px;
  perspective-origin: 47% 42%;
  transform-style: preserve-3d;
  touch-action: pan-y;
  user-select: none;
}
.file-stack::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 2%;
  right: -4%;
  bottom: 8.5%;
  height: 18%;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(56,50,37,.24) 0%, rgba(82,73,50,.11) 42%, transparent 72%);
  filter: blur(11px);
  transform: rotateX(72deg) translateZ(-120px);
  transform-origin: center bottom;
}
.file-card {
  --card-w: clamp(215px, 19.5vw, 365px);
  position: absolute;
  top: auto;
  bottom: 9%;
  left: calc(var(--card-x) + var(--stack-offset, 0%));
  width: var(--card-w);
  aspect-ratio: .69;
  border: 1px solid rgba(77,72,53,.24);
  border-radius: 3px 3px 2px 2px;
  background:
    radial-gradient(ellipse at 46% 38%, rgba(255,255,255,.64) 0%, rgba(255,255,255,.14) 51%, rgba(120,99,57,.08) 100%),
    linear-gradient(100deg, rgba(255,255,255,.38), transparent 28%),
    var(--paper);
  box-shadow:
    8px 2px 0 #d8d1bb,
    11px 3px 2px rgba(80,73,55,.12),
    14px 24px 26px rgba(57,55,45,.17),
    inset -12px 0 20px rgba(108,91,55,.055),
    inset 0 -14px 24px rgba(108,91,55,.04);
  transform: translateX(-50%) translateZ(var(--depth)) rotateY(var(--yaw)) rotateZ(var(--roll)) scale(var(--card-scale));
  transform-origin: 50% 100%;
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
  will-change: transform, left;
  color: var(--ink);
  transition:
    transform .82s cubic-bezier(.16,.84,.2,1),
    left .82s cubic-bezier(.16,.84,.2,1),
    filter .45s,
    box-shadow .55s;
  z-index: calc(10 - var(--i));
  overflow: hidden;
}
.file-card, .file-card * { cursor: pointer; }
.file-card::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(98,84,50,.018) 3px 4px); pointer-events: none; }
.folder-tab { position: absolute; inset: 0 0 auto 0; height: 19%; border-bottom: 1px solid rgba(92,83,59,.18); border-radius: 0 0 26px 26px / 0 0 13px 13px; box-shadow: 0 8px 12px rgba(81,69,41,.035); }
.mark { position: absolute; width: 74%; left: 13%; top: 11%; }
.mark-strands .cord {
  filter: drop-shadow(0 1px .45px rgba(36, 48, 47, .28));
}
.mark-strands.is-untying .cord--left { animation: cord-release-left .68s both; }
.mark-strands.is-untying .cord--right { animation: cord-release-right .68s both; }
@keyframes cord-release-left {
  0%, 72% { opacity: 1; transform: translate(0, 0); }
  100% { opacity: .18; transform: translate(-2px, 5px); }
}
@keyframes cord-release-right {
  0%, 72% { opacity: 1; transform: translate(0, 0); }
  100% { opacity: .18; transform: translate(2px, 5px); }
}
.file-label { position: absolute; z-index: 2; top: 51%; left: 14%; width: 72%; min-height: 16%; background: rgba(248,246,229,.93); border: 1px solid #6d7671; display: grid; place-content: center; gap: 3px; box-shadow: 5px 7px 0 rgba(58,67,62,.07); }
.file-label::before, .file-label::after { content: "+"; position: absolute; font: 8px monospace; color: #7f8b87; }
.file-label::before { left: -5px; top: -6px; }.file-label::after { right: -5px; bottom: -6px; }
.file-label b { font-size: clamp(11px, 1.12vw, 21px); font-weight: 500; letter-spacing: .08em; }
.file-label small { font: clamp(5px, .38vw, 7px) "Special Elite", monospace; letter-spacing: .16em; color: #6b716e; }
.file-meta { position: absolute; bottom: 7.5%; left: 14%; color: var(--red); font: 6px "Special Elite", monospace; letter-spacing: .16em; }
.file-card.is-active {
  /* 唯一的档案转正入口；不要合并 :hover，React 的固定命中轨道才是状态真源。 */
  transform: translateX(-50%) translateY(-2%) translateZ(210px) rotateY(0) rotateZ(0) scale(1.48);
  z-index: 30;
  box-shadow: 10px 2px 0 #d8d1bb, 25px 38px 50px rgba(57,55,45,.28), inset -11px 0 18px rgba(108,91,55,.045);
}
.file-stack.is-dragging .file-card,
.file-stack.is-dragging .file-card * {
  /* 拖动必须立即跟手，left 不能保留普通 Hover 的 .82s 过渡。 */
  cursor: grabbing;
}
.file-stack.is-dragging .file-card {
  transition: transform .18s ease, left 0s, filter .18s, box-shadow .18s;
}
.file-stack.is-wheeling .file-card {
  /* 滚轮保留极短缓动来吸收离散刻度，但不能像 Hover 那样滞后。 */
  transition: transform .18s ease, left .12s linear, filter .18s, box-shadow .18s;
}
.file-card.is-opening { pointer-events: none; transition-duration: .42s; }
.file-card:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 5px;
}
.file-card.is-receding { filter: saturate(.76) brightness(.985); }

footer { height: 42px; border-top: 1px solid rgba(37,52,50,.15); display: flex; justify-content: space-between; align-items: center; padding: 0 3.3vw; font: 6px "Special Elite", monospace; letter-spacing: .16em; }

.opening-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.opening-layer::before { content: ""; position: absolute; inset: 0; background: rgba(242,240,232,0); transition: background .46s .34s; }
.opening-layer.is-expanded::before { background: rgba(242,240,232,.97); }
.letter-sheet {
  position: absolute;
  left: var(--from-x); top: var(--from-y); width: var(--from-w); height: var(--from-h);
  background: #f7f1d9;
  border: 1px solid rgba(95,83,50,.21);
  box-shadow: 10px 20px 30px rgba(51,50,43,.2);
  overflow: hidden;
  opacity: 0;
  /* .68s 后等绳结收尾再现身；.71s 起做 FLIP 展开，约 1.33s 完成。 */
  transition: opacity .01s linear .68s, left .62s cubic-bezier(.72,0,.15,1) .71s, top .62s cubic-bezier(.72,0,.15,1) .71s, width .62s cubic-bezier(.72,0,.15,1) .71s, height .62s cubic-bezier(.72,0,.15,1) .71s, box-shadow .58s .71s;
  transform-origin: center;
}
.is-expanded .letter-sheet { left: 2.7vw; top: 13.5vh; width: 94.6vw; height: 78vh; opacity: 1; box-shadow: 14px 24px 32px rgba(51,50,43,.22); }
.paper-blank { position: absolute; inset: 0; background: radial-gradient(circle at 35% 10%, #fffdf2, transparent 55%), #f7f1d9; display: grid; place-items: center; color: rgba(139,70,63,.45); font: 7px "Special Elite", monospace; letter-spacing: .3em; transition: opacity .28s; }
.is-revealed .paper-blank { opacity: 0; }
.letter-content { height: 100%; opacity: 0; animation: reveal .5s ease forwards; pointer-events: auto; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(96,84,55,.35) transparent; }
@keyframes reveal { to { opacity: 1; } }
.letter-nav { height: 54px; position: sticky; top: 0; z-index: 5; background: rgba(247,241,217,.96); border-bottom: 1px solid rgba(58,68,64,.16); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 3.2vw; font: 7px "Special Elite", monospace; letter-spacing: .18em; }
.letter-nav button { border: 0; background: none; justify-self: start; cursor: pointer; font: inherit; letter-spacing: inherit; padding: 12px 0; }
.letter-nav button span { border: 1px solid #6d7b77; border-radius: 50%; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px; transition: transform .25s; }
.letter-nav button:hover span { transform: translateX(-4px); }
.letter-nav a { justify-self: end; color: var(--red); border: 1px solid rgba(159,74,69,.5); padding: 6px 9px; text-decoration: none; }
.letter-body { width: min(76%, 1110px); min-height: 100%; padding: 52px 5vw 100px; }
.eyebrow { color: var(--red); font: 7px "Special Elite", monospace; letter-spacing: .22em; margin-bottom: 12px; }
.title-row { display: flex; align-items: center; justify-content: space-between; }
.title-row h2 { margin: 0; font-size: clamp(35px, 4vw, 68px); font-weight: 500; letter-spacing: .05em; }
.archive-stamp { width: 65px; height: 65px; border: 2px double var(--red); border-radius: 50%; color: var(--red); display: grid; place-items: center; text-align: center; transform: rotate(8deg); font: 8px Georgia, serif; letter-spacing: .1em; }
.archive-stamp span { display: block; font-size: 5px; }
.rule { height: 8px; border-top: 1px solid rgba(38,54,51,.4); border-bottom: 1px solid rgba(38,54,51,.18); margin: 16px 0 31px; }
.lead { font-size: clamp(16px, 1.45vw, 26px); line-height: 1.8; margin: 0 0 19px; max-width: 900px; }
.tags { display: flex; gap: 7px; margin-bottom: 47px; }.tags span { color: var(--red); border: 1px solid rgba(159,74,69,.38); padding: 4px 7px; font: 6px "Special Elite", monospace; letter-spacing: .08em; }
.letter-body section { max-width: 760px; scroll-margin-top: 76px; }
.letter-body section + section { margin-top: 58px; }
.letter-body h3 { color: var(--red); font: 8px "Special Elite", monospace; letter-spacing: .2em; border-bottom: 1px solid rgba(42,58,55,.23); padding-bottom: 10px; }
.letter-body h4 { margin: 28px 0 9px; font-size: 16px; font-weight: 500; }
.letter-body section p { font-size: 11px; line-height: 2; margin: 0 0 14px; }
.letter-body blockquote { border-left: 2px solid var(--red); color: #6d4f4a; margin: 30px 0; padding: 8px 20px; font-size: 15px; }
.chapter-index { position: fixed; z-index: 60; right: 4.2vw; top: 27vh; width: 150px; display: grid; box-shadow: 4px 8px 16px rgba(54,52,42,.09); }
.chapter-index a { pointer-events: auto; background: rgba(236,230,207,.96); border: 1px solid rgba(55,68,64,.16); border-bottom: 0; padding: 11px 15px; text-decoration: none; font-size: 8px; letter-spacing: .08em; transition: padding .2s, background .2s; }.chapter-index a:last-child { border-bottom: 1px solid rgba(55,68,64,.16); }.chapter-index a:hover { padding-left: 20px; background: #e3dcc5; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 55px; align-items: start; }
  .intro { max-width: 520px; transform: none; }
  .intro p { max-width: 440px; }
  .file-stack { margin-top: 25px; min-height: 480px; height: 64vw; }
  .file-card { --card-w: clamp(165px, 25vw, 235px); }
  .letter-body { width: 82%; }
  .chapter-index { right: 3.4vw; width: 120px; }
}

@media (max-width: 620px) {
  .site-header { height: 62px; padding: 0 20px; }
  .hero { min-height: calc(100vh - 98px); padding: 45px 20px 10px; }
  .intro h1 { font-size: 37px; }
  .file-stack { height: 430px; min-height: 430px; margin-left: -10px; }
  .file-card { --card-w: 154px; transform: translateX(-50%) translateZ(calc(var(--depth) * .38)) rotateY(calc(var(--yaw) * .52)) rotateZ(calc(var(--roll) * .7)) scale(var(--card-scale)); }
  .file-card.is-active { transform: translateX(-50%) translateY(-2%) translateZ(80px) rotateY(0) rotateZ(0) scale(1.16); }
  footer { padding: 0 20px; }
  .is-expanded .letter-sheet { left: 10px; top: 72px; width: calc(100vw - 20px); height: calc(100vh - 92px); }
  .letter-nav { grid-template-columns: 1fr auto; padding: 0 16px; }
  .letter-nav > span { display: none; }
  .letter-body { width: 100%; padding: 35px 24px 90px; }
  .title-row h2 { font-size: 38px; }
  .archive-stamp { width: 54px; height: 54px; }
  .chapter-index { display: none; }
  .tags { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0ms !important; }
}
