/* 手账册：奶油纸、胶带、压花。画风要温，文案不往告白上靠。 */
:root {
  --paper: #f7f1e8;
  --paper-deep: #efe4d4;
  --cream: #f9f5f0;
  --desk: #efe6d8;
  --rose: #c9897a;
  --rose-soft: #e8c4b4;
  --orange: #d0895a;
  --orange-deep: #c47645;
  --ink: #4a3a2f;
  --muted: #8a7464;
  --line: #e4d5c4;
  --tape: rgba(244, 226, 184, 0.62);
  --shadow: rgba(90, 62, 42, 0.18);
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --script: "Caveat", "Ma Shan Zheng", cursive;
  --hand: "Ma Shan Zheng", "Caveat", cursive;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--desk);
  background-image:
    radial-gradient(900px 520px at 12% 8%, rgba(255, 244, 228, 0.7), transparent 55%),
    radial-gradient(700px 420px at 90% 12%, rgba(232, 196, 168, 0.28), transparent 50%),
    linear-gradient(180deg, #f6eee3 0%, #efe4d4 48%, #e8d8c2 100%);
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

#particles {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* 桌面：房间里立一本手账；手机上直接铺满。下面留一行给备案号。 */
.desk {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 12px 12px;
  position: relative;
  z-index: 3;
}

.room-flower {
  position: absolute;
  width: 72px;
  opacity: 0.55;
  pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(90, 62, 42, 0.12));
}

.room-flower-l {
  left: 6vw;
  top: 14vh;
  transform: rotate(-18deg);
}

.room-flower-r {
  right: 7vw;
  bottom: 16vh;
  transform: rotate(22deg) scaleX(-1);
}

.phone {
  width: min(420px, 100%);
  height: min(860px, calc(100dvh - 56px));
  background: var(--paper);
  border-radius: 28px;
  box-shadow:
    0 0 0 1px rgba(255, 248, 236, 0.7) inset,
    0 18px 50px var(--shadow),
    0 2px 0 rgba(255, 255, 255, 0.35) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  /* 纸纹：细噪点叠在奶油底上，避免塑料感白底 */
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.45), transparent 28%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(180, 150, 120, 0.03) 3px 4px);
}

.phone::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(90, 62, 42, 0.06), transparent 14%, transparent 86%, rgba(90, 62, 42, 0.05));
  z-index: 1;
}

.topbar,
.page-meter,
.tabbar {
  position: relative;
  z-index: 5;
}

.topbar {
  height: 56px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  padding: 8px 14px 0;
}

.brand {
  font-family: var(--script);
  font-size: 26px;
  color: var(--rose);
  text-align: center;
  letter-spacing: 0.02em;
}

.top-actions {
  display: flex;
  gap: 2px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.light svg {
  stroke: #fff8ee;
}

.stage {
  flex: 1;
  perspective: 1800px;
  padding: 4px 16px 0;
  position: relative;
  z-index: 4;
  overflow: hidden;
}

/* 左右各留一条热区翻页，中间的照片仍可点开 */
.side-hot {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20%;
  z-index: 6;
  padding: 0;
  background: transparent;
}

.side-hot.left {
  left: 0;
  cursor: w-resize;
}

.side-hot.right {
  right: 0;
  cursor: e-resize;
}

.shot,
.polaroid,
.chapter,
.open-btn {
  position: relative;
  z-index: 8;
}

.book {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.leaf {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.86s cubic-bezier(0.65, 0.05, 0.36, 1);
  /* 默认藏起来，只露出当前页和翻页用的邻页，避免十几张透明纸叠在一起 */
  visibility: hidden;
  pointer-events: none;
}

.leaf.ready {
  visibility: visible;
}

.leaf.ready:not(.flipped) {
  pointer-events: auto;
}

.leaf.flipped {
  transform: rotateY(-180deg);
}

.leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px;
  overflow: hidden;
}

.leaf-back {
  transform: rotateY(180deg);
  background:
    linear-gradient(90deg, rgba(90, 62, 42, 0.08), transparent 18%),
    var(--paper-deep);
}

.leaf-front {
  /* 纸必须不透明，拼贴页周围的空白才不会透出后面几页的字和照片 */
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.35), transparent 28%),
    var(--paper);
  display: flex;
  flex-direction: column;
}

.leaf.turning .leaf-front {
  box-shadow: -18px 0 30px rgba(70, 46, 28, 0.18);
}

/* === 封面 === */
.cover,
.catalog,
.sheet {
  background: var(--paper);
}

.cover {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px 8px;
}

.cover-book {
  width: 100%;
  flex: 1;
  background: linear-gradient(180deg, #f3e6d4 0%, #ead7bf 100%);
  border-radius: 10px 16px 16px 10px;
  box-shadow:
    inset 8px 0 12px rgba(90, 62, 42, 0.08),
    0 10px 24px rgba(90, 62, 42, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 22px 24px;
  position: relative;
}

.polaroid {
  width: min(230px, 72%);
  background: #fffdf8;
  padding: 10px 10px 36px;
  box-shadow: 0 10px 22px rgba(90, 62, 42, 0.16);
  transform: rotate(-2.4deg);
  position: relative;
}

.polaroid > img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  background: #ddd2c2;
}

.polaroid .hand {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  text-align: center;
  font-family: var(--hand);
  font-size: 18px;
  color: #7a6554;
}

.tape {
  position: absolute;
  background: var(--tape);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}

.tape-h {
  width: 64px;
  height: 18px;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
}

.tape-l {
  width: 42px;
  height: 16px;
  top: 18px;
  left: -12px;
  transform: rotate(-38deg);
}

.tape-r {
  width: 38px;
  height: 15px;
  bottom: 40px;
  right: -10px;
  transform: rotate(28deg);
}

.deco-flower {
  position: absolute;
  width: 46px;
  height: 58px;
  right: -8px;
  bottom: 18px;
  transform: rotate(16deg);
  pointer-events: none;
  background: url("../assets/flower.svg") center / contain no-repeat;
}

.cover h1 {
  margin-top: 28px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.06em;
}

.cover .sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
  max-width: 16em;
}

.open-btn {
  margin-top: 22px;
  min-width: 168px;
  height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #d89a68, var(--orange-deep));
  color: #fff8f0;
  box-shadow: 0 8px 16px rgba(180, 96, 50, 0.22);
}

.open-btn:active {
  transform: translateY(1px);
}

/* === 目录 === */
.catalog {
  height: 100%;
  overflow: auto;
  padding: 6px 4px 10px;
}

.catalog h2 {
  font-family: var(--serif);
  font-size: 22px;
  margin: 4px 4px 14px;
}

.chapter {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 8px;
  border-bottom: 1px dashed var(--line);
  text-align: left;
}

.chapter img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 4px solid #fffdf8;
  box-shadow: 0 4px 10px rgba(90, 62, 42, 0.12);
  transform: rotate(-2deg);
}

.chapter b {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}

.chapter small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chapter em {
  font-style: normal;
  color: var(--rose);
  font-size: 12px;
}

/* === 内页 === */
.sheet {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 4px 2px 8px;
}

.sheet-title {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.shot {
  position: relative;
  background: #fffdf8;
  padding: 8px 8px 28px;
  box-shadow: 0 10px 20px rgba(90, 62, 42, 0.12);
  cursor: pointer;
}

.shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #e7d8c6;
}

.shot .hand {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 6px;
  font-family: var(--hand);
  font-size: 16px;
  color: #6e5848;
}

.layout-single {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.layout-single .shot {
  width: min(300px, 92%);
  height: min(400px, 62%);
  transform: rotate(-1.2deg);
}

.layout-collage {
  flex: 1;
  position: relative;
}

.layout-collage .shot {
  position: absolute;
}

.layout-collage .shot:nth-child(1) {
  width: 58%;
  height: 48%;
  left: 2%;
  top: 4%;
  transform: rotate(-3deg);
  z-index: 9;
}

.layout-collage .shot:nth-child(2) {
  width: 46%;
  height: 42%;
  right: 2%;
  top: 18%;
  transform: rotate(4deg);
  z-index: 10;
}

.layout-collage .shot:nth-child(3) {
  width: 54%;
  height: 40%;
  left: 16%;
  bottom: 6%;
  transform: rotate(-1deg);
  z-index: 8;
}

.layout-collage .shot:nth-child(1):nth-last-child(2) {
  width: 56%;
  height: 58%;
  left: 0;
  top: 8%;
}

.layout-collage .shot:nth-child(2):last-child {
  width: 50%;
  height: 50%;
  right: 0;
  bottom: 10%;
  top: auto;
}

.note {
  margin-top: 10px;
  font-family: var(--hand);
  font-size: 18px;
  line-height: 1.6;
  color: #6b5344;
  min-height: 2.4em;
}

.page-meter {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.grid-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
}

.tabbar {
  height: 62px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.86);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}

.tabbar button.active {
  color: var(--ink);
}

.tabbar svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

/* 备案号压在相册下面，字要小、颜色要淡，不抢手账的视线 */
.beian {
  position: relative;
  z-index: 4;
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
}

.beian a {
  color: inherit;
  text-decoration: none;
}

.beian a:hover {
  color: var(--ink);
}

/* === 灯箱 === */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(28, 18, 12, 0.94);
  display: none;
  flex-direction: column;
}

.lightbox .side-hot {
  z-index: 32;
  width: 18%;
}

.lightbox.open {
  display: flex;
}

.lightbox-bar,
.lightbox-tools {
  position: relative;
  z-index: 33;
  height: 58px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  color: #fff8ee;
  padding: 0 10px;
  background: rgba(20, 12, 8, 0.55);
}

.lightbox-tools {
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  font-size: 13px;
}

.lightbox-shot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 16px 8px;
}

.lightbox-shot img {
  max-width: 100%;
  max-height: calc(100dvh - 180px);
  object-fit: contain;
  background: #2a2018;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.lightbox-shot figcaption {
  margin-top: 12px;
  font-family: var(--hand);
  font-size: 20px;
  color: #f3e6d4;
}

.panel {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(60, 42, 30, 0.28);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.panel.open {
  display: flex;
}

.panel-card {
  width: min(420px, 100%);
  background: var(--paper);
  border-radius: 16px;
  padding: 28px 24px 20px;
  box-shadow: 0 16px 40px var(--shadow);
}

.panel-card h2 {
  font-family: var(--serif);
  margin-bottom: 12px;
}

.panel-card p {
  color: var(--muted);
  line-height: 1.8;
  font-size: 14px;
}

#about-sign {
  margin-top: 16px;
  font-family: var(--script);
  color: var(--rose);
  font-size: 20px;
}

.panel-close {
  margin-top: 22px;
  width: 100%;
  height: 42px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff8f0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(58, 40, 30, 0.9);
  color: #fff8ee;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .desk {
    padding: 0;
    justify-content: flex-start;
  }

  .room-flower {
    display: none;
  }

  .phone {
    width: 100%;
    height: calc(100dvh - 36px);
    border-radius: 0;
    box-shadow: none;
  }

  .beian {
    height: 36px;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .leaf {
    transition: none;
  }
}
