/* The shrine cats (js/cats.js; drawings in js/cat-art.js): on the path, in the path's actors layer like the
   other people of the path (css/avatar.css .npc: they inherit its visibility, so nothing of them shows in a
   spot view), and one in each spot view. Transform origins are in the drawing's units (the 64 × 56 box).
   Only the painted cat takes a tap (the button itself and its empty box let taps through), and every
   animation runs only while the cat is on screen in the view shown (.anim, set by js/cats.js). */

.cat { padding: 0; margin: 0; border: 0; background: none; cursor: pointer; pointer-events: none; -webkit-tap-highlight-color: transparent; }
.npc.cat { pointer-events: none; aspect-ratio: 64 / 56; }
.cat .ct-svg { display: none; position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cat * { transform-box: view-box; }
.cat .ct-svg * { pointer-events: visiblePainted; }
.cat .ct-shadow, .cat .ct-zz, .cat clipPath, .cat clipPath *, .cat .pk-bush, .cat .pk-bush * { pointer-events: none; }
.cat:focus-visible { outline: 3px solid var(--lilac-ink, #8f7fe0); outline-offset: 2px; border-radius: 12px; }
.cat-bob { position: absolute; inset: 0; }
.sc-cat { position: absolute; aspect-ratio: 64 / 56; }
.sc-cat .npc-in, .sc-cat .npc-flip { position: absolute; inset: 0; }
.sc-cat .npc-flip { transition: transform .25s; }
.sc-cat.face-r .npc-flip { transform: scaleX(-1); }

/* the pose shown */
.cat[data-pose="sit"] .ct-sit, .cat[data-pose="wash"] .ct-wash, .cat[data-pose="beckon"] .ct-beckon, .cat[data-pose="loaf"] .ct-loaf,
.cat[data-pose="curl"] .ct-curl, .cat[data-pose="side"] .ct-side, .cat[data-pose="roll"] .ct-roll, .cat[data-pose="stretch"] .ct-stretch,
.cat[data-pose="walk"] .ct-walk, .cat[data-pose="trot"] .ct-trot, .cat[data-pose="crouch"] .ct-crouch, .cat[data-pose="drink"] .ct-drink,
.cat[data-pose="peek"] .ct-peek { display: block; }

/* the season's touches: a tiny scarf in winter, a petal on some heads in spring */
.ct-scarf, .ct-petal, .ct-lick, .ct-wet { display: none; }
[data-season="winter"] .cat .ct-scarf { display: inline; }
[data-season="winter"] .cat.has-bell .ct-scarf { display: none; }
[data-season="spring"] .cat.petal .ct-petal { display: inline; }
.cat.wet .ct-wet { display: inline; }
.cat.licking .ct-lick { display: inline; animation: ctLick .5s ease-in-out 2; transform-origin: 0 3.6px; }
@keyframes ctLick { 0%, 100% { transform: scaleY(.2); } 50% { transform: scaleY(1.4) translateY(-.6px); } }

/* eyes: as drawn (open, or the closed arcs), or turned by the cat's state */
.ct-eyes, .ct-shut, .ct-eye, .ct-lid { transition: opacity .18s; }
.cat.eyes-open .ct-eyes { opacity: 1 !important; }
.cat.eyes-open .ct-shut { opacity: 0 !important; }
.cat.eyes-shut .ct-eyes { opacity: 0 !important; }
.cat.eyes-shut .ct-shut { opacity: 1 !important; }
/* one eye opens (the loaf, the hall's cat) */
.cat.one-eye .ct-eyes, .cat.one-eye .ct-shut { opacity: 1 !important; }
.cat.one-eye .ct-eye.l, .cat.one-eye .ct-lid.r { opacity: 0; }
.ct-eyes { transform-origin: 0 .8px; }

/* the face turns to us (side poses) or looks up (front poses) */
.ct-face-in { transition: transform .3s ease; }
.cat.look .ct-face-in { transform: translateX(3.2px); }
.cat.look-up .ct-face-in { transform: translateY(-1.6px); }
.cat .ct-head { transition: transform .35s ease; }
.cat.look-up .ct-head { transform: rotate(-5deg) translateY(-1px); }
.cat.perk .ct-head { transform: translateY(-2.4px) rotate(4deg); }
.cat.proud .ct-head { transform: translateY(-1.4px) rotate(-3deg); }
.cat.proud .ct-body { transform: scale(1.04, 1.03); }

/* ---------- idle life (only on screen) ---------- */
.cat.anim .ct-body { animation: ctBreathe var(--br, 3.3s) ease-in-out infinite; }
@keyframes ctBreathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.02, 1.045); } }
.cat.anim .ct-eyes { animation: ctBlink var(--bl, 5.4s) ease-in-out infinite; animation-delay: var(--bd, 0s); }
@keyframes ctBlink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.cat.anim .ct-ear.l { animation: ctEarL var(--ea, 7.2s) ease-in-out infinite; animation-delay: var(--ed, 0s); }
.cat.anim .ct-ear.r { animation: ctEarR var(--ea, 7.2s) ease-in-out infinite; animation-delay: calc(var(--ed, 0s) - 2.9s); }
@keyframes ctEarL { 0%, 86%, 100% { transform: rotate(0); } 89% { transform: rotate(-16deg); } 92% { transform: rotate(2deg); } 94% { transform: rotate(-9deg); } }
@keyframes ctEarR { 0%, 86%, 100% { transform: rotate(0); } 89% { transform: rotate(16deg); } 92% { transform: rotate(-2deg); } }
.cat.anim .ct-tail { animation: ctSwish var(--sw, 3.6s) ease-in-out infinite; animation-delay: var(--sd, 0s); }
@keyframes ctSwish { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(8deg); } }
/* asleep: a slower breath, the z's rising, a lazy tail */
.cat.anim[data-pose="loaf"] .ct-body, .cat.anim[data-pose="curl"] .ct-body { animation-duration: 3.8s; }
.cat.anim .ct-zz { animation: ctZz 3.2s ease-in-out infinite; }
@keyframes ctZz { 0% { opacity: 0; transform: translate(0, 2px); } 40% { opacity: .9; } 100% { opacity: 0; transform: translate(4px, -7px); } }
.cat.awake .ct-zz, .cat.one-eye .ct-zz, .cat.eyes-open .ct-zz { opacity: 0; animation: none; }
.cat.anim[data-pose="loaf"] .ct-tail, .cat.anim[data-pose="curl"] .ct-tail { animation: ctTailRest 6s ease-in-out infinite; }
@keyframes ctTailRest { 0%, 70%, 100% { transform: rotate(0); } 80% { transform: rotate(-7deg); } 90% { transform: rotate(3deg); } }

/* washing the face: the paw strokes the cheek, the head bobs with it */
.cat.anim[data-pose="wash"] .ct-paw { animation: ctWash 1.05s ease-in-out infinite; }
@keyframes ctWash { 0%, 100% { transform: rotate(0); } 45% { transform: rotate(-20deg) translateY(-1px); } }
.cat.anim[data-pose="wash"] .ct-head { animation: ctWashHead 1.05s ease-in-out infinite; }
@keyframes ctWashHead { 0%, 100% { transform: rotate(0); } 45% { transform: rotate(-6deg) translateY(.6px); } }
.cat.anim[data-pose="wash"] .ct-tongue { animation: ctLap .35s ease-in-out infinite alternate; transform-origin: 0 5.4px; }
/* the beckoning paw (faster for a moment when money lands) */
.cat.anim[data-pose="beckon"] .ct-paw { animation: ctBeckon var(--bk, 1.7s) ease-in-out infinite; }
.cat.anim.fast[data-pose="beckon"] .ct-paw { --bk: .5s; }
@keyframes ctBeckon { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-26deg); } }
.cat.anim.has-bell .ct-bell { animation: ctBell 1.7s ease-in-out infinite; }
@keyframes ctBell { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
/* walking and trotting: the legs swing in turn, a small bob */
.cat.anim.moving .ct-leg.fn, .cat.anim.moving .ct-leg.hf { animation: ctStepA var(--step, .62s) ease-in-out infinite; }
.cat.anim.moving .ct-leg.ff, .cat.anim.moving .ct-leg.hn { animation: ctStepB var(--step, .62s) ease-in-out infinite; }
.cat.anim.moving .cat-bob { animation: ctBob calc(var(--step, .62s) / 2) ease-in-out infinite; }
.cat.anim.moving[data-pose="trot"] { --step: .4s; }
@keyframes ctStepA { 0%, 100% { transform: rotate(-17deg); } 50% { transform: rotate(17deg); } }
@keyframes ctStepB { 0%, 100% { transform: rotate(17deg); } 50% { transform: rotate(-17deg); } }
@keyframes ctBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4%); } }
.cat.anim.moving .ct-tail { animation-duration: 1.2s; }
/* crouched: the rear wiggles before the pounce */
.cat.anim.wiggle .ct-rear { animation: ctWiggle .14s ease-in-out infinite alternate; }
@keyframes ctWiggle { from { transform: translateX(-1.4px) rotate(-3deg); } to { transform: translateX(1.4px) rotate(3deg); } }
.cat.anim[data-pose="crouch"] .ct-tail { animation: ctTwitch 1.6s ease-in-out infinite; }
@keyframes ctTwitch { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-10deg); } 80% { transform: rotate(6deg); } }
/* drinking: the head dips, the tongue laps */
.cat.anim[data-pose="drink"] .ct-head { animation: ctDip .7s ease-in-out infinite; }
@keyframes ctDip { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(1.2px) rotate(2deg); } }
.cat.anim[data-pose="drink"] .ct-tongue { animation: ctLap .35s ease-in-out infinite alternate; transform-origin: 0 5.4px; }
@keyframes ctLap { from { transform: scaleY(.3); } to { transform: scaleY(1.3); } }
/* peeking: the head tilts a little, curious */
.cat.anim[data-pose="peek"] .ct-head { animation: ctPeek 3.4s ease-in-out infinite; }
@keyframes ctPeek { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
/* on its back: the paws paddle */
.cat.anim[data-pose="roll"] .ct-paws { animation: ctPaddle .5s ease-in-out infinite alternate; }
@keyframes ctPaddle { from { transform: rotate(-5deg); } to { transform: rotate(5deg) translateY(-.8px); } }
/* rubbing a cheek on the table leg (the ema's cat) */
.cat.anim.rub .cat-bob { animation: ctRub 1.8s ease-in-out infinite; }
.cat.anim.rub .ct-head { animation: ctRubHead 1.8s ease-in-out infinite; }
@keyframes ctRub { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-3%); } }
@keyframes ctRubHead { 0%, 100% { transform: rotate(4deg); } 50% { transform: rotate(-12deg) translateY(-1px); } }
/* watching the box being shaken: the head follows it */
.cat.anim.watch .ct-head { animation: ctWatch .32s ease-in-out infinite alternate; }
@keyframes ctWatch { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
.cat.anim.sniff .ct-head { animation: ctSniff .28s ease-in-out 5 alternate; }
@keyframes ctSniff { from { transform: translate(-1px, 1.6px) rotate(8deg); } to { transform: translate(-1.4px, 2.4px) rotate(10deg); } }
.cat.anim.lean-back .cat-bob { animation: ctLeanBack 1.3s cubic-bezier(.3, 1.2, .4, 1); }
@keyframes ctLeanBack { 0%, 100% { transform: none; } 30%, 70% { transform: translate(3%, -2%) rotate(7deg); } }

/* ---------- on the path ---------- */
/* in the air (the hunter's pounce): its shadow stays on the ground, so it is not drawn with the lifted cat */
.cat.air .ct-shadow { opacity: 0; }
/* the peeker: behind a bush (its own copy of the bush is drawn over it), ducks out of sight, comes out */
.npc.cat-peeker { aspect-ratio: 1; }
.pk-cat { position: absolute; left: 8.33%; top: 4.2%; width: 83.33%; aspect-ratio: 64 / 56; transition: transform .38s cubic-bezier(.3, 1, .4, 1), opacity .3s; }
.pk-bush { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cat-peeker.pk-duck .pk-cat { transform: translateY(52%); opacity: 0; }
.cat-peeker.pk-out .pk-cat { transform: translate(-82%, 44%); }
/* the hunter's falling leaf, petal or snowflake */
.cat-leaf { position: absolute; left: 0; top: 0; z-index: 1; width: calc(12 / 390 * 100%); aspect-ratio: 1; pointer-events: none; }
.cat-leaf svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cat-leaf > svg > g { display: none; }
[data-season="spring"] .cat-leaf .spring, [data-season="summer"] .cat-leaf .summer,
[data-season="autumn"] .cat-leaf .autumn, [data-season="winter"] .cat-leaf .winter { display: inline; }

/* ---------- in the spot views: one cat each, part of the scene, never in the way ---------- */
/* the worship hall: asleep on the right end of the offering box's top (units of the box's 130 × 120 drawing) */
.sc-haiden { z-index: 1; left: 67.2%; top: 1.7%; width: 36%; }
/* the water basin: on the far side of the rim, right of the middle (units of the 400 × 520 drawing) */
.sc-temizu { z-index: 1; left: calc((248 - 31) / 400 * 100%); top: calc((365 - 50.4) / 520 * 100%); width: calc(62 / 400 * 100%); }
.sc-temizu[data-pose="drink"] .npc-in { transform: translateY(12%); transition: transform .4s ease; }
.sc-temizu .npc-in { transition: transform .4s ease; }
/* the omikuji corner: on the ground at the front left of the box's stand; aside and faded while the box is big */
.sc-omikuji { z-index: 3; left: calc(var(--u) * .04); bottom: calc(var(--u) * -.34); width: calc(var(--u) * .38); transition: opacity .35s ease, translate .45s cubic-bezier(.3, 1, .4, 1); }
.scene.focus .sc-omikuji { opacity: .5; translate: -18% 4%; }
/* a short screen has no grass in front of the box: the cat sits small at the stand's left corner */
@media (max-height: 700px) { .sc-omikuji { left: calc(var(--u) * -.08); bottom: 0; width: calc(var(--u) * .3); } }
/* while a step needs the thing it sits by, its body lets the tap through (the basin when the ladle goes back; the box while shaking) */
.view-temizu[data-state="putBack"] .sc-temizu .ct-svg *, .scene.focus .sc-omikuji .ct-svg * { pointer-events: none; }
/* the ema rack: under the table, its cheek against the left leg (units of the 400 × 520 drawing) */
.sc-ema { z-index: 1; left: calc(95 / 400 * 100%); top: calc((497 - 45.5) / 520 * 100%); width: calc(56 / 400 * 100%); }
/* the shrine office: a beckoning cat at the end of the goshuin counter by the coin tray (units of 750 × 560) */
.sc-goshuin { z-index: 1; left: calc((367 - 25) / 750 * 100%); top: calc((510 - 40.625) / 560 * 100%); width: calc(50 / 750 * 100%); }
/* a wide window shows the whole office and the visitor stands at its middle post: the cat sits at the far end of the counter, by the omamori window's tray */
.view-office.of-wide .sc-goshuin { left: calc((720 - 32) / 750 * 100%); top: calc((510 - 52) / 560 * 100%); width: calc(64 / 750 * 100%); }

@media (prefers-reduced-motion: reduce) {
  .cat, .cat *, .cat-leaf, .pk-cat { animation: none !important; transition: none !important; }
}
