/*
 * The website guide (the mascot). assets/techix/js/guide.js moves it (--x/--y), turns it (--face),
 * points its eyes (--look-x/--look-y) and switches the state classes below. Its chat is the website
 * assistant's panel (custom.css, .site-assistant).
 */

.site-guide {
    --x: 0px;
    --y: 0px;
    --face: 1;
    --look-x: 0;
    --look-y: 0;
    --guide-size: 112px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 990;
    width: var(--guide-size);
    height: calc(var(--guide-size) * 1.09);
    transform: translate3d(var(--x), var(--y), 0);
    pointer-events: none;
    opacity: 0;
    transition: opacity .4s ease;
}

.site-guide.is-size-small { --guide-size: 88px; }
.site-guide.is-size-large { --guide-size: 140px; }

.site-guide.is-ready { opacity: 1; }
.site-guide.is-moving { transition: opacity .4s ease, transform var(--travel, .6s) cubic-bezier(.45, .05, .35, 1); }

.site-guide-body {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    perspective: 520px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

.site-guide-body:focus-visible { outline: 3px solid #5dff8a; outline-offset: 4px; border-radius: 50%; }

/* Turning is a half turn in depth (not a flat flip), and the guide leans a little towards the mouse. */
.site-guide-turn {
    display: block;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform: rotateY(calc((1 - var(--face)) * 90deg + var(--look-x) * 14deg)) rotateX(calc(var(--look-y) * -8deg));
    transition: transform .45s cubic-bezier(.3, .1, .3, 1);
}
.site-guide-motion { width: 100%; height: 100%; transform-origin: 50% 70%; transform-style: preserve-3d; }

/* Its shadow on the floor: smaller when it bobs up, much smaller in the air. */
.site-guide-ground {
    position: absolute;
    bottom: 1%;
    left: 50%;
    width: 46%;
    height: 7%;
    margin-left: -23%;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
    filter: blur(1px);
    animation: guide-ground 2.2s ease-in-out infinite;
    pointer-events: none;
}

.site-guide.is-jumping .site-guide-ground { animation: guide-ground-jump .7s cubic-bezier(.3, .1, .3, 1); }
.site-guide.is-flipping .site-guide-ground { animation: guide-ground-jump .8s cubic-bezier(.3, .1, .3, 1); }
.site-guide.is-running .site-guide-ground { animation: guide-ground .32s ease-in-out infinite; }

.guide-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.guide-svg * { transform-box: fill-box; }

/* ------------------------------------------------------------- idle --- */

.guide-svg .g-figure { transform-origin: 50% 100%; animation: guide-bob 2.2s ease-in-out infinite; }
.guide-svg .g-aura { transform-origin: center; animation: guide-pulse 2.2s ease-in-out infinite; }
.guide-svg .g-fin { transform-origin: 50% 100%; animation: guide-sway 2.6s ease-in-out infinite; }
.guide-svg .g-fin-c { animation-delay: -.6s; }
.guide-svg .g-fin-r { animation-delay: -1.2s; }
.guide-svg .g-ear-l { transform-origin: 100% 50%; animation-duration: 3s; }
.guide-svg .g-ear-r { transform-origin: 0% 50%; animation-duration: 3.2s; animation-delay: -1s; }
.guide-svg .g-wing-l { transform-origin: 100% 40%; animation: guide-flap 1.8s ease-in-out infinite; }
.guide-svg .g-wing-r { transform-origin: 0% 40%; animation: guide-flap 1.8s ease-in-out infinite reverse; }
.guide-svg .g-tail { transform-origin: 0% 0%; animation: guide-sway 2s ease-in-out infinite; }
.guide-svg .g-eyes { transform-origin: center; animation: guide-blink 4.6s infinite; }
.guide-svg .g-pupil { transform: translate(calc(var(--look-x) * 3.5px), calc(var(--look-y) * 3px)); transition: transform .18s ease-out; }
.guide-svg .g-cube-1 { animation: guide-float 3.2s ease-in-out infinite; }
.guide-svg .g-cube-2 { animation: guide-float 2.6s ease-in-out infinite -1s; }
.guide-svg .g-cube-3 { animation: guide-float 3.6s ease-in-out infinite -2s; }
.guide-svg .g-cube { transform-origin: center; }
.guide-svg .g-spark { animation: guide-twinkle 1.8s ease-in-out infinite; }
.guide-svg .g-spark-2 { animation-delay: -.6s; }
.guide-svg .g-spark-3 { animation-delay: -1.2s; }
.guide-svg .g-arm-r { transform-origin: 0% 100%; }
.guide-svg .g-arm-l { transform-origin: 100% 0%; }
.guide-svg .g-leg { transform-origin: 50% 0%; }
.guide-svg .g-mouth { transform-origin: center; }
.guide-svg .g-mark { animation: guide-glow 2.4s ease-in-out infinite; }
/* The VE mark stays readable whichever way the guide faces. */
.site-guide .g-mark { transform: scaleX(var(--face)); transform-origin: center; }

/* ------------------------------------------------------------ moves --- */

.site-guide.is-waving .g-arm-r { animation: guide-wave .45s ease-in-out 4; }
.site-guide.is-running .g-figure { animation: guide-hop .32s ease-in-out infinite; }
.site-guide.is-running .site-guide-motion { transform: rotate(calc(var(--face) * 8deg)); }
.site-guide.is-running .g-leg-l { animation: guide-step .32s ease-in-out infinite; }
.site-guide.is-running .g-leg-r { animation: guide-step .32s ease-in-out infinite reverse; }
.site-guide.is-running .g-arm-l { animation: guide-swing .32s ease-in-out infinite; }
.site-guide.is-flipping .site-guide-motion { animation: guide-flip .8s cubic-bezier(.3, .1, .3, 1); }
.site-guide.is-jumping .site-guide-motion { animation: guide-jump .7s cubic-bezier(.3, .1, .3, 1); }
.site-guide.is-spinning .site-guide-motion { animation: guide-spin .9s ease-in-out; }
.site-guide.is-talking .g-mouth { animation: guide-talk .22s ease-in-out infinite; }
.site-guide.is-happy .g-cheek { opacity: .5; transition: opacity .3s; }

@keyframes guide-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes guide-pulse { 0%, 100% { opacity: .14; transform: scale(1); } 50% { opacity: .26; transform: scale(1.06); } }
@keyframes guide-sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(7deg); } }
@keyframes guide-flap { 0%, 100% { transform: rotate(0) scaleY(1); } 50% { transform: rotate(-10deg) scaleY(.92); } }
@keyframes guide-blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }
@keyframes guide-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-7px) rotate(12deg); } }
@keyframes guide-twinkle { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes guide-glow { 0%, 100% { opacity: .8; } 50% { opacity: 1; } }
@keyframes guide-wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-24deg); } }
@keyframes guide-hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes guide-step { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-5px) rotate(18deg); } }
@keyframes guide-swing { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(14deg); } }

@keyframes guide-flip {
    0% { transform: translateY(0) rotate(0) scale(1, 1); }
    18% { transform: translateY(6px) rotate(0) scale(1.08, .88); }
    55% { transform: translateY(-46px) rotate(calc(var(--face) * 200deg)) scale(.95, 1.05); }
    85% { transform: translateY(0) rotate(calc(var(--face) * 360deg)) scale(1.1, .9); }
    100% { transform: translateY(0) rotate(calc(var(--face) * 360deg)) scale(1, 1); }
}

@keyframes guide-jump {
    0%, 100% { transform: translateY(0) scale(1, 1); }
    20% { transform: translateY(4px) scale(1.1, .88); }
    50% { transform: translateY(-34px) scale(.94, 1.08); }
    80% { transform: translateY(0) scale(1.08, .92); }
}

/* A full turn in depth, twice. */
@keyframes guide-spin { 0% { transform: rotateY(0); } 100% { transform: rotateY(720deg); } }
@keyframes guide-ground { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.86); opacity: .75; } }
@keyframes guide-ground-jump { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.55); opacity: .35; } }
@keyframes guide-talk { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(2.2); } }

/* ----------------------------------------------------------- bubble --- */

.site-guide-bubble {
    position: absolute;
    bottom: calc(100% + 6px);
    inset-inline-start: 50%;
    width: max-content;
    max-width: 250px;
    padding: .7rem .85rem;
    border-radius: 16px;
    background: #fff;
    color: #171b24;
    font-size: .88rem;
    line-height: 1.6;
    box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .45), 0 0 0 1px rgba(61, 255, 143, .35);
    transform: translateX(-50%) translateY(6px) scale(.96);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

[dir="rtl"] .site-guide-bubble { transform: translateX(50%) translateY(6px) scale(.96); }

.site-guide-bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    inset-inline-start: 50%;
    margin-inline-start: -7px;
    border: 7px solid transparent;
    border-top-color: #fff;
}

.site-guide.is-telling .site-guide-bubble { opacity: 1; transform: translateX(calc(-50% + var(--bubble-shift, 0px))) translateY(0) scale(1); pointer-events: auto; }
[dir="rtl"] .site-guide.is-telling .site-guide-bubble { transform: translateX(calc(50% + var(--bubble-shift, 0px))) translateY(0) scale(1); }

/* Near the top of the screen the guide speaks downwards. */
.site-guide.is-speaking-down .site-guide-bubble { bottom: auto; top: calc(100% + 6px); }
.site-guide.is-speaking-down .site-guide-bubble::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: #fff; }

.site-guide-bubble button,
.site-guide-bubble a {
    display: inline-flex;
    margin-top: .45rem;
    padding: .25rem .7rem;
    border: 0;
    border-radius: 999px;
    background: #171b24;
    color: #5dff8a;
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.site-guide-bubble [hidden] { display: none; }

/* -------------------------------------------------------- the beam --- */

/*
 * While the guide runs, a beam of light stretches back from it to where it started (guide.js lays it from the
 * start point to the guide: --length and --angle), then fades away.
 */
.site-guide-trail {
    position: fixed;
    z-index: 989;
    height: 10px;
    margin-top: -5px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(28, 141, 255, 0) 0%, rgba(28, 141, 255, .35) 35%, rgba(61, 255, 143, .85) 85%, #d4ff7a 100%);
    box-shadow: 0 0 14px rgba(61, 255, 143, .65), 0 0 30px rgba(28, 141, 255, .35);
    transform-origin: 0 50%;
    transform: rotate(var(--angle)) scaleX(0);
    pointer-events: none;
    animation: guide-beam var(--travel, .6s) cubic-bezier(.45, .05, .35, 1) forwards, guide-beam-fade .55s ease-out calc(var(--travel, .6s) + .05s) forwards;
}

/* A brighter thin core inside the beam. */
.site-guide-trail::after {
    position: absolute;
    top: 50%;
    right: 0;
    left: 30%;
    height: 2px;
    margin-top: -1px;
    border-radius: 999px;
    content: "";
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .95));
}

@keyframes guide-beam { to { transform: rotate(var(--angle)) scaleX(1); } }
@keyframes guide-beam-fade { to { opacity: 0; transform: rotate(var(--angle)) scaleX(1) scaleY(.2); } }

@media (max-width: 575.98px) {
    .site-guide { --guide-size: 82px; }
    .site-guide.is-size-small { --guide-size: 66px; }
    .site-guide.is-size-large { --guide-size: 104px; }
}

@media (prefers-reduced-motion: reduce) {
    .site-guide *, .site-guide *::before, .site-guide *::after { animation: none !important; }
    .site-guide-trail { display: none; }
    .site-guide.is-moving { transition: opacity .4s ease; }
}
