/**
 * TerpTune Design System v4.0
 * SMS Design Language + Terpene Color System
 *
 * Aesthetic: Dark, typographic, semantic color encoding
 * Primary accent: Linalool Indigo (#6366f1)
 * Typography: Inter + JetBrains Mono
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* ============================================
   * COLOR PALETTE - v4.0 Terpene System
   * ============================================ */

  /* Backgrounds */
  --color-bg: #0a0a0b;
  --color-surface: #111113;
  --color-surface-raised: #1a1a1d;
  --color-surface-hover: #222225;

  /* Borders */
  --color-border: #2c2c2e;
  --color-border-subtle: #1c1c1e;
  --color-border-strong: #3a3a3c;

  /* Text */
  --color-text-primary: #ffffff;
  --color-text-secondary: #a1a1a6;
  --color-text-tertiary: #6e6e73;
  --color-text-inverse: #0a0a0b;

  /* Primary Accent - Linalool (Translocation, TerpTune signature) */
  --color-accent: #6366f1;
  --color-accent-hover: #818cf8;
  --color-accent-muted: #4f46e5;
  --color-accent-subtle: rgba(99, 102, 241, 0.15);
  --color-accent-glow: rgba(99, 102, 241, 0.25);

  /* ============================================
   * SCREEN-SPECIFIC ACCENT COLORS
   * Each screen has its own terpene identity
   * ============================================ */
  --screen-karl: #6366f1;        /* Linalool indigo - primary */
  --screen-profile: #8b5cf6;     /* Nerolidol purple */
  --screen-stash: #10b981;       /* Limonene green */
  --screen-nearme: #3b82f6;      /* Pinene blue */

  /* ============================================
   * TERPENE COLOR SYSTEM
   * Each color encodes neurochemical meaning
   * ============================================ */

  /* Caryophyllene - Body anchor, grounding */
  --terpene-caryophyllene: #20B9B1;
  --terpene-caryophyllene-light: #2dd4c8;
  --terpene-caryophyllene-subtle: rgba(32, 185, 177, 0.15);
  --terpene-caryophyllene-glow: rgba(32, 185, 177, 0.3);

  /* Myrcene - Fog, warning, sedation */
  --terpene-myrcene: #f59e0b;
  --terpene-myrcene-light: #fbbf24;
  --terpene-myrcene-subtle: rgba(245, 158, 11, 0.15);
  --terpene-myrcene-glow: rgba(245, 158, 11, 0.3);

  /* Limonene - Uplift, energy, clarity */
  --terpene-limonene: #10b981;
  --terpene-limonene-light: #34d399;
  --terpene-limonene-subtle: rgba(16, 185, 129, 0.15);
  --terpene-limonene-glow: rgba(16, 185, 129, 0.3);

  /* Linalool - Translocation, dissociation */
  --terpene-linalool: #6366f1;
  --terpene-linalool-light: #818cf8;
  --terpene-linalool-subtle: rgba(99, 102, 241, 0.15);
  --terpene-linalool-glow: rgba(99, 102, 241, 0.3);

  /* Nerolidol - Deep translocation */
  --terpene-nerolidol: #8b5cf6;
  --terpene-nerolidol-light: #a78bfa;
  --terpene-nerolidol-subtle: rgba(139, 92, 246, 0.15);
  --terpene-nerolidol-glow: rgba(139, 92, 246, 0.3);

  /* Pinene - Clarity, focus */
  --terpene-pinene: #3b82f6;
  --terpene-pinene-light: #60a5fa;
  --terpene-pinene-subtle: rgba(59, 130, 246, 0.15);
  --terpene-pinene-glow: rgba(59, 130, 246, 0.3);

  /* Terpinolene - Chaos, carnival, unpredictable */
  --terpene-terpinolene: #ec4899;
  --terpene-terpinolene-light: #f472b6;
  --terpene-terpinolene-subtle: rgba(236, 72, 153, 0.15);
  --terpene-terpinolene-glow: rgba(236, 72, 153, 0.3);

  /* Semantic Colors (mapped to terpenes) */
  --color-warning: var(--terpene-myrcene);
  --color-warning-bg: var(--terpene-myrcene-subtle);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.15);
  --color-success: var(--terpene-limonene);
  --color-success-bg: var(--terpene-limonene-subtle);
  --color-info: var(--terpene-pinene);
  --color-info-bg: var(--terpene-pinene-subtle);

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

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;

  --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: 1.5rem;   /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

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

  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ============================================
   * BORDER RADIUS
   * ============================================ */

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* ============================================
   * SHADOWS & EFFECTS
   * ============================================ */

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--color-accent-glow);
  --shadow-glow-lg: 0 0 40px var(--color-accent-glow);

  /* ============================================
   * TRANSITIONS
   * ============================================ */

  --transition-fast: 0.1s ease;
  --transition-base: 0.15s ease;
  --transition-slow: 0.25s ease;

  /* ============================================
   * Z-INDEX SCALE
   * ============================================ */

  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;

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

  --nav-height: 64px;
  --header-height: 56px;
  --max-width-app: 480px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================
 * RESET & BASE STYLES
 * ============================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ============================================
 * TYPOGRAPHY UTILITIES
 * ============================================ */

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

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p { color: var(--color-text-primary); }

.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-accent { color: var(--color-accent); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }

.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

/* ============================================
 * BUTTON COMPONENTS
 * ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--font-size-base);
}

/* ============================================
 * CARD COMPONENTS
 * ============================================ */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.card-raised {
  background: var(--color-surface-raised);
}

.card-interactive {
  cursor: pointer;
  transition: all var(--transition-base);
}

.card-interactive:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-strong);
}

.card-interactive:active {
  transform: scale(0.98);
}

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

.input {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  transition: all var(--transition-base);
}

.input::placeholder {
  color: var(--color-text-tertiary);
}

.input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea.input {
  resize: none;
  min-height: 48px;
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

.form-group {
  margin-bottom: var(--space-4);
}

/* ============================================
 * BADGE & TAG COMPONENTS
 * ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
}

.badge-accent {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* ============================================
 * INDICATOR COMPONENTS
 * ============================================ */

.indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-text-tertiary);
}

.indicator-dot.active {
  background: var(--color-accent);
}

.indicator-dot.warning {
  background: var(--color-warning);
}

.indicator-dot.danger {
  background: var(--color-danger);
}

/* ============================================
 * DIVIDER
 * ============================================ */

.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-4) 0;
}

.divider-subtle {
  background: var(--color-border-subtle);
}

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

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Flexbox utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* Spacing utilities */
.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

.m-0 { margin: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }

/* Width utilities */
.w-full { width: 100%; }
.max-w-app { max-width: var(--max-width-app); }

/* Text utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

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

/* Border utilities */
.border { border: 1px solid var(--color-border); }
.border-accent { border-color: var(--color-accent); }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* Background utilities */
.bg-surface { background: var(--color-surface); }
.bg-raised { background: var(--color-surface-raised); }

/* ============================================
 * ANIMATIONS
 * ============================================ */

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

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

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

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

.animate-fade-in { animation: fadeIn var(--transition-slow) ease-out; }
.animate-slide-up { animation: slideUp var(--transition-slow) ease-out; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }

/* ============================================
 * LOADING STATES
 * ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-raised) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

/* ============================================
 * SCROLLBAR STYLING
 * ============================================ */

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

::-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);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

/* ============================================
 * FOCUS VISIBLE (Accessibility)
 * ============================================ */

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

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}
