/* Robot idle animations (the robot appears on many screens; this file is loaded globally) + the shop screen. */

/* ---------- robot (B.avatar.svg adds .bp-anim for sizes >= 90 px) ---------- */
.bot { overflow: visible; }
.bp-anim .bp-eyes { transform-origin: 100px 76px; animation: bp-blink 5.2s var(--bp-d, 0s) infinite; }
.bp-anim.bp-think .bp-eyes { transform-origin: 100px 73px; }
.bp-anim .bp-ant { transform-origin: 100px 40px; animation: bp-sway 3.2s ease-in-out infinite alternate; }
.bp-anim .bp-wave { transform-origin: 132px 132px; animation: bp-wave .9s ease-in-out infinite alternate; }
.bp-anim .bp-q { animation: bp-bob 1.4s ease-in-out infinite alternate; }
.bp-anim .bp-spark { animation: bp-twinkle 1s ease-in-out infinite alternate; }
.bp-anim .bp-pet { animation: bp-bob 1.7s ease-in-out infinite alternate; }
.bp-anim .bp-prop { transform-origin: 100px 0; animation: bp-spin .6s linear infinite; }
@keyframes bp-blink { 0%, 93%, 100% { transform: none; } 96% { transform: scaleY(.1); } }
@keyframes bp-sway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes bp-wave { from { transform: rotate(-8deg); } to { transform: rotate(12deg); } }
@keyframes bp-bob { from { transform: none; } to { transform: translateY(-3px); } }
@keyframes bp-twinkle { from { opacity: .35; } to { opacity: 1; } }
@keyframes bp-spin { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(-1); } }
@media (prefers-reduced-motion: reduce) { .bp-anim * { animation: none !important; } }

/* ---------- shop layout ---------- */
.shop { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px 30px; display: grid; grid-template-columns: 320px 1fr; gap: 22px; align-items: start; }
.shop-side { position: sticky; top: 12px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.shop-stage {
  width: 100%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 20px;
  background: radial-gradient(circle at 50% 42%, #FFFFFF 0%, #EEF5FF 72%); box-shadow: inset 0 0 0 2px var(--line);
}
.shop-stage svg { width: 94%; height: auto; display: block; }
.shop-stage:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
.shop-note { min-height: 48px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 800; color: var(--ink2); font-size: 17px; }
.shop-trying { background: #FFF6D6; color: var(--ink); border-radius: 999px; padding: 8px 16px; }
.shop-alloff { min-height: 48px; font-size: 16px; padding: 10px 20px; }
.shop-main { min-width: 0; }

.shop-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 7px; margin-bottom: 16px; }
.shop-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 64px;
  padding: 7px 3px; overflow-wrap: normal; word-break: normal; hyphens: auto; border-radius: 16px; background: #fff; box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px var(--line);
  font-weight: 800; font-size: 14px; line-height: 1.1; transition: transform .08s;
}
.shop-tab .ic { font-size: 25px; line-height: 1; }
.shop-tab:active { transform: translateY(2px); }
.shop-tab.on { background: var(--blue); color: #fff; box-shadow: 0 4px 0 var(--blue-d); }
.shop-tab:focus-visible, .shop-card .btn:focus-visible, .shop-card .pv:focus-visible, .swatch:focus-visible { outline: 4px solid var(--ink); outline-offset: 2px; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 14px; }
.shop-card {
  position: relative; padding: 10px 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; cursor: pointer; transition: transform .12s, box-shadow .15s;
}
.shop-card:hover { transform: translateY(-3px); }
.shop-card .pv { width: 100%; aspect-ratio: 1; padding: 0; display: grid; place-items: center; background: #F4F7FC; border-radius: 16px; overflow: hidden; }
.shop-card .pv svg { width: 90%; height: auto; display: block; }
.shop-card b { font-size: 16px; line-height: 1.2; min-height: 2.4em; display: flex; align-items: center; justify-content: center; }
.shop-card .btn { width: 100%; min-height: 48px; padding: 8px 12px; font-size: 18px; }
.shop-card .btn .coin-ic { width: 22px; height: 22px; flex: none; }
.shop-card .btn .coin-ic::after { font-size: 12px; }
.shop-card.worn { box-shadow: 0 0 0 4px var(--green), var(--sh); }
.shop-card.trying { box-shadow: 0 0 0 4px var(--yellow), var(--sh); }
.shop-card.dear .btn.price { color: var(--ink2); }
.shop-tag {
  position: absolute; top: 6px; right: 6px; z-index: 1; min-width: 30px; height: 30px; padding: 0 10px; border-radius: 999px;
  display: grid; place-items: center; font-size: 13px; font-weight: 900; background: #fff; color: var(--green-d); box-shadow: inset 0 0 0 2px #BFF3E3;
}
.shop-tag.on { background: var(--green); color: #fff; box-shadow: none; font-size: 17px; padding: 0; }

.shop-colors { padding: 14px 18px 18px; margin-bottom: 18px; }
.shop-colors .color-row { gap: 12px; }
.shop-colors .swatch { width: 48px; height: 48px; }
.shop-sub { font-weight: 900; font-size: 18px; color: var(--ink2); margin: 0 0 12px; }
.shop-sub.big { font-size: 22px; color: var(--ink); }

/* progress bar (not enough coins, badge progress) */
.shop-bar { height: 14px; background: #EEF2F8; border-radius: 999px; overflow: hidden; box-shadow: inset 0 0 0 2px var(--line); }
.shop-bar i { display: block; height: 100%; background: linear-gradient(90deg, #FFD93D, #FFC300); border-radius: 999px; min-width: 6px; }
.shop-bar-lbl { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--ink2); margin-top: 6px; font-size: 16px; }
.shop-bar-lbl .coin-ic { width: 20px; height: 20px; }
.shop-bar-lbl .coin-ic::after { font-size: 11px; }

/* dialogs */
.shop-dlg { display: flex; align-items: center; gap: 18px; }
.shop-dlg svg { display: block; }
.shop-dlg-txt { flex: 1; min-width: 0; }

/* badges */
.shop-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.shop-badge { padding: 14px 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.shop-badge-ic { font-size: 44px; line-height: 1.1; width: 70px; height: 70px; display: grid; place-items: center; border-radius: 50%; background: #FFF6D6; margin-bottom: 4px; }
.shop-badge b { font-size: 16px; line-height: 1.2; }
.shop-badge small { color: var(--ink2); font-weight: 700; font-size: 14px; line-height: 1.25; }
.shop-badge.got { box-shadow: 0 0 0 3px #FFE08A, var(--sh); }
.shop-badge.locked { background: #F7F9FC; box-shadow: inset 0 0 0 2px var(--line); }
.shop-badge.locked .shop-badge-ic { filter: grayscale(1); opacity: .45; background: #EDF1F7; }
.shop-badge.locked b { color: var(--ink2); }
.shop-badge-prog { width: 100%; margin-top: 6px; }
.shop-badge-prog small { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }

@media (max-width: 1100px) {
  .shop { grid-template-columns: 280px 1fr; gap: 18px; padding: 0 18px 24px; }
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .shop-tab { font-size: 13px; }
}
/* small windows (800×600): keep the robot beside the items (sticky) so a try-on is always visible */
@media (max-width: 860px) {
  .shop { grid-template-columns: 200px 1fr; gap: 12px; padding: 0 12px 20px; }
  .shop-side { padding: 10px; gap: 8px; }
  .shop-note { min-height: 40px; font-size: 15px; }
  .shop-tabs { grid-auto-flow: row; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (max-width: 600px) {
  .shop { grid-template-columns: 1fr; }
  .shop-side { position: static; flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .shop-stage { width: 170px; }
  .shop-note { flex: 1; min-width: 160px; }
  .shop-dlg { flex-direction: column; text-align: center; }
}
@media (max-width: 560px) {
  .shop-tabs { display: flex; flex-wrap: wrap; }
  .shop-tab { flex: 1 0 64px; }
}
/* phones (both orientations): no text under 14px */
@media (max-width: 700px), (max-height: 500px) and (min-width: 560px) {
  .shop-tab, .shop-tag, .shop-badge small, .shop-badge-prog small { font-size: 14px; }
}

/* Bipo's reactions to what he wears (shop.js reactTo): a speech bubble and a motion of the whole robot */
.shop-stage-wrap { position: relative; width: 100%; display: flex; justify-content: center; }
.shop-quip { position: absolute; left: 50%; top: -6px; z-index: 3; max-width: 92%; padding: 8px 14px; border-radius: 16px; background: #fff; color: var(--ink);
  font-weight: 900; font-size: 17px; line-height: 1.2; text-align: center; box-shadow: 0 6px 18px rgba(45, 49, 66, .18), inset 0 0 0 2px var(--line);
  transform: translate(-50%, -8px) scale(.6); opacity: 0; pointer-events: none; transition: transform .25s cubic-bezier(.2, 1.6, .4, 1), opacity .2s; }
.shop-quip::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: #fff; }
.shop-quip.in { transform: translate(-50%, -18px) scale(1); opacity: 1; }
.shop-stage.rx-fly svg { animation: rxFly 2.4s ease-in-out; }
.shop-stage.rx-magic, .shop-stage.rx-fly { position: relative; }
.shop-stage.rx-magic::before, .shop-stage.rx-magic::after { content: '✨'; position: absolute; font-size: 34px; pointer-events: none; animation: rxSpark 1.4s ease-out 2 both; }
.shop-stage.rx-magic::before { left: 12%; top: 14%; }
.shop-stage.rx-magic::after { right: 10%; top: 6%; animation-delay: .35s; }
.shop-stage.rx-magic svg { animation: rxGlow 2.2s ease-in-out; }
.shop-stage.rx-shy svg { animation: rxShy 1.6s ease-in-out; }
.shop-stage.rx-think svg { animation: rxThink 2s ease-in-out; }
.shop-stage.rx-spin svg { animation: rxSpin 1s cubic-bezier(.3, .1, .3, 1.3); }
.shop-stage.rx-dance svg { animation: rxDance .5s ease-in-out 4; }
.shop-stage.rx-hop svg { animation: rxHop .45s ease-out 2; }
.shop-stage.rx-wobble svg { animation: rxWobble .9s ease-in-out 2; }
@keyframes rxFly { 0% { transform: none; } 30%, 75% { transform: translateY(-26px); } 45% { transform: translateY(-20px); } 60% { transform: translateY(-28px); } 100% { transform: none; } }
@keyframes rxSpark { 0% { transform: scale(0) rotate(0); opacity: 0; } 40% { transform: scale(1.2) rotate(40deg); opacity: 1; } 100% { transform: scale(.4) translateY(-30px) rotate(90deg); opacity: 0; } }
@keyframes rxGlow { 0%, 100% { filter: none; } 40%, 70% { filter: drop-shadow(0 0 14px #FFD93D) drop-shadow(0 0 26px #B48CFF); } }
@keyframes rxShy { 0%, 100% { transform: none; } 20% { transform: rotate(-6deg) scale(1.03); } 45% { transform: rotate(5deg); } 70% { transform: rotate(-3deg); } }
@keyframes rxThink { 0%, 100% { transform: none; } 25%, 75% { transform: rotate(-8deg) translateX(-4px); } }
@keyframes rxSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes rxDance { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg) translateY(-6px); } 75% { transform: rotate(8deg) translateY(-6px); } }
@keyframes rxHop { 0%, 100% { transform: none; } 40% { transform: translateY(-18px) scale(1.03, .97); } }
@keyframes rxWobble { 0%, 100% { transform: none; } 25% { transform: scale(1.06, .94); } 50% { transform: scale(.95, 1.05); } 75% { transform: scale(1.03, .97); } }
@media (prefers-reduced-motion: reduce) { .shop-stage[class*='rx-'] svg, .shop-stage.rx-magic::before, .shop-stage.rx-magic::after { animation: none; } }
