/* ==========================================================================
   FarmaVia - Performance & Smoothness Engine
   ========================================================================== */

/* ===== 1. GPU-ACCELERATED ANIMATIONS ===== */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

html {
  scroll-behavior: smooth;
}

/* Force GPU on heavy elements */
.header-main,
.nav-categories-bar,
.cart-drawer,
.cart-drawer-overlay,
.modal-overlay,
.modal-box,
.product-card,
.top-announcement {
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

/* ===== 2. PAGE ENTRY ANIMATION ===== */
@keyframes pageReveal {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main-content,
main,
section:not(.top-announcement) {
  animation: pageReveal 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ===== 3. PAGE TRANSITION OVERLAY (DISABLED) ===== */
#page-transition {
  display: none !important;
}

/* ===== 4. SMOOTH CARD HOVERS ===== */
.product-card {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease;
}
.product-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 20px 50px rgba(5,150,105,0.18);
}

/* ===== 5. BUTTON PRESS FEEL ===== */
.btn-add-to-cart,
.btn-checkout-full,
.submit-btn,
.btn-secondary {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.25s ease;
}
.btn-add-to-cart:active,
.btn-checkout-full:active,
.submit-btn:active {
  transform: scale(0.97) !important;
}

/* ===== 6. NAV LINK SMOOTH UNDERLINE ===== */
.nav-link {
  position: relative;
  transition: color 0.2s ease;
}
.nav-link::after {
  content: '';
  position: absolute; bottom: -4px; left: 0; right: 0;
  height: 2px;
  background: var(--primary, #059669);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 2px;
}
.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

/* ===== 7. SKELETON LOADING ===== */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}
.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, #f0f4f8 25%, #e2e8f0 50%, #f0f4f8 75%);
  background-size: 600px 100%;
  animation: shimmer 1.5s infinite linear;
}
.skeleton-card {
  height: 340px; border-radius: 16px; margin-bottom: 24px;
}
.skeleton-text { height: 14px; margin-bottom: 10px; }
.skeleton-text.wide { width: 80%; }
.skeleton-text.medium { width: 60%; }
.skeleton-text.short { width: 40%; }

/* ===== 8. SMOOTH IMAGE REVEAL ===== */
img {
  transition: opacity 0.4s ease, transform 0.4s ease;
}
img.lazy-hidden { opacity: 0; transform: scale(0.98); }
img.lazy-loaded { opacity: 1; transform: scale(1); }

/* ===== 9. SCROLL REVEAL ===== */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }

/* ===== 10. SMOOTH HEADER SCROLL SHADOW ===== */
.header-main {
  transition: box-shadow 0.3s ease, background 0.3s ease;
}
.header-main.scrolled {
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.98);
  backdrop-filter: blur(12px);
}

/* ===== 11. SMOOTH CART DRAWER ===== */
.cart-drawer-overlay {
  visibility: hidden; opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s;
  background: rgba(0,0,0,0);
  transition: background 0.3s ease, opacity 0.3s ease, visibility 0.3s;
}
.cart-drawer-overlay.active {
  visibility: visible; opacity: 1;
  background: rgba(0,0,0,0.5);
}
.cart-drawer {
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.cart-drawer-overlay.active .cart-drawer {
  transform: translateX(0);
}

/* ===== 12. MODAL SMOOTH ENTRY ===== */
.modal-overlay {
  visibility: hidden; opacity: 0;
  transition: opacity 0.25s ease, visibility 0.25s;
}
.modal-overlay.active {
  visibility: visible; opacity: 1;
}
.modal-box {
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}

/* ===== 13. TOP ANNOUNCEMENT MARQUEE ===== */
.announcement-marquee {
  display: flex;
  gap: 60px;
  animation: marqueeScroll 25s linear infinite;
  white-space: nowrap;
}
@keyframes marqueeScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.top-announcement .container {
  overflow: hidden;
}

/* ===== 14. FOCUS STYLES (Accessibility + Polish) ===== */
:focus-visible {
  outline: 2px solid #059669;
  outline-offset: 3px;
  border-radius: 4px;
}

/* ===== 15. SMOOTH NUMBER COUNT ===== */
.count-up {
  display: inline-block;
  transition: all 0.1s ease;
}

/* ===== 16. FAST LINK HOVER ===== */
a {
  transition: color 0.18s ease, opacity 0.18s ease;
}

/* ===== 17. INPUT FOCUS TRANSITIONS ===== */
input, select, textarea {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

/* ===== 18. BADGE PULSE ===== */
.cart-badge {
  animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ===== 19. STICKY HEADER PERFORMANCE ===== */
.top-announcement,
.header-main {
  position: sticky;
  top: 0;
  z-index: 1000;
}
.top-announcement { top: 0; z-index: 1001; }
.header-main { top: 36px; z-index: 1000; }

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