/* Aurora MM2H – "Rimau" the Aurora Star tiger cub chat mascot (add-on to chat.css). States come from data-tiger on .aurora-chat. */

/* ---- Slots ------------------------------------------------------------------------------ */
.aurora-chat.rt-on [data-chat-open] { position: relative; padding-left: 5rem; overflow: visible; }
.rt-slot { display: inline-grid; place-items: center; flex: none; line-height: 0; }
.aurora-chat [data-chat-open] .rt-slot { position: absolute; left: -.55rem; bottom: -.4rem; width: 86px; height: 100px; filter: drop-shadow(0 4px 6px #15141240); }
.rt-title { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.rt-head { width: 58px; height: 68px; margin: -14px 0 -6px; padding: 0; border: 0; background: none; cursor: pointer; }
.rt { width: 100%; height: 100%; display: block; overflow: visible; }

/* ---- Parts & idle ------------------------------------------------------------------------ */
.rt .rt-body, .rt .rt-tilt { transform-box: view-box; }
.rt .rt-look { transform-box: fill-box; }
.rt .rt-body { animation: rtFloat 3.6s ease-in-out infinite; }
.rt .rt-tilt { transform-origin: 100px 190px; transition: transform .4s cubic-bezier(.3,1.6,.5,1); }
.rt .rt-look { transform: translate(calc(var(--lx, 0px) * 2.5), calc(var(--ly, 0px) * 2.5)); transition: transform .2s ease-out; }
.rt .rt-lid { transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); animation: rtBlink 5s infinite; }
.rt .rt-happy, .rt .rt-sweat, .rt .rt-heart, .rt .rt-dots circle { opacity: 0; transition: opacity .2s; }
.rt .rt-blush { opacity: 0; transition: opacity .3s; }
.rt .rt-ring { transition: opacity .3s; }
.rt .rt-spark path { opacity: 0; transform-box: fill-box; transform-origin: 50% 50%; animation: none 1.2s ease-in-out infinite both; }
.rt .rt-spark .sp2 { animation-delay: .35s; }
.rt .rt-spark .sp3 { animation-delay: .7s; }
.rt .rt-heart, .rt .rt-sweat { transform-box: fill-box; transform-origin: 50% 100%; }

/* Hover on the chat button: curious head tilt and twinkles */
.aurora-chat [data-chat-open]:hover .rt-tilt { transform: rotate(-7deg); }
.aurora-chat [data-chat-open]:hover .rt-spark path { animation-name: rtTwinkle; }

/* ---- hello: pops up out of the badge, winks and waves a paw ----------------------------- */
.aurora-chat[data-tiger=hello] .rt-body { animation: rtPeek 1.2s cubic-bezier(.3,1.5,.5,1); }
.aurora-chat[data-tiger=hello] .rt-lid-l { animation: rtWink 1.2s ease-in-out; }
.aurora-chat[data-tiger=hello] .rt-lid-r { animation: none; }
.aurora-chat[data-tiger=hello] .rt-spark path { animation-name: rtPop; }
.aurora-chat[data-tiger=hello] .rt-blush { opacity: .45; }

/* ---- listening: visitor is typing – leans in, ears perk up ------------------------------- */
.aurora-chat[data-tiger=listening] .rt-tilt { transform: rotate(-6deg); }
.aurora-chat[data-tiger=listening] .rt-ring { opacity: .9; }

/* ---- thinking: waiting for the answer – looks up, thought dots, glowing ring -------------- */
.aurora-chat[data-tiger=thinking] .rt-body { animation-duration: 1.8s; }
.aurora-chat[data-tiger=thinking] .rt-tilt { transform: rotate(5deg); }
.aurora-chat[data-tiger=thinking] .rt-look { transform: translate(9px, -12px); }
.aurora-chat[data-tiger=thinking] .rt-ring { animation: rtRing 1.1s ease-in-out infinite; }
.aurora-chat[data-tiger=thinking] .rt-dots circle { animation: rtDot 1.2s ease-in-out infinite; }
.aurora-chat[data-tiger=thinking] .rt-dots circle:nth-child(2) { animation-delay: .2s; }
.aurora-chat[data-tiger=thinking] .rt-dots circle:nth-child(3) { animation-delay: .4s; }

/* ---- replying: answer arrived – happy ^^ eyes, hops, golden glow ------------------------- */
.aurora-chat[data-tiger=replying] .rt-body { animation: rtHop .55s ease-out 2; }
.aurora-chat[data-tiger=replying] .rt-eye { opacity: 0; }
.aurora-chat[data-tiger=replying] .rt-happy { opacity: 1; }
.aurora-chat[data-tiger=replying] .rt-blush { opacity: .5; }
.aurora-chat[data-tiger=replying] .rt-halo { animation: rtHalo 1.1s ease-out; }
.aurora-chat[data-tiger=replying] .rt-spark path { animation-name: rtPop; }

/* ---- oops: handed over to the team – sinks a little, worried brows, sweat drop ----------- */
.aurora-chat[data-tiger=oops] .rt-body { animation: none; transform: translateY(14px); transition: transform .35s ease; }
.aurora-chat[data-tiger=oops] .rt-tilt { transform: rotate(7deg); }
.aurora-chat[data-tiger=oops] .rt-lid { animation: none; transform: scaleY(.35); }
.aurora-chat[data-tiger=oops] .rt-sweat { opacity: 1; animation: rtDrip 1.3s ease-in-out infinite alternate; }

/* ---- giggle: visitor taps the header tiger ------------------------------------------------ */
.aurora-chat[data-tiger=giggle] .rt-eye { opacity: 0; }
.aurora-chat[data-tiger=giggle] .rt-happy { opacity: 1; }
.aurora-chat[data-tiger=giggle] .rt-blush { opacity: .55; }
.aurora-chat[data-tiger=giggle] .rt-tilt { animation: rtGiggle .32s ease-in-out 4; }
.aurora-chat[data-tiger=giggle] .rt-heart { animation: rtHeart 1.3s ease-out forwards; }

/* ---- Unread answer while the chat is closed --------------------------------------------- */
.aurora-chat.rt-unread [data-chat-open]::after { content: ""; position: absolute; top: -4px; right: -4px; width: 14px; height: 14px; border-radius: 50%; background: #e0313c; border: 2px solid #fff; animation: rtPing 1.6s ease-out infinite; }
.aurora-chat.rt-unread [data-chat-open] .rt-body { animation: rtHop .8s ease-out infinite; }

/* ---- Greeting bubble -------------------------------------------------------------------- */
.rt-greet { position: absolute; right: 0; bottom: calc(100% + 36px); display: flex; align-items: flex-start; gap: .4rem; width: max-content; max-width: min(16rem, calc(100vw - 2rem)); padding: .7rem .6rem .7rem .9rem; border: 1px solid #d8c6aa; border-radius: 1rem 1rem .3rem 1rem; background: #fffdf8; color: #302621; font-size: .9rem; line-height: 1.4; box-shadow: 0 10px 30px #22191126; animation: rtBubble .45s cubic-bezier(.3,1.5,.5,1); }
.rt-greet[hidden] { display: none; }
.rt-greet span { cursor: pointer; }
.rt-greet button { flex: none; width: 1.5rem; height: 1.5rem; margin: -.2rem 0 0; border: 0; border-radius: 50%; background: #f4ead5; color: #302621; font-size: 1rem; line-height: 1; cursor: pointer; }
.rt-greet::after { content: ""; position: absolute; right: 1.6rem; bottom: -7px; width: 12px; height: 12px; background: #fffdf8; border-right: 1px solid #d8c6aa; border-bottom: 1px solid #d8c6aa; transform: rotate(45deg); }

/* ---- Mini tiger beside each answer + typing dots while waiting -------------------------- */
.aurora-chat.rt-on .aurora-chat-reply { position: relative; margin-left: 2.6rem; }
.aurora-chat.rt-on .aurora-chat-reply::before { content: ""; position: absolute; left: -2.7rem; bottom: -.1rem; width: 2.3rem; height: 2.7rem; background: var(--rt-mini) 50% 100% / contain no-repeat; }
.aurora-chat.rt-on .aurora-chat-reply.rt-typing::before { animation: rtMini .6s ease-in-out infinite alternate; }
.aurora-chat.rt-on .aurora-chat-reply.rt-typing::after { content: ""; display: inline-block; width: 22px; height: 8px; margin-left: 8px; vertical-align: middle; background: radial-gradient(circle, #c9962e 2.4px, transparent 2.9px) 0 50% / 7.33px 8px repeat-x; clip-path: inset(0 100% 0 0); animation: rtDots 1.2s steps(4, jump-none) infinite; }

/* ---- Keyframes (SVG units: the badge is 200 wide) ---------------------------------------- */
@keyframes rtFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes rtPeek { 0% { transform: translateY(0); } 35% { transform: translateY(-22px); } 65% { transform: translateY(-12px); } 100% { transform: translateY(0); } }
@keyframes rtHop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-16px); } }
@keyframes rtBlink { 0%, 92%, 100% { transform: scaleY(0); } 95% { transform: scaleY(1); } }
@keyframes rtWink { 0%, 100% { transform: scaleY(0); } 25%, 65% { transform: scaleY(1); } }
@keyframes rtRing { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes rtDot { 0%, 100% { opacity: .15; } 50% { opacity: 1; } }
@keyframes rtHalo { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rtTwinkle { 0%, 100% { opacity: 0; transform: scale(.2) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
@keyframes rtPop { 0% { opacity: 0; transform: scale(.2); } 40% { opacity: 1; transform: scale(1.25) rotate(30deg); } 100% { opacity: 0; transform: scale(.6) rotate(70deg); } }
@keyframes rtDrip { from { transform: translateY(-2px); } to { transform: translateY(8px); } }
@keyframes rtGiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes rtHeart { 0% { opacity: 0; transform: translateY(8px) scale(.4); } 25% { opacity: 1; transform: translateY(0) scale(1.1); } 100% { opacity: 0; transform: translateY(-28px) scale(.9); } }
@keyframes rtPing { 0% { box-shadow: 0 0 0 0 #e0313c99; } 100% { box-shadow: 0 0 0 9px #e0313c00; } }
@keyframes rtMini { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-3px) rotate(6deg); } }
@keyframes rtDots { to { clip-path: inset(0 0 0 0); } }
@keyframes rtBubble { from { opacity: 0; transform: translateY(8px) scale(.9); } to { opacity: 1; transform: none; } }

/* Phones: the chat button sits inside the bottom quick bar (gh-mobile-bar), after the round
   WhatsApp / WeChat / consultation icons (their count is --gh-bar-icons on <body>). */
@media (max-width: 760px) {
    .aurora-chat { z-index: 61; left: calc(18px + var(--gh-bar-icons, 3) * 54px); right: 18px; bottom: 18px; }
    .aurora-chat [data-chat-open] { width: 100%; height: 48px; min-height: 48px; padding: 0 .8rem; justify-content: center; border-color: var(--gh-gold); background: var(--gh-gold); color: var(--gh-onyx); font-size: 14px; line-height: 1.15; white-space: normal; text-align: center; box-shadow: none; }
    .aurora-chat [data-chat-open]:hover, .aurora-chat [data-chat-open]:focus-visible { background: #e9c264; color: var(--gh-onyx); }
    .aurora-chat.rt-on [data-chat-open] { padding-left: 4.2rem; }
    .aurora-chat [data-chat-open] .rt-slot { left: -.45rem; bottom: -.2rem; width: 70px; height: 82px; filter: drop-shadow(0 3px 5px #15141255); }
    .aurora-chat.rt-unread [data-chat-open]::after { border-color: var(--gh-onyx); }
    .rt-greet { bottom: calc(100% + 40px); }
}
/* Very small phones (≤359px): keep long labels (e.g. Bengali) inside the 48px button */
@media (max-width: 359px) {
    .aurora-chat [data-chat-open] { font-size: 12px; line-height: 1.1; padding-right: .5rem; }
    .aurora-chat.rt-on [data-chat-open] { padding-left: 3.8rem; }
    .aurora-chat [data-chat-open] .rt-slot { width: 62px; height: 73px; }
}

/* ---- Reduced motion: keep the expressions, drop the movement ----------------------------- */
@media (prefers-reduced-motion: reduce) {
    .rt *, .aurora-chat [data-chat-open]::after, .aurora-chat .aurora-chat-reply::before, .rt-greet { animation: none !important; transition: none !important; }
    .rt .rt-look { transform: none; }
    .aurora-chat[data-tiger=thinking] .rt-dots circle, .aurora-chat[data-tiger=thinking] .rt-ring { opacity: 1; }
    .aurora-chat.rt-on .aurora-chat-reply.rt-typing::after { animation: none; clip-path: none; }
}
