/* 書本：版面、整頁原圖、左右導覽、頁點、雪花（照原版 WeddingWeb css/style.css；字 ≥16px、可點 ≥44px） */

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-serif-zh);
}

.linen {
  background: #cfd3c0;
}

.snow {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
  --hole-x: 0px;
  --hole-y: 0px;
  --hole-w: 0px;
  --hole-h: 0px;
  -webkit-mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
  -webkit-mask-size: 100% 100%, var(--hole-w) var(--hole-h);
  -webkit-mask-position: 0 0, var(--hole-x) var(--hole-y);
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-composite: xor;
  mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
  mask-size: 100% 100%, var(--hole-w) var(--hole-h);
  mask-position: 0 0, var(--hole-x) var(--hole-y);
  mask-repeat: no-repeat;
  mask-composite: exclude;
}

.flake {
  position: absolute;
  top: -8%;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.85);
  animation: fall linear infinite;
}

.flake.star {
  background: transparent;
  box-shadow: none;
  color: rgba(255, 252, 246, 0.95);
  line-height: 1;
}

@keyframes fall {
  0% { transform: translate3d(0, -12vh, 0) rotate(0deg); }
  100% { transform: translate3d(var(--drift), 112vh, 0) rotate(var(--spin)); }
}

.app {
  --fb-extra: 0px;
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 28px 72px 24px;
}

.book-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
}

.book-slot {
  position: relative;
  z-index: 1;
  width: min(560px, calc(100vw - 160px), calc(82vh * 2 / 3));
  aspect-ratio: 2 / 3;
  border-radius: 28px;
}

.book {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  border-radius: 28px;
}

.book.no-motion .sheet { transition: none; }

.sheet {
  position: absolute;
  inset: 0;
  transform: translateX(0);
  transition: transform 0.55s cubic-bezier(0.22, 0.61, 0.36, 1);
  border-radius: 28px;
  will-change: transform;
}

.sheet.is-left { transform: translateX(-100%); }
.sheet.is-right { transform: translateX(100%); }

.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 28px;
  background: var(--paper);
}

.face.back { display: none; }

.page-photo {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: center;
  background: var(--paper);
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.nav {
  position: relative;
  z-index: 50;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(166, 132, 86, 0.45);
  background: rgba(255, 250, 244, 0.92);
  color: var(--sage);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  box-shadow: 0 8px 18px rgba(72, 48, 24, 0.12);
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.4s ease;
}

.nav.is-idle,
.nav.is-idle:disabled {
  opacity: 0;
}

.nav svg { width: 22px; height: 22px; }

.nav:hover:not(:disabled) {
  background: #fffaf4;
}

.nav:disabled {
  opacity: 0.38;
  cursor: default;
  box-shadow: none;
}

.pager {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 44px;
}

.dots {
  display: flex;
}

.dots button {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.dots button::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 252, 246, 0.45);
}

.dots button[aria-current="true"]::before {
  background: #f7f3ec;
  transform: scale(1.25);
}

.book.hint-right { cursor: pointer; }
.book.hint-left { cursor: pointer; }
.book.idle { cursor: default; }

@media (max-width: 720px) {
  .snow { display: none; }

  .dots button::before { background: rgba(61, 79, 66, 0.28); }
  .dots button[aria-current="true"]::before { background: var(--sage); }

  body.fb-on:not(.fb-admin) .app { --fb-extra: 52px; }

  .app {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    padding: max(36px, env(safe-area-inset-top, 0px)) 16px calc(max(56px, calc(env(safe-area-inset-bottom, 0px) + 48px)) + var(--fb-extra));
    gap: 0;
    overflow: hidden;
  }

  .book-row {
    position: relative;
    flex: 1;
    width: 100%;
    min-width: 0;
    height: 100%;
    gap: 0;
  }

  .book-slot {
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    aspect-ratio: auto;
    overflow: hidden;
  }

  .nav {
    position: absolute;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translateY(-50%);
  }

  .nav.prev { left: max(6px, env(safe-area-inset-left, 0px)); }
  .nav.next { right: max(6px, env(safe-area-inset-right, 0px)); }

  .nav:hover:not(:disabled) { transform: translateY(-50%); }

  .pager {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(max(6px, env(safe-area-inset-bottom, 0px)) + var(--fb-extra));
    z-index: 60;
  }
}

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