/* ==========================================================================
   Radha Krishna wedding theme — the motion layer (with rk-motion.js)
   --------------------------------------------------------------------------
   1. The opening run        <- the scroll that carries the opening morpankh
   2. Animation A handover   <- the feather's path moves from CSS to the scroll
   3. Opening depth + exit   <- hands, scroll cue, the scene stepping aside
   4. Animation B            <- the invitation's big morpankh: its pivot
   5. Invitation depth
   5b. Invitation by scroll  <- elephants, names, date, couple, garden; the lotus alive
   6. Love story motifs      <- ink, ornament, frames, memories, ceremonies
   7. Venue, countdown, RSVP

   `.rk-motion` is on the root while the motion layer is live (set before the
   first paint by page.html, taken off again if GSAP never arrives). Rules
   that need rk-motion.js are scoped to it; with no GSAP, or with reduced
   motion, the stylesheets before this one are the whole story.

   THE RULE OF ONE OWNER: an entrance in CSS owns `transform`; scroll depth
   from rk-motion.js only ever writes the `translate` and `rotate` CSS
   properties, through --rk-px / --rk-py / --rk-sway, so the two compose and
   never fight. Nothing here transforms .rk-love or .rk-love__rite — the
   pinned ceremonies live inside them.
   ========================================================================== */


/* 1. The opening run ======================================================
   The opening holds still (sticky) while its run scrolls by; that scroll is
   the feather's path. Short on purpose: one screen of travel, no more. While
   the invitation is closed nothing follows the run, so it is also the end of
   the page — the button is still the only way on.                         */

.rk-opening-run {
  position: relative;
}

.rk-motion .rk-opening-run {
  --rk-run: 100svh;
  height: calc(100vh + 100vh);
  height: calc(100dvh + var(--rk-run));
}

.rk-motion .rk-opening {
  position: sticky;
  top: 0;
}

.rk-opening-run.is-dismissed {
  display: none;
}

@media (max-aspect-ratio: 62 / 100) {
  .rk-motion .rk-opening-run { --rk-run: 85svh; }
}


/* 2. Animation A handover =================================================
   The path itself is unchanged — rk-motion.js plays opening.css's own
   phase-1 keyframes, leg for leg, on the three wrappers. Here the CSS
   versions stand down so only one thing ever moves them. The feather is
   held out of sight until the script has placed it at the top of its path,
   so it can never flash at its resting place first.                        */

.rk-motion .rk-feather__fall,
.rk-motion .rk-feather__drift,
.rk-motion .rk-feather__tilt {
  animation: none;
}

.rk-motion .rk-feather__tilt {
  opacity: 0;
}

/* the settled float is for a feather that has landed, never one in flight */
.rk-motion .rk-feather__idle {
  animation: none;
}

.rk-motion .rk-feather.is-landed .rk-feather__idle {
  animation: rk-feather-idle 8s ease-in-out infinite;
}

/* turns --f-rise / --f-sweep into pixels for the script */
.rk-feather-probe {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--f-sweep);
  height: var(--f-rise);
  visibility: hidden;
  pointer-events: none;
}


/* 3. Opening depth and exit ============================================== */

/* the hands are the nearest layer: they sink a touch as the feather comes
   down through the sky behind them */
.rk-motion .rk-hand {
  translate: 0 var(--rk-hand-y, 0px);
}

/* ...and they reach in with the scroll (rk-motion.js). Until the script has
   placed them, each image is already held back to where the scroll starts,
   so nothing jumps. */
.rk-motion .rk-hand--krishna img { transform: translateX(-36%); }
.rk-motion .rk-hand--radha img   { transform: translateX(36%); }

/* --- the scroll cue ---------------------------------------------------
   A hairline with a drop running down it, and one word. It arrives after
   the button, and fades out the moment the scroll takes the feather.     */
.rk-scroll-cue {
  display: none;
}

.rk-motion .rk-scroll-cue {
  display: block;
  position: absolute;
  z-index: 6;
  right: clamp(12px, 2.6vw, 40px);
  bottom: clamp(70px, 16vh, 170px);
  pointer-events: none;
}

.rk-scroll-cue__in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: rk-cue-in 0.9s var(--ease-reveal) 2.3s both;
}

.rk-scroll-cue__line {
  position: relative;
  display: block;
  width: 1px;
  height: clamp(34px, 6.5vh, 60px);
  overflow: hidden;
  background: rgba(58, 74, 32, 0.2);
}

.rk-scroll-cue__line i {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 45%;
  background: var(--ink-name);
  animation: rk-cue-run 2.4s cubic-bezier(0.6, 0, 0.4, 1) 3s infinite both;
}

.rk-scroll-cue__label {
  font-family: "Poppins", system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(9px, 1.2vh, 11px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cta-ink-soft);
  writing-mode: vertical-rl;
}

@keyframes rk-cue-in {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes rk-cue-run {
  0%   { transform: translate3d(0, -100%, 0); }
  60%  { transform: translate3d(0, 230%, 0); }
  100% { transform: translate3d(0, 230%, 0); }
}

/* --- the scene steps aside ---------------------------------------------
   On the button the hands part, the names lift and the button settles, all
   inside the opening's own 700ms fade (opening.js), so nothing waits on it.
   The hands' new animation replaces their entrance and starts from their
   resting place, so there is no jump.                                     */
@keyframes rk-hand-part-l {
  to { transform: translate3d(-24%, 4%, 0) rotate(-3deg); }
}

@keyframes rk-hand-part-r {
  to { transform: translate3d(24%, 4%, 0) rotate(3deg); }
}

.rk-motion .rk-opening.is-opening .rk-hand--krishna {
  animation: rk-hand-part-l 0.7s cubic-bezier(0.55, 0, 0.75, 0.2) both;
}

.rk-motion .rk-opening.is-opening .rk-hand--radha {
  animation: rk-hand-part-r 0.7s cubic-bezier(0.55, 0, 0.75, 0.2) both;
}

.rk-motion .rk-names,
.rk-motion .rk-cta {
  transition: translate 0.7s cubic-bezier(0.5, 0, 0.75, 0);
}

.rk-motion .rk-opening.is-opening .rk-names {
  translate: 0 -3vh;
}

.rk-motion .rk-opening.is-opening .rk-cta {
  translate: 0 2vh;
}

.rk-motion .rk-opening.is-opening .rk-scroll-cue {
  visibility: hidden;
}


/* 4. Animation B — the invitation's own big morpankh =======================
   No second feather: rk-motion.js turns the invitation's large morpankh
   itself (.rk-plume__tilt) about its quill.

   THE PIVOT IS THE QUILL. Its tip is 30.29% / 85.95% of morpankh.png
   (measured from the artwork). The image rests at rotate(56deg) about its
   own centre, which carries that point to 7.87% / 54.44% of the feather's
   box — so every layer that turns here turns about exactly that point.

   THE QUILL RESTS OUTSIDE THE WINDOW (invitation.css, .rk-plume), so its
   end is never on screen; the stem runs in from the left edge.          */

.rk-plume__tilt {
  transform-origin: 7.87% 54.44%;
}

/* while the sweep owns the feather, the CSS fade-in stands down */
.rk-invite.is-armed .rk-plume.is-sweeping {
  opacity: 1;
}

.rk-invite.is-revealed .is-in .rk-plume.is-sweeping {
  animation: none;
}


/* 5. Invitation depth ==================================================== */

.rk-motion .rk-leaf,
.rk-motion .rk-inv__couple,
.rk-motion .rk-garden-group {
  translate: var(--rk-px, 0px) var(--rk-py, 0px);
}


/* 5b. The invitation follows the scroll =====================================
   Below the head, the invitation's entrances belong to the scroll
   (rk-motion.js): the elephants are scrubbed to it, everything else comes in
   as it is reached and goes back out when scrolled back past. Their CSS
   entrances stand down here so only one thing ever moves them; without
   GSAP, invitation.css plays them exactly as before. */

.rk-motion .rk-invite.is-revealed .rk-inv__names .rk-rise,
.rk-motion .rk-invite.is-revealed .rk-inv__when .rk-rise,
.rk-motion .rk-invite.is-revealed .rk-inv__names .rk-eleph,
.rk-motion .rk-invite.is-revealed .rk-inv__finale .rk-inv__couple,
.rk-motion .rk-invite.is-revealed .rk-inv__finale .rk-garden-group {
  animation: none;
}

/* --- the lotus, alive ---------------------------------------------------
   A slow sway about the foot of the stems at the page edge, endless and
   small, on the rotate property (the entrance owns transform; a passing
   pointer and a tap move the image inside — rk-motion.js). The two are out
   of step, so the pair never moves as one block. */
@keyframes rk-lotus-sway {
  0%, 100% { rotate: -1.4deg; }
  50%      { rotate: 1.6deg; }
}

.rk-motion .rk-invite.is-revealed .rk-inv__names .rk-lotus {
  animation: rk-lotus-sway 7s ease-in-out infinite;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.rk-motion .rk-invite.is-revealed .rk-inv__names .rk-lotus--r {
  animation-duration: 7.8s;
  animation-delay: -3.4s;
}

.rk-lotus--l { transform-origin: 0% 100%; }
.rk-lotus--r { transform-origin: 100% 100%; }

/* A soft pink breath behind each bloom — the blooms' own colour, centred on
   the blooms as measured from the artwork (lotus-1 at 30.6/28.0 and
   75.7/15.1; lotus-2 is lotus-1 mirrored), mapped into this layer, which
   reaches 12% past the flower on every side. Never a hard halo: the lotus'
   reveal clip rests well outside this layer (rk-motion.js). It
   quickens under a pointer and blooms brighter for a moment on a tap. */
@keyframes rk-lotus-breathe {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 0.85; }
}

@keyframes rk-lotus-bloom {
  0%   { opacity: 0.6;  transform: scale(1); }
  35%  { opacity: 1;    transform: scale(1.08); }
  100% { opacity: 0.45; transform: scale(1); }
}

.rk-motion .rk-lotus::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -12%;
  pointer-events: none;
  opacity: 0;
}

.rk-motion .rk-lotus--l::before {
  background:
    radial-gradient(circle at 34.4% 32.3%, rgba(250, 168, 198, 0.52), rgba(250, 168, 198, 0.2) 8%, rgba(250, 168, 198, 0) 20%),
    radial-gradient(circle at 70.7% 21.9%, rgba(250, 168, 198, 0.52), rgba(250, 168, 198, 0.2) 9%, rgba(250, 168, 198, 0) 22%);
}

.rk-motion .rk-lotus--r::before {
  background:
    radial-gradient(circle at 65.6% 32.3%, rgba(250, 168, 198, 0.52), rgba(250, 168, 198, 0.2) 8%, rgba(250, 168, 198, 0) 20%),
    radial-gradient(circle at 29.3% 21.9%, rgba(250, 168, 198, 0.52), rgba(250, 168, 198, 0.2) 9%, rgba(250, 168, 198, 0) 22%);
}

.rk-motion .rk-invite.is-revealed .rk-inv__names .rk-lotus::before {
  animation: rk-lotus-breathe 4.6s ease-in-out infinite;
}

.rk-motion .rk-invite.is-revealed .rk-inv__names .rk-lotus--r::before {
  animation-delay: -2.1s;
}

@media (hover: hover) {
  .rk-motion .rk-invite.is-revealed .rk-inv__names .rk-lotus:hover::before {
    animation-duration: 1.8s;
  }
}

.rk-motion .rk-invite.is-revealed .rk-inv__names .rk-lotus.is-touched::before {
  animation: rk-lotus-bloom 1.1s ease-out, rk-lotus-breathe 4.6s ease-in-out 1.1s infinite;
}


/* 6. Love story motifs ====================================================
   One motion language for the paper: script headings are INKED in, left to
   right, the way they would be written; the ornamental rule under each one
   is DRAWN open from its centre. Each band then has its own idea on top.
   The negative insets leave room for Ananda's swashes, which reach outside
   the line box. */

@media (prefers-reduced-motion: no-preference) {

  .rk-js .rk-love__title.rk-love__rise,
  .rk-js .rk-love__place.rk-love__rise {
    width: fit-content;
    margin-inline: auto;
    clip-path: inset(-0.5em 100% -0.5em -0.5em);
    transition:
      opacity var(--ls-rise-d) var(--ls-ease) var(--ls-d, 0s),
      transform var(--ls-rise-d) var(--ls-ease) var(--ls-d, 0s),
      clip-path 1.6s cubic-bezier(0.45, 0.05, 0.25, 1) var(--ls-d, 0s);
  }

  .rk-love__band.is-revealed .rk-love__title.rk-love__rise,
  .rk-love__band.is-revealed .rk-love__place.rk-love__rise {
    clip-path: inset(-0.5em -0.5em -0.5em -0.5em);
  }

  .rk-js .rk-love__rule.rk-love__rise {
    clip-path: inset(0 50% 0 50%);
    transition:
      opacity var(--ls-rise-d) var(--ls-ease) var(--ls-d, 0s),
      transform var(--ls-rise-d) var(--ls-ease) var(--ls-d, 0s),
      clip-path 1.2s var(--ls-glide) var(--ls-d, 0s);
  }

  .rk-love__band.is-revealed .rk-love__rule.rk-love__rise {
    clip-path: inset(0 0 0 0);
  }

  /* --- Our Love Story: read in order, then the portrait is unveiled ------ */
  .rk-love__intro:nth-of-type(2) { --ls-d: 0.72s; }
  .rk-love__intro:nth-of-type(3) { --ls-d: 0.84s; }
  .rk-love__intro:nth-of-type(n + 4) { --ls-d: 0.96s; }

  .rk-js .rk-love__figure.rk-love__rise {
    scale: 0.94;
    transition:
      opacity 1.3s var(--ls-ease) var(--ls-d, 0s),
      transform 1.3s var(--ls-ease) var(--ls-d, 0s),
      scale 1.7s var(--ls-glide) var(--ls-d, 0s),
      translate 0.5s var(--ls-ease);
  }

  .rk-love__band.is-revealed .rk-love__figure.rk-love__rise {
    scale: 1;
  }

  /* the hanging plumes sway about their quills with the scroll (rk-motion.js) */
  .rk-motion .rk-love__plume {
    rotate: var(--rk-sway, 0deg);
  }

  /* --- the ceremonies: a new roundel turns into its frame ----------------- */
  .rk-love__medal img.is-turning {
    animation: rk-medal-turn 0.7s var(--ls-glide) both;
  }

  /* --- Moments of Love: the memories are dealt in, one after another ------ */
  .rk-js .rk-love__memory {
    opacity: 0;
    translate: 0 clamp(18px, 3vw, 42px);
    transition:
      opacity 0.9s var(--ls-ease) var(--mi-d, 0.4s),
      translate 1.1s var(--ls-glide) var(--mi-d, 0.4s),
      transform 0.45s var(--ls-ease);
  }

  .rk-love__memory:nth-child(2) { --mi-d: 0.52s; }
  .rk-love__memory:nth-child(3) { --mi-d: 0.64s; }
  .rk-love__memory:nth-child(4) { --mi-d: 0.76s; }
  .rk-love__memory:nth-child(n + 5) { --mi-d: 0.88s; }

  .rk-love__moments.is-revealed .rk-love__memory {
    opacity: 1;
    translate: 0 0;
  }

  /* --- countdown: the medallions come up one by one ----------------------- */
  .rk-js .wiy-rk--countdown .wiy-rk__unit {
    opacity: 0;
    scale: 0.82;
    transition:
      opacity 0.6s var(--ls-ease) var(--cu-d, 0.3s),
      scale 0.9s cubic-bezier(0.34, 1.45, 0.64, 1) var(--cu-d, 0.3s);
  }

  .wiy-rk--countdown .wiy-rk__unit:nth-child(2) { --cu-d: 0.42s; }
  .wiy-rk--countdown .wiy-rk__unit:nth-child(3) { --cu-d: 0.54s; }
  .wiy-rk--countdown .wiy-rk__unit:nth-child(4) { --cu-d: 0.66s; }

  .wiy-rk--countdown.is-revealed .wiy-rk__unit {
    opacity: 1;
    scale: 1;
  }

  /* --- closing: the last feather drifts down to rest ----------------------
     A small echo of the opening's own path — in from above, a sway left, a
     sway right, settled — so the page ends the way it began. */
  .rk-love__band.is-revealed .wiy-rk__feather.rk-love__rise {
    animation: rk-close-feather 2.2s cubic-bezier(0.37, 0, 0.63, 1) both;
  }
}

/* the plumes hang from their quills, measured from the artwork */
.rk-love__plume--l { transform-origin: 35.8% 1.4%; }
.rk-love__plume--r { transform-origin: 64.2% 1.4%; }

@keyframes rk-medal-turn {
  from { opacity: 0.1; transform: rotate(-10deg) scale(0.9); }
  to   { opacity: 1; transform: none; }
}

@keyframes rk-close-feather {
  0%   { opacity: 0; transform: translate3d(-40%, -70%, 0) rotate(-22deg); }
  35%  { opacity: 1; transform: translate3d(18%, -38%, 0) rotate(10deg); }
  68%  { transform: translate3d(-8%, -12%, 0) rotate(-6deg); }
  100% { opacity: 1; transform: none; }
}

/* the reel rests while it is off the screen (love-story.js) */
.rk-love__reel.is-idle .rk-love__track.is-running {
  animation-play-state: paused;
}


/* 7. Interaction feedback =================================================
   Hover is a lift, press is a settle, focus keeps its ring. Touch never
   depends on hover: every press state stands on its own. Lifts use the
   `translate` / `scale` properties because the entrances own `transform`. */

.rk-love__cta.rk-love__rise {
  transition:
    opacity var(--ls-rise-d) var(--ls-ease) var(--ls-d, 0s),
    transform var(--ls-rise-d) var(--ls-ease) var(--ls-d, 0s),
    background 0.35s var(--ls-ease),
    translate 0.3s var(--ls-ease),
    scale 0.15s var(--ls-ease);
}

.rk-love__cta:hover,
.rk-love__cta:focus-visible {
  translate: 0 -2px;
}

.rk-love__cta:active {
  translate: 0 0;
  scale: 0.96;
}

.rk-love__nav:active {
  transform: translateY(-50%) scale(0.9);
  transition-duration: 0.1s;
}

.wiy-rk__submit:active {
  transform: translateY(0) scale(0.97);
}

@media (hover: hover) {
  .rk-love__band.is-revealed .rk-love__figure:hover {
    translate: 0 -6px;
  }

  .rk-love__moments.is-revealed .rk-love__memory:hover {
    transform: translate3d(0, -8px, 0);
  }
}

.rk-love__moments.is-revealed .rk-love__memory:active {
  transform: translate3d(0, -4px, 0);
}
