/* =====================================================================
   Wedding invitation — styles
   Mobile-first. Breakpoints: 640px (sm), 768px (md), 1024px (lg).
   ===================================================================== */

:root {
  /* Palette */
  --paper: #f9f6f1;
  --cream: #f9f4ec;
  --sage: #a2b992;
  --sage-deep: #6e8f56;
  --sage-ink: #4a6338;
  --sage-soft: #dfead7;
  --envelope-bg: #c2d4b6;
  --gold: #cb994d;
  --gold-soft: #e6c799;
  --rose: #cc3352;
  --rose-deep: #931f36;
  --ink: #3c2c20;

  --grad-gold: linear-gradient(135deg, #d1a461, #a67d3f);
  --shadow-elegant: 0 20px 60px -20px rgb(61 80 48 / .25);
  --shadow-soft: 0 8px 30px -10px rgb(60 44 32 / .15);
  --shadow-gold: 0 10px 40px -10px rgb(178 127 52 / .4);
  --ease: cubic-bezier(.22, 1, .36, 1);

  /* Type */
  --f-script: "Great Vibes", "Brush Script MT", cursive;
  --f-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --f-caps: "Cinzel", Georgia, serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-serif);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, canvas, iframe { display: block; max-width: 100%; }
img { height: auto; }
p, h1, h2, h3, figure, dl, dd { margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--rose-deep); outline-offset: 4px; }
main:focus { outline: none; }

/* ---------- Shared pieces ---------- */
.section { position: relative; padding: 80px 24px; text-align: center; }
.section--tall { padding-top: 96px; padding-bottom: 96px; }
.bg-cream { background: var(--cream); }
.bg-sage { background: var(--sage-soft); }
.wrap { position: relative; margin: 0 auto; }
.w-2xl { max-width: 672px; }
.w-3xl { max-width: 768px; }
.w-5xl { max-width: 1024px; }
.w-6xl { max-width: 1152px; }

.eyebrow {
  font-family: var(--f-caps);
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--sage-deep);
}
.title {
  margin-top: 8px;
  font-family: var(--f-script);
  font-weight: 400;
  font-size: 48px;
  line-height: 1.15;
  color: var(--rose-deep);
}
.section-head { margin-bottom: 64px; }

/* Emoji decorations use the phone's own emoji font, like the reference */
.emoji, .petal, .corner {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
  font-style: normal;
  line-height: 1;
}

/* ❀ section divider */
.divider {
  display: flex; align-items: center; justify-content: center;
  margin: 24px 0;
  font-size: 18px; line-height: 28px;
  color: var(--gold);
}
.divider--sm { margin: 16px 0; font-size: 16px; line-height: 24px; }

/* faint corner flowers on each section */
.corner { position: absolute; opacity: .2; pointer-events: none; -webkit-user-select: none; user-select: none; }
.corner--tl { top: 24px; left: 16px; font-size: 36px; }
.corner--tr { top: 48px; right: 24px; font-size: 30px; }
.corner--bl { bottom: 40px; left: 40px; font-size: 30px; }
.corner--br { bottom: 24px; right: 16px; font-size: 36px; }

/* ---------- Butterfly ---------- */
.butterfly {
  position: fixed; top: 0; left: 0; z-index: 40;
  pointer-events: none;
  animation: butterfly-fly 18s linear infinite;
  will-change: transform;
}
.butterfly svg {
  width: 42px; height: 36px;
  animation: butterfly-flap .25s ease-in-out infinite;
}

/* ---------- Falling petals ---------- */
.petals { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 10; }
.envelope-screen .petals { z-index: 1; }
.petal {
  position: absolute; top: -10vh;
  animation-name: float-petal;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / .1));
  will-change: transform, opacity;
}

/* ---------- 1. Envelope screen ---------- */
.envelope-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: max(40px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: var(--envelope-bg);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
}
.envelope-screen.is-leaving { opacity: 0; transform: scale(1.05); pointer-events: none; }

.envelope-btn {
  position: relative; z-index: 2;
  margin: auto 0;
  padding: 0; border: 0; background: none;
  cursor: pointer;
  perspective: 1000px;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transition: transform .5s var(--ease), opacity .6s ease;
}
.envelope-btn.is-ready { opacity: 1; }
.envelope-btn:hover { transform: scale(1.05); }
.envelope-btn:focus-visible { outline-offset: 4px; border-radius: 12px; }
/* The envelope artwork is a tall 1080×1920 image with empty space above and
   below; show it through a centred square so it never pushes the text off
   short screens. It also shrinks on very short screens. */
.envelope-frame {
  --env-max: 280px;
  display: block;
  width: min(var(--env-max), calc(100vh - 230px));
  aspect-ratio: 1;
  overflow: hidden;
  filter: drop-shadow(0 25px 25px rgb(0 0 0 / .15));
  transform-origin: center;
}
@supports (height: 100svh) {
  .envelope-frame { width: min(var(--env-max), calc(100svh - 230px)); }
}
.envelope-img { width: 100%; height: 100%; object-fit: cover; }
.envelope-frame.is-opening { animation: envelope-open 1s var(--ease) forwards; }

.seal {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.seal-badge {
  position: relative;
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad-gold);
  box-shadow: var(--shadow-gold), inset 0 1px 2px rgb(255 255 255 / .35);
  animation: shimmer 3s ease-in-out infinite;
}
.seal-text {
  font-family: var(--f-caps); font-weight: 600;
  font-size: 12px; letter-spacing: .12em;
  color: rgb(255 255 255 / .92);
  white-space: nowrap;
}
.seal-flower {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  -webkit-user-select: none; user-select: none;
}
.envelope-copy {
  position: relative; z-index: 2;
  padding-bottom: 16px;
  text-align: center;
  animation: fade-up 1s var(--ease) .3s both;
}
.envelope-title {
  font-family: var(--f-script);
  font-size: 48px; line-height: 1.25;
  color: var(--sage-deep);
}
.envelope-hint {
  margin-top: 4px;
  font-size: 16px; font-style: italic; letter-spacing: .025em;
  color: var(--ink);
}

/* ---------- 2. Invitation ---------- */
.invitation.is-open { animation: fade-in 1.2s ease-out both; }

.music-btn {
  position: fixed; z-index: 50;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer;
  background: rgb(60 44 32 / .8);
  color: var(--cream);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: var(--shadow-elegant);
  transition: transform .15s ease;
}
.music-btn:hover { transform: scale(1.05); }
.music-btn svg { width: 20px; height: 20px; }
.music-btn .i-on, .music-btn[aria-pressed="true"] .i-off { display: none; }
.music-btn[aria-pressed="true"] .i-on { display: block; }

/* Hero */
.hero { position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden; }
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-inner {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center;
  padding: max(48px, env(safe-area-inset-top)) 24px 48px;
  text-align: center;
}
.blessing { color: var(--rose-deep); }
.blessing-icon {
  width: 96px; height: 96px; margin: 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 3px rgb(0 0 0 / .07)) drop-shadow(0 2px 2px rgb(0 0 0 / .06));
}
.blessing-text { margin-top: 8px; font-size: 18px; font-style: italic; }
.intro { margin-top: 32px; max-width: 28rem; font-size: 16px; color: var(--rose-deep); text-wrap: balance; }
.person-name {
  margin-top: 24px;
  font-family: var(--f-script);
  font-size: 72px; line-height: 1;
  color: var(--rose);
  /* Great Vibes swashes overhang; keep them inside the box */
  padding: 0 .12em;
}
.person-name--second { margin-top: 8px; }
.person-parents {
  margin-top: 12px;
  font-size: 16px;
  color: rgb(60 44 32 / .8);
  white-space: pre-line;
}
.person-parents--last { padding-bottom: 48px; }
.joiner {
  margin-top: 20px;
  font-family: var(--f-script);
  font-size: 30px;
  color: var(--rose-deep);
}

/* Save the date */
.scratch {
  position: relative;
  width: 100%; max-width: 448px; height: 128px;
  margin: 0 auto 40px;
  border: 2px solid var(--gold-soft);
  border-radius: 16px;
  overflow: hidden;
  background: var(--cream);
  box-shadow: var(--shadow-elegant);
  -webkit-user-select: none; user-select: none;
}
.scratch-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.scratch-label {
  font-family: var(--f-caps);
  font-size: 16px; letter-spacing: .35em;
  color: var(--sage-deep);
  padding-left: .35em; /* balance the trailing letter-spacing */
}
.scratch-date {
  margin-top: 4px;
  font-family: var(--f-script);
  font-size: 36px; line-height: 1.2;
  color: var(--rose-deep);
}
.scratch-canvas {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%;
  cursor: grab;
  touch-action: none;
  transition: opacity .6s ease-out;
}
.scratch-canvas:active { cursor: grabbing; }
.scratch-canvas:focus-visible { outline: 2px solid var(--rose-deep); outline-offset: -4px; }

.countdown-wrap {
  max-height: 0; overflow: hidden;
  opacity: 0; transform: translateY(16px);
  pointer-events: none;
  transition: opacity .7s var(--ease), transform .7s var(--ease), max-height .7s var(--ease);
}
.countdown-wrap.is-visible { max-height: 260px; opacity: 1; transform: none; pointer-events: auto; }
.countdown { display: flex; justify-content: center; gap: 12px; padding-top: 16px; }
.cd-unit { display: flex; flex-direction: column; align-items: center; width: 68px; }
.cd-box {
  width: 100%; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream);
  border: 1px solid var(--gold-soft);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}
.cd-num {
  font-family: var(--f-caps);
  font-size: 24px; letter-spacing: .15em;
  font-variant-numeric: tabular-nums;
  color: var(--rose-deep);
}
.cd-label {
  margin-top: 8px;
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--sage-deep);
}
.countdown-done {
  padding-top: 8px;
  font-family: var(--f-script);
  font-size: 34px; line-height: 1.3;
  color: var(--rose-deep);
}

/* Events */
.events-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.event {
  position: relative; isolation: isolate;
  overflow: hidden;
  border: 1px solid var(--gold-soft);
  border-radius: 16px;
  background: #2b2420;
  box-shadow: var(--shadow-soft);
  color: #f1f5f9;
  transition: transform .5s var(--ease), box-shadow .5s var(--ease);
}
.event:hover { transform: translateY(-4px); box-shadow: var(--shadow-elegant); }
.event::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgb(0 0 0 / .4); }
.event-bg { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.event-inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: end; padding: 24px; }
.event-art { order: 2; display: flex; align-items: flex-end; justify-content: center; }
.event-art img { width: 100%; max-width: 220px; filter: drop-shadow(0 4px 6px rgb(0 0 0 / .25)); }
.event-text { order: 1; align-self: center; text-align: center; }
.event-title {
  font-family: var(--f-script);
  font-weight: 400; font-size: 48px; line-height: 1.15;
  color: #f8fafc;
}
.event-desc { margin-top: 8px; font-size: 16px; font-style: italic; color: #f1f5f9; }
.event .divider { margin: 20px 0; font-size: 16px; line-height: 24px; }
.event-meta { display: grid; gap: 12px; }
.event-meta dt {
  font-family: var(--f-caps);
  font-size: 14px; letter-spacing: .15em;
  color: #f1f5f9;
}
.event-meta dd { margin-top: 4px; font-size: 20px; color: #f1f5f9; }
.event-meta .is-venue dd { font-size: 18px; }
/* Cards without a couple illustration: centred text over the background */
.event--no-art .event-inner { min-height: 440px; align-items: center; }
.event--no-art .event-text { max-width: 30rem; margin: 0 auto; }

/* Presence */
.presence-text { font-size: 20px; font-style: italic; line-height: 1.625; color: rgb(60 44 32 / .82); }

/* Families */
.family-card {
  max-width: 448px;
  margin: 40px auto 0;
  padding: 32px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  border: 1px solid var(--gold-soft);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}
.family-photo {
  width: 100%; max-width: 260px;
  margin: 0 auto 24px;
  padding: 6px;
  background: var(--cream);
  border: 2px solid var(--gold-soft);
  border-radius: 999px 999px 18px 18px;
  box-shadow: var(--shadow-elegant);
}
.family-photo img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: 999px 999px 12px 12px;
}
.card-title { font-family: var(--f-caps); font-size: 12px; letter-spacing: .2em; color: var(--sage-deep); }
.host { margin: 4px 0; font-size: 20px; font-weight: 600; color: var(--ink); }
.host-note { margin-top: 12px; font-size: 17px; font-style: italic; color: var(--sage-deep); }

/* Venues */
.venues-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 56px 32px;
  margin-top: 40px;
}
.venue-label { font-family: var(--f-caps); font-size: 12px; letter-spacing: .2em; color: var(--sage-deep); }
.venue-name { margin-top: 8px; font-size: 24px; font-weight: 600; line-height: 1.25; color: var(--ink); }
.venue-address { margin-top: 4px; font-size: 18px; color: rgb(60 44 32 / .8); white-space: pre-line; }
.map {
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--gold-soft);
  border-radius: 16px;
  background: var(--sage-soft);
  box-shadow: var(--shadow-elegant);
}
.map iframe { width: 100%; height: 360px; border: 0; }
.btn-gold {
  display: inline-flex; align-items: center; justify-content: center; gap: 16px;
  height: 44px; margin-top: 32px; padding: 0 32px;
  border-radius: 999px;
  background: var(--grad-gold);
  box-shadow: var(--shadow-gold);
  color: #fff;
  font-size: 14px; font-weight: 500; line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity .2s ease, transform .2s ease;
}
.btn-gold:hover { opacity: .9; }
.btn-gold:active { transform: scale(.98); }
.btn-gold svg { width: 16px; height: 16px; }

/* Footer */
.footer {
  padding: 64px 24px calc(80px + env(safe-area-inset-bottom));
  background: var(--ink);
  color: var(--cream);
  text-align: center;
}
.footer { color: var(--paper); }
.footer-eyebrow { font-family: var(--f-caps); font-size: 12px; letter-spacing: .4em; }
.footer-names { margin-top: 12px; font-family: var(--f-script); font-size: 48px; line-height: 1.15; }
.divider--footer { margin: 20px 0; font-size: 24px; line-height: 32px; }
.footer-date { font-size: 18px; font-style: italic; }
.footer-tag { margin-top: 12px; font-family: var(--f-caps); font-size: 12px; letter-spacing: .15em; }

/* Falling paper pieces after the scratch card (created by JS) */
.streamers { position: fixed; inset: 0; z-index: 50; overflow: hidden; pointer-events: none; }
.streamers i { position: absolute; display: block; }
.streamers.is-falling i { transform: translate(var(--dx), 105vh) rotate(var(--spin)); opacity: 0 !important; }

.noscript { padding: 40vh 24px 0; text-align: center; font-size: 20px; }

/* ---------- Load-in animation helpers ---------- */
.fade-up { animation: fade-up 1s var(--ease) both; }
.d2 { animation-delay: .2s; }
.d3 { animation-delay: .3s; }
.d4 { animation-delay: .4s; }
.d5 { animation-delay: .5s; }
.d6 { animation-delay: .6s; }
.d7 { animation-delay: .7s; }

/* ---------- Keyframes ---------- */
@keyframes float-petal {
  0%   { transform: translateY(-10vh) translateX(0) rotate(0deg); opacity: 0; }
  10%  { opacity: .95; }
  90%  { opacity: .95; }
  100% { transform: translateY(110vh) translateX(50px) rotate(360deg); opacity: 0; }
}
@keyframes shimmer {
  0%, 100% { opacity: .85; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.04); }
}
@keyframes envelope-open {
  0%   { transform: scale(1) rotateX(0deg); }
  50%  { transform: scale(1.05) rotateX(-15deg); }
  100% { transform: scale(1.4) rotateX(-90deg); opacity: 0; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes butterfly-fly {
  0%   { transform: translate(-10vw, 85vh) rotate(5deg); }
  25%  { transform: translate(20vw, 60vh) rotate(25deg); }
  50%  { transform: translate(50vw, 40vh) rotate(-10deg); }
  75%  { transform: translate(75vw, 20vh) rotate(20deg); }
  100% { transform: translate(110vw, -10vh) rotate(0deg); }
}
@keyframes butterfly-flap {
  0%, 100% { transform: scaleX(1); }
  50%      { transform: scaleX(.25); }
}

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
  .title { font-size: 60px; }
  .envelope-frame { --env-max: 360px; }
  .seal-badge { width: 96px; height: 96px; }
  .seal-text { font-size: 14px; }
  .seal-flower { width: 22px; height: 22px; }
  .envelope-title { font-size: 60px; }
  .envelope-hint { font-size: 18px; }
  .hero-inner { padding-top: max(80px, env(safe-area-inset-top)); }
  .blessing-text { font-size: 20px; }
  .intro, .person-parents { font-size: 18px; }
  .venue-address { font-size: 20px; }
  .person-name { font-size: 96px; }
  .joiner { font-size: 36px; }
  .countdown { gap: 24px; }
  .cd-unit { width: 90px; }
  .cd-num { font-size: 36px; }
  .cd-label { font-size: 14px; }
  .event-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; padding: 32px; }
  .event-art { order: 1; }
  .event-text { order: 2; }
  .event--flip .event-art { order: 2; }
  .event--flip .event-text { order: 1; }
  .event--no-art .event-inner { grid-template-columns: minmax(0, 1fr); }
  .footer-names { font-size: 60px; }
}
@media (min-width: 768px) {
  .person-name { font-size: 128px; }
}
@media (min-width: 1024px) {
  .events-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event--wide { grid-column: 1 / -1; width: 100%; max-width: 672px; margin: 0 auto; }
}

/* Short screens (small phones, in-app browsers, landscape) */
@media (max-height: 600px) {
  .envelope-screen { padding-top: max(20px, env(safe-area-inset-top)); }
  .envelope-title { font-size: 40px; }
  .envelope-copy { padding-bottom: 4px; }
}

/* Visitors who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  .petals, .butterfly { display: none; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
