/**
 * BASE.CSS
 * Foundation styles: CSS variables, reset, typography, and accessibility
 *
 * This file establishes the design system through CSS custom properties.
 * All colors, spacing, typography, and effects should reference these variables
 * to ensure consistency and easy maintenance.
 */

/* =============================
   DESIGN TOKENS
   CSS Custom Properties (Variables)
   ============================= */

:root {
  /* --------------------------
     COLOR PALETTE

     The sun-inspired palette reflects RESOL's identity:
     warmth, illumination, and hope. Use sparingly as accents.
     -------------------------- */

  /* Primary: Sun-inspired warmth (use for CTAs, highlights, accents) */
  --color-sun: #e8a027;
  --color-sun-bright: #f5b73b;
  --color-sun-light: #fcd581;
  --color-sun-pale: #fef4e1;
  --color-sun-glow: #fff8eb;

  /* Secondary: Healthcare credibility (use for trust-building elements) */
  --color-teal: #2a7d7d;
  --color-teal-dark: #1f5f5f;
  --color-teal-light: #3a9e9e;

  /* Accent: Earth tones inspired by Guatemala */
  --color-terracotta: #c75d3a;
  --color-forest: #3d6b4f;

  /* Neutrals: For text, backgrounds, and UI elements */
  --color-navy: #2d3e50;
  --color-navy-dark: #1e2d3d;
  --color-navy-soft: #4a5d6f;

  --color-bg: #fafafa;
  --color-bg-warm: #fdfcfa;
  --color-white: #ffffff;

  --color-text: #1f2937;
  --color-text-muted: #4b5563;
  --color-text-light: #6b7280;
  --color-border: #e5e7eb;

  /* Semantic colors */
  --color-success: #059669;
  --color-error: #dc2626;

  /* Legacy aliases (for backward compatibility)
     TODO: Gradually migrate to --color-* naming convention */
  --sun: var(--color-sun);
  --sun-bright: var(--color-sun-bright);
  --sun-light: var(--color-sun-light);
  --sun-pale: var(--color-sun-pale);
  --sun-glow: var(--color-sun-glow);
  --teal: var(--color-teal);
  --teal-dark: var(--color-teal-dark);
  --teal-light: var(--color-teal-light);
  --terracotta: var(--color-terracotta);
  --forest: var(--color-forest);
  --navy: var(--color-navy);
  --navy-dark: var(--color-navy-dark);
  --navy-soft: var(--color-navy-soft);
  --bg: var(--color-bg);
  --bg-warm: var(--color-bg-warm);
  --white: var(--color-white);
  --text: var(--color-text);
  --text-muted: var(--color-text-muted);
  --text-light: var(--color-text-light);
  --border: var(--color-border);
  --success: var(--color-success);
  --error: var(--color-error);

  /* --------------------------
     TYPOGRAPHY

     Using Karla for its friendly, readable character.
     Sizes use clamp() for fluid responsive scaling.
     -------------------------- */

  --font-family: Karla, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  /* Font sizes */
  --text-xs: 0.75rem;   /* 12px */
  --text-sm: 0.875rem;  /* 14px */
  --text-base: 1rem;    /* 16px */
  --text-lg: 1.125rem;  /* 18px */
  --text-xl: 1.25rem;   /* 20px */

  /* Heading sizes (fluid) */
  --text-h1: clamp(2.25rem, 4vw, 3.5rem);
  --text-h2: clamp(1.75rem, 3vw, 2.25rem);
  --text-h3: 1.25rem;

  /* Line heights */
  --leading-tight: 1.2;
  --leading-normal: 1.65;
  --leading-relaxed: 1.75;

  /* --------------------------
     SPACING SCALE

     Consistent spacing creates visual rhythm.
     Based on a 4px/0.25rem unit.
     -------------------------- */

  --space-xs: 0.5rem;   /* 8px */
  --space-sm: 1rem;     /* 16px */
  --space-md: 1.5rem;   /* 24px */
  --space-lg: 3rem;     /* 48px */
  --space-xl: 5rem;     /* 80px */
  --space-2xl: 7rem;    /* 112px */

  /* --------------------------
     BORDER RADIUS

     Rounded corners create a softer, more human feel.
     -------------------------- */

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --radius-full: 50%;

  /* --------------------------
     SHADOWS

     Subtle shadows add depth without being heavy.
     -------------------------- */

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 8px 30px rgba(232, 160, 39, 0.2);

  /* --------------------------
     TRANSITIONS

     Consistent, subtle motion.
     -------------------------- */

  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* =============================
   CSS RESET
   Normalize browser defaults
   ============================= */

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

* {
  margin: 0;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =============================
   BASE TYPOGRAPHY
   ============================= */

h1, h2, h3, h4, h5, h6 {
  color: var(--color-navy);
  line-height: var(--leading-tight);
  font-weight: 700;
}

h1 {
  font-size: var(--text-h1);
  margin-bottom: var(--space-md);
}

h2 {
  font-size: var(--text-h2);
  margin-bottom: var(--space-md);
}

h3 {
  font-size: var(--text-h3);
  margin-bottom: var(--space-xs);
}

p {
  margin-bottom: var(--space-sm);
  color: var(--color-text-muted);
}

/* Remove margin from last paragraph in a container */
p:last-child {
  margin-bottom: 0;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-base);
}

/* Links within body text should be distinguishable */
p a, li a {
  color: var(--color-teal);
}

p a:hover, li a:hover {
  color: var(--color-teal-dark);
  text-decoration: underline;
}

strong {
  font-weight: 600;
  color: var(--color-text);
}

/* Text selection highlight */
::selection {
  background: var(--color-sun-pale);
  color: var(--color-navy);
}

/* =============================
   ACCESSIBILITY
   ============================= */

/* Focus styles for keyboard navigation */
:focus {
  outline: 2px solid var(--color-sun);
  outline-offset: 2px;
}

/* Remove outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Restore outline for keyboard users */
:focus-visible {
  outline: 2px solid var(--color-sun);
  outline-offset: 2px;
}

/* Skip link for screen reader users */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-sm);
  background: var(--color-navy);
  color: var(--color-white);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top var(--transition-base);
  font-weight: 600;
}

.skip-link:focus {
  top: var(--space-sm);
}

/* Screen reader only content */
.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;
}

/* Respect user's reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
