/* Pincbone logo mark: sizing and motion for the inline SVG in _src/logo-mark.inline.html.
   Size:     height follows font-size (1em), or set --mark-size on the mark or any parent.
   Colour:   --mark-pink (skull, ears) and --mark-bone (bone). Ink variant: set both to #0D0A0B.
   Motion:   hover/focus inside a link, .pb-mark--alive (idle ear twitch), .pb-mark--chomp (one shot).
   Units:    px inside the keyframes are viewBox units (the mark is 120 units tall). */

.pb-mark {
  display: block;
  flex: none;
  height: var(--mark-size, 1em);
  width: auto;
  aspect-ratio: 1;
  overflow: visible;
  transform-origin: 50% 92%;
  --pb-spring: cubic-bezier(.34, 1.56, .64, 1);
}

@supports (transition-timing-function: linear(0, 1)) {
  /* damped spring: about 20% overshoot, one small rebound, settled by the end */
  .pb-mark {
    --pb-spring: linear(0, .077 4%, .263 8%, .498 12%, .731 16%, .93 20%, 1.104 25%, 1.19 30%,
      1.205 33.5%, 1.193 37%, 1.146 42%, 1.073 48%, 1.002 55%, .965 62%, .959 69%, .971 76%, .993 85%, 1);
  }
}

/* pivots: ears at their base, skull at the neck, bone at its centre */
.pb-mark__ear--l,
.pb-mark__ear--r,
.pb-mark__skull,
.pb-mark__bone { transform-box: fill-box; }
.pb-mark__ear--l { transform-origin: 70% 83%; }
.pb-mark__ear--r { transform-origin: 30% 83%; }
.pb-mark__skull { transform-origin: 50% 100%; }
.pb-mark__bone { transform-origin: 50% 50%; }

/* hover / keyboard focus, when the mark sits inside a link:
   ears flick outward and settle, the head tilts, the bone wiggles once */
@media (hover: hover) and (pointer: fine) {
  .pb-mark,
  .pb-mark__ear--l,
  .pb-mark__ear--r { transition: transform 500ms var(--pb-spring); }

  a:hover .pb-mark,
  a:focus-visible .pb-mark { transform: rotate(-4deg); }
  a:hover .pb-mark__ear--l,
  a:focus-visible .pb-mark__ear--l { transform: rotate(-10deg); }
  a:hover .pb-mark__ear--r,
  a:focus-visible .pb-mark__ear--r { transform: rotate(10deg); }
  a:hover .pb-mark__bone,
  a:focus-visible .pb-mark__bone { animation: pb-bone-wiggle 520ms ease-in-out 1; }
}

@keyframes pb-bone-wiggle {
  30% { transform: rotate(-5deg); }
  62% { transform: rotate(3.5deg); }
  84% { transform: rotate(-1.2deg); }
}

/* idle wink of life: js/shared.js adds .is-twitching to a visible .pb-mark--alive every few
   seconds. (A CSS animation that loops forever, even one that sits still for 90% of its cycle,
   keeps the browser's style engine working on every frame; on phones that was measurable.)
   Uses the individual rotate property so it stacks with the hover pose instead of fighting it. */
.pb-mark--alive.is-twitching .pb-mark__ear--r { animation: pb-ear-twitch 600ms ease-out 1; }

@keyframes pb-ear-twitch {
  0%, 100% { rotate: 0deg; }
  25% { rotate: 10deg; }
  50% { rotate: -2deg; }
  70% { rotate: 5deg; }
}

/* one-shot chomp: add .pb-mark--chomp from JS and remove it on animationend.
   The head (skull and ears) dips 4 units onto the bone, the jaw closes up from below, the bone jiggles. */
.pb-mark.pb-mark--chomp .pb-mark__skull,
.pb-mark.pb-mark--chomp .pb-mark__ear--l,
.pb-mark.pb-mark--chomp .pb-mark__ear--r { animation: pb-chomp-head 450ms cubic-bezier(.3, 0, .3, 1) 1; }
.pb-mark.pb-mark--chomp .pb-mark__jaw { animation: pb-chomp-jaw 450ms cubic-bezier(.3, 0, .3, 1) 1; }
.pb-mark.pb-mark--chomp .pb-mark__bone { animation: pb-chomp-bone 450ms ease-out 1; }

@keyframes pb-chomp-head {
  32% { translate: 0 4px; }
  58% { translate: 0 -1px; }
  80% { translate: 0 .6px; }
}
@keyframes pb-chomp-jaw {
  /* the jaw sits inside the skull group, so -7 here is a net 3 units upward */
  32% { translate: 0 -7px; }
  58% { translate: 0 1.6px; }
  80% { translate: 0 -.8px; }
}
@keyframes pb-chomp-bone {
  32% { rotate: -3deg; }
  58% { rotate: 3deg; }
  80% { rotate: -1.2deg; }
}

/* the site's global pause switch */
html.is-paused .pb-mark,
html.is-paused .pb-mark * { animation-play-state: paused !important; }

/* reduced motion: no animation, no transition, no hover pose */
@media (prefers-reduced-motion: reduce) {
  .pb-mark,
  .pb-mark * { animation: none !important; transition: none !important; }
  .pb-mark * { transform: none !important; rotate: none !important; translate: none !important; }
  a:hover .pb-mark,
  a:focus-visible .pb-mark { transform: none !important; }
}
