/* ============ Barista's Pick cup ============
   Everything that moves only changes transform/opacity, so the browser
   just slides pre-drawn layers around — nothing is redrawn while it animates.
   Layer order: base (saucer, cup, coffee) → art → swirl → ripples → spoon        */

.cup-stack { position: relative; display: block; width: 100%; aspect-ratio: 1; --T: 2.8s; }
.cup-stack > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.cup-base { filter: drop-shadow(0 28px 34px rgba(20, 26, 32, .45)); overflow: visible; }

/* the coffee surface area (cx 150, r 88 in a 300 box) */
.cup-stack .coffee { inset: auto; left: 20.667%; top: 20.667%; width: 58.667%; height: 58.667%; border-radius: 50%; overflow: hidden; }
.cup-stack .coffee > * { position: absolute; inset: 0; width: 100%; height: 100%; will-change: transform, opacity; }
.art { opacity: 0; }
.art.on { opacity: 1; }
.swirl, .tint, .pour-ring { opacity: 0; }
.tint { background: radial-gradient(circle, #ecc697 0%, #dfae78 70%, rgba(223, 174, 120, 0) 100%); border-radius: 50%; }
.pour-ring { border-radius: 50%; border: 3px solid #f6dfc0; transform: scale(.15); }
.pour-ring.r2 { border-width: 1.5px; }

/* spoon: turn (around the cup centre) → dip (towards the coffee) */
.spoon-turn, .spoon-dip { will-change: transform; }
.spoon-turn { transform-origin: 50% 50%; }
.spoon-dip { transform-origin: 37.4% 37.4%; }        /* the bowl of the spoon */
.spoon-wet { opacity: 0; will-change: opacity; }
.spoon-ripple {
  inset: auto; left: 40.7% !important; top: 40.7% !important; width: 7% !important; height: 7% !important;
  margin: -3.5% 0 0 -3.5%; border-radius: 50%; border: 1.5px solid #f0c897;
  opacity: 0; transform: scale(.4); will-change: transform, opacity;
}

/* ---------------- the stir (one timeline, --T long) ----------------
   0–14%   spoon dips in          14–72%  two laps, old art is swept away
   72–86%  spoon lifts out        80–100% milk is poured, new art opens up  */
.stirring .spoon-turn   { animation: s-turn var(--T) both; }
.stirring .spoon-dip    { animation: s-dip var(--T) both; }
.stirring .spoon-wet    { animation: s-wet var(--T) both; }
.stirring .spoon-ripple { animation: s-rip-in var(--T) ease-out both; }
.stirring .spoon-ripple.out { animation-name: s-rip-out; }
.stirring .art.out      { animation: a-out var(--T) both; }
.stirring .art.in       { animation: a-in var(--T) both; }
.stirring .swirl        { animation: a-swirl var(--T) both; }
.stirring .tint         { animation: a-tint var(--T) both; }
.stirring .pour-ring    { animation: a-ring var(--T) ease-out both; }
.stirring .pour-ring.r2 { animation-name: a-ring2; }

@keyframes s-turn {
  0%, 14% { transform: rotate(0deg); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  72%, 100% { transform: rotate(-720deg); }
}
@keyframes s-dip {
  0%   { transform: translate(0, 0) scale(1); animation-timing-function: ease-out; }
  4%   { transform: translate(-1%, -1%) scale(1.03); animation-timing-function: ease-in; }
  14%, 72% { transform: translate(3.3%, 3.3%) scale(.8); animation-timing-function: ease-out; }
  82%  { transform: translate(-1%, -1%) scale(1.03); }
  88%, 100% { transform: translate(0, 0) scale(1); }
}
@keyframes s-wet   { 0%, 8% { opacity: 0; } 14%, 72% { opacity: 1; } 80%, 100% { opacity: 0; } }
@keyframes s-rip-in  { 0%, 11% { opacity: 0; transform: scale(.4); } 13% { opacity: .9; } 30%, 100% { opacity: 0; transform: scale(4); } }
@keyframes s-rip-out { 0%, 72% { opacity: 0; transform: scale(.4); } 75% { opacity: .9; } 90%, 100% { opacity: 0; transform: scale(3.6); } }

/* old design: dragged round with the spoon, shrinking and melting into the crema */
@keyframes a-out {
  0%, 14% { opacity: 1; transform: rotate(0) scale(1); animation-timing-function: cubic-bezier(.5, 0, .75, .4); }
  62%     { opacity: 0; transform: rotate(-250deg) scale(.78); }
  100%    { opacity: 0; transform: rotate(-250deg) scale(.78); }
}
/* soft milk spiral that follows the spoon */
@keyframes a-swirl {
  0%, 16% { opacity: 0; transform: rotate(0deg) scale(.9); animation-timing-function: linear; }
  40%     { opacity: .85; }
  62%     { opacity: .55; }
  76%, 100% { opacity: 0; transform: rotate(-560deg) scale(1.05); }
}
@keyframes a-tint { 0%, 18% { opacity: 0; } 50% { opacity: .5; } 82%, 100% { opacity: 0; } }
/* new design: poured from the centre, blooms out and settles */
@keyframes a-in {
  0%, 80% { opacity: 0; transform: scale(.45) rotate(14deg); animation-timing-function: cubic-bezier(.2, .8, .3, 1); }
  93%     { opacity: 1; transform: scale(1.03) rotate(-2deg); }
  100%    { opacity: 1; transform: scale(1) rotate(0); }
}
/* ripples spread from the centre where the milk lands */
@keyframes a-ring  { 0%, 79% { opacity: 0; transform: scale(.12); } 81% { opacity: .9; } 100% { opacity: 0; transform: scale(1); } }
@keyframes a-ring2 { 0%, 84% { opacity: 0; transform: scale(.12); } 86% { opacity: .7; } 100% { opacity: 0; transform: scale(.8); } }

.cup-btn:hover .cup-stack { transform: rotate(-3deg) scale(1.02); }
.cup-stack { transition: transform .4s; }

@media (prefers-reduced-motion: reduce) {
  .stirring * { animation-duration: .01ms !important; }
}

/* spoon finish */
.spoon-body { fill: url(#steel); stroke: #6f7880; stroke-width: .8; }
.spoon-shadow { fill: #2b1a10; opacity: .35; }

/* spoon layers fill the whole cup box so their % origins line up with the cup */
.spoon-turn, .spoon-dip { position: absolute; inset: 0; width: 100%; height: 100%; }
.spoon-ripple { position: absolute; }
