/* Casper, Adya's white Turkish Angora: the bride's edition only (loaded after adya.css; behaviour in casper.js). */

/* ---------- 1. the gate: on the doorstep between the two rows of diyas, then in through the opening doors ---------- */
/* her paws rest on the step at 81.6% of the painting; she is dusk-dim until the diyas light up */
.casper-gate { left: 50%; top: 81.6%; height: 12.4%; aspect-ratio: 268 / 360; translate: -50% -100%; pointer-events: none;
  transform-origin: 50% 100%; filter: brightness(.8); transition: filter .6s ease; }
.casper-gate img { position: absolute; left: 50%; bottom: 0; width: auto; max-width: none; height: 100%; translate: -50% 0;
  filter: drop-shadow(0 4px 5px rgba(20, 6, 3, .45)); }
.casper-gate .cg-away { opacity: 0; }
.gate.lit .casper-gate { filter: none; }
/* app.js adds .open as the doors start to swing (1.5 s after the knock): she turns and trots up into the doorway */
.gate.open .casper-gate .cg-sit { opacity: 0; }
.gate.open .casper-gate .cg-away { opacity: 1; animation: cg-trot .16s ease-in-out infinite alternate; }
.gate.open .casper-gate { animation: cg-in 1.4s cubic-bezier(.4, .1, .7, .6) .08s forwards; }
@keyframes cg-in { 65% { opacity: 1; } 100% { opacity: 0; transform: translateY(-112%) scale(.42); } }
@keyframes cg-trot { to { translate: -50% -3%; } }

/* ---------- 2. the haldi joke, between the timing and the venue ---------- */
.casper-haldi { display: flex; align-items: center; gap: 12px; max-width: 360px; margin: -4px auto 18px; text-align: left; }
.casper-haldi img { flex: none; width: 70px; height: auto; }
.casper-haldi figcaption { font: italic 500 17px/1.38 "Corm", serif; color: var(--muted); }

/* ---------- 3. the scratch card: her paw is the cursor (hotspot on the claw tips) and follows a finger ---------- */
.casper-scratch .w-foil { cursor: url("bride/casper/paw-cursor.png") 34 29, grab; }
.casper-paw { position: fixed; top: 0; left: 0; z-index: 60; width: 72px; height: auto; max-width: none; pointer-events: none; opacity: 0;
  transition: opacity .15s ease; filter: drop-shadow(0 4px 6px rgba(59, 31, 36, .3)); }
.casper-paw.on { opacity: 1; }

/* ---------- 4. find Casper: five tucked into the paintings and the family card ---------- */
.casper-spot { position: absolute; z-index: 4; padding: 0; border: 0; background: none; line-height: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent; }
.casper-spot img { display: block; width: 100%; height: auto; max-width: none; transform-origin: 50% 100%;
  animation: var(--idle) 9s ease-in-out var(--delay, 0s) infinite; }
.casper-spot:focus-visible { outline-offset: 2px; border-radius: 8px; }
/* (a) sitting on the rooftop railing in the Patna lane, between the finials near the kites */
.casper-spot[data-spot="lane"] { left: 79.2%; top: 13.5%; width: 8.4%; translate: 0 -100%; --idle: casper-twitch; --delay: 1s; }
/* (b) peeking up over the bottom edge of the Haldi & Mehandi painting, by the mehandi guest */
.casper-spot[data-spot="haldi"] { right: 9%; bottom: 0; width: 13.5%; --idle: casper-peek; --delay: 3s; }
/* (c) napping on the mandap floor in the Vivah painting, in front of the little shrine */
.casper-spot[data-spot="mandap"] { left: 51.5%; top: 60%; width: 8.8%; translate: 0 -100%; --idle: casper-breathe; }
/* (d) half behind Gol Ghar, stepping out onto Gandhi Setu: the skyline is drawn over her */
.casper-behind { position: relative; width: min(100%, 900px); margin: 40px auto 0; }
.casper-behind .cele-skyline { position: relative; z-index: 1; width: 100%; margin: 0; pointer-events: none; }
.casper-spot[data-spot="golghar"] { left: 15.2%; top: 66.6%; width: 10%; translate: 0 -100%; z-index: 0; --idle: casper-edge; --delay: 5s; }
[data-mode="night"] .casper-spot[data-spot="golghar"] img { filter: brightness(.55) saturate(.7); }
/* (e) peeking over the top of the "Family names coming soon" card, or of the family portrait on the weds page */
.soon, .family-frame { position: relative; }
.family-frame { max-width: 640px; margin: 44px auto 8px; }
.family-frame .family-art { margin: 0; }
.casper-spot[data-spot="family"] { right: 13%; bottom: 100%; width: 54px; margin-bottom: -3px; --idle: casper-peek; --delay: 6.5s; }

/* found: she gives a happy hop and keeps a little paw badge, so guests can see which ones they've found */
.casper-print { position: absolute; right: -5px; top: -5px; box-sizing: content-box; width: 13px; height: 13px; padding: 3px; border-radius: 50%;
  background: #fff; color: var(--rani); box-shadow: 0 1px 4px rgba(107, 33, 72, .35); opacity: 0; pointer-events: none; }
.casper-spot.found .casper-print { opacity: 1; }
.casper-spot.popping img { animation: casper-pop .5s ease-out; }
.casper-spot.popping .casper-print { animation: casper-print .5s cubic-bezier(.3, 1.6, .5, 1) .25s both; }
.casper-spot.popping::after { content: ""; position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  border: 2px solid var(--gold-2); box-shadow: 0 0 12px rgba(255, 255, 255, .9); animation: casper-ring .55s ease-out forwards; pointer-events: none; }
@keyframes casper-pop { 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes casper-print { from { opacity: 0; scale: .2; } to { opacity: 1; scale: 1; } }
@keyframes casper-ring { from { opacity: 1; scale: .3; } to { opacity: 0; scale: 1.6; } }

/* now and then a little life: a peek, an ear twitch, a sleepy breath, a step out from behind the dome */
@keyframes casper-peek { 0%, 88%, 100% { transform: none; } 91%, 96% { transform: translateY(-8%); } }
@keyframes casper-twitch { 0%, 90%, 100% { rotate: 0deg; } 92% { rotate: -4deg; } 94% { rotate: 3deg; } 96% { rotate: 0deg; } }
@keyframes casper-breathe { 0%, 100% { scale: 1; } 50% { scale: 1.03 1.05; } }
@keyframes casper-edge { 0%, 84%, 100% { transform: none; } 89%, 95% { transform: translateX(14%); } }

/* the secret note: the game sheet's look, with Casper on top */
.casper-note .sheet-body { text-align: center; }
.casper-note-art { width: 112px; height: auto; margin: 2px auto 12px; }
.casper-note-text { max-width: 30ch; margin: 0 auto; font: italic 500 21px/1.45 "Corm", serif; color: var(--ink); }
.casper-note-text + .casper-note-text { margin-top: 10px; }
.casper-note-sign { margin-top: 14px; font: 400 19px "Kalam", cursive; color: var(--rani); }

/* ---------- 5. strolling above the tab bar: x follows the scroll, she sleeps at the very bottom ---------- */
.casper-walker { position: fixed; left: 0; bottom: calc(11px + env(safe-area-inset-bottom, 0px) + var(--bar-h, 66px)); z-index: 49; width: 66px; height: 54px;
  padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; will-change: transform;
  transition: opacity .4s ease, visibility .4s; }
.casper-walker:focus-visible { outline-offset: 0; border-radius: 12px; }
.cw-body { position: absolute; top: 0; right: 0; bottom: 0; left: 0; filter: drop-shadow(0 3px 4px rgba(59, 31, 36, .28)); }
/* walk-a and walk-b share one scale (306 and 320 px wide at the source) and stand on the same line */
.cw-body img { position: absolute; left: 50%; bottom: 0; height: auto; max-width: none; translate: -50% 0; }
.cw-a { width: 64px; }
.cw-b { width: 67px; opacity: 0; }
.cw-sleep { width: 50px; opacity: 0; }
.casper-walker.left .cw-body { scale: -1 1; }
.casper-walker.walking .cw-a { animation: cw-a .34s steps(1) infinite; }
.casper-walker.walking .cw-b { animation: cw-b .34s steps(1) infinite; }
@keyframes cw-a { 50% { opacity: 0; } }
@keyframes cw-b { 0% { opacity: 0; } 50% { opacity: 1; } }
.casper-walker.asleep .cw-a, .casper-walker.asleep .cw-b { opacity: 0; animation: none; }
.casper-walker.asleep .cw-sleep { opacity: 1; }
.casper-bubble { position: fixed; left: 0; bottom: 0; z-index: 49; width: max-content; max-width: min(250px, calc(100vw - 24px)); margin: 0; padding: 9px 13px;
  border-radius: 16px; background: #fff; color: var(--maroon); font: 600 13.5px/1.38 "Jost", sans-serif; box-shadow: 0 8px 22px rgba(59, 31, 36, .22);
  pointer-events: none; opacity: 0; transform: translateY(6px); transition: opacity .3s ease, transform .3s ease; }
.casper-bubble.show { opacity: 1; transform: none; }
.casper-bubble::after { content: ""; position: absolute; left: var(--tail, 32px); bottom: -6px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 0 0 3px 0;
  background: #fff; rotate: 45deg; }
/* out of the way while the gate shows, and while a game sheet, the photo viewer or her note is open */
html.gated .casper-walker, html.sheet-open .casper-walker, html.lb-lock .casper-walker,
html.gated .casper-bubble, html.sheet-open .casper-bubble, html.lb-lock .casper-bubble { opacity: 0; visibility: hidden; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .casper-spot img, .casper-walker.walking .cw-a, .casper-walker.walking .cw-b { animation: none; }
  .casper-spot.popping img, .casper-spot.popping .casper-print, .casper-spot.popping::after { animation: none; }
}
