/* =============================================================
   SENIOR-FIRST DESIGN SYSTEM
   Principles: Clarity, Forgiveness, Delight
   Based on Apple HIG for accessibility & elderly users
   Mobile-first, large-scale approach
   ============================================================= */

:root {
  /* SENIOR-OPTIMIZED COLOR PALETTE - HIGH CONTRAST */
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #555555;
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f7f7f7;
  --color-bg-light: #fafafa;
  
  --color-action: #007aff;
  --color-action-hover: #0056b3;
  --color-success: #34c759;
  --color-warning: #ff9500;
  --color-error: #ff3b30;
  
  /* TYPOGRAPHY - OPTIMIZED FOR 65+ USERS */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  --font-family-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  
  /* LARGE SIZES - MINIMUM 16px BASE */
  --font-size-xs: 14px;
  --font-size-sm: 16px;
  --font-size-base: 18px;
  --font-size-lg: 20px;
  --font-size-xl: 22px;
  --font-size-2xl: 26px;
  --font-size-3xl: 32px;
  --font-size-4xl: 40px;
  
  /* LINE HEIGHT - GENEROUS SPACING */
  --line-height-tight: 1.4;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.8;
  --line-height-loose: 2;
  
  /* SPACING - LARGE TOUCH TARGETS */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;
  --spacing-3xl: 32px;
  --spacing-4xl: 40px;
  
  /* TOUCH TARGETS - APPLE HIG: MINIMUM 44x44px */
  --touch-target-min: 44px;
  --touch-target-large: 56px;
  --touch-target-extra: 64px;
  
  /* BORDERS & RADIUS */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  
  /* SHADOWS - SUBTLE & NON-DISTRACTING */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  
  /* TRANSITIONS - GENTLE & BRIEF */
  --transition-fast: 150ms ease-out;
  --transition-normal: 250ms ease-out;
  --transition-slow: 350ms ease-out;
}

/* ============================================================
   2. GLOBAL STYLES
   ============================================================ */

* {
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  padding-bottom: 80px;
}

/* ============================================================
   3. TYPOGRAPHY - OPTIMIZED FOR SENIORS
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: 600;
  line-height: var(--line-height-tight);
  margin: var(--spacing-xl) 0 var(--spacing-lg) 0;
  color: var(--color-text-primary);
}

h1 {
  font-size: var(--font-size-4xl);
  font-weight: 700;
  margin-top: 0;
}

h2 {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  padding-bottom: var(--spacing-md);
  border-bottom: 3px solid var(--color-action);
  display: inline-block;
}

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

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

p {
  margin: var(--spacing-lg) 0;
  line-height: var(--line-height-relaxed);
}

a {
  color: var(--color-action);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:not(.card):not(.btn):not(.btn-primary):not(.btn-secondary) {
  text-decoration: underline;
}

a:hover, a:active {
  color: var(--color-action-hover);
}

/* Remove all link styling from card elements */
a.card {
  text-decoration: none !important;
  text-decoration-color: transparent !important;
  color: inherit !important;
  cursor: pointer;
  border-bottom: none !important;
  background: none !important;
  background-image: none !important;
  outline: none;
}

a.card:hover {
  text-decoration: none !important;
  text-decoration-color: transparent !important;
  background: none !important;
  background-image: none !important;
}

a.card:focus {
  outline: 3px solid var(--color-primary, #c41e3a);
  outline-offset: 2px;
  background: none !important;
  background-image: none !important;
}

a.card h4,
a.card h3,
a.card h2,
a.card h1,
a.card p,
a.card span {
  text-decoration: none !important;
  text-decoration-color: transparent !important;
  background: none !important;
  background-image: none !important;
}

a.card span {
  display: inline;
}

/* ============================================================
   4. BUTTONS - LARGE, FORGIVING, CLEAR
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  
  min-height: var(--touch-target-large);
  padding: var(--spacing-lg) var(--spacing-2xl);
  
  font-size: var(--font-size-lg);
  font-weight: 600;
  line-height: var(--line-height-tight);
  
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  
  transition: all var(--transition-fast);
  text-decoration: none;
  
  -webkit-user-select: none;
  user-select: none;
  
  appearance: none;
  -webkit-appearance: none;
}

/* PRIMARY BUTTON */
.btn-primary {
  background-color: var(--color-action);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover, .btn-primary:active {
  background-color: var(--color-action-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.btn-primary:focus {
  outline: 4px solid rgba(0, 122, 255, 0.3);
  outline-offset: 2px;
}

/* SECONDARY BUTTON */
.btn-secondary {
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
  border: 2px solid var(--color-text-secondary);
}

.btn-secondary:hover, .btn-secondary:active {
  background-color: var(--color-bg-light);
  border-color: var(--color-text-primary);
}

/* LINK BUTTON */
.btn-link {
  background: transparent;
  color: var(--color-action);
  text-decoration: underline;
  padding: var(--spacing-lg) 0;
  min-height: auto;
}

.btn-link:hover {
  color: var(--color-action-hover);
  text-decoration: none;
}

/* BUTTON STATE CLASSES */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   5. FORMS - FORGIVING & ACCESSIBLE
   ============================================================ */

label {
  display: block;
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  color: var(--color-text-primary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="time"],
textarea,
select {
  width: 100%;
  padding: var(--spacing-lg);
  
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  
  background-color: var(--color-bg-primary);
  border: 2px solid var(--color-text-secondary);
  border-radius: var(--border-radius-md);
  
  transition: all var(--transition-fast);
  box-sizing: border-box;
  
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus {
  outline: 4px solid rgba(0, 122, 255, 0.3);
  outline-offset: 2px;
  border-color: var(--color-action);
  background-color: var(--color-bg-light);
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-family-base);
}

select {
  cursor: pointer;
  padding-right: var(--spacing-2xl);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23333' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--spacing-lg) center;
  background-size: 12px;
  padding-right: var(--spacing-3xl);
}

/* ============================================================
   6. FORM GROUPS & VALIDATION
   ============================================================ */

.form-group {
  margin-bottom: var(--spacing-2xl);
}

.form-error {
  color: var(--color-error);
  font-size: var(--font-size-sm);
  margin-top: var(--spacing-md);
  display: block;
}

.input-error {
  border-color: var(--color-error);
  background-color: rgba(255, 59, 48, 0.05);
}

/* ============================================================
   7. NAVIGATION - SIMPLE, TOUCH-FRIENDLY
   ============================================================ */

nav {
  font-size: var(--font-size-lg);
}

nav a {
  display: inline-block;
  padding: var(--spacing-lg);
  text-decoration: none;
  transition: all var(--transition-fast);
}

nav a:hover {
  color: var(--color-action-hover);
}

/* MOBILE NAVIGATION */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  
  background: white;
  border-top: 2px solid var(--color-text-secondary);
  z-index: 1000;
  
  min-height: 70px;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  padding: var(--spacing-md);
  
  transition: all var(--transition-fast);
}

.mobile-nav-item:active,
.mobile-nav-item.active {
  color: var(--color-action);
  background: var(--color-bg-light);
}

/* ============================================================
   8. CARDS - CLEAR, SCANNABLE CONTENT
   ============================================================ */

.card {
  background: var(--color-bg-primary);
  border: 2px solid var(--color-text-secondary);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-2xl);
  margin-bottom: var(--spacing-2xl);
  transition: all var(--transition-fast);
}

.card:hover {
  border-color: var(--color-action);
  box-shadow: var(--shadow-md);
}

a.card,
.card a {
  text-decoration: none !important;
  text-decoration-color: transparent !important;
  background: none !important;
  background-size: 0 !important;
}

.card-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--spacing-lg);
  color: var(--color-text-primary);
}

.card-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-lg);
}

.card-content {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-primary);
}

/* ============================================================
   9. CONTAINERS & LAYOUT
   ============================================================ */

.container {
  /* Responsive max-width based on screen size */
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-2xl);
  box-sizing: border-box;
}

/* Tablet: slightly narrower */
@media (max-width: 1200px) {
  .container {
    max-width: 1100px;
  }
}

/* Small laptop: even narrower */
@media (max-width: 900px) {
  .container {
    max-width: 800px;
  }
}

.container-wide {
  max-width: 1600px;
}

/* SECTION SPACING */
section {
  margin: var(--spacing-3xl) 0;
  padding: var(--spacing-2xl) 0;
}

section:first-child {
  margin-top: 0;
  padding-top: 0;
}

/* ============================================================
   10. GRIDS - RESPONSIVE & FORGIVING
   ============================================================ */

.grid {
  display: grid;
  gap: var(--spacing-2xl);
  margin-bottom: var(--spacing-2xl);
}

.grid-2 {
  /* Default: 2 columns on desktop */
  display: grid !important;
  gap: var(--spacing-lg) !important;
  width: 100% !important;
  grid-template-columns: repeat(2, 1fr) !important;
}

/* Large screens: 3 columns for better space usage */
@media (min-width: 1200px) {
  .grid-2 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* Very large screens: 4 columns */
@media (min-width: 1600px) {
  .grid-2 {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* Mobile: 1 column */
@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr !important;
  }
}

.grid-3 {
  display: grid !important;
  gap: var(--spacing-lg) !important;
  width: 100% !important;
  grid-template-columns: repeat(3, 1fr) !important;
}

@media (max-width: 768px) {
  .grid-3 {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   11. ALERTS & MESSAGES
   ============================================================ */

.alert {
  padding: var(--spacing-2xl);
  border-radius: var(--border-radius-lg);
  border-left: 4px solid;
  margin-bottom: var(--spacing-2xl);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
}

.alert-success {
  background-color: rgba(52, 199, 89, 0.1);
  border-color: var(--color-success);
  color: var(--color-success);
}

.alert-warning {
  background-color: rgba(255, 149, 0, 0.1);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

.alert-error {
  background-color: rgba(255, 59, 48, 0.1);
  border-color: var(--color-error);
  color: var(--color-error);
}

.alert-info {
  background-color: rgba(0, 122, 255, 0.1);
  border-color: var(--color-action);
  color: var(--color-action);
}

/* ============================================================
   12. ACCESSIBILITY HELPERS
   ============================================================ */

.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;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
  background: var(--color-action);
  color: white;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  top: 16px;
  left: 16px;
  width: auto;
  height: auto;
  padding: var(--spacing-lg);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  border-width: 2px;
}

/* ============================================================
   13. UTILITIES - SPACING & DISPLAY
   ============================================================ */

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-lg); }
.mb-3 { margin-bottom: var(--spacing-2xl); }
.mb-4 { margin-bottom: var(--spacing-3xl); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-lg); }
.mt-3 { margin-top: var(--spacing-2xl); }
.mt-4 { margin-top: var(--spacing-3xl); }

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

.text-muted { color: var(--color-text-secondary); }
.text-error { color: var(--color-error); }
.text-success { color: var(--color-success); }

.text-bold { font-weight: 700; }
.text-light { font-weight: 400; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

.hidden { display: none !important; }
.visible { display: block !important; }

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .show-mobile { display: none !important; }
}

/* ============================================================
   14. RESPONSIVE TYPOGRAPHY
   ============================================================ */

@media (max-width: 768px) {
  body {
    font-size: var(--font-size-base);
  }
  
  h1 {
    font-size: 32px;
  }
  
  h2 {
    font-size: 26px;
  }
  
  h3 {
    font-size: 22px;
  }
}

/* ============================================================
   15. PRINT STYLES
   ============================================================ */

@media print {
  body {
    background: white;
    color: black;
  }
  
  a {
    text-decoration: underline;
  }
  
  .no-print {
    display: none;
  }
}
