/* ==========================================================================
   EaglePay SaaS Web Frontend — Design Tokens, Base Reset & Motion Primitives
   Tailored for East African SMEs & Family Spaces (UG, KE, TZ)
   ========================================================================== */

:root {
  /* Executive Cobalt, Treasury Emerald & Gold Palette for EaglePay */
  --kd-emerald-950: #0a1628;
  --kd-emerald-900: #1e3a8a;
  --kd-emerald-800: #1d4ed8;
  --kd-emerald-700: #2563eb;
  --kd-emerald-600: #059669;
  --kd-emerald-500: #10b981;
  --kd-emerald-200: #bfdbfe;
  --kd-emerald-100: #dbeafe;
  --kd-emerald-50: #eff6ff;

  --kd-amber-700: #b45309;
  --kd-amber-600: #d97706;
  --kd-amber-500: #f59e0b;
  --kd-amber-200: #fde68a;
  --kd-amber-100: #fef3c7;
  --kd-amber-50: #fffbeb;

  --kd-sky-600: #0284c7;
  --kd-sky-100: #e0f2fe;
  --kd-rose-600: #e11d48;
  --kd-rose-50: #fff1f2;

  /* Crisp Surfaces & High-Contrast Agricultural Ink */
  --kd-ink-950: #09111f;
  --kd-ink-900: #0f172a;
  --kd-ink-800: #1e293b;
  --kd-ink-700: #334155;
  --kd-ink-600: #475569;
  --kd-ink-500: #64748b;
  --kd-surface-cream: #f7faf8;
  --kd-surface-white: #ffffff;
  --kd-surface-muted: #f1f5f9;
  --kd-border-subtle: #e2e8f0;
  --kd-border-strong: #cbd5e1;

  /* Elevation & Radii */
  --kd-radius-sm: 0.625rem;
  --kd-radius-md: 1rem;
  --kd-radius-lg: 1.375rem;
  --kd-radius-xl: 1.875rem;
  --kd-radius-pill: 999px;

  --kd-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --kd-shadow-md: 0 12px 30px -8px rgba(6, 78, 59, 0.12), 0 4px 12px rgba(15, 23, 42, 0.05);
  --kd-shadow-lg: 0 24px 54px -14px rgba(6, 78, 59, 0.22), 0 8px 20px rgba(15, 23, 42, 0.07);
  --kd-shadow-glow: 0 0 0 1px rgba(16, 185, 129, 0.22), 0 18px 44px -10px rgba(5, 150, 105, 0.28);

  /* Typography & Layout — 95% Fluid Page Width */
  --kd-font-sans: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --kd-container-max: 95%;
  --kd-section-space: clamp(3.5rem, 6vw, 6.25rem);
}

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

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  font-family: var(--kd-font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--kd-ink-800);
  background-color: var(--kd-surface-cream);
  overflow-x: clip;
}

img,
svg,
video,
canvas {
  display: block;
  max-inline-size: 100%;
}

img {
  block-size: auto;
}

/* WCAG 2.4.7 & 1.4.11 High-Contrast Focus Indicators */
:where(a:any-link, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid var(--kd-emerald-600);
  outline-offset: 3px;
}

@media (forced-colors: active) {
  :where(a:any-link, button, input, select, textarea, summary):focus-visible {
    outline: 3px solid Highlight;
  }
}

/* Visually Hidden Utility with Skip-Link Focus Reveal */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  inline-size: 1px !important;
  block-size: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus-visible {
  position: fixed;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  background: var(--kd-emerald-900);
  color: #ffffff;
  font-weight: 800;
  border-radius: var(--kd-radius-sm);
  text-decoration: none;
  box-shadow: var(--kd-shadow-lg);
}

/* Containers & Section Headings (95% Viewport Coverage + WCAG 1.4.4 200% zoom) */
.kd-container {
  inline-size: min(95%, calc(100% - 1.5rem));
  max-inline-size: 95%;
  margin-inline: auto;
}

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

.kd-section-header {
  max-inline-size: 46rem;
  margin-inline: auto;
  margin-block-end: clamp(2rem, 4vw, 3.25rem);
  text-align: center;
}

.kd-eyebrow {
  display: inline-flex;
  align-items: safe center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--kd-radius-pill);
  background: var(--kd-emerald-50);
  border: 1px solid var(--kd-emerald-200);
  color: var(--kd-emerald-800);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kd-h2 {
  margin-block: 0.75rem 0.65rem;
  font-size: clamp(1.65rem, 1.15rem + 2.1vw, 2.75rem);
  line-height: 1.16;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--kd-ink-950);
}

.kd-lead {
  margin: 0;
  font-size: clamp(1rem, 0.94rem + 0.35vw, 1.18rem);
  color: var(--kd-ink-600);
}

/* Buttons (Minimum 44px comfortable coarse-pointer target) */
.kd-btn {
  display: inline-flex;
  align-items: safe center;
  justify-content: center;
  gap: 0.55rem;
  min-block-size: 2.875rem;
  padding-block: 0.7rem;
  padding-inline: 1.35rem;
  border-radius: var(--kd-radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

@media (pointer: coarse) {
  .kd-btn {
    min-block-size: 3rem;
  }
}

.kd-btn-primary {
  background: linear-gradient(135deg, var(--kd-emerald-700), var(--kd-emerald-600));
  color: #ffffff;
  box-shadow: 0 10px 24px -6px rgba(5, 150, 105, 0.45);
}

.kd-btn-primary:hover {
  background: linear-gradient(135deg, var(--kd-emerald-800), var(--kd-emerald-700));
}

.kd-btn-amber {
  background: linear-gradient(135deg, var(--kd-amber-600), var(--kd-amber-500));
  color: #ffffff;
  box-shadow: 0 10px 24px -6px rgba(217, 119, 6, 0.4);
}

.kd-btn-amber:hover {
  background: linear-gradient(135deg, var(--kd-amber-700), var(--kd-amber-600));
}

.kd-btn-outline {
  background: var(--kd-surface-white);
  border-color: var(--kd-border-strong);
  color: var(--kd-ink-900);
}

.kd-btn-outline:hover {
  background: var(--kd-emerald-50);
  border-color: var(--kd-emerald-500);
  color: var(--kd-emerald-900);
}

/* Native Scroll-Driven Entry Reveal (with Declaration Order After animation shorthand) */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes kd-reveal-up {
      from {
        opacity: 0;
        transform: translateY(1.5rem);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .kd-reveal {
      animation: kd-reveal-up auto ease-out backwards;
      animation-timeline: view();
      animation-range: entry 0% cover 24%;
    }
  }
}

.kd-reveal.is-revealed {
  opacity: 1;
  transform: translateY(0);
}
