/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   WCAG 2.1 AA Compliance
   ======================================== */

/* ========================================
   SKIP LINKS - Screen Readers & Keyboard
   ======================================== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #00ffff;
  color: #000;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 700;
  z-index: 10000;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ========================================
   FOCUS INDICATORS - WCAG 2.4.7
   ======================================== */

/* All interactive elements get visible focus */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
.nav-item:focus,
.btn:focus,
.pill:focus,
[tabindex]:focus {
  outline: 3px solid #00ffff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(0, 255, 255, 0.2);
}

/* Focus-visible for mouse vs keyboard */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #00ffff;
  outline-offset: 2px;
}

/* ========================================
   COLOR CONTRAST FIXES - WCAG 1.4.3
   Minimum 4.5:1 for normal text
   Minimum 3:1 for large text (18pt+)
   ======================================== */

/* Improve muted text contrast */
.subtle,
.muted2,
.card-meta,
.text-secondary {
  color: #b8b8b8; /* Improved from #808080 for better contrast */
}

/* Ensure all body text meets 4.5:1 */
body {
  color: #ffffff; /* Pure white on #0a0a0a = 19.56:1 ✓ */
}

/* Improve link contrast */
a {
  color: #33d6ff; /* Lightened cyan for better contrast */
}

a:hover {
  color: #66e0ff;
}

/* Party pill contrast fixes */
.pill.libdem,
.party-pill.libdem {
  background: #FAA61A;
  color: #000000; /* Black text for contrast */
  font-weight: 700;
}

.pill.snp,
.party-pill.snp {
  background: #FDF38E;
  color: #000000; /* Black text for contrast */
  font-weight: 700;
}

.pill.reform,
.party-pill.reform {
  background: #12B6CF;
  color: #000000; /* Black text for contrast */
  font-weight: 700;
}

/* ========================================
   FORM LABELS - WCAG 1.3.1, 3.3.2
   ======================================== */

/* Ensure all labels are associated */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #ffffff;
}

/* Required field indicator */
.required:after {
  content: ' *';
  color: #ff6b6b;
  font-weight: 700;
}

/* Error messages */
.error-message,
.form-error {
  color: #ff6b6b;
  font-size: 0.9rem;
  margin-top: 0.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-message:before {
  content: '⚠';
  font-size: 1.1rem;
}

/* Success messages */
.success-message {
  color: #5affbd;
  font-size: 0.9rem;
  margin-top: 0.25rem;
  font-weight: 600;
}

/* ========================================
   KEYBOARD NAVIGATION IMPROVEMENTS
   ======================================== */

/* Make focus order logical */
main {
  position: relative;
}

/* Ensure focusable elements are keyboard-accessible */
[role="button"],
[onclick] {
  cursor: pointer;
}

[role="button"]:not(button):not(a) {
  padding: 0.5rem 1rem;
  border: 2px solid var(--accent);
  border-radius: 4px;
}

/* ========================================
   SCREEN READER IMPROVEMENTS
   ======================================== */

/* Screen reader only text */
.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ========================================
   BUTTON TOUCH TARGETS - WCAG 2.5.5
   Minimum 44x44px
   ======================================== */

button,
.btn,
a.button,
input[type="submit"],
input[type="button"] {
  min-height: 44px;
  min-width: 44px;
  padding: 0.75rem 1.5rem;
}

/* Nav items on mobile */
@media screen and (max-width: 767px) {
  .nav-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

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

/* Proper table headers */
table {
  border-collapse: collapse;
}

th {
  text-align: left;
  font-weight: 700;
}

/* Improve table focus */
tr:focus-within {
  outline: 2px solid #00ffff;
  outline-offset: -2px;
}

/* ========================================
   HEADING HIERARCHY - WCAG 1.3.1
   ======================================== */

/* Ensure h1 is largest */
h1 {
  font-size: 2rem;
  font-weight: 700;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

@media screen and (min-width: 768px) {
  h1 {
    font-size: 2.5rem;
  }
  
  h2 {
    font-size: 1.75rem;
  }
}

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

/* Ensure all images are accessible */
img {
  max-width: 100%;
  height: auto;
}

/* Decorative images should have empty alt */
img[alt=""],
img[role="presentation"] {
  /* These are marked as decorative */
}

/* ========================================
   ANIMATION RESPECT - WCAG 2.3.3
   ======================================== */

@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;
  }
  
  .dot:before {
    animation: none;
  }
}

/* ========================================
   HIGH CONTRAST MODE SUPPORT
   ======================================== */

@media (prefers-contrast: high) {
  :root {
    --text-primary: #ffffff;
    --bg-black: #000000;
    --border: rgba(255,255,255,0.5);
  }
  
  .pill,
  .btn,
  button {
    border-width: 3px;
  }
}

/* ========================================
   LANDMARKS - Ensure proper structure
   ======================================== */

header[role="banner"],
main[role="main"],
nav[role="navigation"],
footer[role="contentinfo"] {
  /* Semantic structure for screen readers */
}

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

@media screen and (max-width: 767px) {
  /* Increase touch targets on mobile */
  a,
  button,
  .clickable {
    min-height: 44px;
    padding: 0.75rem;
  }
  
  /* Improve form field size */
  input,
  select,
  textarea {
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 44px;
  }
}

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

@media print {
  /* Hide non-essential elements */
  .skip-link,
  .menu-toggle,
  nav,
  footer {
    display: none;
  }
  
  /* Ensure links are visible */
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  
  /* Don't show links for skip links and anchors */
  a[href^="#"]:after,
  a[href^="javascript"]:after {
    content: "";
  }
}
