/* magic.css — premium motion layer. Everything is transform/opacity based and disabled under prefers-reduced-motion. */
:root { --intro-delay: 0s; }
html.show-intro { --intro-delay: 1.15s; }

/* ---------- 1. Opening intro (doors + gold wax seal) ---------- */
.intro { display: none; }
html.show-intro .intro { display: block; position: fixed; inset: 0; z-index: 900; overflow: hidden; perspective: 1400px; cursor: pointer;
  animation: introAway .45s ease 2.05s forwards; } /* CSS failsafe: hides itself even if JS never runs */
.intro__door { position: absolute; top: 0; bottom: 0; width: 50.5%; will-change: transform;
  background: radial-gradient(circle at 100% 50%, rgba(255, 255, 255, .75), transparent 60%), var(--intro-door, linear-gradient(160deg, #FBD9E3, #F4E1F4 55%, #FFE6D6));
  animation: doorL 1s cubic-bezier(.7, 0, .2, 1) 1.05s forwards; box-shadow: inset 0 0 0 10px rgba(255, 255, 255, .35); }
.intro__door::before { content: ""; position: absolute; inset: 18px; border: 2px solid rgba(var(--gold-rgb), .75); border-radius: 6px; box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .35), inset 0 0 0 7px rgba(var(--gold-rgb), .35); }
.intro__door::after { content: ""; position: absolute; inset: 0; opacity: .45; background-image: radial-gradient(rgba(var(--gold-rgb), .45) 1px, transparent 1.6px); background-size: 22px 22px; }
.intro__door--l { left: 0; transform-origin: left center; border-right: 2px solid rgba(var(--gold-rgb), .8); }
.intro__door--r { right: 0; transform-origin: right center; border-left: 2px solid rgba(var(--gold-rgb), .8); animation-name: doorR;
  background: radial-gradient(circle at 0 50%, rgba(255, 255, 255, .75), transparent 60%), var(--intro-door, linear-gradient(200deg, #FBD9E3, #F4E1F4 55%, #FFE6D6)); }
.intro__door img { position: absolute; width: clamp(90px, 18vw, 170px); opacity: .9; }
.intro__door--l img { left: 8px; top: 8px; } .intro__door--r img { right: 8px; top: 8px; transform: scaleX(-1); }
.intro__center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 2; pointer-events: none;
  animation: fadeOut .45s ease 1.25s forwards; }
.intro__seal { width: clamp(118px, 26vw, 150px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: radial-gradient(circle at 35% 30%, #FFF3C4, #E7C66E 35%, var(--gold) 60%, #9C7A2E 100%); box-shadow: 0 10px 30px rgba(140, 100, 20, .45), inset 0 -6px 14px rgba(110, 70, 10, .35), inset 0 6px 12px rgba(255, 255, 255, .6);
  animation: sealIn .6s cubic-bezier(.2, 1.4, .4, 1) .05s both, sealPop .4s ease .95s forwards; }
.intro__seal::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 2px dashed rgba(255, 246, 214, .8); }
.intro__seal::after { content: ""; position: absolute; inset: -40%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 244, 200, .95), rgba(255, 230, 160, 0) 60%); opacity: 0; animation: flash .6s ease .95s forwards; }
.intro__seal span { font-family: var(--f-names); font-size: clamp(2.6rem, 6vw, 3.3rem); color: #fffaf0; text-shadow: 0 2px 0 rgba(120, 80, 10, .5); position: relative; z-index: 1; }
.intro__names { font-family: var(--f-names); font-size: clamp(2.3rem, 7vw, 3.6rem); color: var(--maroon); margin: 0; line-height: 1.1;
  clip-path: inset(-30% 100% -30% -5%); animation: ink .75s ease-out .35s forwards; }
.intro__date { font-family: var(--f-serif); letter-spacing: .3em; color: #9C7A2E; font-size: .85rem; margin: 0; opacity: 0; animation: fadeIn .4s ease .75s forwards; }
.intro__skip { position: absolute; z-index: 3; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translateX(-50%); border: 1px solid rgba(var(--gold-rgb), .7); background: rgba(255, 255, 255, .7);
  color: var(--maroon); border-radius: 999px; padding: 8px 18px; font: 500 .8rem/1 var(--f-sans); letter-spacing: .12em; cursor: pointer; opacity: 0; animation: fadeIn .3s ease .3s forwards, fadeOut .3s ease 1.1s forwards; }
.intro--skip { animation: introAway .3s ease forwards !important; }
@keyframes doorL { to { transform: translateX(-102%) rotateY(18deg); } }
@keyframes doorR { to { transform: translateX(102%) rotateY(-18deg); } }
@keyframes sealIn { from { transform: scale(.3) rotate(-30deg); opacity: 0; } }
@keyframes sealPop { to { transform: scale(1.35); opacity: 0; } }
@keyframes flash { 50% { opacity: 1; } to { opacity: 0; } }
@keyframes ink { to { clip-path: inset(-30% -5% -30% -5%); } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes introAway { to { opacity: 0; visibility: hidden; pointer-events: none; } }

/* ---------- 2. Hero names: handwriting reveal + gold shimmer ---------- */
.magic .hero__names { text-shadow: none; filter: drop-shadow(0 4px 18px rgba(255, 255, 255, .95)); }
.magic .hero__names span { padding: 0 .12em; margin: 0 -.12em; clip-path: inset(-35% 100% -35% -12%);
  background: linear-gradient(100deg, var(--names-color) 0 42%, #E7C66E 48%, #FFF6D6 50%, var(--gold) 53%, var(--names-color) 60% 100%) 100% 0 / 260% 100% no-repeat; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: ink 1.1s cubic-bezier(.5, .1, .3, 1) calc(var(--intro-delay) + .25s) forwards, shimmer 2.4s ease-in-out calc(var(--intro-delay) + 2.2s) 3; }
.magic .hero__names .amp { margin: 0 -.04em; background-image: linear-gradient(100deg, var(--gold) 0 40%, #FFF6D6 50%, var(--gold) 60% 100%); animation-delay: calc(var(--intro-delay) + 1.15s), calc(var(--intro-delay) + 2.3s); animation-duration: .5s, 2.4s; }
.magic .hero__names span:last-child { animation-delay: calc(var(--intro-delay) + 1.4s), calc(var(--intro-delay) + 2.4s); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- 3. Parallax (driven by --py / --px set in JS) ---------- */
.magic .corner { translate: var(--cx, 0) var(--py, 0); will-change: translate; }
.magic .arch { translate: var(--ax, 0) var(--pa, 0); }
.magic .hero__text { translate: 0 var(--pt, 0); }

/* ---------- 4. Hero rose petals + twinkles ---------- */
.hero-fx { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.rose { position: absolute; top: -40px; width: 16px; height: 20px; border-radius: 80% 0 80% 0; opacity: 0;
  background: radial-gradient(circle at 30% 30%, #FFD1DC, #EE8FAA 55%, #C84B72); box-shadow: inset -2px -2px 4px rgba(120, 20, 50, .25);
  animation: roseFall var(--d, 11s) linear var(--dl, 0s) infinite; will-change: transform; }
@keyframes roseFall { 0% { transform: translate3d(0, 0, 0) rotate(0); opacity: 0; } 8% { opacity: .9; }
  50% { transform: translate3d(var(--sx, 40px), 55vh, 0) rotate(200deg); } 92% { opacity: .85; } 100% { transform: translate3d(calc(var(--sx, 40px) * -.5), 108vh, 0) rotate(420deg); opacity: 0; } }
.twk { position: absolute; width: var(--s, 12px); height: var(--s, 12px); background: linear-gradient(#fff, var(--gold-l));
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); animation: twinkle var(--d, 2.6s) ease-in-out var(--dl, 0s) infinite; }

/* ---------- 5. Swaying garland + marigold toran ---------- */
.magic .arch__garland { transform-origin: 50% 0; animation: sway 5s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-1.4deg); } 50% { transform: rotate(1.4deg); } }
.toran { position: absolute; z-index: 2; top: var(--nav-h); left: clamp(90px, 15vw, 210px); right: clamp(90px, 15vw, 210px); height: 0; display: flex; justify-content: space-between; pointer-events: none; }
.toran::before { content: ""; position: absolute; left: -8px; right: -8px; top: -7px; height: 14px; border-radius: 7px;
  background: radial-gradient(circle at 50% 45%, #FFD66B 0 3px, #F29C1F 4px 6px, transparent 7px) 0 0 / 13px 14px repeat-x; filter: drop-shadow(0 2px 2px rgba(150, 70, 0, .3)); }
.toran__s { width: 12px; height: var(--h, 70px); position: relative; transform-origin: 50% 0; animation: sway var(--d, 3.6s) ease-in-out var(--dl, 0s) infinite;
  background: radial-gradient(circle at 50% 45%, #FFE08A 0 2.5px, #F7A21B 3.5px 5px, #E07A10 5.5px, transparent 6.5px) 0 0 / 12px 11px repeat-y; filter: drop-shadow(0 2px 2px rgba(150, 70, 0, .25)); }
.toran__s::after { content: ""; position: absolute; left: 50%; bottom: -12px; width: 10px; height: 14px; margin-left: -5px; border-radius: 0 60% 0 60%; transform: rotate(45deg); background: linear-gradient(135deg, #6FA86A, #3F7A45); }
.toran__s:nth-child(odd)::after { background: none; border-radius: 50% 50% 40% 40%; width: 9px; height: 11px; margin-left: -4.5px; transform: none; bottom: -10px; background-image: linear-gradient(var(--gold-l), var(--gold)); }
@media (max-width: 860px) { .toran { left: 100px; right: 100px; } .toran__s:nth-child(n+8) { display: none; } }

/* ---------- 6. Staggered letters in section headings ---------- */
.split .ch { display: inline-block; opacity: 0; transform: translateY(.45em) rotate(8deg) scale(.9); transition: opacity .5s ease, transform .7s cubic-bezier(.2, 1.3, .4, 1); transition-delay: calc(var(--i) * 38ms + .1s); }
.split.in .ch { opacity: 1; transform: none; }
.split .w { display: inline-block; white-space: nowrap; }
.magic .script-title.split.reveal { transform: none; }

/* ---------- 7. Directional reveals ---------- */
.magic main { overflow-x: hidden; overflow-x: clip; }
.magic .reveal--l { transform: translate3d(-60px, 0, 0) rotate(-1.5deg); }
.magic .reveal--r { transform: translate3d(60px, 0, 0) rotate(1.5deg); }
.magic .reveal--z { transform: scale(.9) translateY(20px); }
.magic .reveal--f { transform: perspective(900px) rotateX(18deg) translateY(30px); transform-origin: 50% 100%; }
.magic .reveal--l.in, .magic .reveal--r.in, .magic .reveal--z.in, .magic .reveal--f.in { transform: none; }
.magic .reveal.in { transition-delay: var(--rd, 0s); }

/* ---------- 8. Timeline dots pop ---------- */
.magic .t-item .t-item__dot { transform: scale(0) rotate(-120deg); transition: transform .6s cubic-bezier(.2, 1.6, .4, 1) .25s; }
.magic .t-item.in .t-item__dot { transform: none; animation: beat 1.4s ease 1s 2; }
@keyframes beat { 0%, 100% { scale: 1; } 15% { scale: 1.25; } 30% { scale: 1; } 45% { scale: 1.15; } }

/* ---------- 9. Flip-clock countdown ---------- */
.cd__num.flipclock { position: relative; display: inline-block; padding: 0; perspective: 300px; border-radius: 12px; }
.flipclock .fl { position: absolute; inset: 0; padding: .12em .22em; border-radius: 12px; background: linear-gradient(#FFFFFF, #FCEAF0); box-shadow: 0 6px 16px rgba(var(--rose-rgb), .14); backface-visibility: hidden; }
.flipclock .fl--sz { position: relative; display: block; visibility: hidden; inset: auto; }
.flipclock .fl--t { clip-path: inset(0 0 50% 0); } .flipclock .fl--b { clip-path: inset(50% 0 0 0); }
.flipclock .fl--ft { clip-path: inset(0 0 50% 0); transform-origin: 50% 50%; animation: flipT .28s ease-in forwards; z-index: 2; background: linear-gradient(#FFFFFF, #F8E2EA); }
.flipclock .fl--fb { clip-path: inset(50% 0 0 0); transform-origin: 50% 50%; transform: rotateX(90deg); animation: flipB .28s ease-out .28s forwards; z-index: 2; }
.flipclock::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(var(--maroon-rgb), .14); z-index: 3; }
@keyframes flipT { to { transform: rotateX(-90deg); } }
@keyframes flipB { to { transform: rotateX(0); } }

/* ---------- 10. Heart burst ---------- */
.hb { position: fixed; z-index: 450; pointer-events: none; font-size: var(--s, 14px); color: var(--c, var(--heart)); left: 0; top: 0; will-change: transform, opacity;
  animation: hb .8s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes hb { from { transform: translate3d(var(--x), var(--y), 0) scale(.4); opacity: 1; } to { transform: translate3d(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy)), 0) scale(1.1) rotate(var(--r)); opacity: 0; } }

/* ---------- 11. Animated rings ---------- */
.magic img[src$="rings.svg"] { transform-origin: 50% 70%; animation: ringSwing 3.2s ease-in-out infinite, ringGlint 3.2s ease-in-out infinite; }
@keyframes ringSwing { 0%, 100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(6deg) translateY(-4px); } }
@keyframes ringGlint { 0%, 70%, 100% { filter: drop-shadow(0 0 0 rgba(255, 240, 190, 0)); } 80% { filter: drop-shadow(0 0 10px rgba(255, 236, 170, .95)); } }

/* ---------- 12. Cursor sparkle trail ---------- */
.trail { position: fixed; left: 0; top: 0; z-index: 460; width: 10px; height: 10px; pointer-events: none; opacity: 0;
  background: linear-gradient(#fff, var(--gold-l)); clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); }
.trail.go { animation: trail .7s ease-out forwards; }
@keyframes trail { from { opacity: 1; transform: translate3d(var(--x), var(--y), 0) scale(1) rotate(0); } to { opacity: 0; transform: translate3d(var(--x), calc(var(--y) + 18px), 0) scale(.2) rotate(90deg); } }

/* ---------- 13. Gallery tilt + glare ---------- */
.magic .m-item { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .35s ease, box-shadow .35s ease; }
.magic .m-item.tilting { transition: transform .08s linear, box-shadow .35s ease; }
.magic .m-item::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s; background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .45), transparent 55%); }
.magic .m-item:hover::after { opacity: 1; }
.magic .m-item:hover img { transform: scale(1.07); }

/* ---------- 14. Floating heart scroll-to-top ---------- */
.to-top { position: fixed; z-index: 60; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 54px; height: 50px; border: 0; padding: 0; cursor: pointer; background: none;
  opacity: 0; transform: translateY(20px) scale(.6); pointer-events: none; transition: opacity .35s, transform .45s cubic-bezier(.2, 1.4, .4, 1); filter: drop-shadow(0 6px 12px rgba(var(--rose-rgb), .35)); }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top svg { width: 100%; height: 100%; display: block; animation: floatHeart 3s ease-in-out infinite; }
.to-top:hover svg { animation-duration: 1.2s; }
.to-top:focus-visible { outline: 2px solid var(--gold, var(--gold)); outline-offset: 4px; border-radius: 50%; }
@keyframes floatHeart { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(4deg); } }

.magic .hero .reveal.in { transition-delay: var(--intro-delay); }

@media (prefers-reduced-motion: reduce) {
  html.show-intro .intro { display: none; }
  .hero-fx, .toran__s, .trail, .hb { animation: none !important; }
  .rose, .trail, .hb { display: none; }
  .split .ch { opacity: 1; transform: none; }
}
