/* ============================================================================
   BUTTONS
   ============================================================================ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  border: var(--bw) solid transparent;
  font: var(--fw-semibold) 15px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 80ms ease-out, box-shadow 80ms ease-out, transform var(--spring-dur) var(--spring), border-color 80ms ease-out;
}

.button .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Heights: sm = 42 (desktop page-header), default = 44, lg = 48-50 (phone, full width) */
.button--sm {
  height: 42px;
  font-size: 14px;
}

.button--lg {
  height: 50px;
  width: 100%;
  padding: 0 20px;
}

@media (max-width: 46.1875rem) {
  .button--lg {
    height: 50px;
    font-size: 17px;
  }
}

/* Primary */
.button--primary {
  background: var(--ac);
  color: var(--ac-ink);
  border-color: var(--ac);
  box-shadow: var(--sh-1);
}

.button--primary:hover {
  background: color-mix(in oklch, var(--ac) 92%, black);
}

.button--primary:active {
  transform: scale(var(--press-scale));
  box-shadow: none;
}

/* Secondary */
.button--secondary {
  background: var(--sf2);
  color: var(--tx);
  border-color: var(--line);
  box-shadow: var(--sh-1);
}

[data-surface="tinted"] .button--secondary {
  background: var(--sf);
}

.button--secondary:hover {
  background: color-mix(in oklch, var(--sf2) 96%, black);
}

.button--secondary:active {
  transform: scale(var(--press-scale));
  box-shadow: none;
}

/* Text */
.button--text {
  height: 44px;
  padding: 0 4px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ac-text);
}

.button--text:hover {
  color: color-mix(in oklch, var(--ac-text) 85%, black);
}

.button--text.button--muted {
  color: var(--tx2);
}

.button--text.button--muted:hover {
  color: var(--tx);
}

/* Destructive text: same shape as Text, --dan colour, opposite side from Save */
.button--destructive-text {
  height: 44px;
  padding: 0 4px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--dan);
}

.button--destructive-text:hover {
  color: color-mix(in oklch, var(--dan) 85%, black);
}

/* Destructive: the confirm step's one button ("Delete this session"), a
   --dan-bg pill with a soft --dan edge, so it reads as a real action and
   still as the dangerous one */
.button--destructive {
  background: var(--dan-bg);
  color: var(--dan);
  border-color: var(--dan);
  box-shadow: var(--sh-1);
}

.button--destructive:hover {
  background: color-mix(in oklch, var(--dan-bg) 92%, var(--dan));
}

.button--destructive:active {
  transform: scale(var(--press-scale));
  box-shadow: none;
}

/* Press: shrink on pointer-down, fast, then spring back on release (the
   base transition above), so the button answers the finger before the click */
.button:active,
.icon-button:active {
  transition: var(--press), background-color 80ms ease-out, box-shadow 80ms ease-out;
}

.button--text:active,
.button--destructive-text:active {
  transform: scale(var(--press-scale));
  opacity: 0.7;
}

/* Disabled (any variant) */
.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading state: dim the label, spin the icon in its place */
.button.is-loading {
  cursor: progress;
  opacity: 0.85;
}

.button.is-loading .icon {
  animation: button-spin 0.8s linear infinite;
}

@keyframes button-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .button.is-loading .icon {
    animation: none;
  }
}

/* Icon button: circle */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  background: var(--sf);
  border: var(--bw) solid var(--line);
  box-shadow: var(--sh-1);
  color: var(--tx2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 80ms ease-out, box-shadow 80ms ease-out, transform var(--spring-dur) var(--spring);
}

.icon-button .icon {
  width: 18px;
  height: 18px;
}

.icon-button:hover {
  background: color-mix(in oklch, var(--sf) 94%, black);
  color: var(--tx);
}

.icon-button:active {
  transform: scale(var(--press-scale));
  box-shadow: none;
}

@media (max-width: 46.1875rem) {
  .icon-button {
    width: 44px;
    height: 44px;
  }

  .icon-button--lg {
    width: 48px;
    height: 48px;
  }
}

/* Primary icon: 46px circle, phone "Add player" FAB */
.icon-button--primary {
  width: 46px;
  height: 46px;
  background: var(--ac);
  border-color: var(--ac);
  box-shadow: var(--sh-1);
  color: var(--ac-ink);
}

.icon-button--primary:hover {
  background: color-mix(in oklch, var(--ac) 92%, black);
}

.icon-button--primary:active {
  transform: scale(var(--press-scale));
  box-shadow: none;
}

.icon-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Up-next card buttons use the --nx- token family instead of the accent tokens directly */
.button--up-next {
  background: var(--nx-btn);
  color: var(--nx-btn-tx);
  border-color: var(--nx-btn);
  box-shadow: var(--sh-1);
}

.button--up-next:hover {
  background: color-mix(in oklch, var(--nx-btn) 92%, black);
}

.button--up-next:active {
  transform: scale(var(--press-scale));
  box-shadow: none;
}

.button--up-next-ghost {
  background: var(--nx-ghost);
  color: var(--nx-tx);
  border-color: var(--nx-ghost-bd);
  box-shadow: var(--sh-1);
}

.button--up-next-ghost:hover {
  background: color-mix(in oklch, var(--nx-ghost) 96%, black);
}

.button--up-next-ghost:active {
  transform: scale(var(--press-scale));
  box-shadow: none;
}

.button:focus-visible,
.icon-button:focus-visible {
  outline: none;
  border-color: var(--ac);
  box-shadow: var(--focus-ring);
}

.button--primary:focus-visible,
.button--up-next:focus-visible,
.icon-button--primary:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Back: a chevron and the name of the screen it returns to, at the top left,
   as on iPhone. Desktop pages use a chevron icon button instead, as Mac
   toolbars do. */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: var(--tap-min);
  padding: 0 var(--sp-2);
  border-radius: var(--r-field);
  color: var(--ac-text);
  font: var(--fw-regular) 17px/1 var(--font);
  text-decoration: none;
  transition: opacity 120ms ease-out;
}

.back-link .icon {
  width: 22px;
  height: 22px;
  margin-left: -4px;
}

.back-link:active {
  opacity: 0.5;
}

.back-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
