/* ui/QuantaCounter — the Sprokets balance. Contract: ./QuantaCounter.spec.md */

.sp-quanta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sp-font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--sp-text);
  white-space: nowrap;
}
.sp-quanta[data-size="md"] .sp-quanta__value { font-size: 18px; }
.sp-quanta[data-size="sm"] { gap: 5px; }
.sp-quanta[data-size="sm"] .sp-quanta__value { font-size: 13px; }

.sp-quanta__glyph {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--sp-glyph, 16px);
  height: var(--sp-glyph, 16px);
  vertical-align: middle;
  transition: opacity var(--sp-dur) var(--sp-ease-out), filter var(--sp-dur) var(--sp-ease-out);
}
/* The sprocket: eight teeth around a ring with an open hub, one mask filled with the currency's
   colour, so the gain and spend states tint it and it stays one shape at any size. */
.sp-quanta__glyph::before {
  content: "";
  position: absolute;
  inset: -8%;
  background: var(--sp-quanta);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9.6' fill='none' stroke='black' stroke-width='4' stroke-dasharray='3.77 3.77' stroke-dashoffset='1.88'/%3E%3Cpath fill-rule='evenodd' d='M12 3.6a8.4 8.4 0 1 0 0 16.8a8.4 8.4 0 0 0 0-16.8zm0 5.3a3.1 3.1 0 1 1 0 6.2a3.1 3.1 0 0 1 0-6.2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9.6' fill='none' stroke='black' stroke-width='4' stroke-dasharray='3.77 3.77' stroke-dashoffset='1.88'/%3E%3Cpath fill-rule='evenodd' d='M12 3.6a8.4 8.4 0 1 0 0 16.8a8.4 8.4 0 0 0 0-16.8zm0 5.3a3.1 3.1 0 1 1 0 6.2a3.1 3.1 0 0 1 0-6.2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* The hub is the mask's hole: the core the rhombus held is not drawn. */
.sp-quanta__core { display: none; }

.sp-quanta[data-state="gain"] .sp-quanta__glyph {
  filter: drop-shadow(0 0 5px var(--sp-quanta)) drop-shadow(0 0 var(--sp-glow-sm) color-mix(in srgb, var(--sp-quanta) 60%, transparent));
}
.sp-quanta[data-state="gain"] .sp-quanta__value { text-shadow: 0 0 var(--sp-glow-sm) color-mix(in srgb, var(--sp-quanta) 55%, transparent); }
.sp-quanta[data-state="spend"] .sp-quanta__glyph { opacity: 0.5; }

.sp-quanta__delta {
  position: absolute;
  right: 0;
  bottom: 100%;
  font-size: 13px;
  color: var(--sp-quanta);
  text-shadow: 0 0 var(--sp-glow-sm) color-mix(in srgb, var(--sp-quanta) 60%, transparent);
  animation: sp-quanta-rise 900ms var(--sp-ease-out) both;
}
@keyframes sp-quanta-rise {
  from { transform: translateY(0); opacity: 0; }
  20% { opacity: 1; }
  to { transform: translateY(-12px); opacity: 0; }
}
@keyframes sp-quanta-fade {
  from { opacity: 0; }
  20% { opacity: 1; }
  to { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sp-quanta__delta { animation-name: sp-quanta-fade; }
}
