/* =====================================================================
   Happy Biresday · Mom's Archive
   奶油粉手帐（手机端优先）
   ===================================================================== */

:root {
  --cream: #fdf6ec;
  --cream-2: #fbefdf;
  --blush: #fbe6e1;
  --blush-2: #f7d9dd;
  --rose: #eeb6c1;
  --rose-deep: #e39baa;
  --strawberry: #dd8096;
  --cocoa: #6f5447;
  --cocoa-deep: #58402f;
  --ink-soft: #a08a79;
  --line: rgba(150, 115, 95, 0.18);

  --font-serif: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-hand: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-hand-cn: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;

  --shadow-soft: 0 16px 40px rgba(160, 115, 90, 0.18);
  --shadow-card: 0 6px 18px rgba(150, 105, 85, 0.20);
  --shadow-tiny: 0 2px 8px rgba(150, 105, 85, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--cocoa);
  background-color: var(--cream);
  background-image:
    radial-gradient(58% 42% at 6% -2%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 72%),
    radial-gradient(52% 38% at 100% 6%, var(--blush) 0%, rgba(251, 230, 225, 0) 72%),
    radial-gradient(46% 34% at 50% 108%, var(--blush-2) 0%, rgba(247, 217, 221, 0) 70%),
    radial-gradient(42% 30% at -4% 62%, #f7ead8 0%, rgba(247, 234, 216, 0) 70%),
    radial-gradient(36% 28% at 104% 70%, #f4ecdd 0%, rgba(244, 236, 221, 0) 70%),
    linear-gradient(178deg, var(--cream) 0%, var(--cream-2) 46%, #fbf0e2 100%);
  background-attachment: fixed;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* 纸纹噪点（糖霜质感） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: 0.07;
  mix-blend-mode: multiply;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(210, 160, 150, 0.20) 1px, transparent 1.5px),
    radial-gradient(rgba(255, 255, 255, 0.55) 1px, transparent 1.5px);
  background-size: 34px 34px, 58px 58px;
  background-position: 0 0, 17px 21px;
  opacity: 0.5;
}

::selection { background: var(--rose); color: #fff; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; display: block; }
em { font-style: normal; }

/* ---------- 顶部栏（音乐 / 返回） ---------- */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  pointer-events: none;
}
.top-bar > * { pointer-events: auto; }
.btn-music {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 20;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--strawberry);
}

/* 单页视图切换（音乐贯穿全站，页面用视图切换，不刷新） */
.view { display: block; min-height: 100vh; }
.view[hidden] { display: none !important; }
.btn-back {
  font-family: var(--font-hand-cn);
  font-size: 18px;
  color: var(--cocoa);
  padding: 8px 12px;
}

/* ---------- 欢迎页 ---------- */
#welcome {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}
.welcome-bg {
  position: fixed;
  inset: 0;
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;   /* 铺满整屏、不留空白（和主页面一致） */
}
.welcome-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(253, 246, 236, 0) 55%, rgba(253, 246, 236, 0.55) 100%);
}

.typewriter {
  position: absolute;
  top: 24px;
  left: 24px;
  font-family: var(--font-hand);
  font-size: clamp(28px, 8vw, 40px);
  color: var(--cocoa-deep);
  text-align: left;
  line-height: 1.15;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  z-index: 3;
}
.typewriter .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--strawberry);
  margin-left: 3px;
  vertical-align: -0.14em;
  animation: blink 0.85s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 点击背景图上（中间偏下）的信封 → 打开信件 */
.envelope-hit {
  position: absolute;
  left: 0;
  right: 0;
  top: 46%;
  height: 36%;
  z-index: 4;
  cursor: pointer;
}

/* ---------- 信件 ---------- */
#letter {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
}
#letter.show { display: flex; }
.letter-backdrop {
  position: absolute; inset: 0;
  background: rgba(116, 78, 66, 0.30);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.5s both;
}
.letter-sheet {
  position: relative;
  width: min(96vw, 520px);
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #fffdf6, #fbf1de);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  padding: clamp(20px, 5vw, 34px);
  text-align: center;
  animation: letterIn 0.9s cubic-bezier(.3, .7, .3, 1) both;
}
@keyframes letterIn {
  0% { transform: translateY(120px) scale(0.5) rotate(-6deg); opacity: 0; }
  100% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}
.letter-img { width: 100%; border-radius: 4px; box-shadow: var(--shadow-tiny); }
.letter-signoff {
  font-family: var(--font-hand-cn);
  font-size: 20px;
  color: var(--strawberry);
  margin-top: 14px;
}
.letter-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 22px;
}
.btn-letter {
  padding: 9px 24px;
  font-family: var(--font-hand-cn);
  font-size: 16px;
  letter-spacing: 2px;
  color: #fff;
  border-radius: 999px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn-letter:active { transform: translateY(3px); }
.btn-letter.btn-back {
  background: #bfa892;
  box-shadow: 0 4px 0 #97836f, 0 8px 14px rgba(140, 110, 90, 0.30);
}
.btn-letter.btn-back:active {
  box-shadow: 0 1px 0 #97836f, 0 3px 6px rgba(140, 110, 90, 0.25);
}
.btn-letter.btn-enter {
  background: linear-gradient(135deg, var(--rose-deep), var(--strawberry));
  box-shadow: 0 4px 0 #c56a80, 0 8px 14px rgba(210, 120, 138, 0.35);
}
.btn-letter.btn-enter:active {
  box-shadow: 0 1px 0 #c56a80, 0 3px 6px rgba(210, 120, 138, 0.30);
}

/* ---------- 主档案 ---------- */
.archive-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;   /* 铺满整屏，底部不留空白 */
}
#archive { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }
.archive-head { text-align: center; padding: 24px 20px 4px; }
.archive-head h1 {
  font-family: var(--font-serif);
  font-size: clamp(38px, 10vw, 56px);
  font-weight: 600;
  color: var(--cocoa-deep);
  line-height: 1.05;
}
.archive-head h1 em { color: var(--strawberry); }

/* 拍立得时间线 */
.timeline { position: relative; flex: 1; display: flex; align-items: center; padding-top: 20vh; }
.timeline-scroll {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 34px 0 46px;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.timeline-scroll::-webkit-scrollbar { display: none; }
.timeline-scroll.dragging { cursor: grabbing; scroll-snap-type: none; }

.polaroid {
  position: relative;
  flex: 0 0 auto;
  scroll-snap-align: center;
  width: min(60vw, 240px);
  transition: transform 0.5s cubic-bezier(.2, .7, .3, 1), opacity 0.5s, filter 0.5s;
  transform: scale(0.82) rotate(var(--rot, 0deg));
  opacity: 0.45;
  filter: saturate(0.82) brightness(0.97);
  cursor: pointer;
}
.polaroid.active {
  transform: scale(1.06) rotate(0deg);
  opacity: 1;
  filter: none;
  z-index: 5;
}
.polaroid-frame {
  background: #fff;
  padding: 10px 10px 16px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 14px 30px rgba(150, 105, 85, 0.26);
  position: relative;
}
.polaroid-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--blush);
  border-radius: 1px;
  overflow: hidden;
  position: relative;
}
.polaroid-photo img { width: 100%; height: 100%; object-fit: cover; }
.polaroid-note {
  font-family: var(--font-hand-cn);
  font-size: 19px;
  color: var(--cocoa-deep);
  text-align: center;
  margin-top: 13px;
  letter-spacing: 2px;
}

/* 彩色透明胶带（贴在拍立得顶部） */
.washi {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 92px;
  height: 27px;
  border-radius: 3px;
  opacity: 0.8;
  z-index: 6;
  box-shadow: 0 1px 2px rgba(140, 100, 80, 0.16);
  clip-path: polygon(2% 0, 98% 5%, 100% 95%, 5% 100%);
}
.washi.w1 { background: linear-gradient(90deg, rgba(238, 182, 193, 0.92), rgba(238, 182, 193, 0.72)); }
.washi.w2 { background: linear-gradient(90deg, rgba(197, 216, 240, 0.92), rgba(197, 216, 240, 0.72)); }
.washi.w3 { background: linear-gradient(90deg, rgba(242, 228, 172, 0.92), rgba(242, 228, 172, 0.72)); }
.washi.w4 { background: linear-gradient(90deg, rgba(198, 226, 208, 0.92), rgba(198, 226, 208, 0.72)); }

/* 占位（还没照片时） */
.placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 1px 3px rgba(150, 100, 90, 0.3);
}
.placeholder .ph-txt {
  font-family: var(--font-hand-cn);
  font-size: 20px;
}

.timeline-spacer { flex: 0 0 auto; width: calc(50vw - 120px); min-width: 24px; }

/* ---------- 章节页 ---------- */
.chapter-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.55;
  pointer-events: none;
}
#chapter, #gifts, #future { position: relative; z-index: 1; min-height: 100vh; padding-top: 74px; padding-bottom: 70px; }
.chapter-head { text-align: center; padding: 10px 20px 4px; }
.chapter-head h2 {
  font-family: var(--font-hand-cn);
  font-size: clamp(46px, 13vw, 72px);
  font-weight: normal;
  color: var(--cocoa-deep);
  line-height: 1.1;
}

/* 散落照片墙 */
.gallery {
  columns: 2;
  column-gap: 14px;
  padding: 22px 14px;
  max-width: 720px;
  margin: 0 auto;
}
.photo-card {
  position: relative;
  break-inside: avoid;
  margin-bottom: 20px;
  background: #fff;
  padding: 9px 9px 13px;
  border-radius: 4px;
  box-shadow: var(--shadow-card);
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.35s cubic-bezier(.2, .7, .3, 1), box-shadow 0.35s;
  cursor: pointer;
}
.photo-card:nth-child(3n+1) { --rot: -2.6deg; }
.photo-card:nth-child(3n+2) { --rot: 2.4deg; }
.photo-card:nth-child(3n) { --rot: -1deg; }
.photo-card .frame-img { width: 100%; border-radius: 1px; background: var(--blush); display: block; }
.photo-card .cap {
  font-family: var(--font-hand-cn);
  font-size: 15px;
  color: var(--cocoa-deep);
  text-align: center;
  margin-top: 10px;
  line-height: 1.5;
  padding: 0 2px;
}

.chapter-end { text-align: center; margin-top: 6px; padding: 0 20px; }
.to-be-continued {
  font-family: var(--font-serif);
  font-size: clamp(24px, 6vw, 32px);
  color: var(--cocoa-deep);
  letter-spacing: 2px;
}
.add-memory-btn {
  display: inline-block;
  margin: 20px auto 4px;
  padding: 15px 30px;
  font-family: var(--font-hand-cn);
  font-size: 19px;
  letter-spacing: 2px;
  color: var(--cocoa-deep);
  background: rgba(255, 255, 255, 0.82);
  border: 2px dashed var(--rose-deep);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}

/* ---------- 照片查看 ---------- */
#viewer {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
#viewer.show { display: flex; }
.viewer-backdrop {
  position: absolute; inset: 0;
  background: rgba(108, 70, 60, 0.38);
  backdrop-filter: blur(4px);
}
.viewer-card {
  position: relative;
  background: #fff;
  padding: 12px 12px 22px;
  border-radius: 6px;
  box-shadow: 0 26px 70px rgba(120, 80, 60, 0.4);
  max-width: min(90vw, 430px);
  transform: rotate(-1.4deg);
  animation: floatUp 0.5s cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes floatUp {
  0% { transform: translateY(64px) rotate(-4deg) scale(0.9); opacity: 0; }
  100% { transform: translateY(0) rotate(-1.4deg) scale(1); opacity: 1; }
}
.viewer-card img { width: 100%; max-height: 66vh; object-fit: contain; border-radius: 2px; background: var(--blush); }
.viewer-card .cap {
  font-family: var(--font-hand-cn);
  font-size: 19px;
  color: var(--cocoa-deep);
  text-align: center;
  margin-top: 14px;
  line-height: 1.5;
}
.viewer-close {
  position: absolute; top: -14px; right: -12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-card);
  font-size: 16px;
  color: var(--cocoa);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- 礼物 ---------- */
.gift-list { max-width: 420px; margin: 0 auto; padding: 14px 18px 30px; }
.gift-year {
  display: block;
  width: 100%;
  margin-bottom: 15px;
  padding: 17px 22px;
  text-align: left;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  transition: transform 0.25s, box-shadow 0.25s;
}
.gift-year .year { font-family: var(--font-serif); font-size: 28px; color: var(--strawberry); }
.gift-year .title { font-family: var(--font-hand-cn); font-size: 17px; color: var(--cocoa); }

.gift-envelope { position: relative; width: min(82vw, 340px); margin: 26px auto; cursor: pointer; }
.gift-envelope .envelope-img { width: 100%; border-radius: 8px; mix-blend-mode: multiply; filter: drop-shadow(0 12px 24px rgba(150, 100, 82, 0.26)); transition: transform 0.5s, opacity 0.5s; }
.gift-envelope.open .envelope-img { transform: translateY(-14px) scale(0.97); opacity: 0.2; }
.gift-open-btn {
  display: block; margin: 0 auto;
  padding: 11px 30px;
  font-family: var(--font-hand-cn);
  font-size: 20px; letter-spacing: 4px;
  color: #fff;
  background: linear-gradient(135deg, var(--rose-deep), var(--strawberry));
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}
.gift-card {
  max-width: min(88vw, 380px);
  margin: 18px auto;
  background: #fffdf5;
  border-radius: 8px;
  padding: 28px 24px;
  box-shadow: var(--shadow-soft);
  animation: letterIn 0.7s both;
  text-align: center;
}
.gift-card .g-msg { font-family: var(--font-hand-cn); font-size: 20px; line-height: 1.9; color: var(--cocoa-deep); margin-top: 10px; }
.gift-card img { width: 100%; border-radius: 4px; margin-top: 14px; box-shadow: var(--shadow-tiny); }
.gift-list-back {
  display: block; margin: 16px auto 0;
  font-family: var(--font-hand-cn);
  font-size: 18px; color: var(--ink-soft);
}

/* ---------- 未来 / 记忆 ---------- */
.memory-list { max-width: 520px; margin: 0 auto; padding: 16px 18px; }
.memory-empty {
  text-align: center;
  font-family: var(--font-hand-cn);
  color: var(--ink-soft);
  font-size: 18px;
  margin: 22px 0;
  line-height: 1.9;
}
.memory-card {
  position: relative;
  background: #fffdf6;
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
  transform: rotate(var(--rot, 0deg));
}
.memory-card:nth-child(odd) { --rot: -1deg; }
.memory-card:nth-child(even) { --rot: 1.1deg; }
.memory-card .m-date { font-family: var(--font-serif); font-size: 13px; letter-spacing: 2px; color: var(--ink-soft); }
.memory-card .m-title { font-family: var(--font-hand-cn); font-size: 24px; color: var(--cocoa-deep); margin-top: 4px; }
.memory-card .m-text { font-family: var(--font-hand-cn); font-size: 18px; line-height: 1.9; color: var(--cocoa); margin-top: 8px; white-space: pre-wrap; }
.memory-card .m-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.memory-card .m-photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 6px; box-shadow: var(--shadow-tiny); }
.memory-del { position: absolute; top: 12px; right: 14px; font-size: 16px; color: var(--ink-soft); opacity: 0.5; }
.add-hint { text-align: center; font-family: var(--font-hand-cn); font-size: 16px; color: var(--ink-soft); margin-top: 10px; }

/* ---------- 日记编辑器 ---------- */
#diary {
  position: fixed; inset: 0; z-index: 55;
  display: none; align-items: center; justify-content: center;
  padding: 18px;
}
#diary.show { display: flex; }
.diary-backdrop {
  position: absolute; inset: 0;
  background: rgba(108, 70, 60, 0.34);
  backdrop-filter: blur(3px);
}
.diary-sheet {
  position: relative;
  width: min(94vw, 460px);
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #fffdf5, #fbf0dd);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  padding: 28px 24px 22px;
  animation: letterIn 0.5s both;
}
.diary-sheet h3 { font-family: var(--font-hand-cn); font-size: 25px; color: var(--cocoa-deep); margin-bottom: 16px; text-align: center; }
.diary-field { margin-bottom: 14px; }
.diary-field label { display: block; font-family: var(--font-hand-cn); font-size: 16px; color: var(--ink-soft); margin-bottom: 5px; }
.diary-field input, .diary-field textarea {
  width: 100%;
  font-family: var(--font-hand-cn);
  font-size: 18px;
  color: var(--cocoa-deep);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
}
.diary-field input:focus, .diary-field textarea:focus { border-color: var(--rose-deep); }
.diary-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.diary-photos img { width: 76px; height: 76px; object-fit: cover; border-radius: 6px; box-shadow: var(--shadow-tiny); }
.diary-actions { display: flex; gap: 12px; margin-top: 20px; }
.btn-cancel { flex: 1; padding: 13px; font-family: var(--font-hand-cn); font-size: 18px; color: var(--ink-soft); background: rgba(255, 255, 255, 0.6); border: 1px solid var(--line); border-radius: 999px; }
.btn-save { flex: 1; padding: 13px; font-family: var(--font-hand-cn); font-size: 18px; letter-spacing: 2px; color: #fff; background: linear-gradient(135deg, var(--rose-deep), var(--strawberry)); border-radius: 999px; box-shadow: 0 6px 14px rgba(210, 120, 138, 0.35); }

/* ---------- 提示 ---------- */
#toast {
  position: fixed;
  left: 50%; bottom: 44px;
  transform: translateX(-50%) translateY(20px);
  z-index: 80;
  background: rgba(88, 64, 47, 0.95);
  color: #fdeff3;
  font-family: var(--font-hand-cn);
  font-size: 17px;
  line-height: 1.6;
  padding: 13px 22px;
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  white-space: pre-line;
  text-align: center;
  max-width: 86vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 桌面增强 ---------- */
@media (min-width: 640px) {
  .polaroid { width: 230px; }
  .gallery { columns: 3; }
  .timeline-scroll { gap: 22px; }
}
@media (min-width: 900px) {
  .polaroid { width: 250px; }
  .archive-head h1 { font-size: 58px; }
}
