/* ============================================================
   17-history-ball.css — Number history bar, ball drop animation
   ============================================================ */

/* Number history bar (sticky, swipe sideways) */
:root { --hist-h: 54px; }

.hist-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 8px 0;
  padding: 6px 8px;
  min-height: var(--hist-h);
  box-sizing: border-box;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.25);
}

.hist-bar-btn {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 6px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.1;
}

.hb-ico { font-size: 14px; }

.hb-n { font-size: 11px; font-weight: 800; color: #f0c14b; }

.hist-bar .recent-calls {
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 14px 2px 0;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  mask-image: linear-gradient(90deg, #000 88%, transparent);
}

.hist-bar .recent-calls::-webkit-scrollbar { display: none; }

.hist-empty { font-size: 12px; color: var(--text-muted); padding-left: 2px; white-space: nowrap; }

.recent-ball {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: #fff;
  line-height: 1;
  border: 1.5px solid rgba(255,255,255,0.75);
  box-shadow: 0 2px 5px rgba(0,0,0,0.35), inset 0 -3px 5px rgba(0,0,0,0.28);
}

.recent-ball::after {
  content: '';
  position: absolute;
  top: 12%;
  left: 18%;
  width: 34%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 40% 40%, rgba(255,255,255,0.7), rgba(255,255,255,0));
  transform: rotate(-25deg);
}

.recent-ball i {
  font-style: normal;
  font-size: 9px;
  font-weight: 800;
  opacity: 0.9;
  letter-spacing: 0.4px;
}

.recent-ball b { font-size: 15px; font-weight: 900; }

.recent-ball.b { background: radial-gradient(circle at 35% 30%, #ff7a6b, var(--b-color) 55%, #8f1d12); }

.recent-ball.i { background: radial-gradient(circle at 35% 30%, #6aa8ff, var(--i-color) 55%, #0a2f78); }

.recent-ball.n { background: radial-gradient(circle at 35% 30%, #ffd86b, var(--n-color) 55%, #7a5409); }

.recent-ball.g { background: radial-gradient(circle at 35% 30%, #5fd17a, var(--g-color) 55%, #0c3a16); }

.recent-ball.o { background: radial-gradient(circle at 35% 30%, #b99bff, var(--o-color) 55%, #43208a); }

.recent-ball.new { animation: chipIn 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both; }

@keyframes chipIn {
  0% { transform: translateX(-26px) scale(0.2); opacity: 0; }
  70% { transform: translateX(2px) scale(1.15); opacity: 1; }
  100% { transform: none; }
}

/* make the sticky ball and board sit under the bar */
.ball-sticky { top: calc(var(--hist-h) + 4px); }

.left-sticky { top: calc(var(--hist-h) + 10px); }

/* Ball draw: drop, squash, bounce, shockwave + sparkles */
.current-ball::after {
  content: '';
  position: absolute;
  top: 9%;
  left: 15%;
  width: 38%;
  height: 25%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 40% 40%, rgba(255,255,255,0.75), rgba(255,255,255,0));
  transform: rotate(-25deg);
  pointer-events: none;
}

.current-ball.drop-anim { animation: ballDrop 0.95s cubic-bezier(0.3, 0.6, 0.3, 1) both; }

@keyframes ballDrop {
  0% { transform: translateY(-86px) rotate(-260deg) scale(0.55); opacity: 0; }
  12% { opacity: 1; }
  42% { transform: translateY(0) rotate(0) scale(1.14, 0.84); }
  56% { transform: translateY(-16px) rotate(8deg) scale(0.95, 1.08); }
  72% { transform: translateY(0) rotate(-3deg) scale(1.06, 0.95); }
  86% { transform: translateY(-4px) rotate(0) scale(1); }
  100% { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
}

#ball-ring[data-l="b"]::before { background: conic-gradient(var(--b-color), #fff6, var(--b-color)); }

#ball-ring[data-l="i"]::before { background: conic-gradient(var(--i-color), #fff6, var(--i-color)); }

#ball-ring[data-l="n"]::before { background: conic-gradient(var(--n-color), #fff6, var(--n-color)); }

#ball-ring[data-l="g"]::before { background: conic-gradient(var(--g-color), #fff6, var(--g-color)); }

#ball-ring[data-l="o"]::before { background: conic-gradient(var(--o-color), #fff6, var(--o-color)); }

.current-ball-ring.burst::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 3px solid var(--sc, #fff);
  pointer-events: none;
  z-index: 3;
  animation: ringShock 0.8s ease-out 0.38s both;
}

@keyframes ringShock {
  0% { transform: scale(0.9); opacity: 0.95; }
  100% { transform: scale(1.75); opacity: 0; }
}

.spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--sc, #fff);
  box-shadow: 0 0 8px var(--sc, #fff);
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  animation: sparkOut 0.75s ease-out both;
}

@keyframes sparkOut {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}


@media (prefers-reduced-motion: reduce) {
  .current-ball.drop-anim,
  .recent-ball.new,
  .current-ball-ring.burst::after {
    animation: none;
  }
}

@media (max-height: 720px) {
  :root { --hist-h: 48px; }
  .recent-ball { width: 34px; height: 34px; }
  .recent-ball b { font-size: 13px; }
}
