/**
 * ImageIQ Design System - Modern Editorial Studio
 *
 * A refined, publisher-focused aesthetic with editorial warmth,
 * distinctive typography, and professional polish.
 */

/* ============================================================================
   CSS VARIABLES - Design Tokens
   ============================================================================ */

:root {
  /* ===== Color Palette - Editorial Warmth ===== */

  /* Neutrals - Warm, sophisticated grays */
  --color-bg-primary: #fefefe;          /* Warm white, not stark */
  --color-bg-secondary: #f8f7f6;        /* Subtle cream undertone */
  --color-bg-tertiary: #f1efed;         /* Deeper cream for cards */
  --color-bg-elevated: #ffffff;         /* Pure white for modals/overlays */

  --color-text-primary: #1a1a1a;        /* Deep charcoal, not pure black */
  --color-text-secondary: #4a4a4a;      /* Mid gray for body text */
  --color-text-tertiary: #6a6a6a;       /* Light gray for labels */
  --color-text-muted: #9a9a9a;          /* Very light gray for placeholders */

  --color-border: #e5e3e1;              /* Warm border color */
  --color-border-light: #f0eeec;        /* Very light border */
  --color-border-dark: #d5d3d1;         /* Darker border for emphasis */

  /* Brand Colors - Editorial accents */
  --color-primary: #c7522a;             /* Editorial rust/terracotta */
  --color-primary-hover: #a8451f;       /* Darker on hover */
  --color-primary-light: #e8866a;       /* Light variant */
  --color-primary-pale: #f9e8e3;        /* Very pale for backgrounds */

  --color-secondary: #4a6860;           /* Deep sage green */
  --color-secondary-hover: #3d5550;     /* Darker sage */
  --color-secondary-light: #7a9990;     /* Light sage */
  --color-secondary-pale: #e8efed;      /* Pale sage for backgrounds */

  /* Semantic Colors */
  --color-success: #4a6860;             /* Sage green */
  --color-success-bg: #e8f5f1;
  --color-warning: #d97706;             /* Amber */
  --color-warning-bg: #fef3c7;
  --color-error: #c7522a;               /* Use primary rust for errors */
  --color-error-bg: #fee2e2;
  --color-info: #2563eb;                /* Classic blue */
  --color-info-bg: #dbeafe;

  /* ===== Typography ===== */

  /* Font Families - Distinctive editorial choices */
  --font-display: 'Fraunces', 'Georgia', serif;     /* Editorial serif for headlines */
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;  /* Clean sans for UI */
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;  /* Technical monospace */

  /* Font Sizes - Modular scale (1.25 ratio) */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */
  --text-5xl: 3rem;        /* 48px */
  --text-6xl: 3.75rem;     /* 60px */

  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;

  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* ===== Spacing - 8px base unit ===== */
  --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 */

  /* ===== Layout ===== */
  --container-xs: 640px;
  --container-sm: 768px;
  --container-md: 1024px;
  --container-lg: 1280px;
  --container-xl: 1536px;

  --sidebar-width: 280px;
  --header-height: 72px;
  --panel-width: 420px;

  /* ===== Borders & Radius ===== */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --border-width: 1px;
  --border-width-thick: 2px;

  /* ===== Shadows - Refined, editorial quality ===== */
  --shadow-sm: 0 1px 2px 0 rgba(26, 26, 26, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(26, 26, 26, 0.08),
               0 2px 4px -1px rgba(26, 26, 26, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(26, 26, 26, 0.08),
               0 4px 6px -2px rgba(26, 26, 26, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(26, 26, 26, 0.08),
               0 10px 10px -5px rgba(26, 26, 26, 0.03);
  --shadow-2xl: 0 25px 50px -12px rgba(26, 26, 26, 0.15);

  /* Inner shadows for depth */
  --shadow-inner: inset 0 2px 4px 0 rgba(26, 26, 26, 0.06);

  /* ===== Transitions ===== */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Easing curves */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ===== Z-index layers ===== */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-fixed: 1200;
  --z-modal-backdrop: 1300;
  --z-modal: 1400;
  --z-popover: 1500;
  --z-tooltip: 1600;
}

/* ============================================================================
   DARK THEME - Editorial Night Mode
   ============================================================================ */

[data-theme="dark"] {
  --color-bg-primary: #1a1a1a;
  --color-bg-secondary: #242424;
  --color-bg-tertiary: #2d2d2d;
  --color-bg-elevated: #333333;

  --color-text-primary: #fefefe;
  --color-text-secondary: #d1d1d1;
  --color-text-tertiary: #a8a8a8;
  --color-text-muted: #6a6a6a;

  --color-border: #3a3a3a;
  --color-border-light: #2d2d2d;
  --color-border-dark: #4a4a4a;

  /* Adjust accent colors for dark mode */
  --color-primary: #e8866a;
  --color-primary-hover: #f0a589;
  --color-primary-light: #f5baa9;
  --color-primary-pale: #3a2722;

  --color-secondary: #7a9990;
  --color-secondary-hover: #90aea5;
  --color-secondary-light: #a5c3ba;
  --color-secondary-pale: #293832;

  /* Adjusted shadows for dark mode */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4),
               0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4),
               0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4),
               0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* ============================================================================
   GLOBAL RESETS & BASE STYLES
   ============================================================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--font-normal);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  background-color: var(--color-bg-primary);
  overflow-x: hidden;

  /* Subtle paper texture overlay */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(26, 26, 26, 0.01) 2px,
      rgba(26, 26, 26, 0.01) 4px
    );
}

/* ============================================================================
   TYPOGRAPHY SYSTEM
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
  font-feature-settings: 'liga' 1, 'calt' 1, 'ss01' 1;
}

h1 {
  font-size: var(--text-5xl);
  font-weight: var(--font-semibold);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-4xl);
  font-weight: var(--font-medium);
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--text-3xl);
  font-weight: var(--font-medium);
}

h4 {
  font-size: var(--text-2xl);
  font-weight: var(--font-medium);
}

h5 {
  font-size: var(--text-xl);
  font-weight: var(--font-medium);
}

h6 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

p {
  margin-bottom: var(--space-4);
  max-width: 65ch;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

strong, b {
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
}

em, i {
  font-style: italic;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.125em 0.375em;
  background-color: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  padding: var(--space-4);
  background-color: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  padding: 0;
  background: none;
  border: none;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

/* Container */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.container-sm { max-width: var(--container-sm); }
.container-md { max-width: var(--container-md); }
.container-lg { max-width: var(--container-lg); }
.container-xl { max-width: var(--container-xl); }

/* Text utilities */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-muted { color: var(--color-text-muted); }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }

.font-display { font-family: var(--font-display); }
.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); }

.font-light { font-weight: var(--font-light); }
.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

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

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

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.animate-fade-in {
  animation: fadeIn var(--transition-base) var(--ease-out);
}

.animate-slide-in-up {
  animation: slideInUp var(--transition-base) var(--ease-out);
}

.animate-slide-in-down {
  animation: slideInDown var(--transition-base) var(--ease-out);
}

.animate-scale-in {
  animation: scaleIn var(--transition-base) var(--ease-out);
}

/* Stagger animation delays */
.animate-delay-1 { animation-delay: 100ms; }
.animate-delay-2 { animation-delay: 200ms; }
.animate-delay-3 { animation-delay: 300ms; }
.animate-delay-4 { animation-delay: 400ms; }
.animate-delay-5 { animation-delay: 500ms; }
