/* ==========================================================================
   Motion extras (scripts/bc-motion-extra.js)
   Vote celebration, like pop, skeletons, toasts, badge pops, number ticks.
   Tokens come from styles/modern.css.
   ========================================================================== */

/* ---------- Toasts: slide + fade in, drawn check ---------- */
@keyframes bc-toast-in-top {
  from { opacity: 0; transform: translate(-50%, -14px) scale(0.96); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes bc-toast-in-bottom {
  from { opacity: 0; transform: translate(-50%, 14px) scale(0.96); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes bc-toast-shake {
  0%, 100% { transform: translate(-50%, 0); }
  20% { transform: translate(calc(-50% - 6px), 0); }
  40% { transform: translate(calc(-50% + 5px), 0); }
  60% { transform: translate(calc(-50% - 3px), 0); }
  80% { transform: translate(calc(-50% + 2px), 0); }
}
.toast.toast-tiny.toast-top.show {
  animation: bc-toast-in-top 0.45s var(--bc-ease, ease-out) both !important;
  box-shadow: 0 10px 28px -10px rgba(16, 16, 30, 0.35);
}
.toast.toast-tiny.toast-bottom.show {
  animation: bc-toast-in-bottom 0.45s var(--bc-ease, ease-out) both !important;
  box-shadow: 0 10px 28px -10px rgba(16, 16, 30, 0.35);
}
.toast.toast-tiny.toast-top.bg-red-dark.show,
.toast.toast-tiny.toast-bottom.bg-red-dark.show {
  animation-name: bc-toast-in-top, bc-toast-shake !important;
  animation-duration: 0.4s, 0.4s !important;
  animation-delay: 0s, 0.4s !important;
  animation-timing-function: var(--bc-ease, ease-out), ease-in-out !important;
  animation-fill-mode: both, none !important;
}

/* Check mark "draws" itself left to right */
@keyframes bc-check-draw {
  from { clip-path: inset(0 100% 0 0); opacity: 0.4; }
  to   { clip-path: inset(0 0 0 0); opacity: 1; }
}
.toast.show .fa-check {
  display: inline-block;
  animation: bc-check-draw 0.45s var(--bc-ease, ease-out) 0.18s both;
}

/* Custom toast used by the vote celebration */
.bc-mtoast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));   /* above the floating bottom menu */
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 11px 18px 11px 12px;
  border-radius: 999px;
  background: var(--bc-ink, #0b0b10);
  color: var(--bc-on-ink);
  font: 600 14px/1.3 var(--bc-font, system-ui, sans-serif);
  box-shadow: 0 18px 40px -14px rgba(16, 16, 30, 0.55);
  opacity: 0;
  transform: translate(-50%, 18px) scale(0.96);
  transition: opacity 0.35s var(--bc-ease, ease-out), transform 0.45s var(--bc-ease-spring, ease-out);
  pointer-events: none;
}
.bc-mtoast.is-in { opacity: 1; transform: translate(-50%, 0) scale(1); }
.bc-mtoast.is-out { opacity: 0; transform: translate(-50%, 10px) scale(0.98); transition-duration: 0.3s; }
.bc-mtoast-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-mtoast-check { flex: 0 0 22px; width: 22px; height: 22px; }
.bc-mtoast-check circle { fill: var(--bc-green, #16a34a); }
.bc-mtoast-check path {
  fill: none;
  stroke: #fff;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16;
  stroke-dashoffset: 16;
}
.bc-mtoast.is-in .bc-mtoast-check path { animation: bc-stroke-draw 0.45s var(--bc-ease, ease-out) 0.2s forwards; }
@keyframes bc-stroke-draw { to { stroke-dashoffset: 0; } }

/* ---------- Vote celebration ---------- */
.bc-burst-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  pointer-events: none;
}
@keyframes bc-vote-pop {
  0% { transform: scale(1); }
  30% { transform: scale(0.94); }
  65% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.bc-vote-pop { animation: bc-vote-pop 0.55s var(--bc-ease-spring, ease-out); }

@keyframes bc-vote-glow {
  0% { box-shadow: 0 0 0 0 rgba(91, 75, 209, 0); }
  30% { box-shadow: 0 0 0 6px rgba(91, 75, 209, 0.18), 0 12px 32px -12px rgba(91, 75, 209, 0.45); }
  100% { box-shadow: 0 0 0 0 rgba(91, 75, 209, 0); }
}
.bc-vote-glow { animation: bc-vote-glow 1.6s var(--bc-ease, ease-out); }

@keyframes bc-ring-bump {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.07); }
}
.bc-vring.bc-ring-bump { animation: bc-ring-bump 0.7s var(--bc-ease-spring, ease-out) 0.9s; }

.bc-points-num, .bc-counting { font-variant-numeric: tabular-nums; }
.bc-points-num { font-weight: 700; color: var(--bc-accent, #5b4bd1); }

/* ---------- Number ticks ---------- */
@keyframes bc-tick {
  0% { transform: translateY(55%); opacity: 0; }
  60% { transform: translateY(-8%); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}
.bc-tick { display: inline-block; animation: bc-tick 0.42s var(--bc-ease, ease-out); }
@keyframes bc-num-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.bc-num-pop { display: inline-block; animation: bc-num-pop 0.35s var(--bc-ease-spring, ease-out); }

/* ---------- Likes: spring pop ---------- */
@keyframes bc-like-pop {
  0% { transform: scale(1); }
  25% { transform: scale(0.8); }
  55% { transform: scale(1.35) rotate(-8deg); }
  75% { transform: scale(0.95) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}
.bc-like-pop {
  display: inline-block;
  animation: bc-like-pop 0.55s var(--bc-ease-spring, ease-out);
  filter: drop-shadow(0 3px 6px rgba(91, 75, 209, 0.25));
}
/* Keep the 180° rotation of the thumbs-down icon while it pops */
img.like-icon[style*="rotate(180deg)"].bc-like-pop { animation-name: bc-like-pop-flip; }
@keyframes bc-like-pop-flip {
  0% { transform: rotate(180deg) scale(1); }
  25% { transform: rotate(180deg) scale(0.8); }
  55% { transform: rotate(172deg) scale(1.35); }
  100% { transform: rotate(180deg) scale(1); }
}

/* ---------- Top bar badges ---------- */
@keyframes bc-badge-pop {
  0% { transform: scale(0.4); opacity: 0; }
  55% { transform: scale(1.25); opacity: 1; }
  80% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.header .header-icon .badge.bc-badge-pop,
.bc-badge-pop { animation: bc-badge-pop 0.55s var(--bc-ease-spring, ease-out) both; }

/* ---------- Skeletons ---------- */
.bc-skel { padding: 6px 2px; }
.bc-skel-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.bc-skel-lines { flex: 1; display: grid; gap: 8px; min-width: 0; }
.bc-skel-circle,
.bc-skel-line {
  display: block;
  background-color: var(--bc-surface-3, #eeeef2);
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.65) 50%, rgba(255, 255, 255, 0) 100%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: bc-shimmer 1.3s ease-in-out infinite;
}
.bc-skel-circle { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; }
.bc-skel-circle.is-lg { width: 96px; height: 96px; flex-basis: 96px; }
.bc-skel-line { height: 10px; border-radius: 6px; width: 72%; }
.bc-skel-line.is-short { width: 44%; }
.bc-skel-line.is-title { height: 14px; width: 55%; }
.bc-skel-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0 14px; }
.bc-skel-row + .bc-skel-row { border-top: 1px solid var(--bc-line, rgba(15, 15, 25, 0.07)); }
.bc-skel-row:nth-child(2) .bc-skel-line,
.bc-skel-row:nth-child(2) .bc-skel-circle { animation-delay: 0.08s; }
.bc-skel-row:nth-child(3) .bc-skel-line,
.bc-skel-row:nth-child(3) .bc-skel-circle { animation-delay: 0.16s; }
.bc-skel-row:nth-child(4) .bc-skel-line,
.bc-skel-row:nth-child(4) .bc-skel-circle { animation-delay: 0.24s; }
@keyframes bc-shimmer {
  from { background-position: 150% 0; }
  to   { background-position: -50% 0; }
}

@keyframes bc-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bc-fade-in { animation: bc-fade-in 0.35s var(--bc-ease, ease-out) both; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .toast.toast-tiny.toast-top.show,
  .toast.toast-tiny.toast-bottom.show,
  .toast.toast-tiny.bg-red-dark.show {
    animation: none !important;
    transform: translate(-50%, 0) !important;
  }
  .toast.show .fa-check,
  .bc-mtoast.is-in .bc-mtoast-check path { animation: none; stroke-dashoffset: 0; }
  .bc-mtoast, .bc-mtoast.is-in, .bc-mtoast.is-out { transform: translate(-50%, 0); transition: opacity 0.2s linear; }
  .bc-vote-pop, .bc-vote-glow, .bc-vring.bc-ring-bump, .bc-tick, .bc-num-pop,
  .bc-like-pop, img.like-icon[style*="rotate(180deg)"].bc-like-pop,
  .header .header-icon .badge.bc-badge-pop, .bc-badge-pop,
  .bc-fade-in { animation: none !important; }
  .bc-skel-circle, .bc-skel-line { animation: none; background-image: none; }
}
