/*
 * florafal-performance.css
 * ✅ Add this file to your project and link it in layouts/app.blade.php
 * ✅ Addresses Lighthouse: Performance, Accessibility, Best Practices, SEO
 *
 * Usage: <link rel="stylesheet" href="{{ asset('css/florafal-performance.css') }}">
 * Place AFTER florafal.css
 */

/* ================================================================
   ACCESSIBILITY — Screen Reader Only utility
================================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ================================================================
   ACCESSIBILITY — Focus visible styles (Best Practices + A11y)
   Ensures keyboard users can always see focused elements
================================================================ */
:focus-visible {
  outline: 3px solid #e91e8c;
  outline-offset: 2px;
  border-radius: 3px;
}

/* Remove default outline only when focus-visible is supported */
:focus:not(:focus-visible) {
  outline: none;
}

/* ================================================================
   ACCESSIBILITY — Minimum tap target size (48x48 for mobile)
   Lighthouse flags touch targets < 48px
================================================================ */
.mob-nav-item,
.header-icon-btn,
.announcement-close,
.sidebar-close,
.modal-close {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.currency-btn {
  min-height: 44px;
  padding-top: 4px;
  padding-bottom: 4px;
}

/* ================================================================
   ACCESSIBILITY — Sufficient colour contrast on muted text
   Ensure --muted meets 4.5:1 ratio on white background
================================================================ */
:root {
  --muted: #767676; /* WCAG AA compliant on white (#fff) */
}

/* ================================================================
   PERFORMANCE — Reduce layout shifts (CLS)
   Reserve space for images before they load
================================================================ */
.product-card-img-wrap,
.hero-img-wrap,
.blog-card-img {
  position: relative;
  overflow: hidden;
  background: #f5f5f5; /* placeholder colour prevents CLS */
}

/* ================================================================
   PERFORMANCE — Optimise animations
   Use will-change only on actively animated elements
   Use transform/opacity instead of top/left for animations
================================================================ */
.product-card {
  will-change: transform;
  contain: layout style;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

/* Remove inline JS hover handlers — use CSS instead */
.product-card img {
  transition: transform 0.3s ease;
}

.product-card:hover img {
  transform: scale(1.05);
}

/* ================================================================
   PERFORMANCE — Font display
   Prevent invisible text during font load (FOIT)
================================================================ */
@font-face {
  font-display: swap; /* use system font until custom font loads */
}

/* ================================================================
   SEO — Semantic heading hierarchy helper
   Prevents h3/h4 being used before h1/h2
================================================================ */
.product-card h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.3;
}

/* ================================================================
   BEST PRACTICES — Smooth scroll behaviour
================================================================ */
html {
  scroll-behavior: smooth;
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================================================================
   BEST PRACTICES — Consistent image rendering
================================================================ */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ================================================================
   ACCESSIBILITY — Link underlines (improves readability)
   Content links should be distinguishable without colour alone
================================================================ */
.footer-links-grid a:hover,
.footer-links-grid a:focus {
  text-decoration: underline;
}

/* ================================================================
   BEST PRACTICES — Prevent horizontal scroll (CLS / mobile)
================================================================ */
body {
  overflow-x: hidden;
}

/* ================================================================
   ACCESSIBILITY — High contrast mode support
================================================================ */
@media (forced-colors: active) {
  .product-card,
  .header-icon-btn,
  .mob-nav-item {
    border: 1px solid ButtonText;
  }
}
