/**
 * MATERI GLOBAL STYLES
 * Foundation CSS + Tailwind directives + Global custom properties
 */

/* ============================================================================
   TAILWIND DIRECTIVES
   ============================================================================ */

@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================================================
   CSS CUSTOM PROPERTIES (Design Tokens as CSS Variables)
   For use in CSS-in-JS and dynamic styling
   ============================================================================ */

:root {
  /* Spacing */
  --spacing-px: 1px;
  --spacing-0: 0;
  --spacing-1: 4px;
  --spacing-2: 8px;
  --spacing-3: 12px;
  --spacing-4: 16px;
  --spacing-5: 20px;
  --spacing-6: 24px;
  --spacing-8: 32px;
  --spacing-10: 40px;
  --spacing-12: 48px;

  /* Colors - Neutral */
  --color-neutral-50: #fafafa;
  --color-neutral-100: #f5f5f5;
  --color-neutral-200: #eeeeee;
  --color-neutral-300: #e0e0e0;
  --color-neutral-400: #bdbdbd;
  --color-neutral-500: #9e9e9e;
  --color-neutral-600: #757575;
  --color-neutral-700: #616161;
  --color-neutral-800: #424242;
  --color-neutral-900: #212121;

  /* Colors - Primary */
  --color-primary-500: #4ba8ff;
  --color-primary-600: #3184e6;
  --color-primary-700: #2563cc;
  --color-primary-800: #2050b3;

  /* Colors - Semantic */
  --color-text: #212121;
  --color-text-secondary: #616161;
  --color-text-tertiary: #9e9e9e;
  --color-background: #fafafa;
  --color-background-secondary: #f5f5f5;
  --color-border: #eeeeee;
  --color-interactive: #4ba8ff;

  /* Colors - Status */
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #06b6d4;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  --font-mono: Menlo, Monaco, 'Courier New', monospace;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-base: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Motion */
  --duration-fast: 75ms;
  --duration-standard: 150ms;
  --duration-slow: 300ms;
  --easing-out: cubic-bezier(0, 0, 0.2, 1);
  --easing-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   DARK MODE (Future enhancement with prefers-color-scheme)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --color-neutral-50: #121212;
    --color-neutral-100: #212121;
    --color-neutral-200: #424242;
    --color-neutral-300: #616161;
    --color-neutral-900: #fafafa;

    --color-background: #121212;
    --color-background-secondary: #212121;
    --color-text: #fafafa;
    --color-border: #424242;
  }
}

/* ============================================================================
   BASE STYLES
   ============================================================================ */

html {
  /* Prevent font scaling on orientation change */
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-background);
  transition: background-color var(--duration-standard) var(--easing-out);
}

/* ============================================================================
   FOCUS STYLES (Accessibility)
   ============================================================================ */

:focus-visible {
  outline: 2px solid var(--color-interactive);
  outline-offset: 2px;
}

/* Remove focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================================
   FORM ELEMENTS
   ============================================================================ */

input,
textarea,
select {
  font-family: inherit;
  font-size: 16px; /* Prevents zoom on iOS */
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ============================================================================
   SCROLLBAR STYLING (Webkit browsers)
   ============================================================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-background);
}

::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300);
  border-radius: var(--spacing-1);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-400);
}

/* ============================================================================
   RICH TEXT EDITOR STYLES
   ============================================================================ */

/* Placeholder for empty contenteditable */
.editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--color-neutral-400);
  pointer-events: none;
}

/* Dark mode placeholder color */
.dark .editor-content:empty::before {
  color: var(--color-neutral-500);
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  body {
    background: white;
    color: black;
  }
}
