/* Reset, typography, layout primitives and utilities. Mobile-first. */
@layer base {

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + var(--space-5));
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Lock background scroll while the mobile drawer (a modal dialog) is open. */
html:has(dialog[open].drawer) {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-background);
  color: var(--color-text);
  font: 400 var(--text-base) / var(--leading-body) var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

main {
  flex: 1;
  /* Nothing in the page (a photograph sliding in, a wide table) may make the whole page
     scroll sideways. "clip" rather than "hidden" keeps sticky elements working. */
  overflow-x: clip;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

/* :where() gives this reset zero specificity, so any component class overrides it. */
:where(ul[role="list"], ol[role="list"]) {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

img {
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

/* ---- headings ---- */
h1,
h2,
h3,
.display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h4 {
  font-weight: 600;
  line-height: var(--leading-snug);
}

/* Italic accent phrase inside a display heading: <h2>Kenya and beyond, <em>planned here</em></h2>.
   Colour, not underline, sets it apart. */
:where(h1, h2, h3, .display) em {
  font-style: italic;
  color: var(--color-sage);
}
:where(.section-dark, .section-night, .on-dark) :where(h1, h2, h3, .display) em {
  color: var(--color-accent);
}

.text-4xl { font-size: var(--text-4xl); letter-spacing: -0.035em; }
.text-3xl { font-size: var(--text-3xl); letter-spacing: -0.03em; }
.text-2xl { font-size: var(--text-2xl); }
.text-xl  { font-size: var(--text-xl); }
.text-lg  { font-size: var(--text-lg); }
.text-sm  { font-size: var(--text-sm); }

.lead {
  font-size: var(--text-lg);
  line-height: 1.55;
  color: var(--color-muted);
  max-width: 60ch;
}

/* Eyebrow: the short uppercase label above a heading. .kicker is the older name. */
.eyebrow,
.kicker {
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-accent-text);
}
.eyebrow-light,
:is(.section-dark, .section-night, .on-dark) :is(.eyebrow, .kicker) {
  color: var(--color-accent);
}

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

p {
  text-wrap: pretty;
}

/* ---- prose (CMS rich text) ---- */
.prose {
  max-width: 68ch;
}
.prose > * + * {
  margin-top: 1em;
}
.prose h2 { font-size: var(--text-2xl); margin-top: 1.6em; }
.prose h3 { font-size: var(--text-xl); margin-top: 1.4em; }
.prose a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.prose ul,
.prose ol {
  padding-left: 1.3em;
}
.prose blockquote {
  margin-inline: 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 3px solid var(--color-accent);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1.4;
  color: var(--color-primary);
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--color-border);
}

/* ---- layout ---- */
.container {
  width: var(--container);
  margin-inline: auto;
}

.container-narrow {
  width: var(--container-narrow);
  margin-inline: auto;
}

.section {
  padding-block: var(--space-section);
}

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

.section-sand {
  background: var(--color-sand-light);
}

.section-sage {
  background: var(--color-sage-tint);
}

.section-dark {
  background: var(--color-primary-dark);
  color: var(--color-on-dark);
}

.section-night {
  background: var(--color-night);
  color: var(--color-on-dark);
}

:where(.section-dark, .section-night) .lead,
:where(.section-dark, .section-night) .muted {
  color: var(--color-on-dark-muted);
}

.stack > * + * {
  margin-top: var(--stack-gap, var(--space-4));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-4));
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

/* Auto-fitting grid: columns never narrower than --grid-min. */
.grid-auto {
  display: grid;
  gap: var(--grid-gap, var(--space-5));
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--grid-min, 18rem)), 1fr));
}

/* ---- accessibility ---- */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: 2px;
}

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

.skip-link {
  position: fixed;
  left: var(--space-4);
  top: calc(-1 * var(--space-8));
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-4);
  background: var(--color-accent);
  color: var(--color-night);
  font-weight: 600;
  border-radius: var(--radius);
  text-decoration: none;
}
.skip-link:focus {
  top: var(--space-4);
}

/* ---- icons ---- */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: currentColor;
}

@media print {
  .site-header,
  .drawer,
  .skip-link {
    display: none !important;
  }
  body {
    background: #fff;
  }
}

} /* end @layer base */

/* ---- motion safety net ----
   In the last layer: an !important declaration in an earlier layer beats one in a
   later layer, so a page's own !important motion rule (crm.css: the sidebar) still
   wins here, exactly as before layers. */
@layer utilities {
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
    }
  }
}
