/* ==========================================================================
   ToolKit Core Design System — Design Tokens, Typography & Reset
   ========================================================================== */

:root {
  /* Color Palette - Neutrals (Slate Scale) */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-surface-alt: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;
  --color-border-focus: #3b82f6;
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;
  --color-text-inverse: #ffffff;

  /* Color Palette - Brand (Indigo / Modern Blue) */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-active: #1e40af;
  --color-primary-bg: #eff6ff;
  --color-primary-border: #bfdbfe;

  /* Color Palette - Semantic States */
  --color-success: #16a34a;
  --color-success-hover: #15803d;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;

  --color-error: #dc2626;
  --color-error-hover: #b91c1c;
  --color-error-bg: #fef2f2;
  --color-error-border: #fecaca;

  --color-warning: #d97706;
  --color-warning-hover: #b45309;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;

  --color-info: #0284c7;
  --color-info-bg: #f0f9ff;
  --color-info-border: #bae6fd;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Fluid Font Sizes using clamp() for perfect mobile responsiveness */
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: clamp(1.35rem, 2vw + 1rem, 1.65rem); /* ~22px - 26px */
  --font-size-3xl: clamp(1.65rem, 3vw + 1rem, 2.15rem); /* ~26px - 34px */
  --font-size-4xl: clamp(2rem, 4vw + 1rem, 2.75rem);    /* ~32px - 44px */

  /* Elevation / Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.03);

  /* Radius */
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Spacing Scale */
  --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 */

  /* Layout Widths */
  --container-max-width: 1200px;
  --tool-workspace-width: 960px;
  --header-height: 64px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   CSS Modern Reset & Base Rules
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text-main);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

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

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-main);
  letter-spacing: -0.015em;
}

h1 { font-size: var(--font-size-4xl); margin-bottom: var(--space-3); }
h2 { font-size: var(--font-size-3xl); margin-bottom: var(--space-3); }
h3 { font-size: var(--font-size-2xl); margin-bottom: var(--space-2); }
h4 { font-size: var(--font-size-xl);  margin-bottom: var(--space-2); }

p {
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
  line-height: 1.6;
}

p:last-child {
  margin-bottom: 0;
}

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

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

code, pre, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

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

.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;
}
