/* =========================================================================
 *  buttons.css — Shafa Shahd Button System
 *  Phase 2A — Brand token migration
 *  Source: DESIGN_SYSTEM.md §5.1
 *
 *  Variants:
 *    .btn--primary    → Forest Green (CTA, purchase)
 *    .btn--gold       → Satin Gold (prestige/secondary)
 *    .btn--outline    → Ghost / outline
 *    .btn--neon       → Remapped to .btn--primary (legacy templates; no neon)
 *    .btn--sm         → Smaller size
 *    .btn[disabled]   → Disabled state
 *    .btn.is-loading  → Loading state
 * ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: var(--shafa-touch-lg);
  padding: 0.75rem 1.85rem;
  border-radius: var(--shafa-radius-full);
  font-family: 'Vazirmatn', 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: var(--shafa-fs-body);
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform var(--shafa-duration-base) var(--shafa-ease-natural),
    background var(--shafa-duration-base) var(--shafa-ease-natural),
    box-shadow var(--shafa-duration-base) var(--shafa-ease-natural),
    border-color var(--shafa-duration-base) var(--shafa-ease-natural);
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  letter-spacing: 0;
  text-align: center;
}

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

/* Focus — Gold outline (keyboard only) */
.btn:focus-visible {
  outline: 3px solid var(--shafa-border-focus);
  outline-offset: 3px;
}
/* روی دکمهٔ طلایی، --shafa-border-focus (#C5A059) دقیقاً وسطِ
   --shafa-gold-gradient است (stop 50%) — پس outline هم‌رنگِ پس‌زمینه می‌شود و
   عملاً نامرئی. هالهٔ تیره تضاد لازم را برمی‌گرداند. */
.btn--gold:focus-visible {
  outline-color: var(--shafa-focus-halo);
}

/* === Primary — Forest Green CTA (Luxury Noble) === */
.btn--primary {
  background: var(--shafa-green-gradient);
  color: #FFFFFF;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 16px -2px rgba(22, 43, 33, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
/* شیمر روی ::after زندگی می‌کند اما .btn::after (ripple، خط 198) هم همان شبه‌عنصر
   را هدف می‌گیرد. هر دو specificity (0,1,1) دارند و ripple بعدتر است، پس برنده است.
   نکتهٔ حیاتی: cascade per-property است — ripple مقدار opacity:0 می‌آورد که شیمر
   اصلاً تنظیم نمی‌کند، پس شیمر در ALL states شفاف می‌ماند، نه فقط در hover.
   به همین دلیل specificity این قاعده (0,2,1) است و opacity/inset/background را
   صریحاً بازتعریف می‌کند. */
.btn.btn--primary::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -70%;
  width: 45%;
  height: 200%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  opacity: 1; /* beat .btn::after's opacity:0 */
  z-index: 0;  /* روی پس‌زمینه، مثل رفتار اصلیِ z-index:auto */
  transform: translateX(0) rotate(25deg);
  pointer-events: none;
  transition: none;
}
.btn--primary:hover {
  background: var(--shafa-green-gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -2px rgba(22, 43, 33, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.3);
}
/* شیمر با transform حرکت می‌کند نه left — یعنی بدون reflow در هر hover.
   از left:-70% تا left:140% یعنی ۲۱۰٪ عرض دکمه؛ عرض خودِ ::after ۴۵٪ دکمه است،
   پس ۲۱۰/۴۵ = ۴۶۶.۶۷٪ عرض عنصر. ترتیب translate سپس rotate لازم است تا
   مسیر بصری دقیقاً همانند نسخهٔ قبل (که left جابه‌جا و rotate حول مرکز بود) بماند.
   selector عمداً (0,3,1) است تا از .btn:active::after (0,2,1) در پایین فایل ببرد. */
.btn.btn--primary:hover::after {
  transform: translateX(466.67%) rotate(25deg);
  transition: transform 850ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* === Gold — Prestige / Secondary CTA (Satin Gold Luxury) === */
.btn--gold {
  background: var(--shafa-gold-gradient);
  color: var(--shafa-on-gold);
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 20px -2px rgba(197, 160, 89, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn--gold:hover {
  background: var(--shafa-gold-gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px -2px rgba(197, 160, 89, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* === Google OAuth button === */
.btn--google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--shafa-surface-card);
  color: var(--shafa-text-primary);
  border: 1px solid var(--shafa-border-subtle);
  font-weight: 500;
  box-shadow: var(--shafa-shadow-sm);
}
.btn--google:hover {
  background: var(--shafa-surface-muted);
  box-shadow: var(--shafa-shadow-md);
}
.btn--google .google-icon {
  flex-shrink: 0;
}

/* === OAuth divider === */
.oauth-divider {
  position: relative;
  text-align: center;
  margin: 1.5rem 0;
  font-size: var(--shafa-fs-sm);
  color: var(--shafa-text-tertiary);
  line-height: 1;
}
.oauth-divider::before,
.oauth-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--shafa-border-subtle);
}
.oauth-divider::before { left: 0; }
.oauth-divider::after { right: 0; }
.oauth-divider__text {
  display: inline-block;
  background: var(--shafa-surface-card);
  padding: 0 0.75rem;
}

/* === Outline / Ghost / Glass === */
.btn--ghost,
.btn--outline {
  background: var(--shafa-glass-panel-bg);
  color: var(--shafa-text-primary);
  border: 1px solid rgba(197, 160, 89, 0.35);
  backdrop-filter: blur(10px);
}
.btn--ghost:hover,
.btn--outline:hover {
  border-color: var(--shafa-gold-satin);
  background: var(--shafa-input-bg-strong);
  color: var(--shafa-text-primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(197, 160, 89, 0.18);
}

.btn--glass {
  background: var(--shafa-glass-panel-bg);
  color: var(--shafa-text-primary);
  border: 1px solid rgba(197, 160, 89, 0.25);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.03);
}
.btn--glass:hover {
  background: var(--shafa-input-bg-strong);
  border-color: var(--shafa-gold-satin);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(197, 160, 89, 0.2);
}

/* === Neon — REMAPPED to Primary (brand anti-pattern → brand CTA)
 *   Used in: index.php, product-card.php, newsletter-form.php
 *   These will be migrated to .btn--primary or .btn--gold in Phase 2B.
 *   For now, remap visual to Primary so no neon appears. === */
.btn--neon {
  background: var(--shafa-green-alpine);
  color: var(--shafa-on-emerald);
  font-weight: 500;
  border-color: transparent;
  box-shadow: var(--shafa-shadow-sm);
}
.btn--neon:hover {
  background: var(--shafa-green-hover);
  transform: translateY(-1px);
  box-shadow: var(--shafa-shadow-md);
}

/* === Neon spin wrapper — NEUTRALIZED
 *   Used in product-card.php; now renders as plain container.
 *   The inner .btn already has its own styles. === */
.btn-neon-spin {
  position: relative;
  display: block;
}
/* ::before spinner removed — neon animation disabled */
.btn-neon-spin::before { display: none; }
.btn-neon-spin > .btn {
  position: relative;
  width: 100%;
}

/* === Neon pulse — NEUTRALIZED
 *   .neon-pulse class used in templates; remove animation. === */
.neon-pulse { animation: none; }

/* === Shine — neutral highlight (no white flash)
 *   .btn-shine used in some templates; keep class but neutralize. === */
.btn-shine::after { display: none; }

/* === Sizes === */
.btn--block { width: 100%; }
.btn--sm {
  min-height: var(--shafa-touch-sm);
  padding: 6px 16px;
  font-size: var(--shafa-fs-sm);
}

/* === States === */
.btn[disabled],
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}
.btn.is-loading {
  opacity: 0.8;
  pointer-events: none;
  cursor: progress;
}

/* === Ripple effect (subtle, non-neon) === */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at var(--ripple-x, 50%) var(--ripple-y, 50%),
    rgba(255, 255, 255, 0.18) 0%,
    transparent 60%
  );
  opacity: 0;
  transform: scale(0);
  transition: transform 500ms ease, opacity 300ms ease;
  pointer-events: none;
  z-index: -1;
}
.btn:active::after {
  opacity: 1;
  transform: scale(2);
  transition: transform 0ms, opacity 0ms;
}
/* روی دکمهٔ primary همان ::after حامل شیمر است، نه ripple. بدون این محافظ،
   .btn:active::after بالایی (0,2,1) در حال فشردن دکمه، شیمر را scale(2)
   می‌کرد — یعنی یک پوشش سفید بزرگ روی کل دکمه. */
.btn.btn--primary:active::after {
  transform: translateX(0) rotate(25deg);
  opacity: 1;
}

/* ===================================================================
 *  Password field helper — kept here for co-location with form state
 * =================================================================== */
.pw-strength {
  height: 4px;
  border-radius: 999px;
  background: var(--shafa-border-subtle);
  overflow: hidden;
}
.pw-strength__bar {
  height: 100%;
  width: 0;
  background: var(--shafa-status-error);
  transition: width var(--t-base) var(--ease), background var(--t-base) var(--ease);
}
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.pw-toggle svg { width: 20px; height: 20px; }
