/* ==========================================================================
   BASE — Premium design system tokens and foundational styles
   Mbabazi Blessing | Portfolio
   ========================================================================== */

:root {
  /* Brand colors */
  --color-primary: #2563EB;
  --color-secondary: #0F172A;
  --color-background: #FFFFFF;
  --color-surface: #F8FAFC;
  --color-text: #0F172A;
  --color-muted: #64748B;
  --color-border: #E2E8F0;
  --color-success: #10B981;

  /* Semantic aliases for existing usage */
  --color-primary-dark: #1D4ED8;
  --color-primary-light: #3B82F6;
  --color-navy: #0F172A;
  --color-accent-glow: rgba(37, 99, 235, 0.18);

  /* Surface tokens */
  --bg-primary: var(--color-background);
  --bg-secondary: var(--color-surface);
  --bg-elevated: #FFFFFF;
  --bg-glass: var(--glass-bg);
  --border-color: var(--glass-border);

  /* Glass tokens */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.84);
  --glass-border: rgba(255, 255, 255, 0.62);
  --glass-shadow: 0 18px 45px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  --glass-shadow-hover: 0 24px 60px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --glass-blur: blur(18px);
  --glass-radius: 1rem;
  --surface-elevation: 0 14px 34px rgba(15, 23, 42, 0.08);
  --glass-glow: rgba(37, 99, 235, 0.12);
  --glass-glow-strong: rgba(37, 99, 235, 0.2);

  /* Text tokens */
  --text-primary: var(--color-text);
  --text-secondary: var(--color-muted);
  --text-inverse: #F8FAFC;
  --text-on-primary: #FFFFFF;

  /* Typography */
  --font-heading: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --fs-xs: 0.875rem;
  --fs-sm: 1rem;
  --fs-base: 1.125rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.625rem;
  --fs-3xl: 2rem;
  --fs-4xl: 2.5rem;
  --fs-5xl: 4rem;

  --font-size-hero: clamp(2.5rem, 1.5rem + 3vw, 4rem);
  --font-size-page-title: clamp(2.25rem, 1.5rem + 2.1vw, 3.25rem);
  --font-size-h2: clamp(1.875rem, 1.35rem + 1.8vw, 2.5rem);
  --font-size-h3: clamp(1.625rem, 1.25rem + 1.3vw, 2rem);
  --font-size-h4: clamp(1.375rem, 1.15rem + 0.8vw, 1.625rem);
  --font-size-h5: 1.375rem;
  --font-size-h6: 1.125rem;
  --font-size-body: clamp(1.0625rem, 1rem + 0.2vw, 1.125rem);
  --font-size-small: 1rem;
  --font-size-caption: 0.875rem;
  --font-size-nav: 0.95rem;
  --font-size-button: 1rem;
  --font-size-card-title: 1.25rem;

  --lh-tight: 1.1;
  --lh-snug: 1.2;
  --lh-normal: 1.7;
  --lh-relaxed: 1.8;
  --lh-list: 1.8;
  --lh-button: 1.2;

  --letter-spacing-tight: -0.02em;
  --letter-spacing-hero: -0.03em;
  --letter-spacing-nav: 0.01em;
  --letter-spacing-uppercase: 0.12em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.02em;

  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;
  --font-weight-hero: 800;
  --font-weight-page-title: 700;
  --font-weight-section-title: 700;
  --font-weight-card-title: 600;
  --font-weight-nav: 500;
  --font-weight-button: 600;
  --font-weight-body: 400;
  --font-weight-small: 400;
  --font-weight-eyebrow: 600;

  --text-wrap-balance: balance;
  --text-wrap-pretty: pretty;
  --content-max-width: 1200px;
  --content-read-width: 700px;
  --section-space-desktop: 7.5rem;
  --section-space-tablet: 6rem;
  --section-space-mobile: 4.5rem;
  --flow-heading-paragraph: 1rem;
  --flow-paragraph-button: 1.5rem;
  --flow-card-gap: 2rem;

  /* Spacing scale */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4rem;
  --space-7: 6rem;
  --space-8: 8rem;

  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: var(--glass-shadow);
  --shadow-lg: var(--glass-shadow-hover);
  --shadow-glow: 0 12px 45px var(--glass-glow);

  /* Motion */
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base: 250ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1200px;
  --container-max: 1280px;
  --header-height: 84px;

  /* Utility vars */
  --flow-space: 1.5rem;
  --section-padding: clamp(4rem, 7vw, 7rem);
  --content-padding: clamp(1rem, 2.5vw, 2rem);

  /* Premium background system */
  --bg-base: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
  --bg-accent-a: rgba(37, 99, 235, 0.09);
  --bg-accent-b: rgba(16, 185, 129, 0.06);
  --bg-accent-c: rgba(15, 23, 42, 0.03);
  --section-divider: rgba(148, 163, 184, 0.18);
}

[data-theme="dark"] {
  --color-background: #020617;
  --color-surface: #0F172A;
  --color-text: #F8FAFC;
  --color-muted: #94A3B8;
  --color-border: rgba(255, 255, 255, 0.12);
  --bg-primary: var(--color-background);
  --bg-secondary: var(--color-surface);
  --bg-elevated: #111827;
  --bg-glass: var(--glass-bg);
  --text-primary: var(--color-text);
  --text-secondary: var(--color-muted);
  --glass-bg: rgba(15, 23, 42, 0.62);
  --glass-bg-strong: rgba(15, 23, 42, 0.78);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-shadow: 0 20px 50px rgba(2, 6, 23, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --glass-shadow-hover: 0 28px 65px rgba(2, 6, 23, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --glass-blur: blur(18px);
  --glass-radius: 1rem;
  --surface-elevation: 0 16px 38px rgba(2, 6, 23, 0.42);
  --glass-glow: rgba(59, 130, 246, 0.2);
  --glass-glow-strong: rgba(59, 130, 246, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: var(--glass-shadow);
  --shadow-lg: var(--glass-shadow-hover);
  --shadow-glow: 0 12px 45px var(--glass-glow);
  --bg-base: linear-gradient(135deg, rgba(2, 6, 23, 0.99) 0%, rgba(15, 23, 42, 0.96) 100%);
  --bg-accent-a: rgba(59, 130, 246, 0.17);
  --bg-accent-b: rgba(16, 185, 129, 0.1);
  --bg-accent-c: rgba(248, 250, 252, 0.04);
  --section-divider: rgba(148, 163, 184, 0.16);
}

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

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

/* Accessible focus styles for keyboard users */
:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--component-focus-ring);
  border-radius: calc(var(--radius-sm) + 0px);
}

/* Unified, high-contrast focus styles for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.btn:focus-visible,
.theme-toggle:focus-visible,
.nav-toggle:focus-visible,
.nav-links a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--component-focus-ring);
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  a:focus-visible,
  button:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  select:focus-visible,
  .btn:focus-visible,
  .theme-toggle:focus-visible,
  .nav-toggle:focus-visible,
  .nav-links a:focus-visible {
    box-shadow: none !important;
    outline: 2px solid var(--color-primary) !important;
  }
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  letter-spacing: var(--letter-spacing-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  background-image:
    var(--bg-base),
    radial-gradient(circle at top left, var(--bg-accent-a) 0%, transparent 34%),
    radial-gradient(circle at 85% 12%, var(--bg-accent-b) 0%, transparent 28%),
    radial-gradient(circle at 80% 85%, var(--bg-accent-c) 0%, transparent 30%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-variant-numeric: lining-nums proportional-nums;
  overflow-x: hidden;
  position: relative;
  isolation: isolate;
  transition: background-color var(--transition-base), color var(--transition-base);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.02) 45%, transparent 100%),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.025) 0%, transparent 26%);
  opacity: 0.75;
}

body::after {
  content: "";
  position: fixed;
  right: -8rem;
  bottom: -10rem;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  pointer-events: none;
  z-index: -2;
  background: radial-gradient(circle, var(--bg-accent-c) 0%, transparent 70%);
  filter: blur(60px);
  opacity: 0.8;
}

section {
  position: relative;
  isolation: isolate;
}

section + section {
  border-top: 1px solid var(--section-divider);
}

section::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(circle at top left, var(--bg-accent-a) 0%, transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 75%);
  opacity: 0.45;
}

.section--alt {
  background: var(--bg-secondary);
}

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

/* Responsive embeds and media */
iframe,
embed,
object,
video {
  max-width: 100%;
  height: auto;
}

/* Prevent long words or unbroken content from causing horizontal scroll */
h1, h2, h3, h4, h5, h6, .hero-title {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Ensure containers have consistent horizontal padding on small screens */
.container {
  padding-inline: var(--content-padding);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: none;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

ul, ol {
  list-style: none;
}

p,
li,
blockquote,
label,
figcaption,
small,
span {
  text-wrap: pretty;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: var(--lh-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-primary);
  text-wrap: balance;
  font-weight: var(--font-weight-semibold);
}

h1 {
  font-size: var(--font-size-hero);
  font-weight: var(--font-weight-hero);
  letter-spacing: var(--letter-spacing-hero);
  line-height: 1.02;
}

h2 {
  font-size: var(--font-size-page-title);
  font-weight: var(--font-weight-page-title);
  letter-spacing: var(--letter-spacing-tight);
}

h3 {
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-bold);
}

h4 {
  font-size: var(--font-size-h3);
}

h5 {
  font-size: var(--font-size-h4);
}

h6 {
  font-size: var(--font-size-h5);
}

p {
  font-size: var(--font-size-body);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  max-width: var(--content-read-width);
  hyphens: auto;
}

strong,
b {
  font-weight: var(--font-weight-semibold);
}

em,
i {
  font-style: italic;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.94em;
}

pre {
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

blockquote {
  font-size: var(--fs-lg);
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
  border-left: 2px solid rgba(37, 99, 235, 0.25);
  padding-left: 1rem;
}

label,
.caption,
figcaption,
.form-text,
.helper-text {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-secondary);
}

small,
.text-sm {
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.text-xs {
  font-size: var(--fs-xs);
  line-height: 1.5;
}

button,
.btn,
.link,
.nav-link {
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--letter-spacing-normal);
}

@media (max-width: 768px) {
  :root {
    --section-space-desktop: var(--section-space-tablet);
  }

  h1 {
    font-size: var(--font-size-page-title);
  }

  h2 {
    font-size: var(--font-size-h2);
  }

  h3 {
    font-size: var(--font-size-h3);
  }

  p,
  li,
  label,
  .card p,
  .card li {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 0.97rem;
  }

  :root {
    --section-space-desktop: var(--section-space-mobile);
  }

  .hero h1 {
    font-size: 2.5rem;
  }

  h1 {
    font-size: 2.25rem;
  }

  h2 {
    font-size: 1.875rem;
  }

  h3 {
    font-size: 1.625rem;
  }

  p,
  li,
  label,
  .card p,
  .card li {
    font-size: 0.95rem;
  }
}


::selection {
  background: rgba(37, 99, 235, 0.2);
  color: var(--color-text);
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --color-border: #64748B;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-section-title);
  line-height: var(--lh-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-primary);
  margin: 0;
}

.hero h1 {
  font-size: var(--font-size-hero);
  font-weight: var(--font-weight-hero);
  line-height: 1.08;
  letter-spacing: var(--letter-spacing-hero);
  max-width: 100%;
  word-break: normal;
}

h1 {
  font-size: var(--font-size-page-title);
  font-weight: var(--font-weight-page-title);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--font-size-h2);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h3 {
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-section-title);
  line-height: 1.2;
}

h4 {
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-section-title);
  line-height: 1.2;
}

h5 {
  font-size: var(--font-size-h5);
  font-weight: var(--font-weight-card-title);
  line-height: 1.25;
}

h6 {
  font-size: var(--font-size-h6);
  font-weight: var(--font-weight-card-title);
  line-height: 1.25;
}

p,
li,
blockquote,
label,
figcaption,
small,
span,
.card p,
.card li,
.hero-copy,
.footer-links a,
.footer-contact-list a,
.footer-bottom p {
  color: var(--text-secondary);
  line-height: var(--lh-normal);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-body);
}

p {
  max-width: var(--content-read-width);
}

strong,
b {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
}

h1 + p,
h2 + p,
h3 + p,
h4 + p,
h5 + p,
h6 + p {
  margin-top: var(--flow-heading-paragraph);
}

p + .btn,
p + .hero-actions,
p + .section-actions {
  margin-top: var(--flow-paragraph-button);
}

.section-head {
  margin-bottom: var(--space-5);
  max-width: var(--content-read-width);
}

.section-head--center {
  margin-inline: auto;
  text-align: center;
}

.section-head--center p {
  margin-inline: auto;
}

.section-head > * + * {
  margin-top: var(--flow-heading-paragraph);
}

code,
pre {
  font-family: var(--font-mono);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--font-weight-eyebrow);
  color: var(--color-primary);
  letter-spacing: var(--letter-spacing-uppercase);
  text-transform: uppercase;
}

.text-mono {
  font-family: var(--font-mono);
}

button,
.btn,
.nav-links a {
  font-family: var(--font-body);
  font-size: var(--font-size-button);
  font-weight: var(--font-weight-button);
  line-height: var(--lh-button);
  letter-spacing: var(--letter-spacing-normal);
  text-align: center;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 1.5rem);
}

.nav-links a {
  font-size: var(--font-size-nav);
  font-weight: var(--font-weight-nav);
  letter-spacing: var(--letter-spacing-nav);
  padding-block: 0.35rem;
}

.card h3,
.card h4 {
  font-size: var(--font-size-card-title);
  font-weight: var(--font-weight-card-title);
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.card p,
.card li {
  font-size: var(--font-size-body);
  line-height: var(--lh-normal);
}

ul,
ol {
  padding-left: 1.25rem;
}

li + li {
  margin-top: 0.5rem;
}

li {
  line-height: var(--lh-list);
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-medium);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: var(--font-size-body);
  line-height: 1.5;
  border-radius: var(--radius-md);
}

input::placeholder,
textarea::placeholder {
  font-size: var(--font-size-small);
  color: var(--text-secondary);
}

.form-status,
.helper-text,
.form-text {
  font-size: var(--font-size-caption);
  line-height: 1.5;
}

.site-footer .footer-title {
  font-size: var(--font-size-h6);
  font-weight: var(--font-weight-section-title);
  margin-bottom: 1rem;
}

.site-footer .footer-links,
.site-footer .footer-contact-list {
  display: grid;
  gap: 0.75rem;
}

.site-footer .footer-links a,
.site-footer .footer-contact-list a {
  font-size: var(--font-size-small);
  line-height: 1.6;
}

.site-footer .footer-bottom p {
  font-size: var(--font-size-caption);
  line-height: 1.6;
}

/* Layout utilities */
.container {
  width: min(100% - 2rem, var(--content-max-width));
  margin-inline: auto;
  max-width: var(--content-max-width);
}

.flow > * + * {
  margin-top: var(--flow-space);
}

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

@media (max-width: 768px) {
  h1 { font-size: var(--fs-4xl); }
  h2 { font-size: var(--fs-3xl); }
}
