/*
 * button.css - canonical AlaskaAutomations button
 *
 * Default: <button class="btn">Action</button>  (red, primary)
 * Secondary: <button class="btn btn--secondary">Action</button>  (grey, paired with primary)
 * Small: add btn--sm for compact size
 *
 * Loading state (animated spinner inside button):
 *   <button class="btn">
 *     <span class="btn-text">Submit</span>
 *     <span class="btn-spinner"></span>
 *   </button>
 *   Add `.loading` class via JS to swap text for spinner.
 *
 * Required CSS variables: --radius-sm
 */

.btn {
  display: inline-block;
  width: 100%;
  padding: 13px 24px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, rgba(220,20,50,0.78) 0%, rgba(180,14,38,0.68) 100%);
  backdrop-filter: blur(12px) saturate(220%);
  -webkit-backdrop-filter: blur(12px) saturate(220%);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow:
    0 8px 32px rgba(200,16,46,0.2),
    0 2px 8px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(255,255,255,0.05);
}

/* Top specular highlight */
.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  pointer-events: none;
  border-radius: var(--radius-sm, 8px) var(--radius-sm, 8px) 0 0;
}

/* Shine sweep on hover */
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 80%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transition: none;
  z-index: 2;
}

.btn:hover {
  background: linear-gradient(180deg, rgba(230,22,55,0.85) 0%, rgba(190,16,42,0.75) 100%);
  border-color: rgba(255,255,255,0.25);
  box-shadow:
    0 8px 40px rgba(200,16,46,0.3),
    0 4px 16px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.35),
    inset 0 -1px 0 rgba(255,255,255,0.08);
}

.btn:hover::after {
  animation: btn-shine 0.6s ease forwards;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover,
.btn[disabled]:hover {
  background: linear-gradient(180deg, rgba(220,20,50,0.78) 0%, rgba(180,14,38,0.68) 100%);
  box-shadow:
    0 8px 32px rgba(200,16,46,0.2),
    0 2px 8px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(255,255,255,0.05);
}

.btn:disabled:hover::after,
.btn[disabled]:hover::after {
  animation: none;
}

/* Loading state: hide text, show spinner */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading .btn-text { opacity: 0; }
.btn.loading .btn-spinner { display: block; }

@keyframes btn-shine {
  0%   { left: -100%; }
  100% { left: 200%; }
}

/* ── Variant: secondary (grey, used only when paired with primary) ── */
.btn--secondary {
  background: linear-gradient(180deg, rgba(60,60,68,0.78) 0%, rgba(40,40,46,0.68) 100%);
  border-color: rgba(255,255,255,0.12);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.3),
    0 2px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -1px 0 rgba(0,0,0,0.2);
}

.btn--secondary:hover {
  background: linear-gradient(180deg, rgba(70,70,80,0.85) 0%, rgba(50,50,58,0.75) 100%);
  border-color: rgba(255,255,255,0.2);
  box-shadow:
    0 8px 40px rgba(0,0,0,0.4),
    0 4px 16px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.22),
    inset 0 -1px 0 rgba(0,0,0,0.2);
}

.btn--secondary:disabled:hover,
.btn--secondary[disabled]:hover {
  background: linear-gradient(180deg, rgba(60,60,68,0.78) 0%, rgba(40,40,46,0.68) 100%);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.3),
    0 2px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -1px 0 rgba(0,0,0,0.2);
}

/* ── Variant: small (compact) ── */
.btn--sm {
  width: auto;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}

/* ── Loading spinner inside .btn ── */
.btn .btn-text {
  position: relative;
  z-index: 1;
}

.btn .btn-spinner {
  display: none;
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  z-index: 1;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
