/* Miaoo ribbon poster stickers v1.0 (22 Nov 2026)
   Adds the elites' poster stickers inside the existing .landing-marquee ribbon on miaoo.io.
   Every few seconds a cat paw swipes one sticker and claws tear through it, then it heals.
   Nothing else in the ribbon changes. */

.ms-poster {
  --ms-tilt: -2deg;
  --ms-ribbon: var(--landing-accent, #E8879B);
  --ms-ink: var(--landing-border, #5D4E37);
  --ms-paper: #f3eefd;
  --ms-text: #5b438f;
  --ms-t: 3600ms;                 /* one full scratch: swipe, tear, hold, heal */
  position: relative;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  flex-shrink: 0;
  padding: 4px 12px 5px;
  border: 2.5px solid var(--ms-ink);
  border-radius: 8px;
  background: var(--ms-paper);
  color: var(--ms-text);
  box-shadow: 2px 2px 0 var(--ms-ink);
  font-family: inherit;
  font-weight: 700;
  font-size: .82rem;
  line-height: 1.1;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(var(--ms-tilt));
  transform-origin: 50% 60%;
  isolation: isolate;
}
.ms-poster__label { font-size: .58em; letter-spacing: .12em; opacity: .65; }
.ms-poster__text { position: relative; z-index: 1; }

/* laminate glint before the swipe (moves its background, so it never leaves the sticker) */
.ms-poster::after {
  content: ""; position: absolute; inset: 0; border-radius: 6px; pointer-events: none; z-index: 3;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.9) 50%, transparent 60%) no-repeat;
  background-size: 300% 100%; background-position: 150% 0; opacity: 0;
}

/* claw layer: covers the sticker; JS sizes its viewBox to the sticker in px */
.ms-poster__claw { position: absolute; inset: -3px; z-index: 2; pointer-events: none; overflow: visible; width: calc(100% + 6px); height: calc(100% + 6px); }
.ms-poster__claw .ms-gash { fill: var(--ms-ribbon); stroke: var(--ms-ink); stroke-width: 1.4; stroke-linejoin: round; }
.ms-poster__claw .ms-gash-shade { fill: #c45f77; }
.ms-poster__claw .ms-flap { fill: #fffdfa; stroke: var(--ms-ink); stroke-width: 1.1; stroke-linejoin: round; }
.ms-poster__claw .ms-tear { opacity: 0; }
.ms-poster__claw .ms-reveal { fill: none; stroke: #fff; stroke-linecap: round; stroke-dasharray: 120; stroke-dashoffset: 120; }

/* the paw that does it */
.ms-poster__paw {
  position: absolute; z-index: 4; pointer-events: none; width: 34px; height: 34px;
  top: -8px; right: -14px; opacity: 0; transform-origin: 50% 50%;
}

/* torn paper flecks */
.ms-poster__fleck {
  position: absolute; z-index: 4; pointer-events: none; width: 5px; height: 3px; left: 62%; top: 45%;
  background: var(--ms-paper); border: 1.5px solid var(--ms-ink); border-radius: 1px; opacity: 0;
}

/* ===== the scratch: one 3.6 s timeline, every part keyed to it =====
   0-7%    paw winds up top-right and swipes down-left       (anticipation, fast ease-in)
   4.6-11% three tears rip open behind the paw, 43 ms apart                 (primary action, snap ease-out)
   5-19%   sticker jolts: squash, overshoot, settle          (secondary, ease-out-back)
   6-24%   paper flecks fly and fall                         (secondary)
   11-82%  hold: the torn sticker hangs there                (read time)
   82-100% tears close and fade, sticker settles             (resolution, ease-in)        */
.ms-poster.is-scratching { animation: ms-jolt var(--ms-t) cubic-bezier(.175,.885,.32,1.275) both; }
.ms-poster.is-scratching::after { animation: ms-glint var(--ms-t) ease-out both; }
.ms-poster.is-scratching .ms-poster__paw { animation: ms-paw var(--ms-t) both; }
.ms-poster.is-scratching .ms-tear { animation: ms-cut-show var(--ms-t) both; }
.ms-poster.is-scratching .ms-reveal.r1 { animation: ms-rip-1 var(--ms-t) both; }
.ms-poster.is-scratching .ms-reveal.r2 { animation: ms-rip-2 var(--ms-t) both; }
.ms-poster.is-scratching .ms-reveal.r3 { animation: ms-rip-3 var(--ms-t) both; }
.ms-poster.is-scratching .ms-poster__fleck { animation: ms-fleck var(--ms-t) both; }

@keyframes ms-glint { 0% { opacity: 1; background-position: 150% 0; } 3.5% { opacity: 1; background-position: -50% 0; } 4%, 100% { opacity: 0; background-position: -50% 0; } }

@keyframes ms-paw {
  0%   { opacity: 0; transform: translate(10px, -4px) rotate(-10deg) scale(.6); animation-timing-function: cubic-bezier(.2,0,0,1); }
  2.5% { opacity: 1; transform: translate(4px, -6px) rotate(-24deg) scale(1.08); animation-timing-function: cubic-bezier(.55,0,1,.45); }
  7%   { opacity: 1; transform: translate(var(--ms-paw-x, -110px), 14px) rotate(-4deg) scale(.95); animation-timing-function: ease-out; }
  10%  { opacity: 0; transform: translate(calc(var(--ms-paw-x, -110px) - 18px), 16px) rotate(0deg) scale(.8); }
  100% { opacity: 0; transform: translate(calc(var(--ms-paw-x, -110px) - 18px), 16px) rotate(0deg) scale(.8); }
}

/* each tear reveals along its own path, staggered 60 ms (1.67%) */
@keyframes ms-rip-1 { 0%, 4.6%  { stroke-dashoffset: 120; animation-timing-function: cubic-bezier(.05,.7,.1,1); } 8.6%  { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; } }
@keyframes ms-rip-2 { 0%, 5.8%  { stroke-dashoffset: 120; animation-timing-function: cubic-bezier(.05,.7,.1,1); } 9.8%  { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; } }
@keyframes ms-rip-3 { 0%, 7%    { stroke-dashoffset: 120; animation-timing-function: cubic-bezier(.05,.7,.1,1); } 11%   { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; } }

@keyframes ms-cut-show {
  0%, 4.5% { opacity: 0; }
  4.6%     { opacity: 1; }
  82%      { opacity: 1; animation-timing-function: cubic-bezier(.3,0,1,1); }
  95%      { opacity: 0; }
  100%     { opacity: 0; }
}

@keyframes ms-jolt {
  0%, 4.5% { transform: rotate(var(--ms-tilt)) scale(1); }
  7%       { transform: rotate(calc(var(--ms-tilt) + 6deg)) translate(-2px, 2px) scale(1.04, .9); }
  11%      { transform: rotate(calc(var(--ms-tilt) - 3deg)) translate(1px, -1px) scale(.98, 1.05); }
  16%      { transform: rotate(calc(var(--ms-tilt) + 1deg)) scale(1); }
  19%      { transform: rotate(calc(var(--ms-tilt) + 2.5deg)) translateY(1px); }
  82%      { transform: rotate(calc(var(--ms-tilt) + 2.5deg)) translateY(1px); animation-timing-function: cubic-bezier(.4,0,.2,1); }
  92%      { transform: rotate(var(--ms-tilt)) scale(1.03); }
  100%     { transform: rotate(var(--ms-tilt)) scale(1); }
}

@keyframes ms-fleck {
  0%, 5.5% { opacity: 0; transform: translate(0, 0) rotate(0); }
  6.5%     { opacity: 1; transform: translate(calc(var(--fx) * .25), calc(var(--fy) * .35)) rotate(calc(var(--fr) * .3)); animation-timing-function: cubic-bezier(.2,0,.4,1); }
  14%      { opacity: 1; transform: translate(var(--fx), var(--fy)) rotate(var(--fr)); animation-timing-function: cubic-bezier(.5,0,1,1); }
  24%      { opacity: 0; transform: translate(calc(var(--fx) * 1.2), calc(var(--fy) + 26px)) rotate(calc(var(--fr) * 1.6)); }
  100%     { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ms-poster, .ms-poster * , .ms-poster::after { animation: none !important; }
  .ms-poster__paw, .ms-poster__fleck { display: none; }
}
