/* ===================================================================
   Ruzzy — Animations & Motion Design
   Pure CSS enhancements — zero functional changes
   =================================================================== */

/* ── Keyframes ─────────────────────────────────────────────────────── */

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

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

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

@keyframes badgeBounce {
  0%   { transform: scale(0); }
  65%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

@keyframes cartWiggle {
  0%, 100% { transform: rotate(0deg); }
  20%       { transform: rotate(-18deg); }
  40%       { transform: rotate(16deg); }
  60%       { transform: rotate(-10deg); }
  80%       { transform: rotate(7deg); }
}

@keyframes heartPop {
  0%   { transform: scale(0.8); }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes successPop {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg);  opacity: 1; }
  100% { transform: scale(1)   rotate(0deg);  opacity: 1; }
}

@keyframes rippleEffect {
  to { transform: scale(4); opacity: 0; }
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0   rgba(37, 99, 235, 0.40); }
  70%  { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0   rgba(37, 99, 235, 0); }
}

/* ── Page entrance ─────────────────────────────────────────────────── */
body {
  animation: fadeIn 0.4s ease forwards;
}

/* ── Scroll reveal ─────────────────────────────────────────────────── */
.anim-fade-up {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}
.anim-fade-up.anim-visible {
  opacity: 1;
  transform: translateY(0);
}
.anim-delay-1 { transition-delay: 0.07s; }
.anim-delay-2 { transition-delay: 0.14s; }
.anim-delay-3 { transition-delay: 0.21s; }
.anim-delay-4 { transition-delay: 0.28s; }
.anim-delay-5 { transition-delay: 0.35s; }
.anim-delay-6 { transition-delay: 0.42s; }

/* ── Header ────────────────────────────────────────────────────────── */
.site-header {
  transition: box-shadow 0.3s ease !important;
}
.site-header.header-scrolled {
  box-shadow: 0 6px 28px rgba(0, 0, 0, .11) !important;
}

/* Logo icon bounce */
.logo-icon {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.logo:hover .logo-icon {
  transform: rotate(-12deg) scale(1.12);
}

/* Header action buttons lift */
.header-btn {
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.header-btn:hover {
  transform: translateY(-3px);
}
.header-btn i {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
}
.header-btn:hover i {
  transform: scale(1.2);
}

/* Cart / heart icon wiggle on hover */
.header-btn:hover .fa-shopping-cart,
.header-btn:hover .fa-heart {
  animation: cartWiggle 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Badge pop-in */
.badge-count {
  animation: badgeBounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Search bar glow on focus */
.search-form {
  transition: all 0.3s ease !important;
}
.search-form:focus-within {
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.15) !important;
}

/* ── Flash messages ────────────────────────────────────────────────── */
.flash-msg {
  animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ── Hero — staggered entrance ─────────────────────────────────────── */
.hero-badge {
  animation: slideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
}
.hero-content h1 {
  animation: fadeInUp 0.65s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}
.hero-content > p {
  animation: fadeInUp 0.65s cubic-bezier(0.16, 1, 0.3, 1) 0.28s both;
}
.hero-btns {
  animation: fadeInUp 0.65s cubic-bezier(0.16, 1, 0.3, 1) 0.38s both;
}
.hero-stats {
  animation: fadeInUp 0.65s cubic-bezier(0.16, 1, 0.3, 1) 0.50s both;
}

/* Hero visual mini-cards — scale in then float */
.hero-mini-card {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.3s ease !important;
}
.hero-mini-card:nth-child(1) {
  animation: scaleIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both,
             float    4.5s ease-in-out 1.2s infinite;
}
.hero-mini-card:nth-child(2) {
  animation: scaleIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.48s both,
             float    4.5s ease-in-out 2.0s infinite;
}
.hero-mini-card:nth-child(3) {
  animation: scaleIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.42s both,
             float    4.5s ease-in-out 1.6s infinite;
}
.hero-mini-card:nth-child(4) {
  animation: scaleIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.55s both,
             float    4.5s ease-in-out 2.4s infinite;
}
.hero-mini-card:hover {
  transform: translateY(-6px) scale(1.05) !important;
}

/* ── Features bar ──────────────────────────────────────────────────── */
.feature-icon {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.3s ease,
              color 0.3s ease;
}
.feature-item:hover .feature-icon {
  transform: scale(1.18) rotate(-6deg);
  background: var(--primary);
  color: #fff;
}
.feature-item:hover .feature-icon i {
  color: #fff;
}

/* ── Category cards ────────────────────────────────────────────────── */
.cat-card {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  overflow: hidden;
}
.cat-icon {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
}
.cat-card:hover .cat-icon {
  transform: scale(1.25) rotate(-8deg);
}
.cat-card:hover {
  transform: translateY(-4px) !important;
}

/* ── Product cards ─────────────────────────────────────────────────── */
.product-card {
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.32s ease,
              border-color 0.25s ease !important;
}
.product-card:hover {
  transform: translateY(-7px) !important;
  box-shadow: 0 14px 44px rgba(37, 99, 235, 0.13) !important;
}

/* Subtle blue gradient overlay on image hover */
.product-img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(37, 99, 235, 0.07) 0%,
    transparent 55%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.product-card:hover .product-img-wrap::after { opacity: 1; }

/* Badge pop */
.product-badge {
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

/* Fav button heart pop */
.fav-btn {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              color 0.2s ease,
              background 0.2s ease !important;
}
.fav-btn:hover { transform: scale(1.22) !important; }
.fav-btn.active {
  animation: heartPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Add-to-cart hover + active press
   NOTE: transition only transform/box-shadow (NOT `all`) and keep the button on
   a stable GPU layer (translateZ/backface) so the gradient background doesn't
   flash white when the scale transform repaints. */
.add-cart-btn {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease !important;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  will-change: transform;
}
.add-cart-btn:hover  { transform: scale(1.04) translateZ(0);  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3); }
.add-cart-btn:active { transform: scale(0.96) translateZ(0); }

/* Product name hover underline slide */
.product-name {
  background-image: linear-gradient(var(--primary), var(--primary));
  background-size: 0 1.5px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.3s ease, color 0.2s ease !important;
}
.product-name:hover {
  background-size: 100% 1.5px;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
/* Ripple-ready */
.btn {
  position: relative;
  overflow: hidden;
}
/* Ripple span injected by JS */
.btn .ripple-span {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  pointer-events: none;
  transform: scale(0);
  animation: rippleEffect 0.65s ease forwards;
}

.btn-primary {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.btn-primary:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.38) !important;
}
.btn-primary:active { transform: scale(0.97) !important; }

/* Pulsing ring on hero CTA */
.btn-pulse {
  animation: pulseRing 2.2s ease infinite;
}

/* ── Form inputs ───────────────────────────────────────────────────── */
.form-control {
  transition: border-color 0.25s ease,
              box-shadow 0.25s ease,
              background 0.25s ease !important;
}
.form-control:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

.payment-option label {
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.payment-option input:checked + label {
  transform: scale(1.02);
}

/* ── Flash sale strip ──────────────────────────────────────────────── */
.flash-sale-strip {
  background-size: 200% 100%;
  background-image: linear-gradient(90deg,
    #b91c1c, #dc2626, #ef4444, #dc2626, #b91c1c);
  animation: gradientShift 5s ease infinite;
}
.flash-sale-strip > span {
  display: inline-block;
}
.flash-sale-strip i {
  display: inline-block;
  animation: cartWiggle 2s ease infinite;
}

/* ── Order success page ────────────────────────────────────────────── */
.success-page .success-icon {
  display: inline-block;
  animation: successPop 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}
.success-page h1 {
  animation: fadeInUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both;
}
.success-page .container > p {
  animation: fadeInUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.45s both;
}
.order-box {
  animation: fadeInUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.55s both;
}

/* ── Promo banner ──────────────────────────────────────────────────── */
.promo-emoji {
  display: inline-block;
  animation: float 3.2s ease-in-out infinite;
}

/* ── Footer ────────────────────────────────────────────────────────── */
.social-link {
  transition: all 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.social-link:hover {
  transform: translateY(-5px) scale(1.12) !important;
}

.footer-col a {
  transition: color 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.footer-col a:hover {
  transform: translateX(5px);
}

/* ── Pagination ────────────────────────────────────────────────────── */
.page-btn {
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.page-btn:hover:not(.disabled) {
  transform: translateY(-2px) !important;
}

/* ── Cart items ────────────────────────────────────────────────────── */
.cart-item {
  transition: background 0.2s ease;
}
.cart-item:hover {
  background: var(--surface2);
}

/* ── See all link ──────────────────────────────────────────────────── */
.see-all i {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
}
.see-all:hover i {
  transform: translateX(5px);
}

/* ── Admin ─────────────────────────────────────────────────────────── */

/* Stat cards lift */
.stat-card {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.stat-card:hover {
  transform: translateY(-5px) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22) !important;
  border-color: #3b82f6 !important;
}
.stat-card:hover .stat-card-value {
  color: #60a5fa;
}
.stat-card-value {
  transition: color 0.3s ease;
}

/* Admin nav items slide */
.admin-nav-item {
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.admin-nav-item:hover,
.admin-nav-item.active {
  transform: translateX(4px);
}

/* Admin table row hover */
.admin-table tbody tr {
  transition: background 0.18s ease;
}
.admin-table tbody tr:hover td {
  background: rgba(59, 130, 246, 0.06) !important;
}

/* Admin button actions */
.btn-admin {
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.btn-admin:hover {
  transform: translateY(-2px);
}
.btn-admin:active {
  transform: scale(0.95);
}

/* ── Reduced motion ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .anim-fade-up {
    opacity: 1 !important;
    transform: none !important;
  }
}
