/* Gilded lotus: oxblood paper, gold line, cream lotus, teal leaves.
   Everything is laid out 430 wide (see the viewport meta); --H is the height of the phone-sized window. */
:root {
  --H: 100vh;
  --ox: #642220;
  --cream: #f1e6cf;
  --ink: #4f1918;
  --gold: #c9a55c;
  --gold-l: #e8d29a;
  --paper: linear-gradient(180deg, #4f191822, #26080644), url("assets/gilded-lotus/web/oxblood-paper.webp") center / 430px auto;
  --txt: #f5ead2;
  --zh: "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans: "Tenor Sans", "Noto Serif SC", "Songti SC", sans-serif;
  --script: "Pinyon Script", "Snell Roundhand", cursive;
  --num: "Cormorant Garamond", "Noto Serif SC", serif;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 -.08'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  --noise-l: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .2 0 0 0 0 .1 0 0 0 .22 -.05'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
@supports (height: 100svh) { :root { --H: 100svh; } }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #2a0f0e; }
body { font-family: var(--sans); color: var(--txt); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img { display: block; -webkit-user-drag: none; user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

#shell { position: relative; left: 50%; width: 430px; height: var(--H); margin: 0 0 0 -215px; overflow: hidden; background: var(--ox); transform-origin: 50% 0; }
#app { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; overscroll-behavior: contain; }
#app::-webkit-scrollbar { display: none; }
body.sealed #app { overflow: hidden; }
/* on a desktop the invitation sits in a phone-sized window */
@media (min-width: 700px) {
  :root { --H: min(880px, calc(100vh - 48px)); }
  body { display: grid; place-items: center; background: radial-gradient(90% 90% at 50% 40%, #4a1817 0%, #2a0f0e 70%); }
  #shell { left: auto; margin: 0; transform-origin: 50% 50%; border-radius: 44px; box-shadow: 0 0 0 9px #1c0a09, 0 0 0 10.5px #8a6a32, 0 40px 90px rgba(0, 0, 0, 0.55); }
}

/* ---------- shared pieces ---------- */
.sec { position: relative; padding: 78px 34px 84px; text-align: center; overflow: hidden; }
.ox { background: var(--paper); }
.cream { background: var(--noise-l), var(--cream); color: var(--ink); }
.teal { background: var(--noise), radial-gradient(120% 70% at 50% 28%, #20504a 0%, #163a35 62%, #102c28 100%); }
.frame { position: absolute; inset: 13px; border: 1px solid rgba(210, 176, 106, 0.78); pointer-events: none; }
.frame i { position: absolute; width: 20px; height: 20px; background: url("img/corner.svg") center / contain no-repeat; }
.frame i:nth-child(1) { left: 5px; top: 5px; }
.frame i:nth-child(2) { right: 5px; top: 5px; transform: scaleX(-1); }
.frame i:nth-child(3) { left: 5px; bottom: 5px; transform: scaleY(-1); }
.frame i:nth-child(4) { right: 5px; bottom: 5px; transform: scale(-1); }
.xi { font-family: var(--zh); font-weight: 900; font-size: 28px; line-height: 1; color: var(--gold); }
.caps { font-size: 11px; line-height: 19px; letter-spacing: 0.24em; text-indent: 0.24em; text-transform: uppercase; }
.script { font-family: var(--script); font-weight: 400; }
.kicker { font-family: var(--zh); font-weight: 700; font-size: 15px; line-height: 24px; letter-spacing: 0.55em; text-indent: 0.55em; color: var(--gold-l); }
.cream .kicker { color: #8a3a2c; }
h2.script { font-size: 48px; line-height: 58px; margin: 2px 0 8px; color: #f7ecd4; }
.cream h2.script { color: #6a2422; }
.cream .caps { color: #8a5a3a; }
.btn { display: block; width: 286px; height: 50px; margin: 14px auto 0; border-radius: 25px; font-family: var(--sans); font-weight: 500; font-size: 14.5px; line-height: 50px; letter-spacing: 0.05em; text-align: center; text-decoration: none; transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.25s; }
.btn:active { transform: scale(0.96); }
.btn.gold { background: linear-gradient(180deg, #f0deaa 0%, #d0ae66 58%, #b8954e 100%); color: #2e0c0b; box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.55); }
.btn.line { border: 1px solid var(--gold); color: var(--gold-l); }
.btn.line:active { background: rgba(210, 176, 106, 0.14); }

/* sections rise into place as they scroll in */
[data-r] { opacity: 0; transform: translateY(20px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); transition-delay: calc(var(--i, 0) * 85ms); }
.in [data-r] { opacity: 1; transform: none; }
/* decorations fade in with their section; only hidden first when the script is there to reveal them */
.deco { transition: opacity 0.9s var(--ease) 0.2s, transform 1.1s var(--ease) 0.2s; }
.js .deco { opacity: 0; }
.js .in .deco { opacity: 1; }

/* ---------- 1 · hero ---------- */
#hero { height: var(--H); min-height: 700px; padding: 0; }
.hero-txt { position: absolute; left: 0; right: 0; top: 0; height: calc(100% - 440px); min-height: 293px; padding: 34px 30px 0; display: flex; flex-direction: column; justify-content: center; z-index: 2; }
.hero-txt .xi { margin-bottom: 12px; }
.hero-txt .caps { color: rgba(245, 234, 210, 0.88); }
.names { margin: 8px 0 0; font-size: 54px; line-height: 58px; color: #f8eed7; }
.names em { font-style: normal; font-size: 0.66em; color: var(--gold); margin: 0 0.06em; }
.zh-names { margin: 2px 0 12px; font-family: var(--zh); font-weight: 700; font-size: 15px; line-height: 24px; letter-spacing: 0.55em; text-indent: 0.55em; color: var(--gold-l); }
.lead { margin-bottom: 12px; font-size: 18px; line-height: 26px; color: #f8eed7; }
#hero .scene { position: absolute; left: 0; bottom: 0; width: 430px; height: 440px; z-index: 1; }
.fall { position: absolute; top: -90px; width: 15px; z-index: 1; opacity: 0; pointer-events: none; }
body.open .fall { animation: fall 11s linear infinite; }
.f1 { left: 64px; } .f2 { left: 250px; animation-delay: 3.6s !important; width: 12px; } .f3 { left: 356px; animation-delay: 7s !important; width: 17px; }
@keyframes fall {
  0% { transform: translate(0, 0) rotate(20deg); opacity: 0; }
  8% { opacity: 0.85; }
  55% { transform: translate(-46px, 430px) rotate(190deg); opacity: 0.8; }
  100% { transform: translate(20px, 860px) rotate(330deg); opacity: 0; }
}
.cue { position: absolute; left: 0; right: 0; bottom: 16px; z-index: 3; color: #f8eed7; font-size: 11px; letter-spacing: 0.24em; text-indent: 0.24em; text-transform: uppercase; opacity: 0; transition: opacity 0.8s; pointer-events: none; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.cue svg { display: block; width: 18px; margin: 6px auto 0; animation: nudge 1.8s ease-in-out infinite; }
body.open .cue { opacity: 0.9; }
body.scrolled .cue { opacity: 0; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* ---------- 2 · countdown ---------- */
#count { padding-bottom: 96px; }
.card { position: relative; width: 330px; margin: 28px auto 0; padding: 40px 20px 34px; background: var(--paper); color: var(--txt); box-shadow: 0 22px 44px rgba(0, 0, 0, 0.24); }
.card .frame { inset: 8px; }
.days b { display: block; font-family: var(--num); font-weight: 500; font-size: 108px; line-height: 98px; color: #f8eed7; font-variant-numeric: lining-nums; }
.days span, .hms span { display: block; font-size: 11px; letter-spacing: 0.26em; text-indent: 0.26em; text-transform: uppercase; color: var(--gold-l); }
.days span { margin-top: 8px; }
.hms { display: flex; justify-content: center; gap: 30px; width: 250px; margin: 22px auto 0; padding-top: 20px; border-top: 1px solid rgba(210, 176, 106, 0.5); }
.hms b { display: block; min-width: 52px; font-family: var(--num); font-weight: 500; font-size: 40px; line-height: 40px; color: #f8eed7; font-variant-numeric: lining-nums tabular-nums; }
.hms span { margin-top: 6px; font-size: 11px; letter-spacing: 0.16em; text-indent: 0.16em; }
.c-lotus { position: absolute; right: -58px; bottom: -64px; width: 156px; transform: rotate(8deg) scale(0.8); }
.c-bud { position: absolute; left: -16px; top: -40px; width: 44px; transform: rotate(-16deg) scale(0.8); }
.in .c-lotus { transform: rotate(8deg); }
.in .c-bud { transform: rotate(-16deg); }

/* ---------- 3 · our story ---------- */
#story { padding-top: 40px; padding-bottom: 150px; }
.kopi { width: 210px; margin: 22px auto 22px; }
.zh-p { font-family: var(--zh); font-weight: 700; font-size: 17px; line-height: 32px; letter-spacing: 0.14em; color: var(--ink); }
.en-p { margin-top: 12px; font-size: 13px; line-height: 22px; color: #7a4a38; }
.sign { margin-top: 18px; font-size: 34px; line-height: 44px; color: #8a3a2c; }
.s-hill { position: absolute; left: -44px; bottom: -6px; width: 230px; transform: translateY(40px); }
.in .s-hill { transform: none; }

/* ---------- 4 · the banquet ---------- */
#party { padding: 96px 34px 100px; }
#party .xi { margin-bottom: 18px; }
.p-moon { position: absolute; left: 44px; top: 46px; width: 54px; transform: translateY(26px); }
.in .p-moon { transform: none; }
.zh-line { margin-top: 6px; font-family: var(--zh); font-weight: 500; font-size: 16px; line-height: 26px; letter-spacing: 0.3em; text-indent: 0.3em; color: #f1e3c2; }
.times { display: flex; width: 300px; margin: 30px auto 30px; }
.times div { flex: 1; }
.times div + div { border-left: 1px solid rgba(210, 176, 106, 0.5); }
.times b { display: block; font-family: var(--num); font-weight: 500; font-size: 44px; line-height: 46px; color: #f8eed7; font-variant-numeric: lining-nums; }
.times b small { margin-left: 4px; font-family: var(--sans); font-size: 11px; letter-spacing: 0.14em; color: var(--gold-l); }
.times span { display: block; margin-top: 8px; font-family: var(--zh); font-weight: 700; font-size: 15px; letter-spacing: 0.4em; text-indent: 0.4em; color: #f1e3c2; }
.times em { display: block; margin-top: 3px; font-style: normal; font-size: 11px; letter-spacing: 0.24em; text-indent: 0.24em; text-transform: uppercase; color: var(--gold-l); }
.venue { font-family: var(--zh); font-weight: 900; font-size: 27px; line-height: 38px; letter-spacing: 0.22em; text-indent: 0.22em; color: var(--gold-l); }
#party .caps { margin-top: 6px; color: rgba(241, 227, 194, 0.86); }
#map { margin-top: 30px; }

/* ---------- 5 · the day ---------- */
#day { padding-bottom: 310px; } /* the pond painting is clear in its top third, so the sign-off can sit over it */
.sched { position: relative; width: 322px; margin: 30px auto 0; list-style: none; text-align: left; }
.sched::before { content: ""; position: absolute; left: 107px; top: 10px; bottom: 10px; width: 1px; background: linear-gradient(180deg, rgba(210, 176, 106, 0), #c9a55c 12%, #c9a55c 88%, rgba(210, 176, 106, 0)); }
.sched li { position: relative; display: grid; grid-template-columns: 86px 44px 1fr; align-items: center; height: 76px; }
.sched time { text-align: right; font-family: var(--num); font-weight: 500; font-size: 26px; line-height: 30px; color: #f8eed7; font-variant-numeric: lining-nums; white-space: nowrap; }
.sched time small { margin-left: 3px; font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; color: var(--gold-l); }
.sched i { justify-self: center; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(160deg, #f0deaa, #d0ae66 55%, #b8954e); box-shadow: 0 0 0 4px #611f1e, 0 0 0 5px rgba(210, 176, 106, 0.6); font-family: var(--zh); font-style: normal; font-weight: 900; font-size: 17px; line-height: 36px; text-align: center; color: #2e0c0b; }
.sched div { padding-left: 14px; }
.sched b { display: block; font-family: var(--zh); font-weight: 700; font-size: 19px; line-height: 26px; letter-spacing: 0.26em; color: #f8eed7; }
.sched span { display: block; font-size: 11px; line-height: 16px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-l); }
.rsvp { margin-top: 44px; }
.rsvp .caps { margin: 2px 0 14px; color: rgba(245, 234, 210, 0.86); }
#rsvp-msg { min-height: 38px; margin: 16px 0 0; color: var(--gold-l); }
body.replied .rsvp .btn { opacity: 0.45; pointer-events: none; }
body.replied .rsvp .btn.chosen { opacity: 1; }
.foot { margin-top: 26px; font-family: var(--zh); font-weight: 700; font-size: 16px; line-height: 26px; letter-spacing: 0.4em; text-indent: 0.4em; color: var(--gold-l); }
#replay { display: block; margin: 20px auto 0; padding: 8px 14px; color: rgba(245, 234, 210, 0.7); border-bottom: 1px solid rgba(210, 176, 106, 0.4); }
#day .scene { position: absolute; left: 0; bottom: 0; width: 430px; height: 440px; }
.pt { position: absolute; left: -11px; top: -40px; width: 22px; z-index: 9; pointer-events: none; }

/* ---------- the envelope ---------- */
#stage { position: absolute; inset: 0; z-index: 5; overflow: hidden; cursor: pointer; outline: none; }
#veil { position: absolute; inset: 0; background: var(--paper); }
.lf { position: absolute; width: 520px; height: 378px; }
#env { position: absolute; inset: 0; perspective: 1300px; perspective-origin: 50% 40%; }
#env-in { position: absolute; inset: 0; transform-style: preserve-3d; }
#env-body { position: absolute; inset: 0; background: var(--paper); }
#env-body .scene { position: absolute; left: 0; bottom: 0; width: 430px; height: 440px; }
/* the moon waits under the flap */
#env-body .moon { position: absolute; left: 177px; top: 150px; width: 76px; }
#flap-shade { position: absolute; left: 0; top: 0; width: 430px; height: 474px; filter: blur(10px); opacity: 0.5; transform-origin: 50% 0; }
#flap-shade i { position: absolute; left: 6px; top: 0; width: 418px; height: 474px; background: #1c0706; clip-path: polygon(0 0, 100% 0, 100% 12%, 50% 100%, 0 12%); }
#flap { position: absolute; left: 0; top: 0; width: 430px; height: 460px; transform-style: preserve-3d; transform-origin: 50% 0; }
#flap > * { position: absolute; left: 0; top: 0; width: 430px; height: 460px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
/* front of the flap: the pack's oxblood paper cut to the flap outline (img/flap-paper.webp), gold line work on top */
#flap-front img { position: absolute; left: 0; top: 0; width: 430px; height: 460px; }
/* the lining is the mirror side of the flap: turned about the vertical axis, so its wide edge stays on the hinge */
#flap-back { transform: rotateY(180deg); }
#ribbon { position: absolute; left: 0; top: 0; width: 430px; height: 1400px; filter: drop-shadow(0 4px 5px rgba(20, 4, 0, 0.5)); pointer-events: none; }
#rib { position: absolute; left: 0; top: 0; width: 430px; height: 1400px; transform-origin: 215px 430px; }
#rib img { position: absolute; max-width: none; }
/* the band as short links, so it can fall like cloth (built in app.js) */
.seg { position: absolute; left: 190px; width: 50px; background-size: 50px 1480px; background-repeat: no-repeat; transform-origin: 50% 0; will-change: transform; }
/* each piece turns about the point where it meets the knot (pivots from the ribbon manifest) */
#tailL { transform-origin: 94px -2px; } #tailR { transform-origin: 14px -2px; }
#loopL { transform-origin: 146px 76px; } #loopR { transform-origin: 4px 76px; }
#knot { transform-origin: 21px 23px; }
#ring { position: absolute; left: 215px; top: 430px; width: 170px; height: 170px; margin: -85px 0 0 -85px; border-radius: 50%; border: 1px solid rgba(241, 222, 166, 0.9); animation: ring 2.2s ease-out infinite; pointer-events: none; }
@keyframes ring { 0% { transform: scale(0.55); opacity: 0; } 25% { opacity: 0.9; } 100% { transform: scale(1.25); opacity: 0; } }
#hint { position: absolute; left: 0; right: 0; bottom: 9%; margin: 0 auto; width: 236px; height: 38px; border-radius: 19px; background: rgba(40, 12, 11, 0.72); box-shadow: 0 0 0 1px rgba(210, 176, 106, 0.75), 0 8px 20px rgba(0, 0, 0, 0.35); font-size: 11px; line-height: 38px; letter-spacing: 0.22em; text-indent: 0.22em; text-transform: uppercase; text-align: center; color: #f8eed7; pointer-events: none; animation: breathe 2.2s ease-in-out infinite; }
body.going #ring, body.going #hint { animation: none; opacity: 0; transition: opacity 0.25s; }
body.skip #ring, body.skip #hint { display: none; } /* test hooks jump straight in */
@keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ---------- sound switch ---------- */
#snd { position: absolute; right: 24px; top: 48px; z-index: 8; width: 36px; height: 36px; border-radius: 50%; background: rgba(40, 12, 11, 0.5); box-shadow: 0 0 0 1px rgba(210, 176, 106, 0.7); color: #f1dea6; }
#snd svg { width: 18px; height: 18px; margin: 9px; }
#snd .x { display: none; }
#snd.off .w { display: none; }
#snd.off .x { display: inline; }

/* a phone on its side: ask for portrait */
#turn { display: none; }
@media (orientation: landscape) and (max-width: 699px) {
  #turn { display: grid; place-items: center; position: fixed; inset: 0; z-index: 20; background: #5a1c1b; color: #f8eed7; font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .fall, #ring, #hint, .cue svg { animation: none !important; }
  [data-r], .deco { transition-duration: 0.01s; }
}
