/* Manyue invitation. Phone first. Two themes: open house (red packet) and Christmas Eve (pine + gold). */
:root {
  --red: #8f1820;
  --red-deep: #5e0d13;
  --red-soft: #f6e9e8;
  --gold-1: #8d6320;
  --gold-2: #c99a3c;
  --gold-3: #f3dc95;
  --gold: linear-gradient(115deg, var(--gold-1) 0%, var(--gold-2) 28%, var(--gold-3) 48%, var(--gold-2) 62%, var(--gold-1) 100%);
  --ink: #261516;
  --ink-2: #6a5455;
  --paper: #ffffff;
  --line: #ead9d7;
  --ok: #2f7a4f;
  --warn: #b86b12;
  --display: "Bodoni Moda", "Times New Roman", serif;
  --body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --wrap: min(1120px, 100% - 2 * clamp(20px, 5vw, 48px));
  --r: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
html[data-event="eve"] {
  --red: #173d31;
  --red-deep: #0d2820;
  --red-soft: #ebf2ee;
  --line: #d6e3dc;
  --ink-2: #4f5f59;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
body {
  margin: 0;
  font: 400 18px/1.55 var(--body);
  color: var(--ink);
  background: var(--paper);
  overflow-x: clip;
}
body.is-locked { overflow: hidden; }
img { display: block; max-width: 100%; }
h1, h2 { font-family: var(--display); font-weight: 500; line-height: 1.02; margin: 0; letter-spacing: -.01em; }
h2 { font-size: clamp(34px, 6vw, 60px); }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
.wrap { width: var(--wrap); margin-inline: auto; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--paper); padding: 10px 16px; border-radius: 8px; }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 3px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 24px; border-radius: 12px; border: 0; cursor: pointer;
  font-weight: 600; font-size: 17px; text-decoration: none;
  background: var(--red); color: #fff;
  transition: transform .18s var(--ease), background-color .18s, box-shadow .18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px -8px rgb(0 0 0 / .45); }
.btn:active { transform: translateY(1px) scale(.985); box-shadow: none; }
.btn[disabled] { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.btn-gold { background: var(--gold); background-size: 220% 100%; color: var(--red-deep); }
.btn-gold:hover { background-position: 100% 0; }
.btn-line { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; }
.btn-line:hover { background: rgb(255 255 255 / .08); }
.link {
  background: none; border: 0; padding: 10px 0; min-height: 44px; cursor: pointer;
  color: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 4px;
  text-decoration-thickness: 1px; transition: text-decoration-thickness .15s;
}
.link:hover { text-decoration-thickness: 2px; }

/* ---------- live strip (event day only) ---------- */
.live {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 10px clamp(20px, 5vw, 48px); padding-top: max(10px, env(safe-area-inset-top));
  background: var(--red-deep); color: #fff; font-size: 15px; font-weight: 500;
}
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa; flex: none; }
.live[data-baby="awake"] .live-dot, .live[data-baby="moment"] .live-dot { background: #6fd39a; }
.live[data-baby="feeding"] .live-dot { background: #f0b45a; }
.live[data-baby="sleeping"] .live-dot { background: #a9b4d6; }
.live-now { opacity: .75; font-weight: 400; margin-left: auto; }
body.has-live .cover { padding-top: 72px; }

/* ---------- 1. cover ---------- */
.cover {
  position: relative; min-height: 100svh;
  display: grid; place-items: center; align-content: center; gap: 26px;
  padding: 48px 20px; text-align: center; color: #fff;
  background: var(--red);
  overflow: hidden;
}
/* foil frame around the screen, like the edge of a packet */
.cover::before {
  content: ""; position: absolute; inset: 14px; border-radius: 18px; pointer-events: none;
  border: 1.5px solid transparent;
  background: var(--gold) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0);
  opacity: .75;
}
.cover-to { font-family: var(--display); font-size: clamp(24px, 6vw, 34px); line-height: 1.15; max-width: 18ch; }
.cover-hint { font-size: 15px; letter-spacing: .02em; opacity: .85; transition: opacity .3s; }
.is-open .cover-hint { opacity: 0; }
.cover-to { transition: opacity .4s .3s; }
.is-open .cover-to { opacity: 0; }

.packet {
  --w: min(250px, 62vw);
  position: relative; width: var(--w); aspect-ratio: 0.6;
  border: 0; padding: 0; background: none; cursor: pointer;
  perspective: 900px; -webkit-tap-highlight-color: transparent;
  transition: transform .25s var(--ease);
}
.packet:hover { transform: translateY(-3px); }
.packet:active { transform: scale(.98); }
.is-open .packet { cursor: default; transform: none; }
.packet > span { position: absolute; inset: 0; border-radius: 10px; }
.packet-back { background: var(--red-deep); box-shadow: 0 30px 60px -24px rgb(0 0 0 / .6); }
.packet-front {
  background:
    radial-gradient(120% 70% at 50% 0%, rgb(255 255 255 / .10), transparent 60%),
    #a71d26;
  display: grid; place-items: center; z-index: 3;
  clip-path: polygon(0 30%, 50% 47%, 100% 30%, 100% 100%, 0 100%);
}
html[data-event="eve"] .packet-front { background: #1f4d3f; clip-path: none; }
.packet-front::after { /* foil lines across the bottom */
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 13%; height: 2px;
  background: var(--gold); box-shadow: 0 -8px 0 -0.5px var(--gold-2);
}
.seal {
  position: relative; top: 9%;
  width: 34%; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold); background-size: 220% 100%;
  color: var(--red-deep); font-family: var(--display); font-weight: 600;
  font-size: clamp(17px, 4.6vw, 24px); letter-spacing: .04em; writing-mode: vertical-rl;
  box-shadow: 0 4px 10px rgb(0 0 0 / .3);
  background-position: 30% 0;
  animation: foil 2.4s var(--ease) 1s 1 both;
}
html[data-event="eve"] .seal { display: none; }
.packet-flap {
  z-index: 4; transform-origin: 50% 0; transform-style: preserve-3d;
  background: linear-gradient(180deg, #b3232d, #951922);
  clip-path: polygon(0 0, 100% 0, 100% 30%, 50% 47%, 0 30%);
  transition: transform .7s var(--ease), z-index 0s .35s;
}
html[data-event="eve"] .packet-flap { display: none; }
.is-open .packet-flap { transform: rotateX(180deg); z-index: 1; background: #7a131b; }
.packet-card {
  z-index: 2; inset: 6% 7% 8% !important; border-radius: 8px !important;
  background: #fff; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 6px; padding: 18px 12px; text-align: center;
  transition: transform .9s var(--ease) .45s;
}
.is-open .packet-card { transform: translateY(-58%); }
.packet-card-line { font-size: 13px; color: var(--ink-2); }
.packet-card-name { font-family: var(--display); font-size: clamp(20px, 5.4vw, 26px); line-height: 1.1; }
.packet-card-date { font-size: 13px; font-weight: 600; color: var(--red); }

/* Christmas Eve: a wrapped gift. The lid lifts off. */
.gift-lid { display: none; }
html[data-event="eve"] .packet { aspect-ratio: 0.82; }
html[data-event="eve"] .packet-front {
  background:
    linear-gradient(90deg, transparent 44%, var(--gold-2) 44%, var(--gold-3) 50%, var(--gold-2) 56%, transparent 56%),
    #1f4d3f;
  top: 22%;
}
html[data-event="eve"] .packet-back { top: 22%; }
html[data-event="eve"] .packet-card { inset: 26% 8% 6% !important; }
html[data-event="eve"] .is-open .packet-card { transform: translateY(-82%); }
html[data-event="eve"] .gift-lid {
  display: block; z-index: 5; inset: 12% -4% auto !important; height: 17%;
  background:
    linear-gradient(90deg, transparent 44%, var(--gold-2) 44%, var(--gold-3) 50%, var(--gold-2) 56%, transparent 56%),
    #245a4a;
  box-shadow: 0 8px 14px -8px rgb(0 0 0 / .5);
  transition: transform .8s var(--ease), opacity .5s .4s;
}
.gift-bow {
  position: absolute; left: 50%; bottom: 100%; width: 34%; aspect-ratio: 2.2; translate: -50% 18%;
  background:
    radial-gradient(circle at 50% 100%, var(--gold-3) 0 14%, transparent 15%),
    radial-gradient(ellipse 48% 70% at 22% 70%, var(--gold-2) 0 60%, transparent 62%),
    radial-gradient(ellipse 48% 70% at 78% 70%, var(--gold-2) 0 60%, transparent 62%);
}
html[data-event="eve"] .is-open .gift-lid { transform: translate(18%, -70%) rotate(16deg); opacity: 0; }

@keyframes foil { from { background-position: 0 0; } to { background-position: 30% 0; } }

/* entrance, once on load */
[data-enter] { animation: enter .9s var(--ease) both; }
.packet[data-enter] { animation-delay: .12s; }
.cover-hint[data-enter] { animation-delay: .5s; }
@keyframes enter { from { opacity: 0; transform: translateY(18px); } }

/* ---------- sections ---------- */
main > section { padding-block: clamp(72px, 12vh, 128px); }
.frame { margin: 0; border-radius: var(--r); overflow: hidden; background: var(--red-soft); position: relative; }
.frame img { width: 100%; height: 100%; object-fit: cover; }
.ph { /* a frame waiting for its photo */
  width: 100%; height: 100%; display: grid; place-items: center;
  color: var(--red); opacity: .55; font-family: var(--display); font-size: clamp(64px, 14vw, 140px);
  background: repeating-linear-gradient(135deg, transparent 0 18px, rgb(143 24 32 / .05) 18px 19px);
}
.kicker { font-size: 17px; color: var(--ink-2); margin-bottom: 6px; }

/* 2. baby */
.baby { min-height: 100svh; display: grid; align-items: center; }
.baby-grid { display: grid; gap: 32px; }
.baby-photo { aspect-ratio: 4 / 5; }
.baby-name { font-size: clamp(76px, 22vw, 180px); color: var(--red); line-height: .92; overflow-wrap: anywhere; }
.baby-names { margin-top: 16px; font-family: var(--display); font-size: clamp(24px, 5vw, 34px); line-height: 1.2; }
.baby-names span, .seal { font-family: "Noto Serif SC", "Songti SC", "STSong", serif; }
.baby-names span { margin-left: .4em; color: var(--red); }
.baby-meaning { margin-top: 14px; font-size: 19px; color: var(--ink-2); max-width: 34ch; }
.stats { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 6px 32px; margin: 28px 0 0; }
.stats div { display: contents; }
.stats dt { grid-row: 1; font-size: 14px; color: var(--ink-2); }
.stats dd { grid-row: 2; margin: 0; font-family: var(--display); font-size: clamp(24px, 5vw, 32px); }
.baby-from { margin-top: 28px; color: var(--ink-2); }

/* 3. days: scroll scrubs through the month */
.days { height: 340svh; padding: 0 !important; background: var(--red-soft); }
.days-sticky { position: sticky; top: 0; height: 100svh; display: grid; align-items: center; overflow: hidden; }
body.has-live .days-sticky { padding-top: 48px; }
.days-grid { display: grid; gap: 18px; height: 100%; padding-block: 28px; grid-template-rows: auto 1fr; }
.days-count { display: flex; align-items: baseline; gap: 12px; margin-top: 8px; }
.days-num { font-family: var(--display); font-size: clamp(64px, 15vw, 132px); line-height: 1; color: var(--red); font-variant-numeric: tabular-nums; min-width: 2ch; }
.days-of { color: var(--ink-2); }
.ticks { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; margin-top: 10px; max-width: 420px; }
.ticks i { height: 6px; border-radius: 3px; background: var(--line); transition: background-color .2s; }
.ticks i.on { background: var(--red); }
.days-frame { min-height: 0; height: 100%; max-height: 72svh; aspect-ratio: 4 / 5; justify-self: center; width: auto; max-width: 100%; }
.days-frame > * { position: absolute; inset: 0; opacity: 0; transition: opacity .22s linear; }
.days-frame > .on { opacity: 1; }

/* 4. the day */
.day { min-height: 100svh; display: grid; align-items: center; }
.day-grid { display: grid; gap: 36px; align-items: center; }
.egg-wrap { display: grid; place-items: center; }
.egg { position: relative; width: min(190px, 46vw); aspect-ratio: .78; }
.egg-half, .egg-inside { position: absolute; inset: 0; border-radius: 50% 50% 48% 48% / 58% 58% 42% 42%; }
.egg-half {
  background: radial-gradient(60% 50% at 34% 28%, #ff6b6b, #c8102e 55%, #7c0a1a 100%);
  box-shadow: inset -10px -14px 24px rgb(0 0 0 / .25);
  transition: transform 1.1s var(--ease), opacity .6s .7s;
}
.egg-top { clip-path: polygon(0 0, 100% 0, 100% 46%, 86% 52%, 72% 43%, 58% 54%, 44% 44%, 30% 55%, 16% 45%, 0 53%); }
.egg-bottom { clip-path: polygon(0 53%, 16% 45%, 30% 55%, 44% 44%, 58% 54%, 72% 43%, 86% 52%, 100% 46%, 100% 100%, 0 100%); }
.egg-inside {
  display: grid; place-items: center; text-align: center; padding: 12%;
  background: #fff6e0; color: var(--red-deep); box-shadow: inset 0 0 0 2px #f1dfae;
  font-family: var(--display); font-size: clamp(22px, 5.4vw, 30px); line-height: 1.05;
  opacity: 0; transform: scale(.9); transition: opacity .5s .45s, transform .7s var(--ease) .45s;
}
.egg.cracked .egg-top { transform: translate(-14%, -38%) rotate(-24deg); opacity: 0; }
.egg.cracked .egg-bottom { transform: translate(12%, 34%) rotate(14deg); opacity: 0; }
.egg.cracked .egg-inside { opacity: 1; transform: none; }
.day-lede { margin-top: 14px; font-size: 20px; color: var(--ink-2); max-width: 36ch; }
.notes { margin: 30px 0 0; display: grid; gap: 18px; max-width: 560px; }
.notes div { display: grid; grid-template-columns: 7.5em 1fr; gap: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.notes dt { font-weight: 600; }
.notes dd { margin: 0; color: var(--ink-2); }

/* 5. book */
.book { background: var(--red-soft); }
.book-grid { display: grid; gap: 36px; }
.book-head p { margin-top: 12px; color: var(--ink-2); max-width: 40ch; }
.form { display: grid; gap: 20px; background: var(--paper); border-radius: var(--r); padding: clamp(20px, 4vw, 32px); align-content: start; }
.field { display: grid; gap: 8px; }
.field label, .field .label { font-weight: 600; font-size: 16px; }
.field .hint { font-size: 14px; color: var(--ink-2); font-weight: 400; }
.field input[type="text"], .field input[type="tel"], .field textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; font-size: 17px;
  transition: border-color .15s;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--red); outline: none; box-shadow: 0 0 0 3px rgb(143 24 32 / .12); }
.err { color: #b3261e; font-size: 14px; font-weight: 500; }
.err:empty { display: none; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stepper { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; width: fit-content; }
.stepper button { width: 52px; height: 52px; border: 0; background: #fff; font-size: 24px; cursor: pointer; transition: background-color .15s; }
.stepper button:hover { background: var(--red-soft); }
.stepper button:active { background: var(--line); }
.stepper output { min-width: 2.4ch; text-align: center; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 12px; align-items: center; min-height: 44px; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--red); }
.form-msg { font-weight: 500; color: #b3261e; }
.form-msg:empty { display: none; }

.given { background: var(--paper); border-radius: var(--r); padding: clamp(20px, 4vw, 32px); display: grid; gap: 8px; align-content: start; }
.given-day { font-weight: 600; color: var(--red); }
.given-time { font-family: var(--display); font-size: clamp(64px, 16vw, 112px); line-height: .95; }
.given-time span { display: block; font-family: var(--body); font-size: 18px; color: var(--ink-2); margin-top: 8px; }
.given-note { color: var(--ink-2); margin-top: 8px; max-width: 36ch; }

/* 7. pass */
.pass-slot { overflow: hidden; padding: 0 0 24px; margin: 0 -8px; }
.pass {
  position: relative; margin: 0 8px;
  background: var(--red); color: #fff; border-radius: 18px; padding: clamp(24px, 5vw, 40px);
  display: grid; gap: 22px;
  box-shadow: 0 24px 50px -30px rgb(0 0 0 / .7);
}
.pass.printing { animation: print 1.1s var(--ease) both; }
@keyframes print { from { transform: translateY(-104%); } }
.pass::before { /* foil edge */
  content: ""; position: absolute; inset: 8px; border-radius: 12px; pointer-events: none; border: 1px solid transparent;
  background: var(--gold) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0);
  opacity: .6;
}
.pass-date { font-weight: 500; opacity: .85; }
.pass-time { font-family: var(--display); font-size: clamp(72px, 19vw, 128px); line-height: .9; }
.pass-time small { display: block; font-family: var(--body); font-size: 17px; font-weight: 500; margin-top: 10px; opacity: .85; }
.pass-who { font-size: 19px; }
.pass-where { border-top: 1px solid rgb(255 255 255 / .22); padding-top: 18px; display: grid; gap: 6px; }
.pass-where b { font-weight: 600; }
.pass-where span { opacity: .85; }
.pass-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pass-actions .btn { flex: 1 1 200px; }
.pass-more { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.pass.cancelled { background: #6f6262; }
.late { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.late-done { font-weight: 600; }

.thanks { display: grid; gap: 14px; max-width: 40ch; }
.thanks p { color: var(--ink-2); font-size: 20px; }

.foot { padding: 40px 0 calc(40px + env(safe-area-inset-bottom)); color: var(--ink-2); font-size: 15px; }
.solo { min-height: 100svh; display: grid; align-items: center; background: var(--red); color: #fff; }
.solo h1 { font-size: clamp(36px, 7vw, 64px); max-width: 16ch; }
.solo p { margin-top: 16px; opacity: .85; }

/* ---------- wider screens ---------- */
@media (min-width: 820px) {
  .baby-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center; gap: 64px; }
  .days-grid { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 1fr; align-items: center; gap: 48px; }
  .days-frame { max-height: 78svh; height: 78svh; }
  .day-grid { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 64px; }
  .egg { width: min(260px, 26vw); }
  .book-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; gap: 48px; }
  .book-grid > .book-head { grid-column: 1 / -1; }
}
@media (max-width: 380px) {
  .notes div { grid-template-columns: 1fr; gap: 4px; }
  .pair { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
