/**
 * Button Components
 * Simple, clean buttons for CTAs and navigation
 */

/* ============================================
   BASE BUTTON
   ============================================ */

.button,
a.button,
button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  font-size: var(--type-ui-button);
  font-weight: var(--weight-semibold);
  line-height: var(--type-leading-body);
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  /* Increased from --radius-md (4px → 8px) */
  cursor: pointer;
  transition: color var(--motion-medium), background-color var(--motion-medium), border-color var(--motion-medium), box-shadow var(--motion-medium), transform var(--motion-medium);
  white-space: nowrap;
  /* Override content link styles - remove underline and padding-bottom */
  background-image: none;
}

.button.gradient-border {
  border: none;
  background: var(--color-bg-primary);
}

.button-primary {
  --button-primary-base: var(--color-primary);
  --button-primary-hover-fallback: var(--color-primary-hover);

  background: var(--button-primary-gradient, var(--button-primary-base));
  color: var(--color-text-inverse);
  /* Enable shine sweep effect */
  position: relative;
  overflow: hidden;
}

/* Shine sweep on hover for primary buttons */
.button-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.25) 50%,
    transparent 100%
  );
  transform: skewX(-20deg);
  transition: left 0.6s ease;
  pointer-events: none;
}

.button-primary:hover::before {
  left: 150%;
}

/* Modern color mixing for hover state */
@supports (color: color-mix(in srgb, white, black)) {
  .button-primary:hover {
    background: color-mix(in srgb, var(--button-primary-base) 90%, black);
    color: white;
  }
}

/* Fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, white, black)) {
  .button-primary:hover {
    background-color: var(--button-primary-hover-fallback);
    color: white;
  }
}

.button-primary.gradient-border::before {
  display: none;
  /* No border needed on filled button */
}

.button:hover {
  transform: translate3d(0, calc(-1 * var(--motion-distance-1)), 0);
  box-shadow: var(--elevation-medium);
}

/* Skeuomorphic pressed state - satisfying squeeze with haptic feel */
.button:active {
  transform: translate3d(0, 1px, 0) scale(0.94);
  box-shadow:
    inset 1px 1px 2px rgba(0, 0, 0, 0.2),
    inset -0.5px -0.5px 1px rgba(255, 255, 255, 0.1),
    0 1px 1px rgba(0, 0, 0, 0.1);
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}

/* Spring-back effect on release */
.button:not(:active) {
  transition: color var(--motion-medium),
              background-color var(--motion-medium),
              border-color var(--motion-medium),
              box-shadow var(--motion-medium),
              transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.button:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

/* Button text and icon alignment */
.button-text {
  display: inline-block;
}

.button-icon {
  display: inline-flex;
  font-size: 1.25em;
  line-height: 1;
}

/* ============================================
   BUTTON COLORS
   ============================================ */

/* Primary (CTA) */

/* Secondary */
.button-secondary {
  background-color: var(--gray-500);
  color: var(--color-text-inverse);
}

@supports (color: color-mix(in srgb, white, black)) {
  .button-secondary:hover {
    background-color: color-mix(in srgb, var(--gray-500) 90%, black);
    color: var(--color-text-inverse);
  }
}

@supports not (color: color-mix(in srgb, white, black)) {
  .button-secondary:hover {
    background-color: var(--gray-600);
    color: var(--color-text-inverse);
  }
}

/* Success */
.button-success {
  background-color: var(--color-success);
  color: var(--color-text-inverse);
}

@supports (color: color-mix(in srgb, white, black)) {
  .button-success:hover {
    background-color: color-mix(in srgb, var(--color-success) 90%, black);
    color: var(--color-text-inverse);
  }
}

@supports not (color: color-mix(in srgb, white, black)) {
  .button-success:hover {
    background-color: var(--green-700);
    color: var(--color-text-inverse);
  }
}

/* Danger */
.button-danger {
  background-color: var(--color-danger);
  color: var(--color-text-inverse);
}

@supports (color: color-mix(in srgb, white, black)) {
  .button-danger:hover {
    background-color: color-mix(in srgb, var(--color-danger) 90%, black);
    color: var(--color-text-inverse);
  }
}

@supports not (color: color-mix(in srgb, white, black)) {
  .button-danger:hover {
    background-color: var(--red-700);
    color: var(--color-text-inverse);
  }
}

/* Warning */
.button-warning {
  background-color: var(--color-warning);
  color: var(--gray-900);
}

.button-warning:hover {
  background-color: var(--orange-700);
  color: var(--gray-900);
}

/* Info */
.button-info {
  background-color: var(--color-info);
  color: var(--color-text-inverse);
}

.button-info:hover {
  background-color: var(--blue-700);
  color: var(--color-text-inverse);
}

/* Light */
.button-light {
  background: linear-gradient(180deg,
      var(--color-surface),
      var(--color-bg-secondary));
  color: var(--color-text-primary);
  border-color: var(--color-border);
  /* Neumorphic shadow - standardized */
  box-shadow: var(--neumorphic-base);
}

.button-light:hover {
  background: linear-gradient(180deg,
      var(--color-surface),
      var(--color-bg-hover));
  color: var(--color-text-primary);
  /* Neumorphic hover - standardized */
  box-shadow: var(--neumorphic-hover);
  transform: translate3d(0, calc(-1 * var(--motion-distance-1)), 0);
}

.button-light:active {
  background: linear-gradient(180deg,
      var(--color-bg-active),
      var(--color-bg-secondary));
  /* Neumorphic pressed - standardized */
  box-shadow: var(--neumorphic-pressed);
  transform: translate3d(0, 1px, 0) scale(0.98);
}

/* Dark */
.button-dark {
  background-color: var(--gray-800);
  color: var(--color-text-inverse);
}

.button-dark:hover {
  background-color: var(--gray-900);
  color: var(--color-text-inverse);
}

/* (removed glass treatment) */

/* ============================================
   BUTTON STYLES
   ============================================ */

/* Pill style (fully rounded) */
.button-pill {
  border-radius: var(--radius-full);
}

/* Outline style */
.button-outline {
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.95),
      rgba(250, 250, 250, 0.98));
  border-color: currentColor;
  border-width: 2px;
  /* Neumorphic shadow for outline buttons - standardized */
  box-shadow: var(--neumorphic-base);
}

.button-outline.button-primary {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.button-outline.button-primary:hover {
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.98),
      rgba(245, 245, 245, 0.95));
  /* Neumorphic hover - standardized */
  box-shadow: var(--neumorphic-hover);
  transform: translate3d(0, calc(-1 * var(--motion-distance-1)), 0);
}

.button-outline.button-primary:active {
  background: linear-gradient(180deg,
      rgba(238, 238, 238, 0.96),
      rgba(226, 226, 226, 0.93));
  /* Neumorphic pressed */
  box-shadow:
    inset 2px 2px 3px rgba(0, 0, 0, 0.18),
    inset -1px -1px 2px rgba(255, 255, 255, 0.25),
    0 1px 1px rgba(0, 0, 0, 0.05);
  transform: translate3d(0, 1px, 0) scale(0.98);
}

.button-outline.button-secondary {
  color: var(--gray-500);
  border-color: var(--gray-500);
}

.button-outline.button-secondary:hover {
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.98),
      rgba(245, 245, 245, 0.95));
  /* Neumorphic hover - standardized */
  box-shadow: var(--neumorphic-hover);
  transform: translate3d(0, calc(-1 * var(--motion-distance-1)), 0);
}

.button-outline.button-secondary:active {
  background: linear-gradient(180deg,
      rgba(238, 238, 238, 0.96),
      rgba(226, 226, 226, 0.93));
  box-shadow: var(--neumorphic-pressed);
  transform: translate3d(0, 1px, 0) scale(0.98);
}

.button-outline.button-success {
  color: var(--color-success);
  border-color: var(--color-success);
}

.button-outline.button-success:hover {
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.98),
      rgba(245, 245, 245, 0.95));
  /* Neumorphic hover - standardized */
  box-shadow: var(--neumorphic-hover);
  transform: translate3d(0, calc(-1 * var(--motion-distance-1)), 0);
}

.button-outline.button-success:active {
  background: linear-gradient(180deg,
      rgba(238, 238, 238, 0.96),
      rgba(226, 226, 226, 0.93));
  box-shadow: var(--neumorphic-pressed);
  transform: translate3d(0, 1px, 0) scale(0.98);
}

.button-outline.button-danger {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.button-outline.button-danger:hover {
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.98),
      rgba(245, 245, 245, 0.95));
  /* Neumorphic hover - standardized */
  box-shadow: var(--neumorphic-hover);
  transform: translate3d(0, calc(-1 * var(--motion-distance-1)), 0);
}

.button-outline.button-danger:active {
  background: linear-gradient(180deg,
      rgba(238, 238, 238, 0.96),
      rgba(226, 226, 226, 0.93));
  box-shadow: var(--neumorphic-pressed);
  transform: translate3d(0, 1px, 0) scale(0.98);
}

/* ============================================
   BUTTON SIZES
   ============================================ */

/* Small */
.button-sm {
  padding: 0.375rem 1rem;
  font-size: var(--type-ui-button);
}

/* Large */
.button-lg {
  padding: 0.875rem 2rem;
  font-size: var(--type-ui-button);
}

/* ============================================
   BUTTON GROUPS
   ============================================ */

.button-group {
  display: inline-flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Better touch interactions */
button,
.btn,
a.button {
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Ensure minimum touch targets on mobile for CTA/content buttons (WCAG 2.5.5) */
/* Uses .button/.btn classes (not bare <button>) because:
   - CTA/content buttons need 44px minimum for accessibility
   - Icon-only buttons (toggle, close, etc.) handle their own sizing via specific classes
   - Bare <button> elements in forms use browser defaults or form-specific styles */
@media (max-width: 768px) {

  .button,
  .btn,
  a.button {
    min-height: 44px;
    min-width: 44px;
  }
}

@media (max-width: 640px) {
  .button {
    width: 100%;
    justify-content: center;
  }

  .button-group {
    flex-direction: column;
    width: 100%;
  }

  .button-group .button {
    width: 100%;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .button,
  .button:active,
  .button:not(:active),
  .button-primary::before {
    animation: none !important;
    transition: color 0s, background-color 0s, border-color 0s !important;
    transform: none !important;
  }

  /* Still allow shine sweep on hover, just instant */
  .button-primary:hover::before {
    left: 150%;
    transition: none;
  }
}
