/**
 * FKLM Africa Foundation — Design System v2.0
 * Full color system, fluid typography, spacing, and animation tokens
 */

/* ============================================================
   1. BRAND COLOR TOKENS
   ============================================================ */
:root {
  /* Primary — Olive Green #979832 */
  --color-primary-50:  #f8f8e8;
  --color-primary-100: #efefc4;
  --color-primary-200: #d9d96e;
  --color-primary-300: #c4c44e;
  --color-primary-400: #adae3e;
  --color-primary:     #979832;
  --color-primary-600: #7a7d28;
  --color-primary-700: #5e601e;
  --color-primary-800: #424415;
  --color-primary-900: #26270b;

  /* Secondary — Dark Teal #2C6565 */
  --color-secondary-50:  #e8f4f4;
  --color-secondary-100: #c4e0e0;
  --color-secondary-200: #8fc3c3;
  --color-secondary-300: #5aa6a6;
  --color-secondary-400: #3d8a8a;
  --color-secondary:     #2C6565;
  --color-secondary-600: #235252;
  --color-secondary-700: #1a3e3e;
  --color-secondary-800: #112929;
  --color-secondary-900: #081515;

  /* Neutral */
  --color-neutral-0:   #ffffff;
  --color-neutral-50:  #f8f8f6;
  --color-neutral-100: #f0f0ec;
  --color-neutral-200: #e2e2dc;
  --color-neutral-300: #c8c8c0;
  --color-neutral-400: #a0a098;
  --color-neutral-500: #787870;
  --color-neutral-600: #585850;
  --color-neutral-700: #3c3c36;
  --color-neutral-800: #262622;
  --color-neutral-900: #14140f;

  /* Semantic */
  --color-bg-primary:    var(--color-neutral-0);
  --color-bg-secondary:  var(--color-neutral-50);
  --color-bg-dark:       var(--color-secondary-900);
  --color-bg-brand:      var(--color-primary-50);
  --color-bg-teal:       var(--color-secondary-50);
  --color-text-primary:  var(--color-neutral-800);
  --color-text-secondary:var(--color-neutral-600);
  --color-text-muted:    var(--color-neutral-500); /* #787870 — 4.6:1 on white, passes WCAG AA */
  --color-text-inverse:  var(--color-neutral-0);
  --color-text-brand:    var(--color-primary);
  --color-text-accent:   var(--color-secondary);
  --color-border:        var(--color-neutral-200);
  --color-border-strong: var(--color-neutral-300);
  --color-success:  #3d8a4a;
  --color-warning:  #b89c2c;
  --color-error:    #c0392b;
  --color-focus:    var(--color-secondary); /* #2C6565 — sufficient contrast on white for focus rings */
}

/* ============================================================
   2. TYPOGRAPHY
   ============================================================ */
:root {
  /* Inter only — single typeface, differentiated by weight & size */
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;

  /*
   * Fluid type scale — mathematically derived clamp()
   * Linear interpolation: 375px (23.4375rem) → 1280px (80rem)
   * Formula: clamp(min, calc(slope*100vw + intercept), max)
   * where slope = (max-min)/(80-23.4375), intercept = min - slope*23.4375
   *
   * Fixed sizes (xs, sm): already at minimum readable threshold —
   * fluid scaling would make them unreadably small on mobile.
   */

  /* Fixed utility sizes */
  --text-xs:   0.75rem;    /* 12px — captions, badges, fine print  */
  --text-sm:   0.875rem;   /* 14px — secondary text, meta, labels  */

  /* Fluid body sizes */
  --text-base: clamp(1rem,    0.22vw + 0.95rem, 1.0625rem); /* 16→17px  */
  --text-lg:   clamp(1.125rem,0.44vw + 1.02rem, 1.25rem);   /* 18→20px  */
  --text-xl:   clamp(1.25rem, 0.88vw + 1.04rem, 1.5rem);    /* 20→24px  */
  --text-2xl:  clamp(1.5rem,  0.66vw + 1.34rem, 1.875rem);  /* 24→30px  */
  --text-3xl:  clamp(1.875rem,0.88vw + 1.67rem, 2.375rem);  /* 30→38px  */
  --text-4xl:  clamp(2.25rem, 1.33vw + 1.94rem, 3rem);      /* 36→48px  */
  --text-5xl:  clamp(2.75rem, 1.77vw + 2.34rem, 3.75rem);   /* 44→60px  */

  /* Heading scale — Inter-optimised, linear fluid */
  --h1-size: clamp(2.5rem,  3.54vw + 1.67rem, 4.5rem);   /* 40→72px */
  --h2-size: clamp(2rem,    1.77vw + 1.59rem, 3rem);      /* 32→48px */
  --h3-size: clamp(1.625rem,1.33vw + 1.32rem, 2.25rem);   /* 26→36px */
  --h4-size: clamp(1.25rem, 0.66vw + 1.1rem,  1.625rem);  /* 20→26px */
  --h5-size: clamp(1.0625rem,0.44vw + 0.96rem,1.25rem);   /* 17→20px */
  --h6-size: clamp(0.875rem, 0.22vw + 0.82rem,1rem);      /* 14→16px */

  /* Semantic type tokens */
  --text-stat:      clamp(2.25rem, 2.65vw + 1.63rem, 3.75rem); /* 36→60px */
  --text-hero-body: clamp(1.125rem,0.44vw + 1.02rem, 1.25rem); /* = text-lg */
  --text-cta:       0.9375rem; /* 15px fixed — buttons always same size */

  --leading-tight:   1.1;
  --leading-snug:    1.2;
  --leading-normal:  1.7;
  --leading-relaxed: 1.75;

  --fw-regular:   400;
  --fw-medium:    500;
  --fw-semibold:  600;
  --fw-bold:      700;
  --fw-extrabold: 800;

  --tracking-tight:   -0.02em;
  --tracking-normal:   0em;
  --tracking-wide:     0.02em;
  --tracking-wider:    0.06em;
  --tracking-widest:   0.12em;
}

/* ============================================================
   3. SPACING (8px system)
   ============================================================ */
:root {
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --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;

  --section-padding-y: clamp(3rem, 7vw, 7.5rem);
  --section-padding-x: clamp(1rem, 3vw, 2rem);
}

/* ============================================================
   4. LAYOUT
   ============================================================ */
:root {
  --container-max:  1260px;
  --container-wide: 1440px;
  --container-px:   clamp(1rem, 3vw, 2rem);

  --radius-sm:   0.25rem;
  --radius:      0.5rem;
  --radius-md:   0.75rem;
  --radius-lg:   1rem;
  --radius-xl:   1.5rem;
  --radius-2xl:  2rem;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.07), 0 4px 10px rgba(0,0,0,0.04);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.08), 0 6px 16px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 48px rgba(0,0,0,0.10);
  --shadow-colored-primary:  0 8px 24px rgba(151,152,50,0.18);
  --shadow-colored-secondary:0 8px 24px rgba(44,101,101,0.18);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   260ms ease;
  --transition-slow:   420ms ease;
  --transition-image:  600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-spring: 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

  --z-base:    1;
  --z-raised:  10;
  --z-overlay: 100;
  --z-modal:   1000;
  --z-nav:     1100;
  --z-toast:   2000;

  --nav-height: 80px;
}

/* ============================================================
   5. RESET + BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  font-feature-settings: 'kern', 'liga', 'calt'; /* Inter: kerning, ligatures */
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1,h2,h3,h4,h5,h6 {
  font-family: var(--font-display);
  color: var(--color-text-primary);
  font-feature-settings: 'cv11', 'ss01'; /* Inter: open digits, alt a */
}
h1 { font-size: var(--h1-size); line-height: 1.06; font-weight: var(--fw-extrabold); letter-spacing: -0.035em; }
h2 { font-size: var(--h2-size); line-height: 1.1;  font-weight: var(--fw-extrabold); letter-spacing: -0.03em; }
h3 { font-size: var(--h3-size); line-height: 1.2;  font-weight: var(--fw-bold);      letter-spacing: -0.02em; }
h4 { font-size: var(--h4-size); line-height: 1.3;  font-weight: var(--fw-semibold);  letter-spacing: -0.01em; }
h5 { font-size: var(--h5-size); line-height: 1.4;  font-weight: var(--fw-semibold);  letter-spacing: -0.005em; }
h6 { font-size: var(--h6-size); line-height: 1.5;  font-weight: var(--fw-medium);    letter-spacing: 0; }

p {
  color: var(--color-text-secondary);
  line-height: 1.7;
}
/* Constrain prose width only in article-like containers */
.prose p { max-width: 68ch; }

a {
  color: var(--color-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary); }
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

img, svg { display: block; max-width: 100%; height: auto; }

button, input, select, textarea {
  font-family: var(--font-body);
  font-size: var(--text-base);
}

/* ============================================================
   6. UTILITIES
   ============================================================ */
.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;
}

/* Skip link — visually hidden until focused */
.skip-link {
  position: fixed;
  top: -100%;
  left: var(--space-4);
  z-index: 9999;
  padding: var(--space-2) var(--space-5);
  background: var(--color-secondary);
  color: #fff;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus-visible {
  top: var(--space-2);
  outline: 3px solid var(--color-primary-300);
  outline-offset: 2px;
}

.text-center  { text-align: center; }
.text-left    { text-align: left; }
.text-muted   { color: var(--color-text-muted); }
.text-inverse { color: var(--color-text-inverse); }
.text-brand   { color: var(--color-primary-700); }
.text-accent  { color: var(--color-secondary); }

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

.uppercase   { text-transform: uppercase; }
.tracking-widest { letter-spacing: var(--tracking-widest); }

.d-flex       { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.w-full  { width: 100%; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }

.bg-white    { background-color: var(--color-bg-primary); }
.bg-light    { background-color: var(--color-bg-secondary); }
.bg-dark     { background-color: var(--color-bg-dark); }
.bg-primary  { background-color: var(--color-primary); }
.bg-secondary{ background-color: var(--color-secondary); }

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}
