/*! Copyright (c) 2026 BamByte (bambyte.net). All rights reserved.
 * Proprietary code: no copying, redistribution, or use to train or prompt
 * AI / machine-learning systems without written permission from BamByte. */
/* ==========================================================================
   BamBot home-page entrance animation
   --------------------------------------------------------------------------
   Frame selection is done purely by background-position-x in JS, so it scales
   perfectly at any size.

   Strip: 17 frames, each 211 x 294, single horizontal row (3587 x 294).
   Strip frame order (index -> pose):
     0 side-peek A   1 side-peek B   2 side-peek C
     3 bottom-peek eyes   4 bottom-peek head   5 bottom-peek head+shoulders
     6 jump A   7 jump B   8 landing
     9 wave A   10 wave B
     11 stand A  12 stand B  13 stand C  14 stand D (idle)
     15 wave A (mouth open)   16 wave B (mouth open)   <- talking flap
   ========================================================================== */

.bambot-entrance {
  position: fixed;
  z-index: 500;                 /* above page content, below the header dropdown (10000+) */
  width: clamp(140px, 15vw, 215px);
  aspect-ratio: 211 / 294;      /* matches one strip cell */
  pointer-events: none;         /* never blocks clicks/links */
  opacity: 0;
  transition: opacity 200ms ease;
  will-change: transform, opacity;
  contain: layout style;        /* (not paint) so the drop-shadow isn't clipped */
}

.bambot-entrance.is-visible { opacity: 1; }

/* ---- Anchor A: peeking in from the LEFT edge, mid-height ---- */
.bambot-entrance.at-left {
  left: 0;
  right: auto;
  top: clamp(120px, 26vh, 300px);
  bottom: auto;
}

/* ---- Anchor B: BOTTOM-RIGHT corner (bottom peek, hop, final idle) ---- */
.bambot-entrance.at-corner {
  left: auto;
  right: clamp(8px, 3vw, 48px);
  top: auto;
  bottom: 0;                    /* container bottom == viewport bottom, so it can rise from below */
}

/* The sprite itself: one cell of the strip, chosen via background-position-x. */
.bambot-sprite {
  width: 100%;
  height: 100%;
  background-image: url('./assets/img/bambot_home_sprite.webp?v=4');
  background-repeat: no-repeat;
  background-size: 1700% 100%;  /* 17 frames wide */
  background-position: 0% 0%;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.35));
  will-change: background-position;
}

/* Gentle idle "breathing" once BamBot has settled into the folded-arms pose. */
.bambot-entrance.is-idle .bambot-sprite {
  animation: bambot-breathe 3.6s ease-in-out infinite;
}

@keyframes bambot-breathe {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50%      { transform: translateY(-3px) scaleY(1.012); }
}

/* ==========================================================================
   Speech bubble (appears near BamBot's head while he talks)
   Child of .bambot-entrance, so it tracks the mascot's corner automatically.
   Uses the horizontally-flipped bubble art so its tail points down-right,
   toward BamBot on the right edge.
   ========================================================================== */
.bambot-bubble {
  position: absolute;
  width: 182%;                 /* relative to the mascot box */
  aspect-ratio: 1150 / 900;
  right: 27%;                  /* tail (bottom-right of art) sits near his head */
  bottom: 78%;
  background: url('./assets/img/bot_bubble_r.webp') no-repeat center / 100% 100%;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.28));
  opacity: 0;
  transform: scale(0.6) translateY(8px);
  transform-origin: 90% 92%;   /* grow out of the tail */
  transition: opacity 180ms ease, transform 260ms cubic-bezier(.34, 1.56, .5, 1);
  pointer-events: none;
}

.bambot-bubble.show {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Text sits inside the flat cloud body, clear of the puffs and the tail. */
.bambot-bubble-text {
  position: absolute;
  inset: 19% 15% 33% 15%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #14233f;
  font: 800 clamp(12px, 1.15vw, 17px)/1.25 "Baloo 2", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  letter-spacing: .2px;
}

/* Blinking typing caret while the message types out. */
.bambot-bubble-text::after {
  content: "";
  display: inline-block;
  width: 0;
}
.bambot-bubble.typing .bambot-bubble-text::after {
  content: "▌";
  width: auto;
  margin-left: 1px;
  animation: bambot-caret 0.7s steps(1) infinite;
}
@keyframes bambot-caret { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* ---- Smaller screens ---- */
@media (max-width: 720px) {
  .bambot-entrance { width: clamp(96px, 30vw, 150px); }
  .bambot-entrance.at-left { top: 24vh; }
  .bambot-entrance.at-corner { right: 4px; }
  .bambot-bubble { width: 200%; right: 12%; bottom: 82%; }
  .bambot-bubble-text { font-size: clamp(10px, 3vw, 14px); }
}

/* BamBot is a signature decorative mascot the site owner always wants shown,
   so he intentionally plays his full animation regardless of the device's
   "reduce motion" setting -- there is deliberately no prefers-reduced-motion
   override here, and bambot-home.js ignores the preference too. */
