/* ════════════════════════════════════════════════════════
   Wedding samples · shared base (Earvin Laureano)
   Mechanics only: layout plumbing, motion states and the
   reduced-motion rules. Every theme brings its own look in
   <theme>.css, so no two samples look alike.

   Content is visible by default. Hidden starting states only
   apply under html.motion (JS on + motion OK).
════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html.intro-up, html:has(dialog[open]) { overflow: hidden; }
body { margin: 0; overflow-x: clip; -webkit-font-smoothing: antialiased; }
/* tilted things waiting to pop in must never widen the page */
main > section, body > footer { overflow-x: clip; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 3px solid var(--focus, currentColor); outline-offset: 3px; }

/* Phones change their visible height when the address bar moves.
   The engine measures this fixed 100svh probe instead. */
.vh-probe { position: fixed; top: 0; left: 0; width: 0; height: 100vh; height: 100svh; visibility: hidden; pointer-events: none; }

/* ── Demo bar (sits above everything, even the opening) ── */
.demo-bar {
  position: relative; z-index: 120;
  padding: 8px 16px;
  font: 500 13px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  text-align: center;
  background: #121212; color: #d4d4d4;
}
.demo-bar strong { color: #fff; font-weight: 700; }
.demo-bar a { color: #fff; font-weight: 600; text-underline-offset: 2px; white-space: nowrap; }

/* ── Toast (sample-only buttons explain themselves) ── */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 130;
  width: max-content; max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px; border-radius: 14px; text-align: center;
  font: 500 14.5px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #121212; color: #fff;
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
  transition: opacity .3s, transform .4s cubic-bezier(.22, 1, .36, 1);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── Opening ── hidden unless engine.js turns it on, so no one is ever stuck behind it */
.intro { display: none; }
html.js .intro.is-on { display: block; position: fixed; inset: 0; z-index: 100; overflow: hidden; }
.intro-stage {
  position: absolute; inset: var(--bar-h, 0px) 0 0; z-index: 2;
  display: grid; place-items: center;
  padding: 64px 20px 28px;
}
.intro-skip { position: absolute; z-index: 8; top: calc(var(--bar-h, 0px) + 14px); right: 16px; cursor: pointer; }

/* ── Scroll progress ── */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 60;
  transform-origin: 0 50%; transform: scaleX(var(--pg, 0));
  pointer-events: none;
}

/* ── Floating nav (hides on the way down, comes back on the way up) ── */
.nav-wrap {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  pointer-events: none;
  transform: translate3d(0, var(--off, 0px), 0);
}
.nav {
  pointer-events: auto; position: relative;
  display: flex; align-items: center;
  width: max-content; max-width: calc(100% - 28px);
  margin: 14px auto 0;
  transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}
.nav.is-hidden { transform: translateY(calc(-100% - 30px)); }
.nav-links { display: flex; align-items: center; }
.nav-menu { display: none; position: relative; cursor: pointer; }
@media (max-width: 1080px) {
  .nav { width: auto; margin-inline: 14px; justify-content: space-between; }
  .nav-links { display: none; }
  .nav-menu { display: block; }
}
.menu {
  position: fixed; inset: 0; z-index: 45;
  display: grid; place-items: center;
  padding: 100px 20px 40px; overflow-y: auto;
}
.menu nav { display: flex; flex-direction: column; align-items: center; gap: 4px; }
html.motion .menu.is-open a { animation: wd-menu-in .55s cubic-bezier(.34, 1.56, .64, 1) both; animation-delay: calc(var(--k, 0) * 55ms); }
@keyframes wd-menu-in { from { opacity: 0; transform: translateY(26px) rotate(-3deg); } }

/* ── Music: a record that spins while the song plays ── */
.music {
  position: fixed; z-index: 48;
  right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  pointer-events: none;
}
.music-btn { pointer-events: auto; position: relative; flex: none; width: 58px; height: 58px; padding: 0; border-radius: 50%; cursor: pointer; }
.music-disc { display: block; width: 100%; height: 100%; }
.music.is-playing .music-disc { animation: wd-spin 3.2s linear infinite; }
.music-badge { position: absolute; right: -6px; top: -6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.music-badge svg { width: 10px; height: 10px; }
.music-badge .i-pause,
.music.is-playing .music-badge .i-play { display: none; }
.music.is-playing .music-badge .i-pause { display: block; }
.music-pill {
  display: flex; flex-direction: column; gap: 2px;
  max-width: calc(100vw - 118px);
  text-align: left; line-height: 1.15;
  opacity: 0; transform: translateX(16px) scale(.9); transform-origin: 100% 50%;
  transition: opacity .3s cubic-bezier(.22, 1, .36, 1), transform .45s cubic-bezier(.34, 1.56, .64, 1);
}
.music.pill-on .music-pill { opacity: 1; transform: none; }
.music-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Reveal system ── */
html.motion [data-rv] {
  opacity: 0;
  transition:
    opacity .7s cubic-bezier(.22, 1, .36, 1) calc(var(--d, 0) * 90ms),
    transform 1s cubic-bezier(.34, 1.56, .64, 1) calc(var(--d, 0) * 90ms);
}
html.motion [data-rv="up"]         { transform: translateY(44px); }
html.motion [data-rv="fade"]       { transform: none; }
html.motion [data-rv="pop"]        { transform: scale(.6) rotate(-5deg); }
html.motion [data-rv="drop"]       { transform: translateY(-140px) rotate(var(--r0, -8deg)); }
html.motion [data-rv="fan"]        { transform: translateY(90px) rotate(calc(var(--r, 0deg) * 5)) scale(.85); }
html.motion [data-rv="straighten"] { transform: translateY(50px) rotate(calc(var(--r, 0deg) * 4)); }
html.motion [data-rv="left"]       { transform: translateX(-60px); }
html.motion [data-rv="right"]      { transform: translateX(60px); }
html.motion [data-rv].in { opacity: 1; transform: var(--rest, none); }
[data-rv="fan"], [data-rv="straighten"] { --rest: rotate(var(--r, 0deg)); }

/* ── Hero entrance: names write in, then the rest pops in ── */
.hero { min-height: calc(100vh - var(--bar-h, 0px)); min-height: calc(100svh - var(--bar-h, 0px)); }
html.motion .hero .w { clip-path: inset(-40% 100% -40% -8%); }
html.motion .hero.go .w { animation: wd-write 1.15s cubic-bezier(.22, 1, .36, 1) forwards; animation-delay: var(--wd, 0s); }
@keyframes wd-write { to { clip-path: inset(-40% -12% -40% -8%); } }
html.motion [data-hero] {
  opacity: 0; transform: translateY(30px);
  transition: opacity .8s cubic-bezier(.22, 1, .36, 1), transform 1s cubic-bezier(.34, 1.56, .64, 1);
  transition-delay: calc(.6s + var(--hd, 0) * 110ms);
}
html.motion .hero.go [data-hero] { opacity: 1; transform: none; }

/* floating stickers: drift toward the mouse, float away on scroll */
.float {
  position: absolute; z-index: 3;
  transform:
    translate(calc(var(--mx, 0) * var(--depth, 1) * 14px), calc(var(--my, 0) * var(--depth, 1) * 14px))
    translateY(calc(var(--p, 0) * var(--depth, 1) * -110px));
  transition: transform .5s cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}
.float > * { animation: wd-bob 5s ease-in-out infinite alternate; }
@keyframes wd-bob  { to { transform: translateY(-14px) rotate(6deg); } }
@keyframes wd-spin { to { transform: rotate(360deg); } }
@keyframes wd-drift1 { to { transform: translate(12vw, 10vh) scale(1.15); } }
@keyframes wd-drift2 { to { transform: translate(-14vw, 8vh) scale(.9); } }
@keyframes wd-drift3 { to { transform: translate(8vw, -12vh) scale(1.1); } }
@keyframes wd-pulse  { 50% { transform: translateY(-6px); } }
@keyframes wd-nudge  { 50% { transform: translateX(6px); } }
@keyframes wd-morph {
  50%  { border-radius: 42% 58% 38% 62% / 58% 40% 60% 42%; }
  100% { border-radius: 54% 46% 62% 38% / 40% 60% 40% 60%; }
}

/* ── Ribbons ── */
.ribbons { position: relative; z-index: 4; overflow: clip; pointer-events: none; }
.ribbon { position: absolute; left: -5%; right: -5%; white-space: nowrap; overflow: hidden; }
.ribbon-track { display: inline-flex; will-change: transform; }

/* ── Countdown ── */
.count-grid { display: grid; grid-template-columns: repeat(4, 1fr); perspective: 900px; }
.count-card { transform-style: preserve-3d; }
.count-card .num { display: block; font-variant-numeric: tabular-nums; }
.count-card .num.tick { animation: wd-tick .35s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes wd-tick { 40% { transform: translateY(-8px) scale(1.06); } }
@media (max-width: 640px) { .count-grid { grid-template-columns: 1fr 1fr; } }

/* ── Pinned sideways story ── */
.story-track { display: flex; flex-direction: column; gap: 80px; }
.panel { display: grid; justify-items: center; gap: 24px; }
.panel-photo { margin: 0; overflow: hidden; }
.panel-photo img { width: 100%; height: 100%; object-fit: cover; }
.keep-going, .story-progress { display: none; }
html.motion .story { height: calc(var(--n, 4) * 110vh); padding: 0; }
html.motion .story-sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
html.motion .story-track {
  flex-direction: row; gap: 0;
  width: calc(var(--n, 4) * 100%); height: 100%;
  transform: translate3d(calc(var(--sp, 0) * (var(--n, 4) - 1) / var(--n, 4) * -100%), 0, 0);
  will-change: transform;
}
html.motion .panel {
  flex: 0 0 calc(100% / var(--n, 4)); height: 100%;
  grid-template-columns: auto auto; align-content: center; justify-content: center;
  align-items: center; column-gap: clamp(30px, 6vw, 90px);
  padding: 90px 6vw 80px;
}
html.motion .panel--intro { grid-template-columns: 1fr; }
html.motion .panel-text { text-align: left; }
html.motion .panel-photo { transform: rotate(calc(var(--dist, 0) * 18deg)) scale(calc(1 - var(--adist, 0) * .15)); }
html.motion .keep-going { display: inline-flex; align-items: center; gap: 8px; }
html.motion .keep-going svg { animation: wd-nudge 1.2s cubic-bezier(.22, 1, .36, 1) infinite; }
html.motion .story { --spw: min(420px, 70vw); }
html.motion .story-progress { display: block; position: absolute; left: 50%; bottom: 36px; width: var(--spw); transform: translateX(-50%); }
html.motion .sp-bar { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(var(--sp, 0)); }
html.motion .sp-heart { position: absolute; top: 50%; left: 0; line-height: 1; transform: translate(calc(var(--sp, 0) * var(--spw) - 50%), -54%); }
@media (max-width: 760px) {
  html.motion .panel { grid-template-columns: 1fr; justify-items: center; row-gap: 18px; padding: 96px 24px 90px; }
  html.motion .panel-text { text-align: center; }
  html.motion .story { --spw: 52vw; }
}

/* ── Venue ticket + map ── */
.ticket {
  transform-origin: 50% 100%;
  transform: perspective(1400px) rotateX(calc((1 - var(--ep, 1)) * 55deg)) translateY(calc((1 - var(--ep, 1)) * 90px));
}
.map-reveal { overflow: hidden; clip-path: circle(calc(12% + var(--ep, 1) * 88%) at 50% 50%); }
.map-reveal iframe { display: block; width: 100%; height: 360px; border: 0; }
@media (max-width: 860px) { .map-reveal iframe { height: 280px; } }

/* ── Schedule (the line draws itself) ── */
.tl { position: relative; display: flex; flex-direction: column; }
.tl-line { position: absolute; top: 0; left: 50%; width: 120px; height: 100%; transform: translateX(-50%); overflow: visible; }
.tl-line path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.tl-draw { stroke-dasharray: 1 1; stroke-dashoffset: 0; }
.tl-item { position: relative; z-index: 1; width: calc(50% - 90px); text-align: left; }
.tl-item:nth-of-type(odd)  { align-self: flex-start; }
.tl-item:nth-of-type(even) { align-self: flex-end; }
@media (max-width: 760px) {
  .tl-line { left: 26px; width: 52px; }
  .tl-item, .tl-item:nth-of-type(odd), .tl-item:nth-of-type(even) { width: calc(100% - 60px); align-self: flex-end; }
}

/* ── Dress code try-on ── */
.swatch { padding: 0; cursor: pointer; position: relative; }
.picked { min-height: 64px; }
html.motion .picked-name.bump { animation: wd-bump .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes wd-bump { 0% { transform: scale(.6) rotate(-6deg); opacity: 0; } }
.polaroid { display: block; text-decoration: none; cursor: zoom-in; }

/* ── Flip cards ── */
.flip {
  appearance: none; border: 0; background: none; padding: 0; margin: 0;
  text-align: left; cursor: pointer;
  perspective: 1400px; display: block; width: 100%;
}
.flip-inner { display: grid; height: 100%; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.34, 1.56, .64, 1); }
.flip.is-flipped .flip-inner { transform: rotateY(180deg); }
.face { grid-area: 1 / 1; -webkit-backface-visibility: hidden; backface-visibility: hidden; display: flex; flex-direction: column; }
.face.back { transform: rotateY(180deg); }

/* ── Tabs (entourage and more) ── */
html.js .tp:not(.is-on) { display: none; }
html.js .tab-panels { display: block; }
html.motion .tabbed:not(.seen) .nm { opacity: 0; }
html.motion .tabbed.seen .tp.is-on .nm { animation: wd-name-in .6s cubic-bezier(.34, 1.56, .64, 1) both; animation-delay: calc(var(--k, 0) * 45ms); }
@keyframes wd-name-in { from { opacity: 0; transform: translateY(22px) scale(.92); } }

/* ── RSVP demo form + lightbox (native dialogs) ── */
.wd-dialog {
  padding: 0; border: 0; background: transparent; color: inherit;
  width: min(520px, calc(100vw - 32px)); max-width: none;
  max-height: calc(100dvh - 32px); overflow: visible;
}
.wd-dialog::backdrop { background: rgba(12, 12, 20, .58); }
.dlg-card { position: relative; max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
html.motion .wd-dialog[open] .dlg-card { animation: wd-dlg-in .55s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes wd-dlg-in { from { opacity: 0; transform: translateY(30px) scale(.94); } }
.dlg-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.dlg-close svg { width: 18px; height: 18px; }
.rsvp-form .field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.rsvp-form input[type="text"], .rsvp-form textarea { width: 100%; }
.choice { display: flex; flex-wrap: wrap; gap: 10px; }
.choice label { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
html.is-solo [data-plus] { display: none !important; }
html:not(.is-after) [data-when="after"], html.is-after [data-when="before"] { display: none !important; }
html[data-lang="fil"] :not(html)[lang="en"], html:not([data-lang="fil"]) :not(html)[lang="fil"] { display: none !important; }
.faq-q { cursor: pointer; width: 100%; text-align: left; }
.rsvp-done { display: none; }
.rsvp-dialog.is-done .rsvp-form { display: none; }
.rsvp-dialog.is-done .rsvp-done { display: block; }
.lightbox { width: auto; max-width: calc(100vw - 32px); }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 120px); width: auto; margin: 0 auto; }

/* confetti + sparkle layers */
.confetti { position: fixed; z-index: 90; pointer-events: none; width: 10px; height: 14px; border-radius: 2px; }
.sparkle  { position: fixed; z-index: 80; pointer-events: none; font-size: 16px; line-height: 1; }

/* footer names grow into place */
.foot-names { display: inline-block; transform: scale(calc(.72 + var(--ep, 1) * .28)) rotate(calc((1 - var(--ep, 1)) * -6deg)); }

/* loops pause while their section is off screen */
.is-off *, .is-off *::before, .is-off *::after { animation-play-state: paused !important; }

/* ── Reduced motion: everything visible, nothing moves ── */
@media (prefers-reduced-motion: reduce) {
  html:not(.motion) *, html:not(.motion) *::before, html:not(.motion) *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
