/**
 * Base Styles for activAmed Website
 * Foundation styles including reset, typography, and spacing system
 */

/* ==========================================
   CSS RESET & BASE
   ========================================== */

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

html {
  /* Base font size: 18px for senior-friendly readability */
  font-size: 18px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* overflow-x: clip prevents white border from overflowing elements
     without creating a scroll container (which would break position: sticky).
     Do NOT use overflow-x: hidden here or on body — it breaks sticky header.
     Requires Safari 16+. Safari 14/15 fall back to no clipping. */
  overflow-x: clip;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 400;
  color: var(--color-text);
  background-color: var(--color-background);
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

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

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--spacing-md);
  color: var(--color-heading);
  overflow-wrap: break-word;
}

h1 {
  font-size: 2.5rem; /* 45px */
  margin-bottom: var(--spacing-lg);
}

h2 {
  font-size: 2rem; /* 36px */
}

h3 {
  font-size: 1.5rem; /* 27px */
}

h4 {
  font-size: 1.25rem; /* 22.5px */
}

h5 {
  font-size: 1.125rem; /* 20.25px */
}

h6 {
  font-size: 1rem; /* 18px */
}

p {
  margin-bottom: var(--spacing-md);
  line-height: 1.7;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  transition: color 0.2s ease;
}

a:hover,
a:focus {
  color: var(--color-link-hover);
  text-decoration: none;
}

a:focus {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

strong, b {
  font-weight: 600;
}

em, i {
  font-style: italic;
}

/* ==========================================
   LISTS
   ========================================== */

ul, ol {
  margin-bottom: var(--spacing-md);
  padding-left: var(--spacing-lg);
}

li {
  margin-bottom: var(--spacing-xs);
  line-height: 1.7;
}

/* ==========================================
   IMAGES & MEDIA
   ========================================== */

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

figure {
  margin: 0;
  margin-bottom: var(--spacing-md);
}

figcaption {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: var(--spacing-xs);
  font-style: italic;
}

/* ==========================================
   TABLES
   ========================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--spacing-md);
  table-layout: fixed;
}

th, td {
  padding: var(--spacing-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  overflow-wrap: break-word;
}

th {
  font-weight: 600;
  background-color: var(--color-table-header);
}

/* ==========================================
   SPACING SYSTEM
   ========================================== */

:root {
  /* Spacing scale */
  --spacing-xs: 0.5rem;    /* 9px */
  --spacing-sm: 0.75rem;   /* 13.5px */
  --spacing-md: 1rem;      /* 18px */
  --spacing-lg: 1.5rem;    /* 27px */
  --spacing-xl: 2rem;      /* 36px */
  --spacing-2xl: 3rem;     /* 54px */
  --spacing-3xl: 4rem;     /* 72px */

  /* Layout spacing */
  --container-padding: var(--spacing-md);
  --section-spacing: var(--spacing-3xl);

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Z-index scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */

/* Mobile-first approach
   - Default: < 640px (mobile)
   - sm: >= 640px (large mobile)
   - md: >= 768px (tablet)
   - lg: >= 1024px (desktop)
   - xl: >= 1280px (large desktop)
*/

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

/* Disable transitions on page load to prevent flash/jank */
.preload * {
  transition: none !important;
  animation: none !important;
}

/* Skip navigation link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  text-decoration: none;
  z-index: 9999;
  border-radius: 0 0 var(--radius-md) 0;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--color-focus);
}

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

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

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

/* ==========================================
   UTILITY CLASSES
   ========================================== */

.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.mt-0 { margin-top: 0; }
.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

/* ==========================================
   RESPONSIVE UTILITIES
   ========================================== */

@media (min-width: 640px) {
  :root {
    --container-padding: var(--spacing-lg);
  }
}

@media (min-width: 768px) {
  :root {
    --container-padding: var(--spacing-xl);
  }

  h1 {
    font-size: 3rem; /* 54px */
  }

  h2 {
    font-size: 2.25rem; /* 40.5px */
  }
}

@media (min-width: 1024px) {
  h1 {
    font-size: 3.5rem; /* 63px */
  }

  h2 {
    font-size: 2.5rem; /* 45px */
  }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  a {
    text-decoration: underline;
    color: black;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }

  h1 {
    page-break-before: always;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }

  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  table, figure {
    page-break-inside: avoid;
  }
}
