/* ═══════════════════════════════════════════════════════════════════════════
   ELAAF — Global Styles
   Reset, base elements, layout containers, utilities
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--clr-text);
  background-color: var(--clr-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--clr-text);
  letter-spacing: var(--tracking-tight);
}
h1 { font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl)); }
h2 { font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl)); }
h3 { font-size: clamp(var(--text-xl), 3vw, var(--text-3xl)); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-md); }

p { line-height: var(--leading-relaxed); }

/* ── Container System ────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-default);
  margin-inline: auto;
  padding-inline: var(--space-6);
}
.container--wide    { max-width: var(--container-wide); }
.container--narrow  { max-width: var(--container-narrow); }
.container--full    { max-width: 100%; }

/* ── Section Spacing ─────────────────────────────────────────────────────── */
.section {
  padding-block: var(--space-20);
}
.section--sm {
  padding-block: var(--space-12);
}
.section--lg {
  padding-block: var(--space-32);
}
.section--muted {
  background: var(--clr-muted);
}
.section--surface {
  background: var(--clr-surface);
}

/* ── Section Header ──────────────────────────────────────────────────────── */
.section-header {
  text-align: center;
  margin-bottom: var(--space-12);
}
.section-header__eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--clr-primary);
  margin-bottom: var(--space-3);
}
.section-header__title {
  font-family: var(--font-heading);
  font-size: clamp(var(--text-2xl), 3.5vw, var(--text-4xl));
  color: var(--clr-text);
  margin-bottom: var(--space-4);
}
.section-header__subtitle {
  font-size: var(--text-md);
  color: var(--clr-text-muted);
  max-width: 560px;
  margin-inline: auto;
}
.section-header__divider {
  width: 48px;
  height: 2px;
  background: var(--clr-primary);
  margin: var(--space-4) auto 0;
}

/* ── Grid System ─────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: var(--space-6);
}
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--5 { grid-template-columns: repeat(5, 1fr); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ── Flex Utilities ──────────────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.flex-wrap   { flex-wrap: wrap; }
.gap-2       { gap: var(--space-2); }
.gap-4       { gap: var(--space-4); }
.gap-6       { gap: var(--space-6); }
.gap-8       { gap: var(--space-8); }

/* ── Aspect Ratios ───────────────────────────────────────────────────────── */
.aspect-4\/5   { aspect-ratio: 4 / 5; }
.aspect-3\/4   { aspect-ratio: 3 / 4; }
.aspect-1\/1   { aspect-ratio: 1 / 1; }
.aspect-16\/9  { aspect-ratio: 16 / 9; }
.object-cover  { object-fit: cover; width: 100%; height: 100%; }

/* ── Image Overlay Fade ──────────────────────────────────────────────────── */
.img-hover-zoom {
  overflow: hidden;
}
.img-hover-zoom img {
  transition: transform var(--transition-slow);
  transform: scale(1.0);
}
.img-hover-zoom:hover img {
  transform: scale(1.06);
}

/* ── Lazy Image Loading Optimizations ───────────────────────────────────── */
/* Prevent layout shift during lazy load — use a subtle grey background */
img[loading="lazy"] {
  background: var(--clr-muted);
}
/* Smooth fade-in when images load */
img {
  transition: opacity 0.3s ease;
}
/* Product card images — fixed dimensions prevent CLS (Cumulative Layout Shift) */
.product-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  will-change: transform; /* GPU-accelerate the hover zoom */
}
/* Below-fold sections: defer rendering until near viewport */
.section + .section,
.section--muted,
.section--surface {
  content-visibility: auto;
  contain-intrinsic-size: 0 600px;
}

/* ── Utility Classes ─────────────────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--clr-text-muted); }
.text-primary { color: var(--clr-primary); }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.text-lg      { font-size: var(--text-lg); }
.text-xl      { font-size: var(--text-xl); }
.fw-500       { font-weight: 500; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.font-heading { font-family: var(--font-heading); }

.hidden       { display: none !important; }
.sr-only      { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.mt-auto      { margin-top: auto; }
.mb-4         { margin-bottom: var(--space-4); }
.mb-6         { margin-bottom: var(--space-6); }
.mb-8         { margin-bottom: var(--space-8); }
.mt-6         { margin-top: var(--space-6); }
.mt-8         { margin-top: var(--space-8); }

.w-full       { width: 100%; }
.h-full       { height: 100%; }
.relative     { position: relative; }
.overflow-h   { overflow: hidden; }

/* ── Dividers ────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: var(--border);
  margin-block: var(--space-8);
}

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--clr-text-muted);
  padding-block: var(--space-4);
  flex-wrap: wrap;
}
.breadcrumb a:hover { color: var(--clr-primary); }
.breadcrumb__sep { opacity: 0.5; }
.breadcrumb__current { color: var(--clr-text); }

/* ── Skeleton Loader ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--clr-skeleton) 25%, var(--clr-muted-2) 50%, var(--clr-skeleton) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 360px;
  pointer-events: none;
}
.toast {
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-modal);
  border-left: 4px solid var(--clr-primary);
  animation: toast-in 0.3s ease;
}
.toast--success { border-left-color: var(--clr-success); }
.toast--error   { border-left-color: var(--clr-error); }
.toast__icon    { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }
.toast__msg     { font-size: var(--text-sm); font-weight: 500; line-height: 1.4; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}


/* ── Alert Blocks ────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
  border: 1px solid transparent;
}
.alert--success { background: var(--clr-success-bg); border-color: var(--clr-success); color: var(--clr-success); }
.alert--error   { background: var(--clr-error-bg);   border-color: var(--clr-error);   color: var(--clr-error); }
.alert--warning { background: var(--clr-warning-bg); border-color: var(--clr-warning); color: var(--clr-warning); }
.alert--info    { background: var(--clr-info-bg);    border-color: var(--clr-info);    color: var(--clr-info); }

/* ── Page Header (inner pages) ───────────────────────────────────────────── */
.page-header {
  background: var(--clr-muted);
  padding-block: var(--space-12) var(--space-8);
  border-bottom: var(--border);
}
.page-header__title {
  font-family: var(--font-heading);
  font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
  font-weight: 600;
}
.page-header__subtitle {
  font-size: var(--text-md);
  color: var(--clr-text-muted);
  margin-top: var(--space-2);
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-24) var(--space-6);
}
.empty-state__icon {
  font-size: 3rem;
  margin-bottom: var(--space-6);
  opacity: 0.4;
}
.empty-state__title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}
.empty-state__text {
  color: var(--clr-text-muted);
  margin-bottom: var(--space-8);
}

/* ── Overlay / Modal Backdrop ────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: var(--z-overlay); /* 300 */
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.overlay.is-active {
  opacity: 1;
  pointer-events: all;
}

/* ── Search Panel (sits above overlay) ───────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 9000;
  background: #ffffff !important;
}
.search-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 9999 !important;
  border-top: var(--border);
  background: #ffffff !important;
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-hover);
}

/* ── Stars Rating ────────────────────────────────────────────────────────── */
.stars {
  display: inline-flex;
  gap: 2px;
  color: var(--clr-accent);
  font-size: var(--text-sm);
}
.stars--sm { font-size: var(--text-xs); }
.stars--lg { font-size: var(--text-lg); }

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1;
}
.badge--sale    { background: var(--clr-sale-badge);    color: var(--clr-sale-badge-text); }
.badge--new     { background: var(--clr-new-badge);     color: var(--clr-new-badge-text); }
.badge--primary { background: var(--clr-primary);       color: #fff; }
.badge--muted   { background: var(--clr-muted-2);       color: var(--clr-text-muted); }

/* ── Stock Indicator ─────────────────────────────────────────────────────── */
.stock-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
}
.stock-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--clr-success);
}
.stock-indicator--low::before    { background: var(--clr-warning); }
.stock-indicator--out::before    { background: var(--clr-error); }
.stock-indicator--out { color: var(--clr-error); }

/* ── Price Display ───────────────────────────────────────────────────────── */
.price-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.price-current {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--clr-text);
}
.price-original {
  font-size: var(--text-sm);
  color: var(--clr-text-faint);
  text-decoration: line-through;
}
.price-save {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--clr-sale-badge);
}
