/* Enhanced Accessibility Styles for FeedMind */

/* Skip links for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 9999;
  font-weight: bold;
}

.skip-link:focus {
  top: 6px;
}

/* 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;
}

/* High contrast mode styles */
.high-contrast {
  --contrast-bg: #000000;
  --contrast-text: #ffffff;
  --contrast-primary: #ffff00;
  --contrast-secondary: #00ffff;
  --contrast-border: #ffffff;
}

.high-contrast * {
  background-color: var(--contrast-bg) !important;
  color: var(--contrast-text) !important;
  border-color: var(--contrast-border) !important;
}

.high-contrast a,
.high-contrast button:not([aria-pressed="true"]),
.high-contrast .text-indigo-500,
.high-contrast .text-blue-500,
.high-contrast .text-purple-500 {
  color: var(--contrast-primary) !important;
}

.high-contrast button[aria-pressed="true"],
.high-contrast .bg-indigo-500,
.high-contrast .bg-blue-500 {
  background-color: var(--contrast-primary) !important;
  color: var(--contrast-bg) !important;
}

.high-contrast img {
  opacity: 0.8;
  filter: contrast(150%) brightness(120%);
}

/* Dyslexia-friendly font */
.dyslexia-font,
.dyslexia-font * {
  font-family: 'OpenDyslexic', 'Comic Sans MS', cursive !important;
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
  line-height: 1.6 !important;
}

/* Reduced motion styles */
.reduced-motion,
.reduced-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

.reduced-motion .hover\:scale-105:hover {
  transform: none !important;
}

/* Enhanced focus indicators */
*:focus {
  outline: 3px solid #4f46e5;
  outline-offset: 2px;
}

.high-contrast *:focus {
  outline: 3px solid #ffff00 !important;
  outline-offset: 2px;
}

/* Better button touch targets */
button, 
[role="button"],
a {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Improved text spacing for readability */
.dyslexia-font p,
.dyslexia-font li {
  margin-bottom: 1.5em !important;
}

.dyslexia-font h1,
.dyslexia-font h2,
.dyslexia-font h3,
.dyslexia-font h4,
.dyslexia-font h5,
.dyslexia-font h6 {
  margin-top: 1.5em !important;
  margin-bottom: 1em !important;
}

/* High contrast prose adjustments */
.high-contrast-prose p,
.high-contrast-prose li,
.high-contrast-prose h1,
.high-contrast-prose h2,
.high-contrast-prose h3,
.high-contrast-prose h4,
.high-contrast-prose h5,
.high-contrast-prose h6 {
  color: var(--contrast-text) !important;
}

.high-contrast-prose a {
  color: var(--contrast-primary) !important;
  text-decoration: underline !important;
}

/* Smooth scrolling (respects reduced motion) */
html {
  scroll-behavior: smooth;
}

.reduced-motion html {
  scroll-behavior: auto;
}

/* Better font rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Line clamp utilities */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Enhanced hover effects with accessibility considerations */
.hover\:shadow-md:hover:not(.reduced-motion *) {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
  transition: all 0.2s ease;
}

/* Prose styling for article content */
.prose {
  max-width: 65ch;
  color: inherit;
  font-size: 1.1em;
  line-height: 1.7;
}

.prose p {
  margin-bottom: 1.25em;
}

.prose h2 {
  margin-top: 1.5em;
  margin-bottom: 0.8em;
  font-size: 1.5em;
  font-weight: 700;
}

.prose ul {
  margin-top: 1em;
  margin-bottom: 1em;
}

.prose li {
  margin-bottom: 0.5em;
}

/* Dark mode prose adjustments */
.dark .prose-invert {
  color: #e2e8f0;
}

.dark .prose-invert a {
  color: #90cdf4;
}

/* Accessible scrollbar */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.dark ::-webkit-scrollbar-thumb {
  background: #4a5568;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #718096;
}

.high-contrast ::-webkit-scrollbar-thumb {
  background: #ffff00 !important;
}

/* Keyboard shortcut styling */
kbd {
  background-color: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 2px #fff inset;
  color: #2d3748;
  display: inline-block;
  font-family: monospace;
  font-size: 0.85em;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  white-space: nowrap;
}

.dark kbd {
  background-color: #2d3748;
  border-color: #4a5568;
  color: #e2e8f0;
}

.high-contrast kbd {
  background-color: #000000 !important;
  border-color: #ffff00 !important;
  color: #ffff00 !important;
}

/* Modal backdrop for better contrast */
.modal-backdrop {
  backdrop-filter: blur(4px);
}

/* Enhanced focus ring for modal elements */
[role="dialog"] *:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Improved button states */
button[aria-pressed="true"] {
  transform: scale(0.98);
}

button[aria-expanded="true"] {
  font-weight: 600;
}

/* Loading state accessibility */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.reduced-motion .animate-pulse {
  animation: none;
}

/* Progress bar styling */
[role="progressbar"] {
  transition: width 0.3s ease;
}

.reduced-motion [role="progressbar"] {
  transition: none;
}

/* Print styles for accessibility */
@media print {
  .skip-link,
  button:not(.print-button),
  nav,
  .modal-backdrop,
  [role="dialog"] {
    display: none !important;
  }
  
  body {
    font-size: 12pt !important;
    line-height: 1.5 !important;
    color: black !important;
    background: white !important;
  }
  
  a {
    color: black !important;
    text-decoration: underline !important;
  }
  
  .prose {
    max-width: none !important;
  }
}

/* Responsive font scaling */
@media (max-width: 768px) {
  .prose {
    font-size: 1em;
  }
  
  .dyslexia-font {
    font-size: 1.1em !important;
  }
}

/* Animation for screen reader announcements */
#sr-announcements:not(:empty),
#sr-status:not(:empty) {
  clip: auto;
  width: auto;
  height: auto;
  overflow: visible;
  position: fixed;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  z-index: 10000;
  max-width: 300px;
  word-wrap: break-word;
}

/* Ensure proper contrast ratios */
.text-gray-500 {
  color: #6b7280;
}

.dark .text-gray-400 {
  color: #9ca3af;
}

.high-contrast .text-gray-500,
.high-contrast .text-gray-400 {
  color: #ffffff !important;
}

/* Enhanced link styling */
a:hover,
a:focus {
  text-decoration: underline;
}

.high-contrast a:hover,
.high-contrast a:focus {
  background-color: var(--contrast-primary) !important;
  color: var(--contrast-bg) !important;
}

/* Improved table accessibility (if tables are added) */
table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  text-align: left;
}

th {
  background-color: #f7fafc;
  font-weight: 600;
}

.dark th {
  background-color: #2d3748;
}

.high-contrast th,
.high-contrast td {
  border-color: var(--contrast-border) !important;
}

/* Error state styling */
.error {
  color: #dc2626;
  border-color: #dc2626;
}

.high-contrast .error {
  color: #ffff00 !important;
  border-color: #ffff00 !important;
}

/* Success state styling */
.success {
  color: #059669;
  border-color: #059669;
}

.high-contrast .success {
  color: #00ffff !important;
  border-color: #00ffff !important;
}