/**
 * What My Friends Eat - Base Styles & Design Tokens
 * Scandinavian design: minimal, calm, functional, human-centered
 * Clarity over decoration, warmth over flash
 */

/* ===== Design Tokens ===== */
:root {
  /* Scandinavian Primary - Muted slate blue */
  --color-primary: #64748B;      /* Slate */
  --color-primary-dark: #475569;
  --color-primary-light: #94A3B8;

  /* Secondary - Warm sand/beige */
  --color-secondary: #78716C;    /* Stone */
  --color-secondary-dark: #57534E;

  /* Accent - Soft sage (used sparingly) */
  --color-accent: #6B8E7D;       /* Muted sage */
  --color-accent-dark: #5A7A6A;

  /* Warm neutral for highlights */
  --color-warm: #D6CFC7;         /* Warm sand */
  --color-warm-dark: #C4BBB0;

  /* Core Neutrals - The foundation */
  --color-bg: #FAFAF9;           /* Off-white with warmth */
  --color-surface: #FFFFFF;
  --color-surface-elevated: #FFFFFF;
  --color-text: #1C1917;         /* Soft black, not pure */
  --color-text-secondary: #57534E;
  --color-muted: #A8A29E;
  --color-border: #E7E5E4;
  --color-border-light: #F5F5F4;

  /* Semantic colors - Muted versions */
  --color-success: #6B8E7D;      /* Sage green */
  --color-warning: #D4A574;      /* Muted clay */
  --color-danger: #B87070;       /* Muted rose */
  --color-info: #7C9EB2;         /* Fjord blue */

  /* Typography - Scandinavian: clean sans-serif throughout */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', monospace;

  /* Font sizes (fluid scale) */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 0.9375rem);
  --text-base: clamp(1rem, 0.925rem + 0.375vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1rem + 0.5vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.25rem + 1.25vw, 2rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.875vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.75rem + 2.5vw, 3.5rem);
  --text-5xl: clamp(3rem, 2rem + 5vw, 5rem);

  /* Line heights */
  --leading-tight: 1.2;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Spacing scale (8px base) */
  --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 */
  --space-24: 6rem;     /* 96px */

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows - Subtle, soft, Scandinavian */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03);
  --shadow-md: 0 2px 8px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 4px 16px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 8px 24px -6px rgb(0 0 0 / 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* Z-index scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* Container widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1536px;
}

/* Dark mode variables */
:root.dark,
[data-theme="dark"] {
  --color-bg: #1C1917;           /* Warm dark, not pure black */
  --color-surface: #262322;
  --color-surface-elevated: #2E2A28;
  --color-text: #FAFAF9;
  --color-text-secondary: #A8A29E;
  --color-muted: #78716C;
  --color-border: #3D3835;
  --color-border-light: #332F2D;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
  --shadow-md: 0 2px 8px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 4px 16px -4px rgb(0 0 0 / 0.4);
}

/* System preference (when theme is set to "system" or not set) */
@media (prefers-color-scheme: dark) {
  [data-theme="system"],
  :root:not([data-theme]) {
    --color-bg: #1C1917;
    --color-surface: #262322;
    --color-surface-elevated: #2E2A28;
    --color-text: #FAFAF9;
    --color-text-secondary: #A8A29E;
    --color-muted: #78716C;
    --color-border: #3D3835;
    --color-border-light: #332F2D;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 2px 8px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 4px 16px -4px rgb(0 0 0 / 0.4);
  }
}

/* Explicit light mode (overrides system preference) */
[data-theme="light"] {
  --color-bg: #FAFAF9;
  --color-surface: #FFFFFF;
  --color-surface-elevated: #FFFFFF;
  --color-text: #1C1917;
  --color-text-secondary: #57534E;
  --color-muted: #A8A29E;
  --color-border: #E7E5E4;
  --color-border-light: #F5F5F4;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03);
  --shadow-md: 0 2px 8px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 4px 16px -4px rgb(0 0 0 / 0.08);
}

/* ===== Base Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -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: 100vh;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); font-weight: 700; }

p {
  margin-bottom: var(--space-4);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

.section {
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}

@media (min-width: 768px) {
  .section {
    padding-top: var(--space-24);
    padding-bottom: var(--space-24);
  }
}

/* ===== Grid System ===== */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.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; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ===== Spacing Utilities ===== */
.mt-2 { margin-top: var(--space-2); }
.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-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.my-4 { margin-top: var(--space-4); margin-bottom: var(--space-4); }
.my-8 { margin-top: var(--space-8); margin-bottom: var(--space-8); }

.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }

/* ===== Text Utilities ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-muted { color: var(--color-muted); }
.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-secondary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.font-display { font-family: var(--font-display); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

/* ===== Visibility ===== */
.hidden { display: none !important; }
.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;
}

@media (max-width: 639px) {
  .sm\:hidden { display: none !important; }
}
@media (min-width: 640px) {
  .sm\:block { display: block !important; }
}
@media (max-width: 767px) {
  .md\:hidden { display: none !important; }
}
@media (min-width: 768px) {
  .md\:block { display: block !important; }
  .md\:flex { display: flex !important; }
}

/* ===== Images ===== */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== Focus States ===== */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===== Selection ===== */
::selection {
  background-color: var(--color-primary);
  color: white;
}
