/* ============================================
   BicepsBD Design System
   Core tokens, reset, typography, utilities
   ============================================ */

/* --- Google Fonts --- */
/* --- Google Fonts loaded via wp_enqueue_style in enqueue.php --- */

/* --- Design Tokens --- */
:root {
  /* Colors */
  --color-primary: hsl(155, 100%, 34%);        /* #00AF66 */
  --color-primary-light: hsl(155, 100%, 95%);
  --color-primary-lighter: hsl(155, 100%, 98%);
  --color-primary-dark: hsl(155, 100%, 28%);
  --color-primary-rgb: 0, 175, 102;

  --color-secondary: hsl(220, 15%, 18%);
  --color-bg: hsl(0, 0%, 98%);                  /* Clean neutral off-white */
  --color-surface: hsl(0, 0%, 100%);            /* Pure white */
  --color-surface-raised: hsl(0, 0%, 100%);
  --color-border: rgba(0, 0, 0, 0.16);
  --color-border-light: rgba(0, 0, 0, 0.10);
  --color-divider: rgba(0, 0, 0, 0.10);

  --color-text: hsl(220, 15%, 18%);
  --color-text-secondary: hsl(220, 8%, 45%);
  --color-text-muted: hsl(220, 8%, 60%);
  --color-text-inverse: hsl(0, 0%, 100%);

  --color-success: hsl(155, 100%, 34%);
  --color-success-light: hsl(155, 100%, 95%);
  --color-warning: hsl(40, 95%, 50%);
  --color-warning-light: hsl(40, 90%, 94%);
  --color-error: hsl(0, 75%, 55%);
  --color-error-light: hsl(0, 70%, 95%);
  --color-info: hsl(210, 80%, 55%);
  --color-info-light: hsl(210, 75%, 94%);

  --color-badge-sale: hsl(155, 100%, 34%);
  --color-badge-new: hsl(155, 100%, 34%);
  --color-badge-best: hsl(155, 100%, 34%);
  --color-badge-text: hsl(0, 0%, 100%);

  --color-overlay: hsla(220, 15%, 18%, 0.5);
  --color-skeleton: hsl(220, 10%, 92%);
  --color-skeleton-shine: hsl(220, 10%, 96%);

  /* Typography */
  --font-heading: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --text-xs: 0.6875rem;    /* 11px */
  --text-sm: 0.75rem;      /* 12px */
  --text-base: 0.875rem;   /* 14px */
  --text-md: 0.9375rem;    /* 15px */
  --text-lg: 1rem;         /* 16px */
  --text-xl: 1.125rem;     /* 18px */
  --text-2xl: 1.25rem;     /* 20px */
  --text-3xl: 1.5rem;      /* 24px */
  --text-4xl: 1.75rem;     /* 28px */
  --text-5xl: 2rem;         /* 32px */

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.01em;
  --tracking-wider: 0.03em;

  /* Spacing */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */

  /* Layout */
  --page-padding: var(--space-4);
  --section-gap: var(--space-8);
  --card-gap: var(--space-3);
  --header-height: 56px;
  --bottom-nav-height: 64px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --container-max: 1280px;

  /* Border Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px hsla(220, 15%, 18%, 0.04);
  --shadow-sm: 0 1px 3px hsla(220, 15%, 18%, 0.06), 0 1px 2px hsla(220, 15%, 18%, 0.04);
  --shadow-md: 0 4px 6px hsla(220, 15%, 18%, 0.05), 0 2px 4px hsla(220, 15%, 18%, 0.03);
  --shadow-lg: 0 10px 15px hsla(220, 15%, 18%, 0.06), 0 4px 6px hsla(220, 15%, 18%, 0.03);
  --shadow-xl: 0 20px 25px hsla(220, 15%, 18%, 0.08), 0 8px 10px hsla(220, 15%, 18%, 0.03);
  --shadow-top: 0 -2px 8px hsla(220, 15%, 18%, 0.06);
  --shadow-bottom-nav: 0 -1px 8px hsla(220, 15%, 18%, 0.08);

  /* Transitions */
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 350ms;

  /* Z-index */
  --z-base: 1;
  --z-sticky: 100;
  --z-header: 200;
  --z-overlay: 300;
  --z-sheet: 400;
  --z-modal: 500;
  --z-toast: 600;
  --z-bottom-nav: 150;
}

/* --- CSS Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100dvh;
  overflow-x: hidden;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  overflow-wrap: break-word;
}

p {
  overflow-wrap: break-word;
}

/* Remove number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* Focus visible for keyboard users */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Selection */
::selection {
  background-color: var(--color-primary-light);
  color: var(--color-text);
}

/* Scrollbar (thin, subtle) */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* --- Typography Classes --- */
.heading-1 {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.heading-2 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.heading-3 {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-snug);
}

.heading-4 {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: var(--leading-snug);
}

.body-text {
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

.body-text-sm {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.caption {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

.caption-xs {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

.overline {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-text-muted);
}

.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-center { text-align: center; }
.text-right { text-align: right; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Utility Classes --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.hidden { display: none !important; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.block { display: block; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

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

.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Spacing utilities */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

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

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

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

@keyframes cartBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

.animate-fade-in { animation: fadeIn var(--duration-normal) var(--ease-out); }
.animate-fade-in-up { animation: fadeInUp var(--duration-normal) var(--ease-out); }
.animate-slide-up { animation: slideUp var(--duration-slow) var(--ease-out); }
.animate-scale-in { animation: scaleIn var(--duration-normal) var(--ease-out); }

/* --- Responsive Typography Scale --- */
@media (min-width: 768px) {
  :root {
    --text-3xl: 1.75rem;  /* 28px */
    --text-4xl: 2rem;     /* 32px */
    --text-5xl: 2.5rem;   /* 40px */
    --page-padding: var(--space-6);
  }
}

@media (min-width: 1024px) {
  :root {
    --text-3xl: 2rem;     /* 32px */
    --text-4xl: 2.25rem;  /* 36px */
    --text-5xl: 3rem;     /* 48px */
    --page-padding: var(--space-8);
  }
}

/* --- Mobile-specific breakpoints (320px–430px target devices) --- */
@media (max-width: 320px) {
  :root {
    --text-base: 0.8125rem; /* 13px for very small screens */
    --page-padding: 12px;
  }
  .product-grid {
    gap: 8px;
  }
  .mobile-header {
    padding-left: 8px;
    padding-right: 8px;
  }
}

@media (min-width: 321px) and (max-width: 375px) {
  :root {
    --page-padding: 14px;
  }
}

@media (min-width: 376px) and (max-width: 430px) {
  :root {
    --page-padding: 16px;
  }
}
