/**
 * Second Cure — Motion & Microinteractions
 *
 * Smooth transitions, scroll-driven animations, hover polish,
 * and dark UX patterns that make the experience feel premium.
 */

/* ── SCROLL REVEAL ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

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

/* Elements animate in when they enter viewport */
.sc-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.sc-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children */
.sc-stagger > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.sc-stagger.visible > *:nth-child(1) { transition-delay: 0.05s; }
.sc-stagger.visible > *:nth-child(2) { transition-delay: 0.1s; }
.sc-stagger.visible > *:nth-child(3) { transition-delay: 0.15s; }
.sc-stagger.visible > *:nth-child(4) { transition-delay: 0.2s; }
.sc-stagger.visible > *:nth-child(5) { transition-delay: 0.25s; }
.sc-stagger.visible > *:nth-child(6) { transition-delay: 0.3s; }

.sc-stagger.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* ── BUTTON MICROINTERACTIONS ── */
.btn-primary,
.btn,
.pay-btn,
.nav-cta,
.cta-btn,
.success-btn,
[class*="btn-primary"],
button[type="submit"] {
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover,
.btn:hover,
.pay-btn:hover,
.nav-cta:hover,
.cta-btn:hover,
[class*="btn-primary"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(25, 48, 30, 0.2);
}

.btn-primary:active,
.btn:active,
.pay-btn:active,
.nav-cta:active,
.cta-btn:active,
[class*="btn-primary"]:active {
  transform: translateY(0) scale(0.98);
  box-shadow: none;
  transition-duration: 0.1s;
}

/* Ripple effect */
.btn-primary::after,
.pay-btn::after,
.cta-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.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

.btn-primary:active::after,
.pay-btn:active::after,
.cta-btn:active::after {
  opacity: 1;
  transition-duration: 0.05s;
}

/* ── CARD INTERACTIONS ── */
.card,
.story-card,
.pillar-card,
.product-option,
.plan-option,
.stat-card,
[class*="-card"] {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.card:hover,
.story-card:hover,
.pillar-card:hover,
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* Selected state with ring */
.product-option.selected,
.plan-option.selected,
.dosage-option.selected,
.delivery-option.selected {
  box-shadow: 0 0 0 2px var(--green-primary, #19301e), 0 4px 12px rgba(25, 48, 30, 0.1);
}

/* ── INPUT FOCUS ── */
.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
textarea,
select {
  transition: border-color 0.2s ease,
              box-shadow 0.2s ease,
              transform 0.15s ease !important;
}

.form-input:focus,
input:focus,
textarea:focus,
select:focus {
  transform: scale(1.005);
  box-shadow: 0 0 0 3px rgba(25, 48, 30, 0.08) !important;
}

/* ── LINK UNDERLINE ANIMATION ── */
.footer-col a,
.nav-link,
.auth-alt a {
  position: relative;
}

.footer-col a::after,
.auth-alt a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: currentColor;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.footer-col a:hover::after,
.auth-alt a:hover::after {
  width: 100%;
}

/* ── SMOOTH PAGE TRANSITIONS ── */
body {
  animation: fadeIn 0.4s ease;
}

/* ── NAV SCROLL EFFECT ── */
.nav {
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.nav.scrolled {
  height: 72px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* ── MODAL TRANSITIONS ── */
.success-overlay,
.modal-overlay,
[class*="overlay"],
[class*="modal"] {
  transition: opacity 0.3s ease !important;
}

.success-overlay.show,
.modal-overlay.show,
[class*="overlay"].show {
  animation: fadeIn 0.3s ease !important;
}

.success-card,
.modal-content,
[class*="modal-content"] {
  animation: scaleIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* ── TOAST ANIMATION ── */
#sc-toast,
.toast,
#toast {
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  transform: translateX(-50%) translateY(10px);
}

#sc-toast[style*="opacity: 1"],
.toast.visible,
#toast.visible {
  transform: translateX(-50%) translateY(0) !important;
}

/* ── CHECKBOX/RADIO MICROINTERACTIONS ── */
input[type="checkbox"],
input[type="radio"] {
  transition: transform 0.15s ease;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  animation: countUp 0.2s ease;
}

/* ── PROGRESS BAR ANIMATION ── */
.progress-fill,
.dosage-progress__fill,
[class*="progress-fill"] {
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* ── BADGE PULSE ── */
.badge--active .badge__dot,
.nav__badge {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── SKELETON LOADING ── */
.sc-skeleton {
  background: linear-gradient(90deg, var(--stone-light, #f4f1e7) 25%, var(--stone-dark, #e4e1d8) 50%, var(--stone-light, #f4f1e7) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── DARK UX: URGENCY & SCARCITY ── */

/* Stock indicator */
.stock-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #b45309;
  padding: 4px 12px;
  background: rgba(245, 158, 11, 0.08);
  border-radius: 100px;
}

.stock-indicator::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Social proof notification */
.social-proof {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: white;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  animation: slideInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 340px;
  font-size: 13px;
  line-height: 1.5;
}

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

.social-proof__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green-primary, #19301e);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Countdown timer */
.countdown-bar {
  background: rgba(25, 48, 30, 0.04);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--green-primary, #19301e);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.countdown-bar__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34a853;
  animation: pulse 1s ease-in-out infinite;
}

/* ── VIEW TRANSITIONS ── */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: fadeOut 0.2s ease forwards;
}

::view-transition-new(root) {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ── REDUCE MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .sc-reveal {
    opacity: 1;
    transform: none;
  }

  .sc-stagger > * {
    opacity: 1;
    transform: none;
  }
}
