/* Accessible CSS for MerchantsOfHope.org platform */

/* High contrast and accessibility-focused styles */
:root {
  --primary-color: #1a365d; /* Darker blue for better contrast */
  --secondary-color: #2a5cb0; /* Standard blue */
  --accent-color: #b42f2f; /* Red for important elements */
  --light-color: #ffffff; /* Pure white for contrast */
  --dark-color: #000000; /* Pure black for text */
  --success-color: #1f7a1f; /* Darker green */
  --warning-color: #cc6600; /* Darker orange */
  --font-size-base: 18px; /* Larger base font for better readability */
  --font-size-large: 1.375rem; /* 22px */
  --font-size-xlarge: 1.75rem; /* 28px */
  --line-height: 1.6; /* Increased for readability */
  --border-radius: 0px; /* Remove rounded corners for accessibility */
  --spacing-small: 0.75rem;
  --spacing-medium: 1.25rem;
  --spacing-large: 1.75rem;
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Semantic HTML elements */
main,
header,
nav,
footer,
section,
article,
aside {
  display: block;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--dark-color);
  background-color: var(--light-color);
  padding: var(--spacing-medium);
  /* Ensure sufficient contrast */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container for layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header styles */
header {
  background-color: var(--primary-color);
  color: var(--light-color);
  padding: var(--spacing-medium);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-large);
  /* Ensure sufficient contrast */
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Navigation */
nav ul {
  display: flex;
  list-style: none;
  gap: var(--spacing-medium);
}

nav a {
  color: var(--light-color);
  text-decoration: underline; /* Always show underlines for clarity */
  padding: var(--spacing-small);
  border-radius: var(--border-radius);
  transition: background-color 0.3s;
  /* Ensure sufficient contrast */
}

nav a:hover, nav a:focus {
  background-color: rgba(255, 255, 255, 0.2);
  outline: 3px solid var(--light-color); /* Thicker outline for focus */
  outline-offset: 2px;
  /* Ensure link text remains readable */
  color: var(--light-color);
}

/* Main content */
main {
  margin: var(--spacing-large) 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-bottom: var(--spacing-small);
  color: var(--primary-color);
  line-height: 1.2;
  /* Ensure font weights are appropriate */
  font-weight: 600;
}

h1 {
  font-size: var(--font-size-xlarge);
  margin-bottom: var(--spacing-medium);
}

h2 {
  font-size: calc(var(--font-size-large) * 1.2);
  border-bottom: 3px solid var(--secondary-color);
  padding-bottom: var(--spacing-small);
  margin-top: var(--spacing-large);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: var(--spacing-small) var(--spacing-medium);
  background-color: var(--secondary-color);
  color: var(--light-color);
  text-decoration: none;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: 600; /* Bold for better readability */
  transition: background-color 0.3s;
  margin: var(--spacing-small);
  /* Ensure sufficient contrast */
  text-align: center;
}

.btn:hover, .btn:focus {
  background-color: #1d4e89; /* Darker shade on hover */
  outline: 3px solid var(--dark-color); /* Thick outline for focus */
  outline-offset: 2px;
  /* Maintain readability */
  color: var(--light-color);
}

.btn-primary {
  background-color: var(--primary-color);
}

.btn-success {
  background-color: var(--success-color);
}

.btn-danger {
  background-color: var(--accent-color);
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-medium);
}

label {
  display: block;
  margin-bottom: var(--spacing-small);
  font-weight: 600; /* Bold for better readability */
  color: var(--primary-color);
}

input, select, textarea {
  width: 100%;
  padding: var(--spacing-small);
  border: 2px solid #333; /* Thicker border for visibility */
  border-radius: var(--border-radius);
  font-size: var(--font-size-base);
  /* Ensure sufficient contrast */
  background-color: var(--light-color);
  color: var(--dark-color);
}

input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--secondary-color); /* Thick outline for focus */
  outline-offset: 0;
  /* Maintain readable text */
  color: var(--dark-color);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--spacing-medium) 0;
  /* Ensure tables are readable */
  font-size: var(--font-size-base);
}

th, td {
  padding: var(--spacing-small);
  text-align: left;
  border-bottom: 2px solid #333; /* Thicker border for visibility */
  vertical-align: top;
}

th {
  background-color: var(--primary-color);
  color: var(--light-color);
  font-weight: 600; /* Bold header text */
}

tr:hover {
  background-color: rgba(42, 92, 176, 0.1); /* Subtle highlight */
}

/* Cards and sections */
.card {
  background: var(--light-color);
  border: 2px solid #333; /* Thicker border for visibility */
  border-radius: var(--border-radius);
  padding: var(--spacing-medium);
  margin: var(--spacing-medium) 0;
  /* Ensure sufficient contrast */
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Alerts */
.alert {
  padding: var(--spacing-medium);
  border-radius: var(--border-radius);
  margin: var(--spacing-medium) 0;
  border: 2px solid; /* Thicker border */
  font-weight: 600; /* Bold text */
}

.alert-success {
  background-color: #d4f6d4; /* Light green */
  color: var(--success-color);
  border-color: var(--success-color);
}

.alert-error {
  background-color: #fddddd; /* Light red */
  color: var(--accent-color);
  border-color: var(--accent-color);
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-color);
  color: var(--light-color);
  padding: 8px;
  text-decoration: underline;
  border-radius: var(--border-radius);
  z-index: 1000;
  font-weight: 600;
}

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

/* Footer */
footer {
  background-color: var(--primary-color);
  color: var(--light-color);
  padding: var(--spacing-large);
  margin-top: var(--spacing-large);
  border-radius: var(--border-radius);
  text-align: center;
  /* Ensure sufficient contrast */
  box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
}

/* Additional accessibility features */

/* Focus indicators for all interactive elements */
button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
}

/* Ensure proper spacing between elements for users with motor disabilities */
button,
input,
select,
textarea,
a {
  margin: var(--spacing-small);
  min-height: 44px; /* Minimum touch target size */
}

/* Link styling */
a {
  color: var(--secondary-color);
  text-decoration: underline;
  font-weight: 600;
}

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

/* Responsive design */
@media (max-width: 768px) {
  nav ul {
    flex-direction: column;
    gap: 0;
  }
  
  .btn {
    display: block;
    width: 100%;
    margin: var(--spacing-small) 0;
  }
  
  /* Increase font size on touch devices */
  body {
    font-size: calc(var(--font-size-base) * 1.1);
  }
}

/* Print styles */
@media print {
  body {
    font-size: 12pt;
  }
  
  header,
  footer,
  nav,
  .skip-link {
    display: none;
  }
  
  .container {
    max-width: 100%;
  }
}

/* Reduced motion for users with vestibular disorders */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  /* Remove hover effects */
  .btn:hover,
  nav a:hover {
    background-color: transparent;
    outline: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000000;
    --secondary-color: #000080;
    --accent-color: #800000;
    --light-color: #ffffff;
    --dark-color: #000000;
    --success-color: #006400;
    --warning-color: #804000;
  }
  
  body {
    background-color: var(--light-color);
    color: var(--dark-color);
  }
  
  .btn {
    border: 2px solid var(--dark-color);
  }
}

/* Ensure proper semantics for screen readers */
.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 styles for custom components */
.focusable {
  outline: 0;
}

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

/* Ensure sufficient color contrast for all text */
.primary-text {
  color: var(--primary-color);
}

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

.accent-text {
  color: var(--accent-color);
}

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

.warning-text {
  color: var(--warning-color);
}

/* Responsive typography */
html {
  font-size: 100%; /* Sets base font size to browser default */
}

h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

h2 {
  font-size: clamp(1.3rem, 3vw, 2rem);
}

/* Animation for loading states */
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.loading {
  animation: pulse 1.5s infinite;
}