/* =============================================
   Variables
   ============================================= */
:root {
  color-scheme: light;
  /* Color palette */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1f2937;
  --gray-900: #0f172a;

  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-text: var(--gray-900);
  --color-muted: var(--gray-600);
  --color-border: var(--gray-200);

  /* Brand & states (sophisticated, trustworthy) */
  --color-primary: #1d4ed8; /* blue-600 */
  --color-primary-700: #1e40af; /* hover */
  --color-success: #16a34a; /* green-600 */
  --color-warning: #d97706; /* amber-600 */
  --color-danger: #dc2626; /* red-600 */

  /* Typography */
  --font-sans: "Inter", "SF Pro Text", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --text-size-xs: 12px;
  --text-size-sm: 14px;
  --text-size-base: 16px;
  --text-size-lg: 18px;
  --text-size-xl: 20px;
  --text-size-2xl: 24px;
  --text-size-3xl: clamp(28px, 2.3vw + 1rem, 32px);
  --text-size-4xl: clamp(34px, 3vw + 1rem, 40px);

  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  /* Spacing scale (0–96px, 4px step) */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-11: 44px;
  --space-12: 48px;
  --space-13: 52px;
  --space-14: 56px;
  --space-15: 60px;
  --space-16: 64px;
  --space-17: 68px;
  --space-18: 72px;
  --space-19: 76px;
  --space-20: 80px;
  --space-21: 84px;
  --space-22: 88px;
  --space-23: 92px;
  --space-24: 96px;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --transition-fast: 150ms;
  --transition-medium: 250ms;
  --transition-slow: 400ms;
  --easing-default: cubic-bezier(.2, .8, .2, 1);

  /* Layout */
  --container-max: 1280px;
  --container-padding: var(--space-5);
}

/* Dark mode support (optional, subtle) */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --color-bg: #0b1020;
    --color-surface: #11162a;
    --color-text: #e6e8ef;
    --color-muted: #a8b0c3;
    --color-border: #27324a;
    --gray-50: #0f1428;
    --gray-100: #171d34;
    --gray-200: #202845;
    --gray-300: #2b3456;
    --gray-400: #3a4570;
    --gray-500: #4b5887;
    --gray-600: #60709f;
    --gray-700: #7f8db8;
    --gray-800: #a9b4d0;
    --gray-900: #e8ebf5;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
  }
}

/* =============================================
   Reset / Normalize
   ============================================= */
*, *::before, *::after { box-sizing: border-box; }

html:focus-within { scroll-behavior: smooth; }

html, body { height: 100%; }

body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }

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

/* Allow percentage-based heights in the application */
:root, body { min-height: 100%; }

/* Inherit fonts for form controls */
button, input, select, textarea { font: inherit; color: inherit; }

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

/* =============================================
   Base styles
   ============================================= */
body {
  font-family: var(--font-sans);
  font-size: var(--text-size-base);
  line-height: var(--leading-normal);
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Headings: modern, scalable, consistent spacing */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-size-4xl); }
h2 { font-size: var(--text-size-3xl); }
h3 { font-size: var(--text-size-2xl); }
h4 { font-size: var(--text-size-xl); }
h5 { font-size: var(--text-size-lg); }
h6 { font-size: var(--text-size-base); }

/* Vertical rhythm */
:where(h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote) + :where(h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote) {
  margin-top: var(--space-4);
}



/* Links: clean, trustworthy */
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Lists */
ul[role="list"], ol[role="list"] { list-style: none; padding-left: 0; }

/* Selections */
::selection { background: color-mix(in srgb, var(--color-primary) 18%, transparent); }

/* Media helpers */
.media-cover { width: 100%; height: 100%; object-fit: cover; }
.media-contain { width: 100%; height: 100%; object-fit: contain; }

/* =============================================
   Accessibility
   ============================================= */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.not-sr-only {
  position: static !important;
  width: auto; height: auto;
  margin: 0; overflow: visible;
  clip: auto; white-space: normal;
}

/* Respect reduced motion for transitions */
@media (prefers-reduced-motion: reduce) {
  .btn, a, input, select, textarea { transition: none !important; }
}

/* =============================================
   Utilities
   ============================================= */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

.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-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }

.gap-xs { gap: var(--space-2); }
.gap-sm { gap: var(--space-3); }
.gap-md { gap: var(--space-4); }
.gap-lg { gap: var(--space-6); }

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-6); }

.hidden { display: none !important; }

/* Simple max-width helpers for content */
.max-w-sm { max-width: 640px; }
.max-w-md { max-width: 768px; }
.max-w-lg { max-width: 1024px; }
.max-w-xl { max-width: 1280px; }

/* Typography utilities */
.muted { color: var(--color-muted); }
.lead { font-size: var(--text-size-lg); line-height: var(--leading-relaxed); }

/* Spacing utilities (example minimal set) */
.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-3); }
.mt-md { margin-top: var(--space-4); }
.mt-lg { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-3); }
.mb-md { margin-bottom: var(--space-4); }
.mb-lg { margin-bottom: var(--space-6); }
.px-sm { padding-inline: var(--space-3); }
.px-md { padding-inline: var(--space-4); }
.py-sm { padding-block: var(--space-3); }
.py-md { padding-block: var(--space-4); }

/* Shadows & radius helpers */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

/* =============================================
   Forms & Inputs
   ============================================= */
:where(input, select, textarea) {
  appearance: none;
  width: 100%;
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  line-height: 1.4;
  transition: border-color var(--transition-fast) var(--easing-default), box-shadow var(--transition-fast) var(--easing-default), background-color var(--transition-fast) var(--easing-default);
}

:where(input, select, textarea)::placeholder { color: var(--gray-500); }

:where(input, select, textarea):focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

:where(input[disabled], select[disabled], textarea[disabled]) {
  opacity: 0.6;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--color-surface), var(--gray-100) 30%);
}

/* Checkbox/Radio accent */
input[type="checkbox"], input[type="radio"] { accent-color: var(--color-primary); }

/* Field group patterns */
.field { display: grid; gap: var(--space-2); }
.field > label { font-size: var(--text-size-sm); color: var(--color-muted); }

/* =============================================
   Buttons
   ============================================= */
.btn {
  --btn-bg: var(--gray-800);
  --btn-fg: #ffffff;
  --btn-border: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-size-sm);
  line-height: 1;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--btn-border);
  background-color: var(--btn-bg);
  color: var(--btn-fg);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-fast) var(--easing-default), color var(--transition-fast) var(--easing-default), box-shadow var(--transition-fast) var(--easing-default), border-color var(--transition-fast) var(--easing-default), transform var(--transition-fast) var(--easing-default);
}

.btn:hover { filter: brightness(0.98); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn[disabled], .btn.is-disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

/* Variants */
.btn-primary { --btn-bg: var(--color-primary); }
.btn-success { --btn-bg: var(--color-success); }
.btn-warning { --btn-bg: var(--color-warning); }
.btn-danger  { --btn-bg: var(--color-danger); }

.btn-outline {
  --btn-bg: transparent;
  --btn-fg: var(--color-text);
  --btn-border: var(--color-border);
  background-color: transparent;
}
.btn-outline:hover { background: color-mix(in srgb, var(--color-primary) 6%, transparent); border-color: color-mix(in srgb, var(--color-primary) 25%, var(--color-border)); }

/* Subtle button (for filters, tags) */
.btn-ghost {
  --btn-bg: transparent; --btn-fg: var(--color-text);
  background: transparent; border-color: transparent;
}
.btn-ghost:hover { background: color-mix(in srgb, var(--color-primary) 6%, transparent); }

/* =============================================
   Card Component
   ============================================= */
.card {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: var(--space-5);
}

.card:hover { box-shadow: var(--shadow-md); transition: box-shadow var(--transition-medium) var(--easing-default); }

.card-header { margin-bottom: var(--space-4); }
.card-title { font-size: var(--text-size-xl); line-height: var(--leading-tight); font-weight: 700; }
.card-subtitle { font-size: var(--text-size-sm); color: var(--color-muted); margin-top: var(--space-1); }
.card-body { font-size: var(--text-size-base); line-height: var(--leading-normal); }

/* =============================================
   Navigation & Breadcrumb basics (lightweight for e-commerce)
   ============================================= */
.nav {
  display: flex; align-items: center; gap: var(--space-5);
}
.nav a {
  color: var(--color-text);
  text-decoration: none;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
}
.nav a:hover { background: color-mix(in srgb, var(--color-primary) 7%, transparent); }
.nav a[aria-current="page"] { color: var(--color-primary); font-weight: 600; }

.breadcrumb { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: var(--text-size-sm); color: var(--color-muted); }
.breadcrumb a { color: inherit; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* =============================================
   Product media helpers (high-resolution imagery)
   ============================================= */
.product-media { position: relative; background: var(--gray-50); border-radius: var(--radius-md); overflow: hidden; }
.product-media img { width: 100%;  object-fit: cover; }

/* Price & rating helpers */
.price { font-weight: 700; letter-spacing: -0.01em; }
.price--sale { color: var(--color-danger); }
.rating { color: #f59e0b; /* star amber */ }

/* =============================================
   Tables (for order summaries, carts)
   ============================================= */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--color-border); }
.table th { font-size: var(--text-size-sm); color: var(--color-muted); font-weight: 600; }

/* =============================================
   Helper classes for state and feedback
   ============================================= */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: var(--radius-full); font-size: var(--text-size-xs); font-weight: 600; }
.badge-primary { background: color-mix(in srgb, var(--color-primary) 15%, transparent); color: var(--color-primary); }
.badge-success { background: color-mix(in srgb, var(--color-success) 15%, transparent); color: var(--color-success); }
.badge-warning { background: color-mix(in srgb, var(--color-warning) 15%, transparent); color: var(--color-warning); }
.badge-danger  { background: color-mix(in srgb, var(--color-danger) 15%, transparent);  color: var(--color-danger); }

.alert { padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.alert-success { background: color-mix(in srgb, var(--color-success) 10%, var(--color-surface)); }
.alert-warning { background: color-mix(in srgb, var(--color-warning) 10%, var(--color-surface)); }
.alert-danger  { background: color-mix(in srgb, var(--color-danger) 10%, var(--color-surface)); }

/* =============================================
   Footer basics
   ============================================= */
.footer { color: var(--color-muted); font-size: var(--text-size-sm); }
.footer a { color: inherit; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* =============================================
   Checkout form helpers (clean, trustworthy)
   ============================================= */
.checkout-summary { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.checkout-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }

/* =============================================
   Print tweaks (optional)
   ============================================= */
@media print {
  .btn, .nav, .breadcrumb, .footer { display: none !important; }
  .card { box-shadow: none; border-color: var(--gray-300); }
}
