/* ============================================================
   水彩绘本风 · 婚礼电子请柬
   ============================================================ */

@font-face {
  font-family: "Caveat Brush";
  src: url("../assets/fonts/caveat-brush.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #fcf7ee;
  --olive: #7b8854;
  --olive-soft: #909c68;
  --ink: #5c5647;
  --ink-soft: #8b8571;
  --line: rgba(139, 150, 99, .38);
  --script: "Caveat Brush", "Segoe Script", "Brush Script MT", "Snell Roundhand", cursive;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", "Times New Roman", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
}

body {
  font-family: var(--serif);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.pages {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  overscroll-behavior: none;
  background: var(--paper);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pages::-webkit-scrollbar { display: none; }

/* ---------------- 页面 ---------------- */
.page {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: calc(48px + env(safe-area-inset-top)) 22px calc(42px + env(safe-area-inset-bottom));
  text-align: center;
}

.page-cover {
  justify-content: flex-start;
  padding-top: calc(26px + env(safe-area-inset-top));
  padding-bottom: 0;
}

/* ---------------- 水彩装饰 ---------------- */
.deco {
  position: absolute;
  pointer-events: none;
  user-select: none;
  mix-blend-mode: multiply;
  z-index: 1;
}
.deco.garland { top: -10px; left: -32px; width: min(46vw, 212px); }
.deco.ball    { top: -22px; right: -32px; width: min(37vw, 176px); }
.deco.corner-bl { bottom: -16px; left: -40px; width: min(47vw, 222px); }
.deco.corner-br { bottom: -16px; right: -40px; width: min(47vw, 222px); transform: scaleX(-1); }
.deco.meadow  { bottom: -4px; left: 0; width: 100%; opacity: .95; }

/* ---------------- 散落爱心 ---------------- */
.hearts {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.hearts i {
  position: absolute;
  top: var(--y);
  left: var(--x);
  font-style: normal;
  font-size: var(--s);
  line-height: 1;
  color: var(--c);
  opacity: var(--o, .5);
  transform: rotate(var(--r));
}

/* ---------------- 英文手写标题 ---------------- */
.script-title {
  position: relative;
  z-index: 2;
  margin: 0;
  font-family: var(--script);
  font-weight: 400;
  color: var(--olive);
  line-height: .98;
  letter-spacing: .01em;
  font-size: clamp(3.5rem, 16vw, 6rem);
  padding: .06em 0 .12em;
}
.script-title.md { font-size: clamp(2.7rem, 12.5vw, 4.5rem); }
.script-title.sm {
  font-size: clamp(1.9rem, 8.2vw, 3rem);
  line-height: 1.02;
  max-width: 7.4em;
}

/* ---------------- 封面 ---------------- */
.cover-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.cover-illust {
  width: min(96vw, 470px);
  height: auto;
  margin-top: 1.6vh;
  pointer-events: none;
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: .3em;
  color: #979273;
  z-index: 3;
}
.scroll-hint i {
  font-style: normal;
  font-size: 13px;
  animation: bob 1.9s ease-in-out infinite;
}

/* ---------------- 邀请函 ---------------- */
.walk-illust {
  width: min(62vw, 258px);
  max-height: 25svh;
  object-fit: contain;
  margin: 1.2vh 0 2vh;
}
.invite-text {
  position: relative;
  z-index: 2;
  width: min(92%, 452px);
}
.invite-text p {
  margin: 0 0 1.5em;
  white-space: pre-line;
  font-size: clamp(12.5px, 3.5vw, 14px);
  line-height: 2;
  letter-spacing: .07em;
  color: var(--ink);
}
.invite-text p:last-child { margin-bottom: 0; }

/* ---------------- 新人信息 ---------------- */
.couple-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 2vw, 18px);
  margin: clamp(8px, 1.4vh, 16px) 0 clamp(4px, 1vh, 10px);
}
.portrait {
  margin: 0;
  width: min(31vw, 136px);
  text-align: center;
}
.portrait img { display: block; width: 100%; }
.portrait figcaption span {
  display: block;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: .3em;
  color: #9c967f;
  margin-top: 1px;
}
.portrait figcaption b {
  display: block;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(13px, 3.8vw, 15px);
  letter-spacing: .24em;
  color: #6f7d4c;
  margin-top: 2px;
}
.heart-arrow {
  width: clamp(28px, 7.5vw, 44px);
  margin-top: -10px;
  transform: rotate(-4deg);
}

.info-block {
  position: relative;
  z-index: 2;
  width: min(94%, 460px);
}
.info-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
  font-size: clamp(13px, 3.6vw, 15px);
  letter-spacing: .05em;
  color: #57513f;
}
.info-line em {
  font-style: normal;
  font-size: .78em;
  letter-spacing: .12em;
  color: #938d76;
}
.ico {
  width: 16px;
  height: 16px;
  flex: none;
  color: #8b9663;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.info-sub {
  margin: 0;
  font-size: 12px;
  letter-spacing: .08em;
  color: #8b8571;
}

.map-card {
  position: relative;
  width: min(86%, 392px);
  height: clamp(104px, 18svh, 150px);
  margin: 12px auto 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(140, 130, 100, .26);
  box-shadow: 0 7px 16px rgba(120, 105, 70, .12);
  background: #e7e1cd;
}
.map-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.map-pin {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -100%);
  filter: drop-shadow(0 2px 3px rgba(90, 90, 70, .3));
  animation: pinFloat 2.6s ease-in-out infinite;
}
@keyframes pinFloat {
  0%, 100% { transform: translate(-50%, -100%); }
  50% { transform: translate(-50%, -112%); }
}
.nav-btn {
  position: absolute;
  right: 9px;
  bottom: 9px;
  padding: 6px 16px 7px;
  border-radius: 999px;
  background: #7f8c5a;
  color: #fffdf6;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .16em;
  text-decoration: none;
  box-shadow: 0 3px 9px rgba(90, 100, 60, .35);
}
.nav-btn:active { transform: scale(.96); }

.dresscode {
  margin: 13px auto 0;
  max-width: 370px;
  font-size: 11.5px;
  line-height: 1.7;
  letter-spacing: .06em;
  color: #6f6a58;
}
.dresscode b {
  display: inline-block;
  margin-right: 6px;
  font-family: var(--sans);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--olive);
}
.dress-dots {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 8px;
}
.dress-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .7);
}

/* ---------------- 流程 ---------------- */
.timeline-wrap {
  position: relative;
  z-index: 2;
  width: min(96%, 500px);
  margin-top: .6vh;
  padding: 4px 0 8px;
}
.vine {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: visible;
  opacity: .55;
}
.vine > path {
  fill: none;
  stroke: #a8b47e;
  stroke-width: 1.4;
  stroke-linecap: round;
}
.vine-leaves path { fill: #c3cda1; opacity: .8; }

.timeline {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 4px;
  row-gap: clamp(4px, 1.2vh, 12px);
  padding: 2px 6px;
}
.tl-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.tl-item:nth-child(1) { grid-column: 1; grid-row: 1; }
.tl-item:nth-child(2) { grid-column: 2; grid-row: 1; margin-top: clamp(18px, 5vh, 48px); }
.tl-item:nth-child(3) { grid-column: 1; grid-row: 2; margin-top: clamp(2px, 1vh, 14px); }
.tl-item:nth-child(4) { grid-column: 2; grid-row: 2; margin-top: clamp(0px, .6vh, 10px); }

.tl-ico {
  width: clamp(34px, 10vw, 44px);
  height: clamp(34px, 10vw, 44px);
  display: grid;
  place-items: center;
  color: #7b8854;
  margin-bottom: 3px;
}
.tl-ico svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tl-name {
  display: block;
  font-size: clamp(13.5px, 3.7vw, 15.5px);
  letter-spacing: .08em;
  color: #57513f;
}
.tl-sub {
  display: block;
  margin-top: 1px;
  font-family: var(--script);
  font-size: clamp(12px, 3.2vw, 14px);
  color: #a8878c;
  letter-spacing: .02em;
}
.tl-time {
  display: block;
  margin-top: 2px;
  font-size: clamp(10px, 2.8vw, 11px);
  letter-spacing: .04em;
  color: #938d76;
}

/* ---------------- 照片墙 ---------------- */
.photo-wall {
  position: relative;
  z-index: 2;
  width: min(94%, 440px);
  height: clamp(390px, 63svh, 520px);
  margin-top: .6vh;
}
.polaroid {
  position: absolute;
  margin: 0;
  padding: 6px 6px 18px;
  background: #fffdf7;
  box-shadow: 0 8px 20px rgba(120, 105, 70, .19);
  opacity: 0;
  transform: translate3d(var(--fx, 0px), 46px, 0) rotate(calc(var(--rot, 0deg) + var(--fr, 0deg))) scale(.86);
  transition: box-shadow .35s ease;
  will-change: transform, opacity;
  cursor: pointer;
}
.page.is-active .polaroid {
  animation: photoIn .85s cubic-bezier(.2, .85, .25, 1.08) forwards;
  animation-delay: calc(var(--i, 0) * 200ms + 120ms);
}
@keyframes photoIn {
  0% {
    opacity: 0;
    transform: translate3d(var(--fx, 0px), 46px, 0) rotate(calc(var(--rot, 0deg) + var(--fr, 0deg))) scale(.86);
  }
  60% { opacity: 1; }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(var(--rot, 0deg)) scale(1);
  }
}
.polaroid img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #eee7d3;
}
.polaroid figcaption {
  margin-top: 4px;
  font-family: var(--script);
  font-size: 12px;
  color: #8d866f;
  text-align: center;
}
.polaroid:nth-child(1) { width: 45%; left: 0; top: 0; --rot: -5.5deg; --fx: -46px; --fr: -7deg; z-index: 2; }
.polaroid:nth-child(2) { width: 41%; right: 0; top: 2.5%; --rot: 4.5deg; --fx: 46px; --fr: 7deg; z-index: 1; }
.polaroid:nth-child(3) { width: 64%; left: 18%; top: 29%; --rot: -1.8deg; --fx: 0px; --fr: -3deg; z-index: 3; }
.polaroid:nth-child(3) img { aspect-ratio: 3 / 2; }
.polaroid:nth-child(4) { width: 35%; right: -1%; top: 41%; --rot: 5deg; --fx: 44px; --fr: 6deg; z-index: 5; }
.polaroid:nth-child(5) { width: 33%; left: 0; top: 52%; --rot: -4.2deg; --fx: -42px; --fr: -6deg; z-index: 4; }
.polaroid:nth-child(6) { width: 34%; right: 2%; top: 55%; --rot: 3.4deg; --fx: 42px; --fr: 6deg; z-index: 6; }
.polaroid:active { box-shadow: 0 4px 10px rgba(120, 105, 70, .22); }

/* ---------------- 感谢 ---------------- */
.thanks-body {
  position: relative;
  z-index: 2;
  width: min(90%, 448px);
  margin-top: .4vh;
}
.thanks-body p {
  margin: 0 0 1.35em;
  white-space: pre-line;
  font-size: clamp(12.5px, 3.4vw, 13.8px);
  line-height: 2.02;
  letter-spacing: .06em;
  color: var(--ink);
}
.thanks-body p:last-child { margin-bottom: 0; }
.thanks-body p.en {
  font-style: italic;
  font-size: 11.5px;
  line-height: 1.7;
  letter-spacing: .03em;
  color: var(--olive);
  margin-top: .2em;
}
.dance-illust {
  position: relative;
  z-index: 2;
  width: min(68%, 310px);
  max-height: 25svh;
  object-fit: contain;
  margin-top: 2px;
}

/* ---------------- 结尾 ---------------- */
.ending-illust {
  position: relative;
  z-index: 2;
  width: min(52%, 232px);
  max-height: 24svh;
  object-fit: contain;
  margin-bottom: 4px;
}
.poem {
  position: relative;
  z-index: 2;
  font-size: clamp(12.5px, 3.4vw, 13.8px);
  line-height: 2.08;
  letter-spacing: .12em;
  color: #5c5647;
}
.poem span { display: block; }
.signature {
  position: relative;
  z-index: 2;
  margin: 15px 0 12px;
  font-size: clamp(12.5px, 3.4vw, 13.8px);
  letter-spacing: .32em;
  color: var(--olive);
}
.ending-note {
  position: relative;
  z-index: 2;
  font-size: clamp(11.5px, 3.1vw, 12.4px);
  line-height: 2;
  letter-spacing: .06em;
  color: #6f6a58;
}
.ending-note span { display: block; }
.ending-english {
  position: relative;
  z-index: 2;
  max-width: 300px;
  margin: 12px 0 0;
  font-style: italic;
  font-size: 10.5px;
  line-height: 1.8;
  letter-spacing: .02em;
  color: #96907a;
}

/* ---------------- 飘落花瓣 / 爱心 ---------------- */
.falling {
  position: fixed;
  inset: 0;
  z-index: 25;
  overflow: hidden;
  pointer-events: none;
}
.falling i {
  position: absolute;
  top: -14vh;
  left: var(--l);
  font-style: normal;
  font-size: var(--s);
  line-height: 1;
  color: var(--c);
  opacity: var(--o);
  animation: fall var(--t) linear var(--dl) infinite;
  will-change: transform;
}
.falling i.petal-shape {
  width: var(--s);
  height: calc(var(--s) * .72);
  border-radius: 62% 8% 62% 8%;
  background: var(--c);
}

@keyframes fall {
  0%   { transform: translate3d(0, -14vh, 0) rotate(0deg); }
  50%  { transform: translate3d(var(--dx), 52vh, 0) rotate(220deg); }
  100% { transform: translate3d(calc(var(--dx) * -1), 114vh, 0) rotate(520deg); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ---------------- 音乐按钮 ---------------- */
.music-btn {
  position: fixed;
  top: calc(13px + env(safe-area-inset-top));
  right: 13px;
  z-index: 40;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(125, 138, 88, .42);
  background: radial-gradient(circle at 50% 42%, #fffdf6, #f1ecd9);
  color: var(--olive);
  box-shadow: 0 3px 11px rgba(120, 110, 80, .18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.music-btn[hidden] { display: none; }
.icon-disc {
  width: 24px;
  height: 24px;
  animation: spin 6s linear infinite;
  animation-play-state: paused;
}
.music-btn.playing .icon-disc { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 灯箱 ---------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(52, 47, 36, .82);
  backdrop-filter: blur(3px);
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 86svh;
  border: 8px solid #fffdf6;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 18px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 253, 246, .18);
  color: #fffdf6;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(34px + env(safe-area-inset-bottom));
  z-index: 70;
  transform: translate(-50%, 16px);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(76, 70, 55, .9);
  color: #fbf7ea;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .05em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 出现动效 ---------------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .9s ease var(--d, 0s), transform .9s cubic-bezier(.22, .68, .24, 1) var(--d, 0s);
  will-change: opacity, transform;
}
.page.is-active .reveal {
  opacity: 1;
  transform: none;
}

/* ---------------- 大屏优化 ---------------- */
@media (min-width: 640px) {
  .page { padding-left: 32px; padding-right: 32px; }
  .deco.garland { width: 200px; }
  .deco.ball { width: 170px; }
  .deco.corner-bl, .deco.corner-br { width: 220px; }
  .invite-text p, .thanks-body p { font-size: 14px; }
}
@media (min-width: 900px) {
  .page { justify-content: flex-start; padding-top: 70px; }
  .page-cover { justify-content: flex-start; padding-top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .pages { scroll-behavior: auto; }
  .falling { display: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .scroll-hint i, .icon-disc { animation: none; }
  .polaroid { opacity: 1; transform: rotate(var(--rot, 0deg)); animation: none !important; }
}
