/* ============================================================
   kylin.aifuncat.com · 生日×锡婚十周年纪念站 v0.1
   方案 A：时间轴为骨 + 星图为皮 + 锡章节高潮 + 八音盒结尾
   竖屏优先（微信内置浏览器主入口）· 零构建纯静态
   ============================================================ */

/* ---------- 字体 ----------
   像素字体（Fusion Pixel, OFL 开源）尚未投放子集文件。
   投放方法：将子集化 woff2 放到 assets/font-pixel.woff2，
   取消下方 @font-face 注释即可启用（font-display:swap 保证降级不白屏）。
   未投放时优雅降级为系统字体栈。

@font-face {
  font-family: 'KylinPixel';
  src: url('../assets/font-pixel.woff2') format('woff2');
  font-display: swap;
}
---------- */

:root {
  --bg-deep:   #0B1026;  /* 深空蓝黑 */
  --bg-mid:    #1B2545;  /* 墨蓝 */
  --star-white:#F5F0E6;  /* 星白 */
  --tin:       #C0C8D0;  /* 锡银 */
  --cinnabar:  #B03A2E;  /* 朱砂 */
  --gold:      #C9A227;  /* 鎏金 */
  --wine:      #6B2737;  /* 丝绒酒红 */
  --ink-soft:  rgba(245,240,230,.72);
  --ink-dim:   rgba(245,240,230,.45);
  --hairline:  rgba(192,200,208,.22);

  --font-serif: "Noto Serif SC","Songti SC","STSong","SimSun",serif;
  --font-pixel: "KylinPixel","PingFang SC","Courier New",monospace; /* 降级栈 */
  --font-sans:  -apple-system,"PingFang SC","Helvetica Neue",sans-serif;

  --col: min(92vw, 480px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: linear-gradient(175deg, var(--bg-deep) 0%, #10173a 46%, var(--bg-mid) 100%);
  color: var(--star-white);
  font-family: var(--font-serif);
  line-height: 1.9;
  letter-spacing: .02em;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}
body.locked { overflow: hidden; }
img { max-width: 100%; display: block; }
::selection { background: var(--cinnabar); color: #fff; }

/* ============ 拆信开场（信封 overlay） ============ */
#envelope-wrap {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px;
  background: radial-gradient(120% 90% at 50% 10%, #131c3f 0%, var(--bg-deep) 70%);
  transition: opacity .8s ease, visibility .8s;
}
#envelope-wrap.open { opacity: 0; visibility: hidden; pointer-events: none; }
.envelope {
  position: relative; width: min(78vw, 300px); aspect-ratio: 3/2;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 18px 40px rgba(0,0,0,.55));
  transform-style: preserve-3d; perspective: 700px;
}
.env-body {
  position: absolute; inset: 0; border-radius: 6px;
  background: linear-gradient(160deg, #f7f2e8, #efe6d4);
  box-shadow: inset 0 0 0 1px rgba(43,43,43,.08);
}
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 56%;
  background: linear-gradient(180deg, #efe7d6, #e6dcc6);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 6px 6px 0 0;
  transform-origin: top center;
  transition: transform .65s cubic-bezier(.6,-0.2,.3,1.4);
  z-index: 2;
}
.envelope.open .env-flap { transform: rotateX(178deg); z-index: 0; }
.env-seal {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%,-50%);
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #c24b3e, var(--cinnabar) 58%, #7e241b);
  display: flex; align-items: center; justify-content: center;
  color: #f7e9d8; font-size: 30px; font-family: var(--font-serif);
  box-shadow: 0 4px 14px rgba(0,0,0,.4), inset 0 0 0 2px rgba(247,233,216,.35);
  transition: transform .3s ease, opacity .4s ease;
  z-index: 3;
}
.envelope.open .env-seal { transform: translate(-50%,-50%) scale(1.35); opacity: 0; }
.env-letter {
  position: absolute; left: 7%; right: 7%; top: 12%; bottom: 10%;
  background: #fbf7ee; border-radius: 3px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  transform: translateY(14%); transition: transform .7s ease .35s;
}
.envelope.open .env-letter { transform: translateY(-16%); }
.env-hint {
  color: var(--ink-dim); font-size: 14px; letter-spacing: .28em;
  font-family: var(--font-sans); animation: breath 2.6s ease-in-out infinite;
}
@keyframes breath { 0%,100% { opacity:.45 } 50% { opacity:1 } }

/* ============ 首屏 Hero ============ */
#hero {
  position: relative; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 64px 18px 48px; overflow: hidden;
}
#heroStars { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-inner { position: relative; z-index: 2; }
.hero-kicker {
  font-family: var(--font-pixel); font-size: 13px; letter-spacing: .5em;
  color: var(--tin); text-indent: .5em; margin-bottom: 22px;
}
#hero h1 {
  font-size: clamp(30px, 8.4vw, 44px); font-weight: 600;
  letter-spacing: .12em; line-height: 1.55; text-indent: .12em;
  text-shadow: 0 2px 24px rgba(11,16,38,.9);
}
.hero-sub {
  margin-top: 20px; color: var(--ink-soft); font-size: 15px; letter-spacing: .2em;
}
.hero-sub .dot { color: var(--tin); margin: 0 .35em; }
.counters {
  margin-top: 44px; display: flex; gap: clamp(20px, 7vw, 48px); justify-content: center;
}
.counter .num {
  font-family: var(--font-pixel); font-size: clamp(26px, 7.2vw, 38px);
  color: var(--tin); letter-spacing: .04em; font-variant-numeric: tabular-nums;
}
.counter .num b { color: var(--star-white); font-weight: 600; }
.counter .lbl { font-size: 12.5px; color: var(--ink-dim); letter-spacing: .18em; margin-top: 6px; }
.scroll-hint {
  position: absolute; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); width: 22px; height: 36px; z-index: 2;
}
.scroll-hint::before {
  content: ""; position: absolute; left: 50%; top: 6px; width: 2px; height: 12px;
  background: var(--tin); border-radius: 2px;
  animation: hintDrop 1.8s ease-in-out infinite;
}
@keyframes hintDrop { 0% { transform: translate(-50%,0); opacity: 0 } 35% { opacity: 1 } 100% { transform: translate(-50%,16px); opacity: 0 } }

/* ============ 时间轴骨架 ============ */
#timeline { position: relative; padding: 30px 0 10px; }
.spine {
  position: absolute; left: 26px; top: 0; bottom: 0; width: 2px;
  background: var(--hairline);
}
.spine-fill {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  background: linear-gradient(180deg, var(--cinnabar) 0%, var(--cinnabar) 62%, var(--tin) 100%);
  transform-origin: top; transform: scaleY(0);
  box-shadow: 0 0 8px rgba(176,58,46,.5);
}

.chapter {
  position: relative;
  max-width: var(--col); margin: 0 auto 72px;
  padding: 8px 18px 8px 58px;
  opacity: 0; transform: translateY(26px);
  transition: opacity .8s ease, transform .8s ease;
}
.chapter.in { opacity: 1; transform: none; }
.chapter .node {
  position: absolute; left: -38px; top: 10px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--bg-mid);
  border: 2.5px solid var(--cinnabar);
  transition: box-shadow .4s ease, background .4s ease, border-color .4s ease;
}
.chapter.in .node {
  background: var(--cinnabar);
  box-shadow: 0 0 0 5px rgba(176,58,46,.16), 0 0 14px rgba(176,58,46,.65);
}
.chapter--tin .node, .chapter--tin.in .node { border-color: var(--tin); background: var(--tin); }
.chapter--tin.in .node { box-shadow: 0 0 0 5px rgba(192,200,208,.14), 0 0 16px rgba(192,200,208,.7); }

.ch-kicker {
  font-family: var(--font-sans); font-size: 12.5px; letter-spacing: .42em;
  color: var(--ink-dim); margin-bottom: 10px;
}
.ch-title {
  font-size: clamp(22px, 6vw, 28px); font-weight: 600; letter-spacing: .1em;
  margin-bottom: 6px; position: relative; z-index: 1;
}
.year-mark {
  position: absolute; right: -6px; top: -34px; z-index: 0;
  font-family: var(--font-pixel); font-size: clamp(64px, 17vw, 96px);
  color: rgba(245,240,230,.05); letter-spacing: -.02em; pointer-events: none;
  user-select: none; line-height: 1;
}
.poem {
  position: relative; z-index: 1;
  margin: 22px 0 8px; font-size: 16.5px; color: var(--ink-soft);
  line-height: 2.15; letter-spacing: .06em;
}
.poem em { font-style: normal; color: var(--star-white); }
.poem .hl-tin { color: var(--tin); }

/* 章节星图 */
.star-chart {
  position: relative; margin: 18px 0 6px; border-radius: 10px; overflow: hidden;
  aspect-ratio: 4 / 3; background: #080d20;
  border: 1px solid var(--hairline);
  box-shadow: 0 10px 34px rgba(0,0,0,.4), inset 0 0 60px rgba(27,37,69,.5);
}
.star-chart canvas { width: 100%; height: 100%; display: block; }
.star-chart .chart-cap {
  position: absolute; left: 12px; bottom: 10px; z-index: 2;
  font-family: var(--font-pixel); font-size: 11.5px; letter-spacing: .14em;
  color: rgba(245,240,230,.66);
  background: rgba(8,13,32,.55); padding: 4px 10px; border-radius: 4px;
  backdrop-filter: blur(2px);
}

/* 照片槽（data-photo=年份） */
.photo-slot {
  margin: 20px 0 4px; aspect-ratio: 4 / 3; border-radius: 10px;
  border: 1px dashed rgba(192,200,208,.4);
  background:
    linear-gradient(135deg, rgba(27,37,69,.5), rgba(11,16,38,.4)),
    repeating-linear-gradient(45deg, rgba(245,240,230,.028) 0 12px, transparent 12px 24px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; position: relative; overflow: hidden;
}
.photo-slot::before { /* CSS 相机图形（非 emoji） */
  content: ""; width: 44px; height: 34px; border: 2px solid rgba(192,200,208,.55);
  border-radius: 6px; position: relative;
  box-shadow: inset 0 0 0 2px rgba(11,16,38,.9);
}
.photo-slot::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(192,200,208,.55); top: calc(50% - 26px); left: calc(50% - 7px);
  box-shadow: inset 0 0 0 2.5px rgba(11,16,38,.9);
}
.photo-slot .slot-tag {
  font-family: var(--font-sans); font-size: 12.5px; letter-spacing: .3em;
  color: rgba(192,200,208,.75); text-indent: .3em;
}
.photo-slot .slot-year {
  font-family: var(--font-pixel); font-size: 13px; color: var(--ink-dim); letter-spacing: .2em;
}

/* ============ 锡章节（高潮） ============ */
.chapter--tin .ch-title {
  background: linear-gradient(100deg, #e7ecf1 10%, var(--tin) 38%, #8a939e 55%, #dfe5ea 78%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tin-band {
  margin: 20px 0 4px; padding: 22px 20px; border-radius: 12px;
  background: linear-gradient(155deg, rgba(192,200,208,.13), rgba(138,147,158,.05));
  border: 1px solid rgba(192,200,208,.35);
  position: relative; overflow: hidden;
}
.tin-band::after { /* 锡面反光扫过 */
  content: ""; position: absolute; top: -60%; left: -30%; width: 36%; height: 220%;
  background: linear-gradient(100deg, transparent, rgba(245,240,230,.14), transparent);
  transform: rotate(18deg); animation: sheen 5.5s ease-in-out infinite;
}
@keyframes sheen { 0% { left: -40% } 55%, 100% { left: 130% } }
.tin-band .big10 {
  font-family: var(--font-pixel); font-size: clamp(48px, 13vw, 72px); line-height: 1.1;
  color: var(--tin); letter-spacing: .06em; text-shadow: 0 2px 18px rgba(192,200,208,.35);
}
.tin-band .tin-sub { font-size: 14px; color: var(--ink-soft); letter-spacing: .12em; margin-top: 6px; }

/* ============ 像素画布（可替换模块挂载点） ============ */
#studio {
  max-width: var(--col); margin: 0 auto 72px; padding: 8px 18px 8px 58px; position: relative;
}
#studio .node { border-color: var(--gold); }
#studio.in .node { background: var(--gold); box-shadow: 0 0 0 5px rgba(201,162,39,.14), 0 0 14px rgba(201,162,39,.6); }
.studio-tip {
  font-family: var(--font-sans); font-size: 13px; color: var(--ink-dim);
  letter-spacing: .1em; margin: 8px 0 14px;
}
#pixel-mount { touch-action: none; }
.pc-toolbar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 10px; margin-bottom: 12px;
  background: rgba(11,16,38,.88); border: 1px solid var(--hairline);
  border-radius: 12px; backdrop-filter: blur(6px);
}
.pc-palette { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; flex: 1 1 100%; }
.pc-swatch {
  width: 34px; height: 34px; border-radius: 8px; border: 2px solid rgba(245,240,230,.18);
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .12s ease;
}
.pc-swatch.active { border-color: var(--star-white); transform: scale(1.14); box-shadow: 0 0 10px rgba(245,240,230,.4); }
.pc-btn {
  font-family: var(--font-sans); font-size: 13px; letter-spacing: .08em;
  color: var(--star-white); background: rgba(27,37,69,.85);
  border: 1px solid var(--hairline); border-radius: 9px;
  padding: 9px 14px; min-height: 44px; cursor: pointer;
  transition: background .15s ease;
}
.pc-btn:active { background: rgba(192,200,208,.25); }
.pc-btn--primary { background: rgba(176,58,46,.85); border-color: rgba(176,58,46,.6); }
#pixel-canvas {
  display: block; margin: 0 auto; border-radius: 10px;
  border: 1px solid var(--hairline);
  box-shadow: 0 12px 36px rgba(0,0,0,.45);
  background: #0E1830;
  image-rendering: pixelated;
}
/* 长按保存浮层 */
.pc-preview {
  position: fixed; inset: 0; z-index: 70; background: rgba(5,8,18,.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px;
}
.pc-preview[hidden] { display: none; }
.pc-preview img {
  width: min(88vw, 420px); height: auto; border-radius: 8px;
  box-shadow: 0 14px 44px rgba(0,0,0,.6);
}
.pc-preview .hint {
  font-family: var(--font-sans); color: var(--ink-soft); font-size: 14.5px;
  letter-spacing: .14em; text-align: center; line-height: 1.9;
}

/* ============ 尾声 · 八音盒 ============ */
.chapter--finale .node { border-color: var(--gold); }
.chapter--finale.in .node { background: var(--gold); box-shadow: 0 0 0 5px rgba(201,162,39,.14), 0 0 14px rgba(201,162,39,.6); }
.musicbox {
  margin: 24px 0 6px; padding: 26px 20px 22px; border-radius: 14px;
  background: linear-gradient(165deg, #4a3428, #35251c);
  border: 1px solid rgba(176,141,74,.5);
  box-shadow: 0 14px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(245,240,230,.08);
  text-align: center;
}
.mb-title { font-size: 15px; color: #e8d5a8; letter-spacing: .3em; text-indent: .3em; }
.mb-sub { font-size: 12.5px; color: rgba(232,213,168,.6); letter-spacing: .18em; margin-top: 4px; }
.mb-comb { display: flex; justify-content: center; gap: 6px; margin: 20px 0 22px; }
.mb-tooth {
  width: 10px; height: 44px; border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, #b08d4a, #8a6c36);
  transition: background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.mb-tooth.lit {
  background: linear-gradient(180deg, #ffe9ad, #d8b25e);
  box-shadow: 0 0 12px rgba(255,233,173,.8); transform: translateY(3px);
}
.mb-wind {
  font-family: var(--font-sans); font-size: 15px; letter-spacing: .22em; text-indent: .22em;
  color: #35251c; background: linear-gradient(180deg, #e8d5a8, #c9a85f);
  border: none; border-radius: 999px; padding: 13px 34px; min-height: 46px;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.mb-wind:active { transform: translateY(2px); box-shadow: 0 1px 6px rgba(0,0,0,.35); }
.mb-status { margin-top: 12px; font-size: 12.5px; color: rgba(232,213,168,.66); letter-spacing: .12em; min-height: 1.6em; }

/* ============ 页脚 ============ */
footer {
  max-width: var(--col); margin: 0 auto; padding: 34px 18px calc(46px + env(safe-area-inset-bottom));
  text-align: center; color: var(--ink-dim); font-size: 13px; letter-spacing: .12em;
}
footer .sig { color: var(--ink-soft); margin-bottom: 10px; line-height: 2; }
footer .dom { font-family: var(--font-pixel); font-size: 12px; color: rgba(192,200,208,.5); letter-spacing: .18em; }
footer .dom::before, footer .dom::after { content: "·"; margin: 0 8px; color: rgba(192,200,208,.3); }

/* ============ 章节圆点导航 ============ */
#dots {
  position: fixed; right: 9px; top: 50%; transform: translateY(-50%);
  z-index: 40; display: flex; flex-direction: column; gap: 11px;
}
#dots a {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(245,240,230,.24); border: 1px solid rgba(245,240,230,.2);
  transition: background .25s ease, transform .25s ease;
}
#dots a.active { background: var(--cinnabar); transform: scale(1.35); border-color: transparent; }
#dots a[data-ton="tin"].active { background: var(--tin); }
#dots a[data-ton="gold"].active { background: var(--gold); }

/* ============ 音乐按钮 ============ */
#music-btn {
  position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 45; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(11,16,38,.82); border: 1px solid var(--hairline);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#music-btn .disc {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--tin) 0 25%, #2a3448 25% 50%, var(--tin) 50% 75%, #2a3448 75%);
  border: 2px solid rgba(245,240,230,.75);
  animation: spin 3.2s linear infinite; animation-play-state: paused;
}
#music-btn.playing .disc { animation-play-state: running; }
#music-btn::after {
  content: attr(data-hint); position: absolute; right: 54px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; font-family: var(--font-sans); font-size: 12px; letter-spacing: .16em;
  color: var(--tin); background: rgba(11,16,38,.85); padding: 5px 10px; border-radius: 6px;
  opacity: 0; pointer-events: none; transition: opacity .4s ease;
}
#music-btn.hinted::after { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg) } }

/* ============ 横屏轻提示 ============ */
#land-tip {
  display: none; position: fixed; left: 0; right: 0; top: 0; z-index: 50;
  text-align: center; font-family: var(--font-sans); font-size: 12px;
  letter-spacing: .2em; color: var(--tin); background: rgba(11,16,38,.92);
  padding: 6px 10px;
}
@media (orientation: landscape) and (max-height: 420px) { #land-tip { display: block; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
  html { scroll-behavior: auto; }
}
@media (min-width: 700px) {
  .chapter, #studio { padding-left: 64px; }
  .spine { left: calc(50% - var(--col)/2 + 26px); }
  .chapter .node, #studio .node { left: -44px; }
}
