/* ============================================================== Fonts === */
@font-face { font-family: 'StayClassy';  src: url('../fonts/StayClassy.woff2')   format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'HeadingWest'; src: url('../fonts/HeadingWest.woff2')  format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'GenSen';      src: url('../fonts/GenSenRounded.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Swei';        src: url('../fonts/SweiMarkerBlack.woff2') format('woff2'); font-weight: 900; font-display: swap; }

/* ========================================================== Palette ===== */
:root {
  --flare:      #EACFD9;
  --abloom:     #F2CECD;
  --rose:       #CE8F9E;
  --rose-deep:  #b06d80;
  --green:      #818455;
  --ink:        #5b4a44;
  --muted:      #a8998a;

  --font-caption: 'StayClassy', cursive;
  --font-couple:  'HeadingWest', 'StayClassy', cursive;
  --font-cn:      'GenSen', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-label:   'Swei', 'GenSen', sans-serif;
}

/* ============================================================= Base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-cn);
  color: var(--ink);
  background: radial-gradient(120% 90% at 50% 0%, #f7e2e8 0%, #efcfda 45%, #e3b9c8 100%) fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.7;
}
body.phase-envelope, body.phase-intro { overflow: hidden; height: 100svh; }
img { user-select: none; }
a { color: var(--rose-deep); }

/* ============================================ music player (S__8568837) = */
.player {
  display: flex; flex-direction: column; gap: 5px;
  width: 100%; margin: 0; padding: 8px 11px;
  background: rgba(252, 247, 243, .68); border-radius: 12px;
  box-shadow: 0 4px 12px rgba(120, 80, 70, .13);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.player-controls { display: flex; align-items: center; gap: 9px; }
.player-body { flex: 1 1 auto; min-width: 0; }
.player-title {
  margin: 0; font-family: var(--font-caption); font-size: 13px; line-height: 1.15;
  color: var(--ink); letter-spacing: .01em; text-align: center;
}
.player-artist { color: var(--rose-deep); }
.player-seek {
  -webkit-appearance: none; appearance: none; width: 100%; height: 11px;
  background: transparent; cursor: pointer; margin: 0; display: block;
}
.player-seek::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: #7a564f; }
.player-seek::-moz-range-track { height: 2px; border-radius: 2px; background: #7a564f; }
.player-seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 8px; height: 8px; margin-top: -3px;
  border-radius: 50%; background: #5c3a34; box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.player-seek::-moz-range-thumb { width: 8px; height: 8px; border: none; border-radius: 50%; background: #5c3a34; }
.player-times {
  display: flex; justify-content: space-between; margin-top: 2px;
  font-size: 9px; color: #b79a92; font-variant-numeric: tabular-nums;
}
/* vinyl record = play / pause */
.player-disc {
  flex: 0 0 auto; width: 30px; height: 30px; padding: 0; border: none; cursor: pointer;
  border-radius: 50%; position: relative; -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(circle at 50% 50%, #cf7a44 0 17%, #aa5f33 17% 18.5%, rgba(0,0,0,0) 18.5%),
    repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,.05) 0 1px, rgba(0,0,0,0) 1px 2.5px),
    radial-gradient(circle at 38% 32%, #2c2c2c 0, #141414 60%, #050505 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.player-disc::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 3.5px; height: 3.5px;
  transform: translate(-50%, -50%); border-radius: 50%; background: #efe7df;
}
.player.is-playing .player-disc { animation: vinylSpin 4.5s linear infinite; }
@keyframes vinylSpin { to { transform: rotate(360deg); } }

/* ============================================ Intro: handwriting ======== */
.intro-root { position: fixed; inset: 0; z-index: 40; transition: opacity .6s ease; }
.intro-stage {
  position: absolute; inset: 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  background: #f9eef1 url('../img/cover.webp') center center / cover no-repeat;
}
/* "Wedding Invitation" — centred on the 封面 paper texture, shimmering rose gold */
.wi { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(74%, 560px); overflow: visible; }
/* the letters are filled (solid rose gold) from the first frame; a fine same-
   colour edge keeps them crisp. No glow / shadow / border. */
.wi-stroke { fill: none; stroke: url(#roseGold); stroke-width: 24; stroke-linecap: round; stroke-linejoin: round; }
/* the whole .wi svg fades in once via a one-shot WAAPI animation in intro.js
   (declarative opacity animations get reset every frame by the render loop the
   long path keeps alive), so the fill itself just stays opaque */
.wi-fill { fill: url(#roseGold); stroke: none; }
.wi-fallback { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-couple); font-size: clamp(1.4rem, 7vw, 2.6rem); white-space: nowrap;
  background: linear-gradient(100deg, #b76e79 0%, #f8e4d8 50%, #b76e79 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ================================================== Stage 1: Envelope === */
.envelope-stage {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(110% 80% at 50% 38%, #f8e4ea 0%, #ecc9d6 55%, #ddacbd 100%);
  transition: opacity .7s ease;
}
.envelope-scene { width: min(86vw, 460px); margin: 0 auto; }

.envelope-caption {
  width: min(86vw, 460px);
  margin: 0 0 16px;
  font-family: var(--font-caption);
  font-size: clamp(1.7rem, 8vw, 2.8rem);
  line-height: 1.1;
  color: #9a5d54;
  text-align: center;
  transition: opacity .4s ease;
}

.envelope {
  position: relative; width: min(86vw, 460px);
  aspect-ratio: 893 / 598;
  perspective: 1400px;
  filter: drop-shadow(0 20px 32px rgba(120, 70, 80, .38));
}
.env-layer { position: absolute; left: 0; width: 100%; display: block; }
.env-inside {
  top: 0; height: 62%; z-index: 1;
  background: linear-gradient(180deg, #eee3cf 0%, #f7f0e1 75%);
  border-radius: 0 0 4px 4px;
  box-shadow: inset 0 6px 14px rgba(150, 120, 90, .25);
}
.env-body { bottom: 0; z-index: 3; }
.env-flap {
  top: 0; z-index: 4;
  transform-origin: 50% 0; backface-visibility: hidden;
  transition: transform .8s cubic-bezier(.5, 0, .35, 1), opacity .35s ease .5s;
}

/* the reveal photo tucked inside (0403-75) — slides up from behind the body */
.env-photo {
  position: absolute; left: 50%; bottom: 4%; width: 52%; z-index: 2;
  margin: 0; padding: 5px 5px 13px; background: #fff;
  box-shadow: 0 10px 22px rgba(90, 60, 60, .35);
  transform: translate(-50%, 26%) rotate(-2deg);
  opacity: 0;
  transition: transform .85s cubic-bezier(.3, .7, .3, 1), opacity .5s ease;
}
.env-photo img { display: block; width: 100%; }

.seal {
  position: absolute; top: 53%; left: 50%;
  transform: translate(-50%, -50%);
  width: 9%; z-index: 6;
  padding: 0; border: none; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.seal img { display: block; width: 100%; filter: drop-shadow(0 3px 6px rgba(90,30,30,.45)); animation: sealPulse 2.6s ease-in-out infinite; }
@keyframes sealPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.seal:focus-visible { outline: 3px solid #fff; outline-offset: 4px; border-radius: 50%; }

/* ---- opening animation ---- */
body.phase-opening .seal { animation: sealBreak .55s ease forwards; }
body.phase-opening .seal img { animation: none; }
@keyframes sealBreak {
  40%  { transform: translate(-50%, -62%) scale(1.1); }
  100% { transform: translate(-50%, -150%) scale(1.2) rotate(-10deg); opacity: 0; }
}
body.phase-opening .env-flap { transform: rotateX(-165deg); opacity: .98; }
body.photo-out .env-photo { transform: translate(-50%, -46%) rotate(-2deg); opacity: 1; }
body.photo-up  .env-photo { transform: translate(-50%, -120%) rotate(-2deg); opacity: 0; }
body.phase-opening .envelope-caption { opacity: 0; }
body.env-fade .envelope-stage { opacity: 0; pointer-events: none; }

/* ==================================================== Stage 2: Letter === */
.letter-stage { display: none; }
body.phase-letter .letter-stage {
  display: block; min-height: 100svh;
  padding: clamp(16px, 4vw, 54px) clamp(10px, 3.5vw, 30px) 60px;
  animation: letterIn 1s ease both;
}
@keyframes letterIn { from { opacity: 0; transform: translateY(46px) scale(.96); } to { opacity: 1; transform: none; } }

.letter {
  position: relative; max-width: 640px; margin: 0 auto;
  background: #fffdfb;
  border-radius: 16px;
  box-shadow: 0 30px 70px rgba(120, 60, 75, .28);
  padding: clamp(30px, 6vw, 52px) clamp(20px, 5.5vw, 46px) 22px;
  overflow: hidden;
}
.deco-top {
  position: absolute; top: 12px; right: 14px;
  width: 22%; max-width: 130px; z-index: 0; opacity: .92; pointer-events: none;
}
.letter-inner { position: relative; z-index: 1; }
.deco-bottom { display: block; width: 60%; max-width: 340px; margin: 16px auto 0; opacity: .92; }

/* top row: hero photo (left) + couple names (right, below the heart) */
.letter-head { display: flex; align-items: center; gap: clamp(12px, 4vw, 20px); margin: 12px 0 14px; }
.letter-head .hero-col { flex: 0 0 50%; display: flex; flex-direction: column; gap: 8px; }
.letter-head .hero { margin: 0; }
.letter-head .hero figure { display: block; width: 100%; max-width: none; margin: 0; }
/* names: right column, pushed down so they sit between the photo/player and the
   top-right heart (not covering it) */
.letter-head .couple { flex: 1; margin: clamp(62px, 15vw, 104px) 0 0; align-self: flex-start; }

/* hero photo: polaroid with washi tape, square corners */
.hero { margin: 6px 0 20px; }
.hero figure {
  position: relative; display: inline-block;
  width: 60%; max-width: 290px; margin: 6px 0 0 4px;
  background: #fff; padding: 8px 8px 8px;
  box-shadow: 0 9px 20px rgba(120, 60, 70, .22);
  transform: none;
}
.hero img { display: block; width: 100%; border-radius: 0; }
.hero figure::before {                       /* washi tape */
  content: ""; position: absolute; top: -11px; left: 50%;
  width: 74px; height: 22px; transform: translateX(-50%) rotate(-5deg);
  background: rgba(234, 207, 217, .65); box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.couple {
  font-family: var(--font-couple); font-weight: 400;
  text-align: center; font-size: 45px; line-height: 1.05;
  color: var(--ink); margin: 0;
}
/* tagline moved down into the old divider's place (rule + heart removed) */
.tagline { font-family: var(--font-couple); text-align: center; color: var(--rose-deep); font-size: 36px; margin: 30px 0 8px; line-height: 1.2; }

.rule { display: flex; align-items: center; color: var(--rose); margin: 22px 0; }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--rose), transparent); }
.rule span { padding: 0 14px; font-size: .9rem; }

.details { text-align: center; margin: 18px 0; }
.details-inner { display: inline-block; text-align: left; font-size: 14px; line-height: 2; color: var(--ink); }
.details-inner p { margin: 0; }
.details-inner b { color: var(--green); font-weight: 400; }
.details-inner .addr { color: var(--muted); }
.map-link { display: inline-block; margin-top: 8px; font-size: 14px; text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 1px; }

.invite-copy { text-align: center; font-size: 14px; line-height: 2; margin: 22px 0; }

/* ----- scrapbook collage (tight, overlapping, tilted, white frames) ----- */
.collage { position: relative; margin: 24px auto 24px; max-width: 430px; padding: 6px 0 14px; }
.collage figure { position: relative; margin: 0; width: 58%; background: #fff; padding: 7px 7px 9px; box-shadow: 0 7px 16px rgba(120, 70, 80, .22); }
.collage img { display: block; width: 100%; height: auto; border-radius: 0; }
.collage .c1 { margin-left: auto; transform: rotate(2.5deg); z-index: 2; }
.collage .c2 { margin-top: -24%; transform: translateX(-50px) rotate(-5deg); z-index: 3; }
.collage .c3 { margin-left: auto; margin-top: -10%; transform: rotate(2deg); z-index: 4; }
/* hand-drawn illustrations in the whitespace */
.collage .illus { position: absolute; pointer-events: none; z-index: 6; }
.collage .il-2 { top: 16%; left: -4%; width: 134px; transform: rotate(-15deg); }  /* airplane: left-centre whitespace, tilted left, lowered */
.collage .il-3 { top: 60%; right: 14px; left: auto; width: 74px; transform: rotate(10deg); }  /* heart char: right-side pocket, nudged right */
.collage .il-1 { bottom: 3.2%; left: -10%; width: 160px; transform: rotate(-4deg); } /* heart people: lower-left, bottom not past photo-3's bottom */
/* scattered rose petals (花) — varied sizes, irregular scatter, biggest two furthest left */
.collage .petal { position: absolute; pointer-events: none; z-index: 6; filter: drop-shadow(0 2px 3px rgba(150,90,100,.18)); }
.collage .petal.p1 { top: 64%; right: 145px; width: 36px; transform: rotate(-18deg); opacity: .95; } /* biggest: lower-left */
.collage .petal.p2 { top: 56%; right: 108px; width: 16px; transform: rotate(22deg); opacity: .78; }
.collage .petal.p3 { top: 50%; right: 147px; width: 28px; transform: rotate(33deg); opacity: .9; }
.collage .petal.p4 { top: 52%; right: 94px; width: 20px; transform: rotate(-8deg); opacity: .82; }
.collage .petal.p5 { top: 69%; right: 120px; width: 24px; transform: rotate(-24deg); opacity: .85; }
.collage .petal.p6 { top: 62%; right: 116px; width: 14px; transform: rotate(48deg); opacity: .72; }
/* extra petals scattered in the whitespace to the right of photo-3 (0403-139) */
/* right of photo-3: zig-zag left/right (alternating), staggered, clear of the photo */
.collage .petal.p7 { top: 52%; right: -28px; width: 20px; transform: rotate(12deg);  opacity: .9; }
.collage .petal.p8 { top: 62%; right: -40px; width: 13px; transform: rotate(-18deg); opacity: .78; }
.collage .petal.p9 { top: 74%; right: -27px; width: 18px; transform: rotate(26deg);  opacity: .85; }
.collage .petal.p10 { top: 85%; right: -43px; width: 11px; transform: rotate(-8deg); opacity: .7; } /* bottom petal: pushed out near the edge */
/* little hearts of varied sizes around the paper plane (插圖2) */
.collage .hheart { position: absolute; z-index: 6; pointer-events: none; color: #e67e75; line-height: 1; }
.collage .hheart.h1 { top: 3%;  left: 22%; font-size: 22px; transform: rotate(-10deg); opacity: .9; }
.collage .hheart.h2 { top: 1%;  left: 33%; font-size: 12px; transform: rotate(16deg);  opacity: .8; }
.collage .hheart.h3 { top: 12%; left: 5%;  font-size: 17px; transform: rotate(-16deg); opacity: .85; }
.collage .hheart.h4 { top: 8%;  left: 30%; font-size: 11px; transform: rotate(8deg);   opacity: .75; }
.collage .hheart.h5 { top: 27%; left: 12%; font-size: 15px; transform: rotate(22deg);  opacity: .8; }
.collage figure::before { content: ""; position: absolute; top: -10px; left: 50%; width: 56px; height: 20px; transform: translateX(-50%) rotate(-4deg); background: rgba(180, 205, 170, .5); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.collage .c2::before { background: rgba(234, 207, 217, .6); left: 24%; transform: translateX(-50%) rotate(5deg); }
.collage .c3::before { background: rgba(245, 226, 160, .55); left: 76%; transform: translateX(-50%) rotate(-6deg); }

/* ============================================================= Form ===== */
.rsvp { margin-top: 14px; }
.q { border: none; margin: 0 0 22px; padding: 0; min-width: 0; }
.q legend {
  display: block; width: 100%; padding: 0; margin-bottom: 8px;
  font-family: var(--font-label);
  font-size: 16px; color: var(--ink); line-height: 1.7;
}
.q legend .heart { color: var(--rose); margin-right: .35em; }
.req { font-family: var(--font-cn); color: #c0556b; font-size: 12px; margin-left: .4em; font-style: normal; white-space: nowrap; }
.hint { color: var(--muted); font-size: 12px; }

.rsvp input[type=text], .rsvp input[type=email], .rsvp input[type=tel] {
  width: 100%; padding: .35em .15em; border: none; border-bottom: 1.6px solid #e0cdbb;
  border-radius: 0; background: transparent;
  font-family: var(--font-cn); font-size: 15px; color: var(--ink); transition: border-color .2s;
}
.rsvp input::placeholder { color: #c8baa8; }
.rsvp input:focus { outline: none; border-bottom-color: var(--rose); }

.opts { display: flex; flex-direction: column; gap: .15em; }
.opt { position: relative; display: flex; align-items: center; gap: .55em; cursor: pointer; padding: .3em 0; font-family: var(--font-cn); font-size: 15px; line-height: 1.6; }
.opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.dot { flex: none; width: 17px; height: 17px; border-radius: 50%; border: 1.6px solid #c9b6a6; position: relative; transition: border-color .18s; }
.opt input:checked ~ .dot { border-color: var(--rose); }
.opt input:checked ~ .dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--rose); }
.opt input:checked ~ .opt-t { color: var(--rose-deep); }
.opt input:focus-visible ~ .dot { box-shadow: 0 0 0 3px rgba(206, 143, 158, .4); }

.err { color: #c0556b; font-size: 13px; margin: .35em 0 0; }
.err:empty { display: none; }
.q.invalid input { border-bottom-color: #d98a9b; }
.rsvp.hide-dayof #dayOf, .rsvp.hide-dayof #dayOf2 { display: none; }
.not-attending-note { text-align: center; color: var(--rose-deep); background: #fbeef1; border-radius: 12px; padding: .8em 1em; margin: 0 0 20px; }

.submit-wrap { text-align: center; margin-top: 26px; }
.submit-btn {
  display: inline-block; min-width: 150px; padding: .6em 2.4em;
  border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--rose), #c2778d);
  color: #fff; font-family: var(--font-cn); font-size: 16px; letter-spacing: .08em; cursor: pointer;
  box-shadow: 0 10px 20px rgba(206, 143, 158, .42);
  transition: transform .15s, box-shadow .15s, opacity .2s;
}
.submit-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 26px rgba(206, 143, 158, .5); }
.submit-btn:active { transform: translateY(0); }
.submit-btn:disabled { opacity: .6; cursor: progress; transform: none; }
.form-error { color: #c0556b; text-align: center; margin-top: 14px; }

.thanks { animation: thanksIn .6s ease both; }
@keyframes thanksIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.thanks-card { text-align: center; padding: 30px 8px 10px; }
.thanks-mark { font-size: 3rem; color: var(--rose); animation: pop .7s ease both; }
@keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
.thanks-card h2 { color: var(--ink); margin: .2em 0 .3em; font-size: 1.5rem; }
.thanks-card p { color: var(--rose-deep); margin: 0; }

.letter-foot { text-align: center; margin-top: 28px; font-family: var(--font-cn); font-size: 12px; color: var(--muted); letter-spacing: .05em; }

/* ====================================================== Responsive ====== */
@media (max-width: 430px) {
  .collage { max-width: 330px; }
  .hero figure { width: 64%; }
}
@media (prefers-reduced-motion: reduce) {
  .seal img, body.phase-opening .seal, body.phase-opening .env-flap, body.phase-opening .env-photo,
  body.phase-letter .letter-stage, .thanks, .thanks-mark { animation: none !important; }
  .env-flap, .env-photo { transition: none !important; }
  * { transition-duration: .01ms !important; }
}
