/* Bubble Bond (js/arcade/bubble.js). Every class starts with .bb- */

/* --cell: one bubble's square. The pond is 5 bubbles across and 6.6 down; it shrinks to fit a short phone. */
.bb-wrap { --cell: min(calc((min(100vw, 720px) - 32px) / 5), calc((100svh - 318px) / 6.6), 112px); --slot: clamp(44px, 12.5vw, 62px); --ice: #17598A; display: grid; justify-items: center; gap: 8px; width: 100%; }
.bb-hud { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; font: 700 clamp(14px, 2.1vw, 17px) var(--font-ui); color: var(--muted); }
.bb-hud b { color: var(--ink); font-size: clamp(17px, 2.6vw, 21px); }

/* The card: the bond to make as an equation, and a tiny number line under it */
.bb-card { width: min(100%, calc(var(--cell) * 5)); background: var(--card); border-radius: 20px; box-shadow: var(--shadow-soft); padding: 8px 10px 0; display: grid; justify-items: center; }
.bb-eq { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: calc(var(--slot) + 6px); }
.bb-eq i { font: 900 26px/1 var(--font-ui); font-style: normal; color: var(--muted); }
.bb-eq i.ne { color: var(--danger); font-size: 30px; }
.bb-slot { width: var(--slot); height: var(--slot); border-radius: 50%; display: grid; place-items: center; font: 900 calc(var(--slot) * 0.44)/1 var(--font-ui); color: var(--ink); letter-spacing: -0.5px; }
button.bb-slot { border: 0; padding: 0; cursor: pointer; }
button.bb-slot:active { transform: scale(0.9); }
.bb-slot.empty { border: 3px dashed #C9C0E6; background: #FBF9FF; }
.bb-slot.warm { background: radial-gradient(circle at 34% 28%, #fff 0 9%, rgba(255, 255, 255, 0) 24%), radial-gradient(circle at 50% 60%, #FFE4F0, #FFBFDA); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85), 0 3px 0 #F4B3CE; animation: pop 0.3s; }
.bb-slot.ice { background: radial-gradient(circle at 34% 28%, #fff 0 9%, rgba(255, 255, 255, 0) 24%), radial-gradient(circle at 50% 60%, #E8F8FF, #A9DEFF); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9), 0 3px 0 #86C9F0; color: var(--ice); animation: pop 0.3s; }
.bb-target { min-width: calc(var(--slot) + 14px); height: calc(var(--slot) + 6px); padding: 0 10px; border-radius: 18px; display: grid; place-items: center; background: #FFF3C4; box-shadow: inset 0 0 0 3px #FFC93C, 0 4px 0 #F0B429; font: 900 calc(var(--slot) * 0.72)/1 var(--font-ui); color: var(--ink); letter-spacing: -1px; }
.bb-target.ice { background: #DDF3FF; box-shadow: inset 0 0 0 3px #7CCBF5, 0 4px 0 #5BB5E6; color: var(--ice); }
.bb-eq.bb-k3 { --slot: clamp(40px, 11vw, 54px); gap: 3px; }
.bb-eq.bb-k3 i { font-size: 22px; }
.bb-eq.right .bb-target { background: #CDF5D3; box-shadow: inset 0 0 0 3px var(--green), 0 4px 0 var(--green-d); animation: pop 0.4s; }
.bb-eq.wrong { animation: shake 0.4s; }
.bb-line { display: block; width: min(100%, 400px); height: auto; overflow: visible; }
.bb-line text { font: 800 12px var(--font-ui); fill: var(--muted); text-anchor: middle; }
.bb-line .bb-goal-n { fill: var(--ink); font-size: 13px; font-weight: 900; }
.bb-axis { stroke: #CFC6EA; stroke-width: 3; stroke-linecap: round; }
.bb-tick { stroke: #CFC6EA; stroke-width: 2; stroke-linecap: round; }
.bb-tick.zero { stroke: var(--muted); stroke-width: 2.5; }
.bb-goal { fill: #FFF3C4; stroke: #FFC93C; stroke-width: 3; }
.bb-hop { fill: none; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 5 4; }
.bb-hop.warm { stroke: #F27BAA; }
.bb-hop.ice { stroke: #3FA7E0; }
.bb-now rect { fill: var(--grape); stroke: #fff; stroke-width: 2; }
.bb-now text { fill: #fff; font-size: 13px; font-weight: 900; }
.bb-goal.hit { fill: var(--green); stroke: var(--green-d); animation: pop 0.4s; transform-box: fill-box; transform-origin: center; }
.bb-now.bad rect { fill: var(--danger); }

/* The bond meter: a little bubble for each bond to make */
.bb-meter { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; max-width: 100%; }
.bb-dot { width: clamp(15px, 2.3vw, 19px); height: clamp(15px, 2.3vw, 19px); border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #BFE3F7; transition: background 0.3s, box-shadow 0.3s, transform 0.3s; }
.bb-dot.on { background: radial-gradient(circle at 35% 30%, #fff 0 18%, rgba(255, 255, 255, 0) 34%), var(--sky); box-shadow: inset 0 0 0 2px var(--sky-d); animation: pop 0.4s; }

/* The pond */
.bb-pond { position: relative; width: calc(var(--cell) * 5); height: calc(var(--cell) * 6.6); border-radius: 24px; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  background-color: #EEF8FF;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px), radial-gradient(circle, rgba(255, 255, 255, 0.7) 0 3px, transparent 4px), linear-gradient(180deg, #E4F4FF 0%, #F1EEFF 55%, #E9F8F0 100%);
  background-size: 70px 90px, 110px 150px, 100% 100%; background-position: 10px 20px, 50px 70px, 0 0;
  box-shadow: inset 0 0 0 3px #C6E6F8, var(--shadow-soft); animation: bb-fizz 14s linear infinite; transition: box-shadow 0.3s; }
@keyframes bb-fizz { to { background-position: 10px -160px, 50px -230px, 0 0; } }
/* the surface: a scalloped white edge along the top */
.bb-pond::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 9px; background: radial-gradient(circle at 10px 0, rgba(255, 255, 255, 0.95) 0 8px, transparent 9px) repeat-x; background-size: 20px 9px; z-index: 1; pointer-events: none; }
/* nearly full: a rose glow rises from the bottom */
.bb-pond::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; background: linear-gradient(0deg, rgba(226, 80, 106, 0.28), rgba(226, 80, 106, 0) 45%); transition: opacity 0.4s; z-index: 0; }
.bb-pond.bb-danger { box-shadow: inset 0 0 0 3px #F39AAB, var(--shadow-soft); }
.bb-pond.bb-danger::after { opacity: 1; animation: bb-throb 1s ease-in-out infinite; }
@keyframes bb-throb { 50% { opacity: 0.45; } }
.bb-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.bb-links polyline { fill: none; stroke: #FFC93C; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 3px rgba(255, 201, 60, 0.8)); }

/* A bubble: the button holds its place (--x, --y in bubbles), the ball inside bobs, glows and bursts */
.bb-bub { position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); padding: 0; border: 0; background: none; border-radius: 50%; z-index: 2; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transform: translate(calc(var(--x) * var(--cell)), calc(var(--y) * var(--cell))); transition: transform 0.45s cubic-bezier(0.3, 1.35, 0.5, 1); }
.bb-bub.bb-rising { transition: transform 1.1s cubic-bezier(0.2, 0.8, 0.3, 1) var(--delay, 0ms); }
.bb-bub:focus-visible { outline: none; }
.bb-bub:focus-visible .bb-ball { outline: 3px solid var(--grape); outline-offset: 2px; }
.bb-ball { position: absolute; inset: 4%; border-radius: 50%; display: grid; place-items: center; --t1: #FFE6F1; --t2: #FFBCD8; --rim: rgba(242, 123, 170, 0.35);
  background: radial-gradient(circle at 32% 27%, #fff 0 8%, rgba(255, 255, 255, 0) 20%), radial-gradient(circle at 70% 76%, rgba(255, 255, 255, 0.7) 0 5%, rgba(255, 255, 255, 0) 12%), radial-gradient(circle at 50% 55%, var(--t1) 0 45%, var(--t2) 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85), inset 0 -5px 10px var(--rim), 0 4px 8px rgba(46, 42, 71, 0.1);
  animation: bb-bob 3.2s ease-in-out var(--d, 0s) infinite; transition: scale 0.18s, box-shadow 0.18s; }
.bb-ball b { font: 900 calc(var(--cell) * 0.4)/1 var(--font-ui); color: var(--ink); letter-spacing: -1px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); pointer-events: none; }
.bb-long .bb-ball b { font-size: calc(var(--cell) * 0.32); letter-spacing: -1.5px; }
@keyframes bb-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 calc(var(--cell) * -0.05); } }
.bb-t1 .bb-ball { --t1: #E3F8F2; --t2: #A8E6D6; --rim: rgba(19, 163, 145, 0.35); }
.bb-t2 .bb-ball { --t1: #FFF8D6; --t2: #FFE27A; --rim: rgba(224, 170, 26, 0.35); }
.bb-t3 .bb-ball { --t1: #F3EBFF; --t2: #D6C0FF; --rim: rgba(155, 93, 229, 0.3); }
.bb-zero .bb-ball { --t1: #FFFFFF; --t2: #E4DFF0; --rim: rgba(123, 118, 145, 0.25); }
/* icy bubbles are minus numbers: frosty blue, a snowflake, the minus sign in deep blue */
.bb-ice .bb-ball { --t1: #F0FAFF; --t2: #95D3FF; --rim: rgba(30, 120, 190, 0.35); box-shadow: inset 0 0 0 2.5px rgba(255, 255, 255, 0.95), inset 0 -5px 10px var(--rim), 0 0 0 2px #8FCDF4, 0 4px 8px rgba(46, 42, 71, 0.1); }
.bb-ice .bb-ball b { color: var(--ice); }
.bb-ice .bb-ball::after { content: '❄'; position: absolute; top: 4%; right: 12%; font-size: calc(var(--cell) * 0.2); line-height: 1; color: #fff; text-shadow: 0 0 3px rgba(30, 120, 190, 0.6); pointer-events: none; }
/* in the bond: bigger, with a gold glow */
.bb-on { z-index: 3; }
.bb-on .bb-ball { scale: 1.1; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 0 4px #FFC93C, 0 0 18px 5px rgba(255, 201, 60, 0.75); animation-play-state: paused; }
.bb-wobble .bb-ball { animation: bb-wobble 0.5s ease-in-out; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 0 4px #F39AAB; }
@keyframes bb-wobble { 20% { rotate: -14deg; translate: -5px 0; } 40% { rotate: 12deg; translate: 5px 0; } 60% { rotate: -8deg; translate: -3px 0; } 80% { rotate: 4deg; translate: 2px 0; } }
.bb-popping { z-index: 4; pointer-events: none; }
.bb-popping .bb-ball { animation: bb-burst 0.4s ease-out forwards; }
.bb-popping .bb-ball::before { content: ''; position: absolute; inset: -6%; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.95); animation: bb-ring 0.4s ease-out forwards; }
@keyframes bb-burst { 0% { scale: 1.1; opacity: 1; } 35% { scale: 1.32; opacity: 1; filter: brightness(1.15); } 100% { scale: 0.2; opacity: 0; } }
@keyframes bb-ring { from { scale: 1; opacity: 1; } to { scale: 1.9; opacity: 0; } }
.bb-magic .bb-ball { animation: bb-magic 0.7s ease-out; }
@keyframes bb-magic { 30% { scale: 1.2; filter: brightness(1.25) drop-shadow(0 0 8px #FFD54A); } }

/* Pops, points and words over the pond */
.bb-fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.bb-drop { position: absolute; left: 0; top: 0; width: calc(var(--cell) * 0.16); height: calc(var(--cell) * 0.16); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 25%, #FFB3D1 60%); transform: translate(calc(var(--x) * var(--cell)), calc(var(--y) * var(--cell))); animation: bb-drop 0.6s ease-out forwards; }
.bb-drop.ice { background: radial-gradient(circle at 35% 30%, #fff 0 25%, #7CCBF5 60%); }
@keyframes bb-drop { to { transform: translate(calc((var(--x) + var(--dx)) * var(--cell)), calc((var(--y) + var(--dy)) * var(--cell))) scale(0.3); opacity: 0; } }
.bb-float { position: absolute; left: calc(var(--x) * var(--cell)); top: calc(var(--y) * var(--cell)); transform: translate(-50%, -50%); font: 900 28px/1 var(--font-ui); color: var(--grape-d); -webkit-text-stroke: 4px #fff; paint-order: stroke fill; animation: bb-float 0.95s ease-out forwards; white-space: nowrap; }
@keyframes bb-float { 0% { opacity: 0; translate: 0 8px; scale: 0.5; } 25% { opacity: 1; scale: 1.2; } 100% { opacity: 0; translate: 0 -44px; scale: 1; } }
.bb-banner { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; background: radial-gradient(circle, rgba(255, 255, 255, 0.88) 0 34%, rgba(255, 255, 255, 0) 68%); animation: bb-banner 1.5s ease-out both; }
.bb-banner small { font: 800 17px var(--font-ui); color: var(--ink); }
.bb-banner b { font: 900 calc(var(--cell) * 1.15)/1 var(--font-ui); color: var(--grape-d); -webkit-text-stroke: 5px #fff; paint-order: stroke fill; }
.bb-banner.ice b { color: var(--ice); }
.bb-banner.win b, .bb-banner.full b { font-size: calc(var(--cell) * 0.75); }
.bb-banner.full b { color: var(--danger-d); }
.bb-banner.win, .bb-banner.full { animation-fill-mode: forwards; animation-name: bb-banner-stay; }
@keyframes bb-banner { 0% { opacity: 0; transform: scale(0.4) rotate(-8deg); } 20% { opacity: 1; transform: scale(1.12) rotate(2deg); } 35% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
@keyframes bb-banner-stay { 0% { opacity: 0; transform: scale(0.4) rotate(-8deg); } 30% { opacity: 1; transform: scale(1.12) rotate(2deg); } 50%, 100% { opacity: 1; transform: scale(1); } }
.bb-pond.bb-full .bb-bub { filter: saturate(0.6) brightness(0.97); }
.bb-pond.bb-won .bb-bub .bb-ball { animation: bb-cheer 0.6s ease-in-out infinite alternate; }
@keyframes bb-cheer { to { translate: 0 calc(var(--cell) * -0.12); scale: 1.06; } }

.bb-msg { min-height: 1.35em; margin: 0; padding: 0 8px; text-align: center; font: 800 clamp(17px, 2.5vw, 21px)/1.3 var(--font-ui); color: var(--grape-d); }

@media (prefers-reduced-motion: reduce) {
  .bb-pond, .bb-ball, .bb-pond.bb-danger::after, .bb-pond.bb-won .bb-bub .bb-ball { animation: none; }
  .bb-bub, .bb-bub.bb-rising { transition-duration: 0.15s; transition-delay: 0s; }
  .bb-popping .bb-ball, .bb-banner, .bb-float, .bb-wobble .bb-ball, .bb-magic .bb-ball { animation-duration: 0.2s; }
}
