/* ==============================================
   BASE — CSS custom properties, reset, typography,
   global element defaults. Loaded by every page.
   ============================================== */

/* GLOBAL */
:root {
  /* ── Existing color tokens (preserved) ── */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-primary: #10b981;
  --color-primary-dark: #059669;
  --color-primary-soft: #d1fae5;
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;

  /* ── Extended primary palette (HSL-based) ── */
  --color-primary-50: #ecfdf5;
  --color-primary-100: #d1fae5;
  --color-primary-200: #a7f3d0;
  --color-primary-300: #6ee7b7;
  --color-primary-400: #34d399;
  --color-primary-500: #10b981;
  --color-primary-600: #059669;
  --color-primary-700: #047857;
  --color-primary-800: #065f46;
  --color-primary-900: #064e3b;

  /* ── Accent palette (cool blue) ── */
  --color-accent-50: #eff6ff;
  --color-accent-100: #dbeafe;
  --color-accent-200: #bfdbfe;
  --color-accent-400: #60a5fa;
  --color-accent-500: #3b82f6;
  --color-accent-600: #2563eb;

  /* ── Neutral palette (slate) ── */
  --color-neutral-50: #f8fafc;
  --color-neutral-100: #f1f5f9;
  --color-neutral-200: #e2e8f0;
  --color-neutral-300: #cbd5e1;
  --color-neutral-400: #94a3b8;
  --color-neutral-500: #64748b;
  --color-neutral-600: #475569;
  --color-neutral-700: #334155;
  --color-neutral-800: #1e293b;
  --color-neutral-900: #0f172a;

  /* ── Typography scale ── */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.8125rem;  /* 13px */
  --text-base: 0.9375rem; /* 15px */
  --text-md: 1rem;       /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.3rem;     /* ~21px */
  --text-2xl: 1.6rem;    /* ~26px */
  --text-3xl: 2rem;      /* 32px */

  /* ── Font stacks ── */
  --font-display: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;

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

  /* ── Layered shadows ── */
  --shadow-xs: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow-sm: 0 1px 3px rgb(15 23 42 / 0.08), 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-soft: 0 4px 12px -2px rgb(15 23 42 / 0.05), 0 2px 4px -2px rgb(15 23 42 / 0.08);
  --shadow-md: 0 8px 16px -2px rgb(15 23 42 / 0.06), 0 4px 6px -2px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 12px 24px -4px rgb(15 23 42 / 0.08), 0 6px 12px -3px rgb(15 23 42 / 0.06);
  --shadow-xl: 0 20px 30px -4px rgb(15 23 42 / 0.08), 0 10px 15px -4px rgb(15 23 42 / 0.06);
  --shadow-strong: 0 24px 38px -6px rgb(15 23 42 / 0.14), 0 12px 18px -6px rgb(15 23 42 / 0.12);
  --shadow-glow-primary: 0 0 0 3px rgba(16, 185, 129, 0.15);

  /* ── Spacing scale ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* ── Semantic aliases (preserved) ── */
  --bg-page: var(--color-bg);
  --bg-surface: var(--color-surface);
  --bg-soft: #f1f5f9;
  --text-main: var(--color-text-main);
  --text-muted: var(--color-text-muted);
  --line-soft: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand-dark: #1e293b;
  --brand-accent: var(--color-primary);
  --brand-accent-strong: var(--color-primary-dark);
  --cart-drawer-width: min(380px, 92vw);
  --cart-drawer-top-offset: 78px;
  --cart-drawer-bottom-gap: 12px;
  --warning-bg: #fff8e6;
  --warning-text: #8b5b00;
  --error-bg: #ffeef0;
  --error-text: #ae2134;
  --success-bg: #eaf9ef;
  --success-text: #16653f;

  /* ── Transitions ── */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%; /* prevent iOS font inflation on orientation change */
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text-main);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
  color: var(--color-neutral-900);
  letter-spacing: -0.02em;
  line-height: 1.3;
  font-family: var(--font-display);
}

h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
}

h2 {
  font-size: var(--text-xl);
  font-weight: 600;
}

h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

body.drawer-open {
  overflow: hidden;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(27, 157, 98, 0.35);
  outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-ghost:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}
