/* ============================================================
   杏仁的小树洞 · 多页面日记博客 · 全局样式
   ------------------------------------------------------------
   崩坏分阶段（通过 <body data-stage="0..3"> 控制整个页面）：

     stage 0 = 正常（第 1~9 篇）  奶油纸 + 粉色 + 花瓣飘落
     stage 1 = 异样（第 10~11 篇）褪色、发冷、轻微闪烁
     stage 2 = 崩裂（第 12~13 篇）等宽字体、扫描线、故障文字
     stage 3 = 崩坏（第 14 篇）    近黑、红光、CRT、剧烈抖动

   改主题颜色只需改 :root 里的变量。
   ============================================================ */

:root {
  --bg: #fdf6ee;
  --paper: #fffdf8;
  --ink: #5a4a42;
  --ink-soft: #9a867a;
  --accent: #f2a7c3;
  --accent-deep: #d97ba4;
  --line: #f0e2d0;
  --shadow: rgba(180, 140, 120, .16);
  --hand: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "FangSong", serif;
  --mono: "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  line-height: 1.9;
  background:
    radial-gradient(circle at 10% 6%, rgba(242,167,195,.20), transparent 40%),
    radial-gradient(circle at 92% 16%, rgba(178,202,240,.18), transparent 42%),
    repeating-linear-gradient(0deg, #fdf6ee 0 28px, #fbf0e4 28px 29px);
  background-attachment: fixed;
  transition: background .8s ease, color .8s ease;
}

/* ============================================================
   分阶段整页变化
   ============================================================ */

/* stage 1 · 异样：褪色发冷 */
body[data-stage="1"] {
  background:
    radial-gradient(circle at 12% 8%, rgba(150,160,180,.16), transparent 42%),
    radial-gradient(circle at 88% 18%, rgba(140,150,170,.14), transparent 44%),
    #ececf0;
  background-attachment: fixed;
  color: #55524e;
  animation: body-flicker 6s infinite;
}
body[data-stage="1"] .paper {
  background: #f4f4f6;
  filter: saturate(.6) brightness(.98);
}

/* stage 2 · 崩裂：扫描线 + 冷灰 */
body[data-stage="2"] {
  background: #131418;
  color: #b9b4c0;
  font-family: var(--mono);
}
body[data-stage="2"]::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
  animation: scan 8s linear infinite;
}
body[data-stage="2"] .paper {
  background: #1c1b21;
  border-color: #3a3844;
  box-shadow: 0 0 0 1px rgba(160,60,80,.12), 0 10px 30px rgba(0,0,0,.5);
}

/* stage 3 · 崩坏：近黑红光 CRT */
body[data-stage="3"] {
  background: #0a0608;
  color: #e8d7d7;
  font-family: var(--mono);
  animation: body-flicker 1.6s infinite, body-shake .12s infinite;
}
body[data-stage="3"]::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 998;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.85) 100%),
    repeating-linear-gradient(0deg, rgba(255,0,40,.05) 0 2px, transparent 2px 4px);
}
body[data-stage="3"]::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0 1px, transparent 1px 3px);
  animation: scan 4s linear infinite;
}
body[data-stage="3"] .paper {
  background: #141013;
  border-color: #3a1420;
  box-shadow: 0 0 30px rgba(180,20,50,.4);
  animation: flicker 2.4s infinite;
}

/* ---------- 通用动效 ---------- */
@keyframes body-flicker {
  0%, 100% { opacity: 1; }
  41% { opacity: .96; }
  43% { opacity: 1; }
  46% { opacity: .93; }
  48% { opacity: 1; }
  72% { opacity: .97; }
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  41% { opacity: .94; }
  43% { opacity: 1; }
  46% { opacity: .9; transform: translateX(1px); }
  48% { opacity: 1; transform: translateX(0); }
  72% { opacity: .96; }
}
@keyframes scan {
  from { background-position: 0 0; }
  to   { background-position: 0 100vh; }
}
@keyframes body-shake {
  0% { transform: translate(0,0); }
  25% { transform: translate(-1px,1px); }
  50% { transform: translate(1px,-1px); }
  75% { transform: translate(-1px,-1px); }
  100% { transform: translate(0,0); }
}
@keyframes glitch-shift {
  0%, 100% { text-shadow: 1px 0 #ff2d55, -1px 0 #0ff; transform: translateX(0); }
  20% { text-shadow: -2px 0 #ff2d55, 2px 0 #0ff; transform: translateX(-1px); }
  40% { text-shadow: 2px 0 #ff2d55, -2px 0 #0ff; transform: translateX(1px); }
  60% { text-shadow: -1px 0 #ff2d55, 1px 0 #0ff; transform: translateX(0); }
}
@keyframes float-petal {
  0% { transform: translateY(-10vh) translateX(0) rotate(0deg); opacity: 0; }
  10% { opacity: .9; }
  100% { transform: translateY(110vh) translateX(-40px) rotate(360deg); opacity: 0; }
}

/* 故障文字 */
.glitch { animation: glitch-shift .5s infinite; }

/* ============================================================
   头部 / 导航
   ============================================================ */
.site-header {
  text-align: center;
  padding: 40px 20px 18px;
  border-bottom: 1px dashed var(--line);
  background: linear-gradient(180deg, rgba(255,253,248,.9), rgba(255,253,248,.5));
}
.avatar { width: 192px; height: 192px; object-fit: cover; -webkit-user-drag: none; -webkit-user-select: none; user-select: none; display: inline-block; background: #fff; border-radius: 50%; padding: 3px; box-shadow: 0 4px 14px var(--shadow); border: 2px solid var(--accent); }
.blog-title { font-family: var(--hand); font-size: 42px; margin: 10px 0 4px; letter-spacing: 4px; color: var(--accent-deep); }
.blog-subtitle { margin: 0; color: var(--ink-soft); font-size: 14px; letter-spacing: 1px; }
.site-nav { display: flex; justify-content: center; gap: 24px; margin-top: 16px; flex-wrap: wrap; }
.nav-link { color: var(--ink-soft); text-decoration: none; font-size: 14px; padding: 2px 8px; border-bottom: 2px solid transparent; }
.nav-link:hover, .nav-link.active { color: var(--accent-deep); border-color: var(--accent); }

/* ============================================================
   布局容器（纸页）
   ============================================================ */
.wrap { max-width: 760px; margin: 30px auto; padding: 0 20px; }
.paper {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 6px 20px var(--shadow);
  padding: 30px 34px 34px;
  transition: background .8s ease, filter .8s ease;
}
.paper::before {
  content: "";
  position: absolute;
  top: -9px; left: 26px;
  width: 84px; height: 26px;
  background: linear-gradient(90deg, rgba(242,167,195,.55), rgba(217,123,164,.35));
  transform: rotate(-3deg);
  border-radius: 4px;
  box-shadow: 0 2px 5px var(--shadow);
}
body[data-stage="2"] .paper::before,
body[data-stage="3"] .paper::before {
  background: linear-gradient(90deg, #6d1a2c, #3a0d17);
}

.back {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--accent-deep);
  text-decoration: none;
  font-size: 14px;
}
body[data-stage="2"] .back, body[data-stage="3"] .back { color: #ff5a6e; }

/* ============================================================
   列表首页
   ============================================================ */
.entry-list { display: flex; flex-direction: column; gap: 16px; }
.entry-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 14px var(--shadow);
  padding: 16px 20px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.entry-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px var(--shadow); }
.card-date { font-size: 12px; color: var(--accent-deep); }
.card-title { font-family: var(--hand); font-size: 20px; margin: 4px 0; }
.card-excerpt { font-size: 13px; color: var(--ink-soft); margin: 0; }

/* 列表中已崩坏的条目 */
.entry-card.c1 { filter: saturate(.6); background: #f4f4f6; }
.entry-card.c2 { background: #1c1b21; color: #b9b4c0; font-family: var(--mono); border-color: #3a3844; }
.entry-card.c3 { background: #141013; color: #ff8fa0; font-family: var(--mono); border-color: #3a1420; box-shadow: 0 0 18px rgba(180,20,50,.4); animation: flicker 2.4s infinite; }

/* ============================================================
   单篇
   ============================================================ */
.post-date { display: inline-block; font-size: 13px; color: var(--accent-deep); background: rgba(242,167,195,.16); padding: 3px 12px; border-radius: 999px; margin-bottom: 10px; }
.post-title { font-family: var(--hand); font-size: 28px; margin: 0 0 14px; color: var(--ink); letter-spacing: 2px; }
.post-body { font-family: var(--hand); font-size: 17px; white-space: pre-line; color: var(--ink); }

body[data-stage="2"] .post-title,
body[data-stage="3"] .post-title { font-family: var(--mono); color: #e8d7d7; letter-spacing: 3px; }
body[data-stage="2"] .post-body { font-family: var(--mono); color: #c5bcc8; letter-spacing: 1px; }
body[data-stage="3"] .post-body { font-family: var(--mono); color: #e8d7d7; text-shadow: 0 0 2px rgba(255,80,110,.6); letter-spacing: 2px; }
body[data-stage="2"] .post-date, body[data-stage="3"] .post-date { color: #a04a5a; background: rgba(160,74,90,.14); }

.post-nav { display: flex; justify-content: space-between; margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--line); font-size: 14px; }
.post-nav a { color: var(--accent-deep); text-decoration: none; }
body[data-stage="2"] .post-nav a, body[data-stage="3"] .post-nav a { color: #ff5a6e; }

/* ============================================================
   密码锁（第 14 篇）
   ============================================================ */
.lock-area { text-align: center; padding: 26px 14px; border: 1px dashed #5a2434; border-radius: 12px; background: #1e131a; }
.lock-hint { color: #ffb3c0; margin: 0 0 4px; font-size: 16px; }
.lock-sub { color: #8f7a80; margin: 0 0 16px; font-size: 13px; }
.lock-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#lock-input { font-family: var(--hand); font-size: 15px; padding: 9px 14px; border-radius: 8px; border: 1px solid #5a2434; background: #231720; color: #ffe; min-width: 220px; outline: none; }
#lock-input:focus { border-color: #ff5a6e; }
#lock-btn { font-family: inherit; font-size: 15px; padding: 9px 20px; border-radius: 8px; border: none; cursor: pointer; background: #ff5a6e; color: #fff; }
#lock-btn:hover { background: #ff7586; }
.lock-msg { min-height: 22px; margin: 14px 0 0; color: #ffd3d9; font-size: 14px; }
.locked-body { margin-top: 20px; white-space: pre-line; font-family: var(--mono); color: #e8d7d7; }

.shake { animation: shake .45s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.hidden-note { margin-top: 18px; padding: 18px; border: 1px solid #6d1a2c; border-radius: 12px; background: #17101a; }
.hidden-note h2 { margin: 0 0 10px; color: #ff5a6e; font-family: var(--hand); letter-spacing: 3px; font-size: 20px; }
.hidden-note .hidden-body { white-space: pre-line; color: #e6d8da; font-family: var(--hand); font-size: 16px; line-height: 2; }

/* ============================================================
   页脚
   ============================================================ */
.site-footer { text-align: center; padding: 34px 20px 60px; color: var(--ink-soft); font-size: 13px; }
.site-footer p { margin: 4px 0; }
.footer-faint { opacity: .7; }
.hidden-clue { color: transparent; user-select: text; font-size: 12px; letter-spacing: 1px; }
.hidden-clue::selection { color: #a04a5a; background: #ffe; }
body[data-stage="2"] .site-footer, body[data-stage="3"] .site-footer { color: #6f5f6a; }

/* 花瓣（stage 0 由 JS 注入） */
.petal {
  position: fixed;
  top: 0;
  font-size: 18px;
  pointer-events: none;
  z-index: 0;
  animation: float-petal linear infinite;
  will-change: transform;
}
