/**
 * interactions.css — JavaScript-driven UI states and components
 *
 * This file contains styles for elements created or managed by JS:
 *   - Processing payment overlay
 *   - Progress indicator (injected by ui.js)
 *   - Password visibility toggle
 *   - Express CTA button
 *   - Payment button selected state
 *   - Form input shake animation
 *   - Card form hidden-by-express state
 *   - Step transition animations
 */

/* ==========================================================================
   PROCESSING OVERLAY
   ========================================================================== */

#payment-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#payment-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

.payment-overlay__card {
  background: #ffffff;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  max-width: 320px;
  width: 90%;
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#payment-overlay.is-visible .payment-overlay__card {
  transform: scale(1);
}

.payment-overlay__spinner {
  width: 52px;
  height: 52px;
  margin: 0 auto 20px;
  color: #fbbf24;
  animation: spin 0.9s linear infinite;
}

.payment-overlay__spinner svg {
  width: 100%;
  height: 100%;
}

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

.payment-overlay__title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 6px;
}

.payment-overlay__subtitle {
  font-size: 14px;
  color: #64748b;
  margin: 0;
}

/* ==========================================================================
   SIGNUP PROGRESS INDICATOR
   ========================================================================== */

.signup-progress {
  margin-bottom: 32px;
}

.signup-progress__list {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
}

.signup-progress__item {
  display: flex;
  align-items: center;
  flex: 1;
  position: relative;
}

/* Connector line between steps */
.progress-connector {
  flex: 1;
  height: 2px;
  background: #e2e8f0;
  margin: 0 6px;
  border-radius: 1px;
  transition: background 0.35s ease;
  min-width: 16px;
}

.signup-progress__item.is-complete .progress-connector {
  background: #fbbf24;
}

/* Dot */
.progress-dot {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  cursor: default;
}

.progress-dot__inner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.progress-dot__number {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  line-height: 1;
  transition: opacity 0.2s ease;
}

.progress-dot__check {
  position: absolute;
  width: 12px;
  height: 12px;
  color: #ffffff;
  opacity: 0;
  transition: opacity 0.2s ease;
  stroke-width: 2.5;
}

/* Active step */
.signup-progress__item.is-active .progress-dot__inner {
  border-color: #fbbf24;
  background: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.18);
}

.signup-progress__item.is-active .progress-dot__number {
  color: #0f172a;
}

/* Completed step */
.signup-progress__item.is-complete .progress-dot__inner {
  border-color: #05cc69;
  background: #05cc69;
}

.signup-progress__item.is-complete .progress-dot__number {
  opacity: 0;
}

.signup-progress__item.is-complete .progress-dot__check {
  opacity: 1;
}

/* Label */
.progress-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  margin-left: 6px;
  transition: color 0.3s ease;
}

.signup-progress__item.is-active .progress-label {
  color: #0f172a;
}

.signup-progress__item.is-complete .progress-label {
  color: #05cc69;
}

/* Hide labels on very small screens */
@media (max-width: 400px) {
  .progress-label {
    display: none;
  }
  .progress-dot {
    width: 28px;
    height: 28px;
  }
  .progress-dot__inner {
    width: 28px;
    height: 28px;
  }
}

/* ==========================================================================
   PASSWORD TOGGLE BUTTON
   ========================================================================== */

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s ease;
  z-index: 2;
}

.password-toggle:hover {
  color: #475569;
}

.password-toggle:focus-visible {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

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

/* Ensure input has padding for the toggle */
#password {
  padding-right: 44px;
}

/* ==========================================================================
   EXPRESS CTA BUTTON (injected by payment.js)
   ========================================================================== */

.express-cta {
  width: 100%;
  margin-top: 16px;
  animation: fadeInStep 0.2s ease-out both;
}

/* ==========================================================================
   PAYMENT BUTTON — SELECTED STATE
   ========================================================================== */

.btn--apple-pay.is-selected {
  outline: 2.5px solid #fbbf24;
  outline-offset: 2px;
}

.btn--google-pay.is-selected {
  outline: 2.5px solid #fbbf24;
  outline-offset: 2px;
}

.btn--paypal.is-selected {
  outline: 2.5px solid #0f172a;
  outline-offset: 2px;
}

/* ==========================================================================
   CARD FORM — HIDDEN BY EXPRESS SELECTION
   ========================================================================== */

.payment-card-section.is-hidden-by-express {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.3);
  transition: opacity 0.25s ease, filter 0.25s ease;
}

.payment-card-section {
  transition: opacity 0.25s ease, filter 0.25s ease;
}

/* ==========================================================================
   FORM INPUT — SHAKE ANIMATION (validation error)
   ========================================================================== */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-6px); }
  30%       { transform: translateX(5px); }
  45%       { transform: translateX(-4px); }
  60%       { transform: translateX(3px); }
  75%       { transform: translateX(-2px); }
  90%       { transform: translateX(1px); }
}

.form-input.is-shaking {
  animation: shake 0.45s ease-in-out;
}

/* ==========================================================================
   FORM INPUT — ERROR STATE (JS-driven)
   ========================================================================== */

.form-input--error {
  border-color: #ef4444 !important;
  background-color: #fff5f5;
  color: #0f172a;
}

.form-input--error:focus {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.form-error {
  font-size: 12px;
  color: #ef4444;
  margin-top: 5px;
  display: none;
  font-weight: 500;
  line-height: 1.4;
}

/* ==========================================================================
   STEP TRANSITIONS
   ========================================================================== */

.signup-step {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.signup-step.is-active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: stepEnter 0.3s ease-out both;
}

@keyframes stepEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   ACCORDION BODY — SMOOTH HEIGHT TRANSITION
   ========================================================================== */

.step-panel__body {
  transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.28s ease;
  overflow: hidden;
}

.step-panel:not(.is-open) .step-panel__body {
  opacity: 0;
}

.step-panel.is-open .step-panel__body {
  opacity: 1;
}

/* ==========================================================================
   ORDER SUMMARY — COUPON ROW TRANSITION
   ========================================================================== */

.order-summary__coupon {
  transition: opacity 0.25s ease, max-height 0.3s ease;
  overflow: hidden;
  max-height: 60px;
}

/* ==========================================================================
   CONFIRMATION — DOWNLOAD LINK FEEDBACK
   ========================================================================== */

.order-summary__order-id a {
  transition: color 0.2s ease;
}

/* ==========================================================================
   MOBILE REFINEMENTS
   ========================================================================== */

@media (max-width: 768px) {
  .signup-progress {
    margin-bottom: 24px;
  }

  .payment-overlay__card {
    padding: 32px 24px;
  }

  /* Ensure accordion bodies don't cause layout shift on mobile */
  .step-panel__body {
    transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
}
