/* ═══════════════════════════════════════════════════════════════
   Kili Design System — Colors & Typography
   "Savanna" color system + DM Serif Display / DM Sans
   Source: design-spec/design-spec/02-color.md, 03-typography.md
   ═══════════════════════════════════════════════════════════════ */

/* ── Brand fonts — Inter (self-hosted variable) ── */
@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-VariableFont_opsz_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Italic-VariableFont_opsz_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* ── DM Serif Display — display/wordmark (Google Fonts) ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&display=swap');

/* ── Brand primitive tokens (theme-invariant) ── */
:root {
  /* Twiga — Savanna amber (warm earthy, giraffe-coat) */
  --amber:        #B8732A;
  --amber-muted:  #D9A56B;
  --amber-light:  #F2E1C9;
  --amber-pale:   #FAF3E8;
  --amber-dark:   #7A4A18;

  /* Twiga — Acacia bark (deep brown, sidebar) */
  --bark:         #2A211A;
  --bark-2:       #3A2E24;
  --bark-soft:    rgba(58,46,36,0.10);

  /* Swahili teal — success & growth */
  --teal:         #2E9E7A;
  --teal-muted:   #7ECDB8;
  --teal-light:   #D4F0E8;
  --teal-pale:    #F0FAF7;
  --teal-dark:    #1A6650;

  /* Kanga violet — identity & reference */
  --violet:       #7B4FC9;
  --violet-muted: #B49AE4;
  --violet-light: #EAE0F8;
  --violet-pale:  #F6F2FC;
  --violet-dark:  #4E2A8A;

  /* Laterite coral — alerts & errors */
  --coral:        #D95F3B;
  --coral-muted:  #F0A088;
  --coral-light:  #FAE3DC;
  --coral-pale:   #FDF3F0;
  --coral-dark:   #8F3018;

  /* ── Spacing scale ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-8:  48px;
  --space-10: 64px;
  --space-12: 80px;

  /* ── Border radius ── */
  --radius-none: 0px;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-pill: 9999px;

  /* ── Border width ── */
  --border-width-default: 1px;
  --border-width-thick:   2px;

  /* ── Shadows ── */
  --shadow-none:  none;
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:    0 4px 8px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 24px rgba(0,0,0,0.12);
  --shadow-focus: 0 0 0 3px rgba(45,111,204,0.30);

  /* ── Motion ── */
  --duration-instant: 0ms;
  --duration-fast:    100ms;
  --duration-base:    200ms;
  --duration-slow:    400ms;
  --easing-default:   ease;
  --easing-enter:     ease-out;
  --easing-exit:      ease-in;
  --easing-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── Shell dimensions ── */
  --sidebar-width-open:      240px;
  --sidebar-width-collapsed: 56px;
  --secondary-sidebar-width: 200px;
  --topbar-height:           56px;
  --secondary-nav-height:    44px;
  --auth-form-max-width:     480px;

  /* ── Breakpoints ── */
  --breakpoint-sm-min: 480px;
  --breakpoint-md-min: 768px;
  --breakpoint-lg-min: 1024px;
}

/* ── Light theme (default) ── */
[data-theme="light"],
:root {
  /* Backgrounds */
  --bg-page:        #FAFAF8;   /* Page canvas — warm cream */
  --bg-surface:     #FFFFFF;   /* Cards, panels, modals */
  --bg-surface-2:   #F5F2ED;   /* Nested surfaces, alternating rows */
  --bg-surface-3:   #EDE9E3;   /* Deeply nested, selected rows */
  --bg-sidebar:     #2A211A;   /* Navigation sidebar — Acacia bark */
  --bg-topbar:      #FFFFFF;   /* Top navigation bar */

  /* Text */
  --text-primary:   #2C2C2A;
  --text-secondary: #4A4845;
  --text-muted:     #888780;
  --text-subtle:    #B4B0A8;

  /* Borders */
  --border:         rgba(44,44,42,0.10);
  --border-soft:    rgba(44,44,42,0.06);
  --border-medium:  rgba(44,44,42,0.16);

  /* Interaction */
  --row-hover:      #FAF3E8;     /* Table row hover — warm amber tint */
  --input-bg:       #FFFFFF;
  --progress-bg:    #EDE9E3;
  --overlay-scrim:  rgba(44,44,42,0.45);
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg-page:        #1A1917;
  --bg-surface:     #242320;
  --bg-surface-2:   #2E2C29;
  --bg-surface-3:   #383530;
  --bg-sidebar:     #111110;
  --bg-topbar:      #242320;

  --text-primary:   #F0EDE8;
  --text-secondary: #C8C4BC;
  --text-muted:     #888780;
  --text-subtle:    #5A5854;

  --border:         rgba(240,237,232,0.10);
  --border-soft:    rgba(240,237,232,0.06);
  --border-medium:  rgba(240,237,232,0.16);

  --row-hover:      rgba(45,111,204,0.10);
  --input-bg:       #2E2C29;
  --progress-bg:    #383530;
  --overlay-scrim:  rgba(0,0,0,0.55);

  /* Brand fill variants adapt for dark surfaces */
  --amber-pale:     rgba(45,111,204,0.12);
  --amber-light:    rgba(45,111,204,0.22);
  --teal-pale:      rgba(46,158,122,0.10);
  --teal-light:     rgba(46,158,122,0.20);
  --violet-pale:    rgba(123,79,201,0.12);
  --violet-light:   rgba(123,79,201,0.22);
  --coral-pale:     rgba(217,95,59,0.10);
  --coral-light:    rgba(217,95,59,0.20);
}

/* ══════════════════════════════════════════════
   SEMANTIC CSS CLASSES
   ══════════════════════════════════════════════ */

/* ── Typography base ── */
body, .body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

/* Display — DM Serif Display, hero text */
.display {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.display-italic {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 400;
  font-style: italic;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Headings */
.h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.h2 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}
.h3 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: clamp(18px, 2.5vw, 22px);
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}
.h4 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary);
}

/* Body */
.body-lg {
  font-size: 18px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-primary);
  max-width: 65ch;
}
.body {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
}
.body-sm {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* UI text */
.label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}
.caption {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}
.overline {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.code {
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--violet);
  background: var(--violet-pale);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

/* Semantic text colors */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-subtle    { color: var(--text-subtle); }
.text-blue      { color: var(--amber); } /* alias: --amber now = Kili Blue */
.text-amber     { color: var(--amber); }
.text-teal      { color: var(--teal); }
.text-violet    { color: var(--violet); }
.text-coral     { color: var(--coral); }

/* ── Base reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Utility ── */
.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;
}
