/* =========================================================================
   mascot.css - the CrawlMe crawler mascot ("Crawly"), shared by the public
   homepage (home.css, .hm-mascot--hero / --cta) and the customer dashboard
   (dashboard-mascot.css, .dm). Markup: includes/partials/home-mascot.php.

   Only the body, legs, face and the expression classes live here:
     default    open eyes that follow the pointer (--mx / --my on the wrapper)
     .is-happy  closed smiling eyes and a grin
     .is-wow    raised brows, small pupils, round mouth
     .is-boing  one bounce
     .is-pulled idle sway holds still while it is dragged
   Where it sits, how big it is and what it reacts to belong to the page's
   own stylesheet. Colors come from the --hm-m-* tokens the page defines on
   the mascot's ancestor, so a picked accent theme recolors it.
   ========================================================================= */
.hm-mascot {
    --mx: 0;
    --my: 0;
    pointer-events: none;
}

.hm-mascot__svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.hm-mascot__thread {
    stroke: rgba(255, 255, 255, 0.28);
    stroke-width: 1.5;
}

.hm-mascot__knot {
    fill: var(--hm-m-deep);
}

.hm-mascot__swing {
    transform-origin: 120px -520px;
    animation: hm-swing 5.2s ease-in-out infinite alternate;
}

@keyframes hm-swing {
    from { transform: rotate(-1.6deg); }
    to { transform: rotate(1.6deg); }
}

.hm-mascot__bob {
    animation: hm-bob 2.9s ease-in-out infinite alternate;
}

@keyframes hm-bob {
    from { transform: translateY(-3px); }
    to { transform: translateY(5px); }
}

.hm-mascot.is-boing .hm-mascot__bob {
    animation: hm-boing 720ms var(--hm-ease);
}

@keyframes hm-boing {
    0% { transform: translateY(0) scale(1, 1); }
    28% { transform: translateY(34px) scale(0.94, 1.07); }
    55% { transform: translateY(-14px) scale(1.04, 0.96); }
    78% { transform: translateY(6px) scale(0.99, 1.01); }
    100% { transform: translateY(0) scale(1, 1); }
}

.hm-mascot__leg {
    animation: hm-leg 1.7s ease-in-out infinite alternate;
}

/* A leg is a dark tube with a thin highlight along it and a foot at the end. */
.hm-mascot__leg-tube,
.hm-mascot__leg-hi {
    fill: none;
    stroke-linecap: round;
}

.hm-mascot__leg-tube {
    stroke: var(--hm-m-leg);
    stroke-width: 9.5;
}

.hm-mascot__leg-hi {
    stroke: rgba(255, 255, 255, 0.24);
    stroke-width: 2.2;
}

.hm-mascot__foot {
    fill: var(--hm-m-deep);
}

@keyframes hm-wave {
    0%, 100% { transform: rotate(0deg); }
    15%, 45%, 75% { transform: rotate(34deg); }
    30%, 60% { transform: rotate(12deg); }
}

.hm-mascot__leg--1 { animation-delay: -0.5s; }
.hm-mascot__leg--2 { animation-delay: -1s; }
.hm-mascot__leg--3 { animation-delay: -1.4s; }
.hm-mascot__leg--r { animation-duration: 1.9s; }

@keyframes hm-leg {
    from { transform: rotate(-5deg); }
    to { transform: rotate(6deg); }
}

/* The face and the highlight slide in opposite directions with the pointer: the ball seems to turn. */
.hm-mascot__face {
    transform: translate(calc(var(--mx) * 11px), calc(var(--my) * 8px));
    transition: transform 220ms var(--hm-ease);
}

.hm-mascot__pupils {
    transform: translate(calc(var(--mx) * 5px), calc(var(--my) * 5px));
    transition: transform 160ms var(--hm-ease);
}

.hm-mascot__shine {
    transform: translate(calc(var(--mx) * -7px), calc(var(--my) * -5px));
    transition: transform 260ms var(--hm-ease);
}

.hm-mascot__eyes {
    transform-box: fill-box;
    transform-origin: center;
    animation: hm-blink 4.6s infinite;
}

@keyframes hm-blink {
    0%, 93%, 100% { transform: scaleY(1); }
    96% { transform: scaleY(0.08); }
}

.hm-mascot__cheek {
    fill: #ffb4a8;
    opacity: 0.32;
}

.hm-mascot__mouth {
    fill: none;
    stroke: #0a0f0c;
    stroke-width: 4;
    stroke-linecap: round;
    opacity: 0.8;
}

.hm-mascot__belly {
    fill: var(--hm-m-light);
    opacity: 0.16;
}

.hm-mascot__iris {
    fill: var(--hm-m-deep);
}

.hm-mascot__pupil {
    transition: transform 180ms var(--hm-ease);
}

.hm-mascot__brows {
    transition: transform 220ms var(--hm-spring);
}

.hm-mascot__brows path {
    fill: none;
    stroke: var(--hm-m-deep);
    stroke-width: 4;
    stroke-linecap: round;
    opacity: 0.7;
}

/* ---- Faces. Default: open eyes. .is-happy: smiling eyes and a grin. .is-wow: round mouth. ---- */
.hm-mascot__eyes,
.hm-mascot__eyes-happy,
.hm-mascot__grin,
.hm-mascot__mouth,
.hm-mascot__mouth-o {
    transition: opacity 110ms linear;
}

.hm-mascot__eyes-happy,
.hm-mascot__grin,
.hm-mascot__mouth-o {
    opacity: 0;
}

.hm-mascot__eyes-happy path {
    fill: none;
    stroke: #06110b;
    stroke-width: 5.5;
    stroke-linecap: round;
}

.hm-mascot__mouth-o {
    fill: #06110b;
}

.hm-mascot.is-happy .hm-mascot__eyes,
.hm-mascot.is-happy .hm-mascot__mouth {
    opacity: 0;
}

.hm-mascot.is-happy .hm-mascot__eyes-happy,
.hm-mascot.is-happy .hm-mascot__grin {
    opacity: 1;
}

.hm-mascot.is-happy .hm-mascot__brows {
    transform: translateY(-3px);
}

/* Surprise wins over happy. */
.hm-mascot.is-wow .hm-mascot__eyes,
.hm-mascot.is-wow .hm-mascot__mouth-o {
    opacity: 1;
}

.hm-mascot.is-wow .hm-mascot__eyes-happy,
.hm-mascot.is-wow .hm-mascot__grin,
.hm-mascot.is-wow .hm-mascot__mouth {
    opacity: 0;
}

.hm-mascot.is-wow .hm-mascot__brows {
    transform: translateY(-8px);
}

.hm-mascot.is-wow .hm-mascot__pupil {
    transform: scale(0.68);
}

/* While it is pulled (home.js moves .hm-mascot__pull) the idle sway holds still. */
.hm-mascot.is-pulled .hm-mascot__swing,
.hm-mascot.is-pulled .hm-mascot__bob {
    animation-play-state: paused;
}
