/**
 * SoulEngine Design System
 * Deep Space Obsidian Theme - Warm ember accents on charcoal depths
 */

/* ========================================
   CSS Variables / Design Tokens
   ======================================== */

:root {
  /* Color Palette - Deep Space Obsidian */
  --color-bg-primary: #0c0d10;
  --color-bg-secondary: #141414;
  --color-bg-tertiary: #1a1a1a;
  --color-bg-elevated: #212121;
  --color-bg-hover: #2a2a2a;

  /* Surface colors - subtle warmth */
  --color-surface-1: rgba(255, 245, 238, 0.02);
  --color-surface-2: rgba(255, 245, 238, 0.04);
  --color-surface-3: rgba(255, 245, 238, 0.06);
  --color-surface-raised: rgba(255, 245, 238, 0.08);

  /* Text colors - warm off-whites */
  --color-text-primary: #f5f0eb;
  --color-text-secondary: #a8a099;
  --color-text-tertiary: #6b6560;
  --color-text-muted: #4a4643;
  --color-text-on-accent: #ffffff;

  /* Accent colors - Ember/Copper tones */
  --color-accent-primary: #e07850;
  --color-accent: #e07850;
  --color-accent-primary-hover: #eb9070;
  --color-accent-primary-muted: rgba(224, 120, 80, 0.15);
  --accent-primary-rgb: 224, 120, 80;
  --color-accent-secondary: #c9a86c;
  --color-accent-secondary-muted: rgba(201, 168, 108, 0.15);

  /* Pillar colors - Pastel tones */
  --color-pillar-core: #f1a6c4;      /* Pink (pinned identity) */
  --color-pillar-daily: #f5c27a;     /* Light Orange */
  --color-pillar-weekly: #f5e27a;    /* Light Yellow */
  --color-pillar-persona: #83e0c6;   /* Teal (pinned identity) */
  --color-pillar-mcp: #b6a6f2;       /* Lavender (pinned identity) */

  /* Semantic colors */
  --color-success: #5cb87a;
  --color-success-muted: rgba(92, 184, 122, 0.15);
  --color-warning: #d9a643;
  --color-warning-muted: rgba(217, 166, 67, 0.15);
  --color-error: #d95454;
  --color-error-muted: rgba(217, 84, 84, 0.15);
  --color-info: #5494d9;
  --color-info-muted: rgba(84, 148, 217, 0.15);

  /* Border colors */
  --color-border: rgba(255, 245, 238, 0.08);
  --color-border-hover: rgba(255, 245, 238, 0.15);
  --color-border-focus: var(--color-accent-primary);

  /* Brain visualization base color */
  --color-brain-base: rgba(168, 160, 153, 0.4);
  --color-brain-node: rgba(168, 160, 153, 0.6);
  --color-brain-edge: rgba(168, 160, 153, 0.25);

  /* Typography */
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-wordmark: 'Fraunces', 'Georgia', serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Font sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;
  --text-7xl: 4.5rem;

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

  /* Line heights */
  --leading-tight: 1.1;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Letter spacing */
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;

  /* Spacing */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-1-5: 0.375rem;
  --space-2: 0.5rem;
  --space-2-5: 0.625rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* 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 - warm tinted */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5), 0 8px 10px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px rgba(224, 120, 80, 0.25);
  --shadow-glow-accent: 0 0 40px rgba(224, 120, 80, 0.35);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
  --transition-slower: 600ms ease;

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-tooltip: 500;

  /* Layout */
  --nav-height: 72px;
  --sidebar-width: 280px;
  --content-max-width: 1400px;
}

/* ========================================
   Base Styles
   ======================================== */

*, *::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-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
}

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

h1 {
  font-size: var(--text-4xl);
}

h2 {
  font-size: var(--text-2xl);
}

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

h4 {
  font-size: var(--text-lg);
}

h5 {
  font-size: var(--text-base);
}

h6 {
  font-size: var(--text-sm);
}

p {
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

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

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface-2);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  background: var(--color-bg-tertiary);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

/* ========================================
   Utility Classes
   ======================================== */

.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.text-gradient {
  background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient-pillar-core {
  background: linear-gradient(135deg, var(--color-pillar-core), var(--color-pillar-daily));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient-pillar-persona {
  background: linear-gradient(135deg, var(--color-pillar-persona), var(--color-pillar-mcp));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-secondary {
  color: var(--color-text-secondary);
}

.text-center {
  text-align: center;
}

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

/* Subtle grain texture overlay */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Selection */
::selection {
  background: var(--color-accent-primary-muted);
  color: var(--color-text-primary);
}

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--color-accent-primary);
  outline-offset: 2px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ========================================
   Animation Utilities
   ======================================== */

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

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

@keyframes fadeInDown {
  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);
  }
}

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

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

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes glow {
  0%, 100% { 
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(224, 120, 80, 0);
  }
  50% { 
    filter: brightness(1.2);
    box-shadow: 0 0 30px rgba(224, 120, 80, 0.3);
  }
}

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

.animate-fade-in-up {
  animation: fadeInUp var(--transition-slow) ease forwards;
}

.animate-fade-in-down {
  animation: fadeInDown var(--transition-slow) ease forwards;
}

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

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

/* ========================================
   Light Theme Override
   ======================================== */

.light-theme {
  --color-bg-primary: #faf8f5;
  --color-bg-secondary: #ffffff;
  --color-bg-tertiary: #f2efe9;
  --color-bg-elevated: #ffffff;
  --color-bg-hover: #e8e5de;

  --color-surface-1: rgba(0, 0, 0, 0.02);
  --color-surface-2: rgba(0, 0, 0, 0.04);
  --color-surface-3: rgba(0, 0, 0, 0.06);

  --color-text-primary: #1a1816;
  --color-text-secondary: #5a5651;
  --color-text-tertiary: #8a857f;
  --color-text-muted: #aaa59f;

  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-hover: rgba(0, 0, 0, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.12), 0 4px 6px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15), 0 8px 10px rgba(0, 0, 0, 0.08);

  --color-brain-base: rgba(90, 86, 81, 0.4);
  --color-brain-node: rgba(90, 86, 81, 0.6);
  --color-brain-edge: rgba(90, 86, 81, 0.25);
}

.light-theme .grain-overlay {
  opacity: 0.02;
}
