/* Giraffe mascot animation for the menu page (/). Loaded by two lines in public/index.html;
   delete this folder and those lines to remove it. */

/* ---------- Layers ----------
   The giraffe's neck (z-index 1) goes over the page's backgrounds and lines (section borders, heading
   underlines) but under the actual content (z-index 2): cards, headings, buttons. */
#top, #menu { position: relative; }
#top > *,
#menu > :not(.cat),
#menu .cat-head > :not(.al-pop),
#menu .row { position: relative; z-index: 2; }
/* The section pills bar is its own layer (it sticks to the top), so it gets its own copy of the giraffe,
   drawn between the bar's background and its pills. Its bottom line is drawn inside the bar so the copy
   can go over it too. */
nav.cats { border-bottom-width: 0; padding-bottom: 19px; box-shadow: inset 0 -3px 0 var(--ink); }   /* "nav." so it wins over the page's own .cats rule */
nav.cats > a { position: relative; z-index: 1; }
.gir-clip { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
.gir.gir-copy { position: absolute; z-index: auto; }

/* ---------- Giraffe ----------
   The mascot artwork, unchanged, peeks up from the bottom of the screen beside the menu. Its neck is the
   picture's own neck repeated (giraffe-neck.webp), so it can grow as you scroll. Two copies of the same
   picture: the back one (whole giraffe + neck) sits behind the cards, the front one is only the head
   and goes over them a little. Positioned every frame by giraffe.js. */
.gir { --gw: clamp(130px, 13vw, 210px); position: fixed; left: 0; top: 0; width: var(--gw); pointer-events: none; visibility: hidden; will-change: transform; }
.gir.on { visibility: visible; }
.gir-in { position: relative; transform-origin: calc(var(--gw) * 0.423) calc(var(--gw) * 1.235); }   /* where the neck leaves the picture */
.gir img { display: block; width: 100%; height: auto; aspect-ratio: 480 / 593; }
.gir-back { z-index: 1; }
.gir-front { z-index: 5; }
.gir-neck { height: 140vh; margin-top: -1px; background: url(/giraffe/giraffe-neck.webp) top center / 100% auto repeat-y; }

/* the head can be clicked / tapped (bang!) and breathes smoke when the mouse is over it */
.gir-hit { position: absolute; left: 14%; top: 3%; width: 71%; height: 52%; border-radius: 45%; pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.gir-dot { position: absolute; width: 0; height: 0; }
.gir.bang .gir-in { animation: gir-bang 0.62s cubic-bezier(0.3, 0, 0.3, 1); }
@keyframes gir-bang {
  0%   { transform: none; }
  32%  { transform: scale(0.92) rotate(-6deg); }          /* winds up */
  46%  { transform: scale(1.38) rotate(3deg); }           /* hits the glass */
  54%  { transform: scale(1.3) rotate(2deg); }
  74%  { transform: scale(1.04) rotate(-1.5deg); }
  100% { transform: none; }
}

/* smoke from the nose: soft, see-through grey wisps (no outline) that grow, curl upwards and fade.
   Grey rather than white so it shows on the light page and on the pictures. */
.gir-puff { position: fixed; left: 0; top: 0; z-index: 6; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(closest-side, rgba(70, 64, 82, 0.9), rgba(98, 92, 110, 0.7) 40%, rgba(130, 125, 142, 0.35) 70%, rgba(150, 145, 160, 0));
  filter: blur(2px); will-change: transform, opacity; }

/* the cracked screen */
.gir-crack { position: fixed; inset: 0; z-index: 25; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.gir-crack path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.gir-crack .c-dark { stroke: rgba(26, 26, 26, 0.85); stroke-width: 2.2; }
.gir-crack .c-glint { stroke: rgba(255, 255, 255, 0.95); stroke-width: 1.4; }
.gir-crack .c-shard { fill: rgba(255, 255, 255, 0.55); stroke: rgba(26, 26, 26, 0.7); stroke-width: 1.2; }
.gir-crack .c-hole { fill: rgba(26, 26, 26, 0.85); }

body.searching .gir { display: none; }
@media (max-width: 640px) { .gir { --gw: 84px; } }   /* phones: smaller, and its face stays in the side margin (giraffe.js) */
@media (prefers-reduced-motion: reduce) { .gir { display: none; } }
