/* Ganesha from the original invitation: its gold line art, split into layers (assets/ganesha/)
   so it can come alive the way the rest of the card does.
   Entrance: once the gate opens, the figure is revealed top to bottom and pops softly; the halo blooms.
   Idle: a gentle float, ears flop, the trunk sways, eyes blink.
   Tap: a happy squish, an ear flutter, a raised trunk, smiling eyes and a petal shower (main.js). */

.ganesha {
  --g-gold: #A8732C;
  --g-gold-hi: #C99A45;
  position: relative;
  width: 156px;
  margin: -12px 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ganesha svg { width: 100%; height: auto; display: block; overflow: visible; }
.ganesha:focus-visible { outline-offset: -8px; border-radius: 50%; }

/* ── Aura (SVG): halo glow, dotted ring, sparkles ── */
.g-ring { fill: none; stroke: var(--g-gold-hi); stroke-width: 1.2; stroke-linecap: round; stroke-dasharray: 0.01 2.4; opacity: .7; }
.g-spark { fill: #E2B865; }
.g-glow, .g-ring, .g-spark { transform-box: fill-box; transform-origin: 50% 50%; }
.g-glow { animation: g-glow 3.8s ease-in-out infinite; }
.g-ring { animation: g-spin 46s linear infinite; }
.g-spark { animation: g-twinkle 3.2s ease-in-out infinite; }
.s2 { animation-delay: .7s; }
.s3 { animation-delay: 1.5s; }
.s4 { animation-delay: 2.2s; }
.s5 { animation-delay: 1.1s; }

/* ── The figure: layers stacked on one canvas, centred on the halo ── */
.g-art {
  position: absolute;
  left: 50%;
  top: 51%;          /* the halo's centre: (88 + 16) / 204 of the SVG */
  width: 94px;
  aspect-ratio: 322 / 412;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 2.5px rgba(240, 200, 120, .55));
  pointer-events: none;
}
.g-pop, .g-figure { position: absolute; inset: 0; display: block; }
.gp {
  position: absolute;
  inset: 0;
  display: block;
  background: linear-gradient(160deg, #C99A45 0%, #9A6421 55%, #7A4A14 100%);  /* gold lines */
  -webkit-mask: var(--src) center / 100% 100% no-repeat;
  mask: var(--src) center / 100% 100% no-repeat;
}
.gp-base  { --src: url("assets/ganesha/base.webp"); }
.gp-ear-l { --src: url("assets/ganesha/ear-l.webp"); }
.gp-ear-r { --src: url("assets/ganesha/ear-r.webp"); }
.gp-eye-l { --src: url("assets/ganesha/eye-l.webp"); }
.gp-eye-r { --src: url("assets/ganesha/eye-r.webp"); }
.gp-trunk { --src: url("assets/ganesha/trunk.webp"); }

/* Pivots (from the split script): ears at the head, eyes at their centres, trunk where it curls */
.g-pop    { transform-origin: 50% 70%; }
.g-figure { transform-origin: 50% 80%; }
.gp-ear-l { transform-origin: 27.3% 46.4%; }
.gp-ear-r { transform-origin: 73.3% 46.4%; }
.gp-eye-l { transform-origin: 39.1% 43.7%; }
.gp-eye-r { transform-origin: 60.2% 43.7%; }
.gp-trunk { transform-origin: 48.4% 67%; }

/* ── Idle life ── */
.g-figure { animation: g-float 6s ease-in-out infinite; }
.gp-ear-l { animation: g-flop-l 3s ease-in-out infinite; }
.gp-ear-r { animation: g-flop-r 3s ease-in-out infinite; }
.gp-eye-l, .gp-eye-r { animation: g-blink 4.8s ease-in-out infinite; }
.gp-trunk { animation: g-sway 3.6s ease-in-out infinite; }
@keyframes g-float {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50%      { transform: translateY(-2.5px) rotate(1.2deg); }
}
@keyframes g-flop-l {
  0%, 100% { transform: rotate(0deg) scaleX(1); }
  40%      { transform: rotate(5deg) scaleX(.88); }
  55%      { transform: rotate(3deg) scaleX(.93); }
}
@keyframes g-flop-r {
  0%, 100% { transform: rotate(0deg) scaleX(1); }
  40%      { transform: rotate(-5deg) scaleX(.88); }
  55%      { transform: rotate(-3deg) scaleX(.93); }
}
@keyframes g-sway {
  0%, 100% { transform: rotate(-3deg); }
  30%      { transform: rotate(3.5deg); }
  55%      { transform: rotate(1.5deg); }
  75%      { transform: rotate(4deg); }
}
@keyframes g-blink {
  0%, 88%, 100% { transform: scaleY(1); }
  91%           { transform: scaleY(.1); }
  94%           { transform: scaleY(1); }
}
@keyframes g-glow {
  0%, 100% { opacity: .55; transform: scale(.92); }
  50%      { opacity: 1; transform: scale(1.06); }
}
@keyframes g-spin { to { transform: rotate(360deg); } }
@keyframes g-twinkle {
  0%, 100% { opacity: 0; transform: scale(.2) rotate(0deg); }
  40%, 60% { opacity: 1; transform: scale(1) rotate(45deg); }
}

/* ── Entrance: revealed top to bottom as if drawn, then a soft pop; the halo blooms ── */
.js .g-figure { clip-path: inset(0 0 100% 0); }
.js .g-pop { transform: scale(.86); }
.js .g-aura { opacity: 0; transform: scale(.6); transform-box: fill-box; transform-origin: 50% 50%; }
.js.is-open .g-figure { clip-path: inset(-10% -10% -10% -10%); transition: clip-path 2.2s cubic-bezier(.45, 0, .2, 1) .9s; }
.js.is-open .g-pop { transform: none; transition: transform 1.3s cubic-bezier(.34, 1.6, .5, 1) 2.2s; }
.js.is-open .g-aura { opacity: 1; transform: none; transition: opacity 1.6s ease 2s, transform 2s cubic-bezier(.16, 1, .3, 1) 2s; }

/* ── Tap: a happy squish ── */
.ganesha.is-blessing .g-figure { animation: g-squish .9s cubic-bezier(.3, 0, .2, 1); }
.ganesha.is-blessing .gp-ear-l { animation: g-flop-l .32s ease-in-out 3; }
.ganesha.is-blessing .gp-ear-r { animation: g-flop-r .32s ease-in-out 3; }
.ganesha.is-blessing .gp-trunk { animation: g-trunk-up 1s cubic-bezier(.3, 0, .2, 1); }
.ganesha.is-blessing .gp-eye-l,
.ganesha.is-blessing .gp-eye-r { animation: g-happy-eyes 1s ease-in-out; }
.ganesha.is-blessing .g-glow { animation: g-flash 1s ease-out; }

@keyframes g-squish {
  0%   { transform: scale(1, 1); }
  25%  { transform: scale(1.07, .93) translateY(3px); }
  50%  { transform: scale(.96, 1.06) translateY(-4px); }
  75%  { transform: scale(1.02, .98); }
  100% { transform: scale(1, 1); }
}
@keyframes g-trunk-up {
  0%, 100% { transform: rotate(0deg); }
  40%      { transform: rotate(-9deg); }
  70%      { transform: rotate(-3deg); }
}
@keyframes g-happy-eyes {
  0%, 100% { transform: scaleY(1); }
  25%, 70% { transform: scaleY(.45); }
}
@keyframes g-flash {
  0%   { opacity: .7; transform: scale(.95); }
  35%  { opacity: 1; transform: scale(1.3); }
  100% { opacity: .7; transform: scale(1); }
}
