/* AP String Beating Demo (frontend styles)
   Light, high-contrast theme that still inherits your site's accent color.
*/

.apb-widget {
  /* Always-light base (so it stays readable even on dark themes) */
  --apb-bg: #ffffff;
  --apb-surface: #f6f8fc;
  --apb-card: #ffffff;

  --apb-text: #0f172a;
  --apb-muted: rgba(15, 23, 42, 0.68);
  --apb-border: rgba(15, 23, 42, 0.14);

  /* Inherit the site's accent color where possible */
  --apb-accent: var(
    --wp--preset--color--primary,
    var(--global--color-primary, var(--ast-global-color-0, #1e73be))
  );
  --apb-accent-2: var(
    --wp--preset--color--secondary,
    var(--global--color-secondary, var(--ast-global-color-1, #0ea5e9))
  );

  --apb-radius: 18px;

  /* Visual vibration intensity (set by JS) */
  --apb-vib: 0;
  --apb-glow: 0px;

  color: var(--apb-text);
  width: 100%;
  /* Keep the widget from feeling too wide on large layouts */
  max-width: 880px;
  border: 1px solid var(--apb-border);
  border-radius: var(--apb-radius);
  padding: 20px;
  margin: 18px auto;
  box-shadow: 0 18px 54px rgba(15, 23, 42, 0.10);
  font-family: inherit;

  /* Soft highlight using accent (falls back harmlessly if color-mix isn't supported) */
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  background-image:
    radial-gradient(900px 420px at 12% 0%, color-mix(in srgb, var(--apb-accent), #ffffff 92%), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

/* Keyboard focus */
.apb-widget :is(button, input, label).apb-chip:focus-visible,
.apb-widget :is(button, input):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--apb-accent), #ffffff 55%);
  outline-offset: 2px;
}

.apb-header {
  /* Put description, then controls on their own lines */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 2px;
}

.apb-header-text {
  min-width: 0;
}

.apb-title {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.15;
  letter-spacing: -0.2px;
}

.apb-subtitle {
  margin: 8px 0 0;
  color: var(--apb-muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

.apb-master {
  /* Start / Stop / Volume all on their own line */
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.apb-start {
  grid-area: start;
}

.apb-stop {
  grid-area: stop;
}

.apb-btn {
  appearance: none;
  border: 1px solid var(--apb-border);
  background: var(--apb-card);
  color: var(--apb-text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.apb-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.apb-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
}

.apb-btn-primary {
  border-color: color-mix(in srgb, var(--apb-accent), #000000 12%);
  background: var(--apb-accent);
  color: #ffffff;
}

.apb-btn-ghost {
  background: transparent;
}

.apb-vol {
  display: grid;
  gap: 6px;
  align-items: center;
  color: var(--apb-muted);
  font-size: 0.85rem;
  margin-left: 4px;
}

.apb-volume {
  width: clamp(160px, 26vw, 240px);
}

/* Presets row */
.apb-presets {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 14px 0 16px;
  flex-wrap: wrap;
}

/* Put the overtone toggle on its own line (friendlier + keeps layout compact) */
.apb-toggle {
  margin-left: 0;
  flex-basis: 100%;
  width: fit-content;
}

.apb-chip {
  border: 1px solid var(--apb-border);
  background: var(--apb-card);
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  color: var(--apb-text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}

.apb-chip:hover {
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.10);
}

.apb-chip.is-active {
  background: color-mix(in srgb, var(--apb-accent), #ffffff 86%);
  border-color: color-mix(in srgb, var(--apb-accent), #000000 10%);
}

.apb-toggle {
  padding-left: 10px;
  padding-right: 14px;
}

.apb-toggle input {
  width: 18px;
  height: 18px;
}

.apb-toggle span {
  white-space: nowrap;
}

/* Strings row (always 3 strings side-by-side) */
.apb-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.apb-card {
  min-width: 0;
  background: var(--apb-card);
  border: 1px solid var(--apb-border);
  border-radius: 16px;
  padding: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 var(--apb-glow, 0px) color-mix(in srgb, var(--apb-accent), #ffffff 38%);
}

.apb-card-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 10px;
}

.apb-string-label {
  font-weight: 900;
  letter-spacing: 0.2px;
}

.apb-readout {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.apb-hz {
  font-weight: 900;
}

.apb-unit {
  color: var(--apb-muted);
  font-weight: 800;
  font-size: 0.85em;
  margin-left: 2px;
}

.apb-cents {
  color: var(--apb-muted);
  font-weight: 800;
}

.apb-slider-row {
  /* Stack controls so each card can be narrower while still readable */
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.apb-hz-input {
  width: 100%;
}

.apb-hz-input {
  border: 1px solid var(--apb-border);
  border-radius: 12px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--apb-text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Slider (detune) — styled like a “string” bar so the thumb sits on the bar */
.apb-slider-wrap {
  --apb-slider-h: 28px;
  --apb-thumb: 18px;

  position: relative;
  height: var(--apb-slider-h);
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--apb-accent), #ffffff 90%),
    color-mix(in srgb, var(--apb-accent-2), #ffffff 92%)
  );
  border: 1px solid var(--apb-border);
  box-shadow: 0 0 var(--apb-glow, 0px)
    color-mix(in srgb, var(--apb-accent), #ffffff 42%);
  overflow: hidden;
}

.apb-string-line {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  height: 2px;
  background: color-mix(in srgb, var(--apb-text), #ffffff 78%);
  transform: translateY(-50%);
  border-radius: 999px;
  opacity: 0.9;
  pointer-events: none;
  z-index: 1;
}

.apb-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  outline: none;
  appearance: none;
  cursor: pointer;
  z-index: 2;
}

/* Make the track transparent (we use the wrapper background) */
.apb-slider::-webkit-slider-runnable-track {
  height: var(--apb-slider-h);
  background: transparent;
  border-radius: 999px;
}

.apb-slider::-moz-range-track {
  height: var(--apb-slider-h);
  background: transparent;
  border-radius: 999px;
}

.apb-slider::-webkit-slider-thumb {
  appearance: none;
  width: var(--apb-thumb);
  height: var(--apb-thumb);
  border-radius: 999px;
  background: var(--apb-accent);
  border: 2px solid #ffffff;
  box-shadow: 0 10px 16px rgba(15, 23, 42, 0.18);
  cursor: pointer;
  margin-top: calc((var(--apb-slider-h) - var(--apb-thumb)) / 2);
}

.apb-slider::-moz-range-thumb {
  width: var(--apb-thumb);
  height: var(--apb-thumb);
  border-radius: 999px;
  background: var(--apb-accent);
  border: 2px solid #ffffff;
  box-shadow: 0 10px 16px rgba(15, 23, 42, 0.18);
  cursor: pointer;
}

/* Subtle shimmer that increases as beats get faster */
.apb-card::after {
  content: "";
  position: absolute;
  inset: -40% -55%;
  background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%);
  transform: translateX(calc(var(--apb-vib) * 14px)) rotate(12deg);
  transition: transform 120ms ease;
  pointer-events: none;
}

/* Help text */
.apb-help {
  margin-top: 10px;
  color: var(--apb-muted);
  font-size: 0.86rem;
}

/* Bottom beat-rate panel */
.apb-bottom {
  margin-top: 14px;
}

.apb-beats {
  background: var(--apb-surface);
  border: 1px solid var(--apb-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.apb-beat-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.apb-beatbox {
  min-width: 0;
  background: #ffffff;
  border: 1px solid var(--apb-border);
  border-radius: 14px;
  padding: 12px;
}

.apb-beat-label {
  color: var(--apb-muted);
  font-weight: 800;
  font-size: 0.9rem;
}

.apb-beat-number {
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.apb-beat-value {
  font-weight: 950;
  font-size: 1.4rem;
  letter-spacing: -0.2px;
}

.apb-note {
  color: var(--apb-muted);
  font-size: 0.9rem;
  margin-top: 10px;
  line-height: 1.45;
}

/* Playing state polish */
.apb-widget.is-playing {
  border-color: color-mix(in srgb, var(--apb-accent), #000000 10%);
}

/* NoScript */
.apb-noscript {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #fff4f4;
  border: 1px solid rgba(255, 0, 0, 0.25);
  color: #8a1f1f;
  font-weight: 800;
}

/* (No horizontal scrolling needed; layout responsively wraps/flows.) */
