/* Buddy graduates (partials/figures/graduation.php), for the class of 2026
   post. Plays once on load and rests on the last frame; with reduced motion
   only that frame shows. Buddy's bar is the figure's one orange. */

.gr-banner {
  font: 700 34px var(--font-display);
  fill: var(--ink);
}

.gr-ink,
.gr-conf.gr-ink {
  fill: var(--ink);
}

.gr-conf.gr-muted {
  fill: var(--muted);
}

.gr-tassel,
.gr-sparks path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gr-sparks {
  opacity: 0;
}

.gr-curtain {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 4;
}

.gr-valance {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
}

.gr-lip {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
}

.gr-lip--thin {
  stroke: var(--muted);
  stroke-width: 2;
}

/* One 3.6 s timeline, starting 0.3 s after the page loads:
     0–36%   he walks out in three small steps (the curtain swishes)
     44–50%  he crouches
     50–65%  he hops, and lands with a squash
     51–84%  the cap flies: up and down under gravity, two turns at a steady rate
     84–91%  the cap lands and he dips under it
   Rising slows down and falling speeds up, so each keyframe names the easing
   to the next one. */
@media (prefers-reduced-motion: no-preference) {
  .gr-walk {
    animation: gr-walk 3.6s cubic-bezier(0.2, 0, 0.2, 1) 0.3s both;
  }

  .gr-hop {
    animation: gr-hop 3.6s 0.3s both;
  }

  .gr-squash {
    transform-box: fill-box;
    transform-origin: center bottom;
    animation: gr-squash 3.6s ease-in-out 0.3s both;
  }

  .gr-cap-fly {
    animation: gr-cap-fly 3.6s 0.3s both;
  }

  .gr-cap {
    transform-box: fill-box;
    transform-origin: 50% 30%;
    animation: gr-cap 3.6s linear 0.3s both;
  }

  .gr-curtain--left {
    transform-box: fill-box;
    transform-origin: 50% 0;
    animation: gr-swish 1.2s ease-in-out 0.5s both;
  }

  /* The sparks grow from the middle of him (in the 480 × 244 frame), so they
     travel outwards. */
  .gr-sparks {
    transform-origin: 240px 130px;
    animation: gr-sparks 3.6s cubic-bezier(0.2, 0, 0, 1) 0.3s both;
  }

  .gr-conf {
    transform-box: fill-box;
    transform-origin: center;
    animation: gr-fall 1.4s cubic-bezier(0.35, 0, 0.75, 0.9) 2.3s both;
  }

  /* Each piece drifts from side to side on its way down. */
  .gr-sway {
    animation: gr-sway-a 1.4s ease-in-out 2.3s both;
  }

  .gr-sway--b {
    animation-name: gr-sway-b;
  }

  .gr-conf--2, .gr-sway--2 { animation-delay: 2.42s; animation-duration: 1.6s; }
  .gr-conf--3, .gr-sway--3 { animation-delay: 2.34s; animation-duration: 1.25s; }
  .gr-conf--4, .gr-sway--4 { animation-delay: 2.5s; }
  .gr-conf--5, .gr-sway--5 { animation-delay: 2.38s; animation-duration: 1.6s; }
  .gr-conf--6, .gr-sway--6 { animation-delay: 2.46s; }
  .gr-conf--7, .gr-sway--7 { animation-delay: 2.32s; animation-duration: 1.25s; }
  .gr-conf--8, .gr-sway--8 { animation-delay: 2.54s; animation-duration: 1.6s; }
  .gr-conf--9, .gr-sway--9 { animation-delay: 2.4s; }
  .gr-conf--10, .gr-sway--10 { animation-delay: 2.48s; animation-duration: 1.25s; }

  .gr-fig .buddy__eye {
    transform-box: fill-box;
    transform-origin: center;
    animation: gr-blink 1.5s ease-in-out 4.2s both;
  }
}

/* He comes out from behind the left curtain. */
@keyframes gr-walk {
  0% { transform: translateX(-280px); }
  38%, 100% { transform: none; }
}

/* Three small steps, then the hop. */
@keyframes gr-hop {
  0% { transform: translateY(0); animation-timing-function: cubic-bezier(0.1, 0.45, 0.5, 1); }
  6% { transform: translateY(-10px); animation-timing-function: cubic-bezier(0.45, 0, 0.9, 0.55); }
  12% { transform: translateY(0); animation-timing-function: cubic-bezier(0.1, 0.45, 0.5, 1); }
  18% { transform: translateY(-10px); animation-timing-function: cubic-bezier(0.45, 0, 0.9, 0.55); }
  24% { transform: translateY(0); animation-timing-function: cubic-bezier(0.1, 0.45, 0.5, 1); }
  30% { transform: translateY(-9px); animation-timing-function: cubic-bezier(0.45, 0, 0.9, 0.55); }
  36% { transform: translateY(0); animation-timing-function: linear; }
  50% { transform: translateY(0); animation-timing-function: cubic-bezier(0.1, 0.45, 0.5, 1); }
  57.5% { transform: translateY(-34px); animation-timing-function: cubic-bezier(0.45, 0, 0.9, 0.55); }
  65%, 100% { transform: translateY(0); }
}

/* He crouches before the hop, squashes as he lands, and dips as the cap lands. */
@keyframes gr-squash {
  0%, 44% { transform: scale(1, 1); }
  49.5% { transform: scale(1.04, 0.93); }
  53% { transform: scale(0.98, 1.03); }
  60%, 65% { transform: scale(1, 1); }
  68% { transform: scale(1.05, 0.92); }
  73% { transform: scale(0.99, 1.015); }
  77%, 84% { transform: scale(1, 1); }
  87% { transform: scale(1.025, 0.965); }
  91%, 100% { transform: scale(1, 1); }
}

/* The cap sits on his bar, so it dips with his crouch, then flies. */
@keyframes gr-cap-fly {
  0%, 44% { transform: translateY(0); animation-timing-function: ease-in-out; }
  49.5% { transform: translateY(6px); animation-timing-function: ease-in-out; }
  51% { transform: translateY(2px); animation-timing-function: cubic-bezier(0.1, 0.45, 0.5, 1); }
  66% { transform: translateY(-72px); animation-timing-function: cubic-bezier(0.45, 0, 0.9, 0.55); }
  84% { transform: translateY(0); animation-timing-function: ease-in-out; }
  87% { transform: translateY(2.5px); animation-timing-function: ease-in-out; }
  91%, 100% { transform: translateY(0); }
}

/* Two full turns while it is in the air, at a steady rate. */
@keyframes gr-cap {
  0%, 51% { transform: rotate(0deg); }
  84%, 100% { transform: rotate(-720deg); }
}

@keyframes gr-swish {
  0%, 100% { transform: none; }
  28% { transform: skewX(3deg); }
  60% { transform: skewX(-1.5deg); }
  82% { transform: skewX(0.6deg); }
}

@keyframes gr-sparks {
  0%, 52% { opacity: 0; transform: scale(0.8); }
  57% { opacity: 1; }
  68% { opacity: 1; }
  76%, 100% { opacity: 0; transform: scale(1.14); }
}

@keyframes gr-fall {
  0% { opacity: 0; transform: translateY(-230px) rotate(280deg); }
  10% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

@keyframes gr-sway-a {
  0% { transform: translateX(-12px); }
  35% { transform: translateX(11px); }
  70% { transform: translateX(-6px); }
  100% { transform: none; }
}

@keyframes gr-sway-b {
  0% { transform: translateX(12px); }
  35% { transform: translateX(-11px); }
  70% { transform: translateX(6px); }
  100% { transform: none; }
}

/* Two quick blinks: the lids close faster than they open. */
@keyframes gr-blink {
  0%, 12%, 60%, 72%, 100% { transform: none; }
  5%, 65% { transform: scaleY(0.13); }
}
