/**
 * PixAtlas Design Tokens
 * Precision Instrument Theme
 */

:root {
  /* ========================================
     COLORS - Light Mode (Default)
     ======================================== */

  /* Backgrounds */
  --color-bg: #f8fafc;
  --color-bg-elevated: #ffffff;
  --color-surface-1: #ffffff;
  --color-surface-2: #f1f5f9;
  --color-surface-3: #e2e8f0;

  /* Borders - subtle rgba for soft definition */
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-subtle: rgba(0, 0, 0, 0.05);
  --color-border-strong: rgba(0, 0, 0, 0.12);

  /* Text */
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-text-disabled: #94a3b8;

  /* Accent - Dark Slate Gray #2f4f4f */
  --color-accent: #2f4f4f;
  --color-accent-hover: #3d6363;
  --color-accent-active: #1f3535;
  --color-accent-subtle: rgba(47, 79, 79, 0.1);

  /* Status Colors */
  --color-success: #16a34a;
  --color-success-subtle: rgba(22, 163, 74, 0.1);
  --color-warning: #d97706;
  --color-warning-subtle: rgba(217, 119, 6, 0.1);
  --color-danger: #dc2626;
  --color-danger-hover: #e74c4c;
  --color-danger-active: #b91c1c;
  --color-danger-subtle: rgba(220, 38, 38, 0.1);
  --color-info: #0284c7;
  --color-info-subtle: rgba(2, 132, 199, 0.1);

  /* Interactive States */
  --color-hover: rgba(0, 0, 0, 0.04);
  --color-active: rgba(0, 0, 0, 0.08);
  --color-selected: rgba(47, 79, 79, 0.12);
  --color-focus-ring: rgba(47, 79, 79, 0.4);

  /* Glass Material (iOS 26 Liquid Glass inspired) */
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-bg-dense: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-blur: blur(16px) saturate(180%);

  /* ========================================
     COLORS - Dark Mode
     ======================================== */
}

.dark-mode {
  /* Backgrounds - subtle elevation progression */
  --color-bg: #0c0c0e;
  --color-bg-elevated: #111113;
  --color-surface-1: #161618;
  --color-surface-2: #1c1c1f;
  --color-surface-3: #232326;

  /* Borders - rgba for soft definition */
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-subtle: rgba(255, 255, 255, 0.05);
  --color-border-strong: rgba(255, 255, 255, 0.12);

  /* Text */
  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-text-disabled: #475569;

  /* Accent - Dark Slate Gray (lighter for dark mode visibility) */
  --color-accent: #8fafaf;
  --color-accent-hover: #a3bfbf;
  --color-accent-active: #7b9b9b;
  --color-accent-subtle: rgba(143, 175, 175, 0.12);

  /* Status Colors - slightly desaturated for dark mode */
  --color-success: #22c55e;
  --color-success-subtle: rgba(34, 197, 94, 0.12);
  --color-warning: #eab308;
  --color-warning-subtle: rgba(234, 179, 8, 0.12);
  --color-danger: #ef4444;
  --color-danger-hover: #f87171;
  --color-danger-active: #dc2626;
  --color-danger-subtle: rgba(239, 68, 68, 0.12);
  --color-info: #38bdf8;
  --color-info-subtle: rgba(56, 189, 248, 0.12);

  /* Interactive States */
  --color-hover: rgba(255, 255, 255, 0.05);
  --color-active: rgba(255, 255, 255, 0.08);
  --color-selected: rgba(143, 175, 175, 0.15);
  --color-focus-ring: rgba(143, 175, 175, 0.4);

  /* Glass Material (dark mode) */
  --glass-bg: rgba(20, 20, 20, 0.6);
  --glass-bg-dense: rgba(20, 20, 20, 0.8);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(16px) saturate(180%);
}

/* ========================================
   SHARED TOKENS (both modes)
   ======================================== */

:root {
  /* ========================================
     TYPOGRAPHY
     ======================================== */

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Font Sizes */
  --text-xs: 0.6875rem;    /* 11px */
  --text-sm: 0.8125rem;    /* 13px */
  --text-base: 0.9375rem;  /* 15px */
  --text-lg: 1.0625rem;    /* 17px */
  --text-xl: 1.3125rem;    /* 21px */
  --text-2xl: 1.6875rem;   /* 27px */
  --text-3xl: 2.125rem;    /* 34px */

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

  /* Line Heights */
  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Letter Spacing */
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.02em;

  /* ========================================
     SPACING (4px base unit)
     ======================================== */

  --space-0: 0;
  --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 */

  /* ========================================
     BORDERS & RADIUS
     ======================================== */

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

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

  /* ========================================
     SHADOWS - Subtle, borders-first approach
     ======================================== */

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.06), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.06), 0 8px 16px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.08), 0 16px 32px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 0 1px var(--color-border-strong);

  /* ========================================
     MOTION
     ======================================== */

  --duration-instant: 50ms;
  --duration-fast: 100ms;
  --duration-normal: 150ms;
  --duration-slow: 250ms;
  --duration-slower: 350ms;

  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --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);
  --ease-spring: cubic-bezier(0.22, 0.68, 0, 1);

  /* ========================================
     Z-INDEX LAYERS
     ======================================== */

  --z-base: 0;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-fixed: 30;
  --z-overlay: 40;
  --z-modal: 50;
  --z-popover: 60;
  --z-toast: 70;
  --z-tooltip: 80;

  /* ========================================
     LAYOUT
     ======================================== */

  --sidebar-width: 280px;
  --topbar-height: 56px;
  --panel-width: 360px;
}

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

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* ========================================
   FOCUS STYLES
   ======================================== */

:focus {
  outline: none;
}

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

/* Focus ring utility class */
.focus-ring:focus-visible {
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-accent);
}

/* ========================================
   SCROLLBAR STYLES
   ======================================== */

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

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-strong);
}

/* ========================================
   SELECTION STYLES
   ======================================== */

::selection {
  background: var(--color-accent-subtle);
  color: var(--color-text);
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   ANIMATION KEYFRAMES
   ======================================== */

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

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Skeleton loading animation */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-2) 25%,
    var(--color-surface-3) 50%,
    var(--color-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ========================================
   CONTINUOUS CURVATURE (Squircle)
   Progressive enhancement for iOS 26-style corners
   ======================================== */

@supports (corner-shape: squircle) {
  [class*="rounded-"] {
    corner-shape: squircle;
  }
}
