/* Accessibility helper */
.asb-visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden; clip: rect(1px,1px,1px,1px);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/*
  Utility variables and theme helpers
  - Use per-instance inline vars (shortcode already emits `--asb-*` values).
  - You can apply these helper classes to buttons or parent containers.
*/

/* Sizes (convenience) */
.asb-size-small { --asb-size: 40px; }
.asb-size-medium { --asb-size: 56px; }
.asb-size-large { --asb-size: 72px; }

/* Theming helpers (container scope) */
.asb-theme-dark { --asb-primary: #ffffff; --asb-icon: #ffffff; --asb-bg: rgba(255,255,255,0.06); --asb-outline: rgba(255,255,255,0.12); }


/* Root button styles */
.asb-button {
  --asb-size: 48px;
  --asb-primary: currentColor; /* progress arc stroke default */
  --asb-icon: currentColor;    /* icon fill default */
  --asb-bg-outline-width: 0px;

  inline-size: var(--asb-size);
  block-size: var(--asb-size);
  border-radius: 999px;
  padding: 0;
  border: none;
  background: transparent !important;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .06s ease, color .2s ease;
  position: relative;
}

/* Prevent site-wide ::selection styles from tinting the button's inner circle */
.asb-button ::selection,
.asb-button *::selection,
.asb-button ::-moz-selection,
.asb-button *::-moz-selection {
  background: transparent !important;
  color: inherit !important;
}

/* Override generic theme button hover/focus/active rules */
.asb-button,
.asb-button:hover,
.asb-button:focus,
.asb-button:active,
.asb-button:focus-visible {
  background-color: transparent !important;
  background-image: none !important;
  color: transparent !important;
  box-shadow: none !important;
  border-color: transparent !important;
  -webkit-tap-highlight-color: transparent;
}

.asb-button:active { transform: translateY(0); }
.asb-button:focus-visible {
  outline: 3px solid var(--asb-outline, rgba(0,0,0,0.12));
  outline-offset: 2px;
}

/* Match the icon color with a solid border when the background is mostly transparent. */
.asb-button--icon-outline .asb-bg-circle {
  stroke: var(--asb-icon);
  stroke-opacity: 1;
}

/* Make focus more visible on dark backgrounds */
.asb-theme-dark .asb-button:focus-visible { outline-color: var(--asb-outline, rgba(255,255,255,0.16)); }


/* SVG container holds the entire SVG graphic */
.asb-svg-container {
  display: inline-grid;
  place-items: center;
  inline-size: 100%;
  block-size: 100%;
  position: relative;
  z-index: 1;
  min-width: 100%;
  min-height: 100%;
}

/* Alignment wrapper for the button */
.asb-align-left { text-align: left; }
.asb-align-center { text-align: center; }
.asb-align-right { text-align: right; }

.asb-bg-circle {
  transition: r 200ms cubic-bezier(.2,.9,.2,1);
  stroke: transparent;
  stroke-width: var(--asb-bg-outline-width, 0px);
  stroke-opacity: 0;
  vector-effect: non-scaling-stroke;
}

/* Icon elements (play, pause, error) within the circle; see .asb-icon-play/pause/error */

/* Start with play visible */
.asb-icon-play { display: block; }
.asb-icon-pause { display: none; }

/* State classes toggled by JS */
.asb-button.is-loading .asb-icon-play { display: none; }
.asb-button.is-loading .asb-icon-pause { display: none; }

/* Toggle icon visibility based on state */
.asb-button.is-playing .asb-icon-play { display: none; }
.asb-button.is-playing .asb-icon-pause { display: block; }

/* Progress ring positioned over the button border */
.asb-progress-val {
  fill: none;
  transform-origin: 50% 50%;
  transform-box: fill-box;
}

.asb-progress-val {
  /* Smooth the arc movement with a slightly longer eased transition */
  transition: stroke-dashoffset 260ms cubic-bezier(.22,.9,.3,1);
  will-change: stroke-dashoffset;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .asb-button,
  .asb-progress-val { transition: none !important; animation: none !important; }
}

/* Error visuals: red ring and X icon */
.asb-button.is-error .asb-progress-val { stroke: #ef4444 !important; stroke-opacity: 1 !important; }
.asb-icon-error { display: none; }
.asb-button.is-error .asb-icon-play { display: none; }
.asb-button.is-error .asb-icon-pause { display: none; }
.asb-button.is-error .asb-icon-error { display: block; }

/* Error state: visible red outline and icon to indicate load/play failure */
.asb-button.is-error {
  /* Make error more visible by overriding the color vars used for the ring and icon */
  --asb-primary: #ef4444;
  --asb-icon: #ef4444;
}
