/* TeleWorld AI - Accessibility Standards CSS */
/* WCAG 2.1 AA Compliance Implementation */

/* Focus Management and Keyboard Navigation */
:focus {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Remove outline for mouse users, keep for keyboard users */
.js-focus-visible :focus:not(.focus-visible) {
  outline: none;
}

.focus-visible {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
}

/* Skip Links for Screen Readers and Keyboard Users */
.skip-links {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 999999;
  width: 100%;
  background: #8b5cf6;
  padding: 0;
  margin: 0;
  list-style: none;
  text-align: center;
}

.skip-links li {
  display: inline-block;
  margin: 0;
}

.skip-link {
  display: inline-block;
  padding: 12px 20px;
  background: #8b5cf6;
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  border-radius: 0 0 8px 8px;
  margin: 0 4px;
  transition: all 0.3s ease;
}

.skip-link:focus {
  position: relative;
  top: 100px;
  outline: 3px solid #ffffff;
  outline-offset: 2px;
  background: #7c3aed;
  color: #ffffff;
}

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

.sr-only:focus,
.screen-reader-text:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: 8px 16px !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  background: #8b5cf6 !important;
  color: #ffffff !important;
  border-radius: 4px !important;
  text-decoration: none !important;
  z-index: 100000 !important;
  font-weight: 600 !important;
  font-size: 1rem !important;
  line-height: 1.4 !important;
}

/* Enhanced Button Accessibility */
button,
.btn,
input[type="button"],
input[type="submit"],
input[type="reset"],
[role="button"] {
  /* Minimum touch target size (44x44px) */
  min-height: 44px;
  min-width: 44px;

  /* Clear visual boundaries */
  border: 2px solid transparent;
  border-radius: 8px;

  /* Consistent typography */
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;

  /* Cursor indication */
  cursor: pointer;

  /* Transition for smooth interactions */
  transition: all 0.3s ease;

  /* Remove default appearance */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  /* Prevent text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

button:focus,
.btn:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
[role="button"]:focus {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
  border-color: #8b5cf6;
}

button:disabled,
.btn:disabled,
input[type="button"]:disabled,
input[type="submit"]:disabled,
input[type="reset"]:disabled,
[role="button"][aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Enhanced Link Accessibility — scoped to content areas only
   (bare `a` min-height/display broke nav, logo, footer, icon links) */
.entry-content a,
.site-main
  > .section
  a:not(.btn):not([role="button"]):not(.nav-menu a):not(.footer-links a):not(
    .social-link
  ):not(.logo a) {
  /* Minimum touch target size */
  min-height: 44px;
  min-width: 44px;
  display: inline-block;

  /* Clear visual indication */
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* Base link colour + smooth transitions (safe globally) */
a {
  color: inherit;
  transition: all 0.3s ease;
}

a:hover {
  color: #a855f7;
  text-decoration-thickness: 3px;
}

a:focus {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 4px;
}

a:visited {
  color: #7c3aed;
}

/* Remove underline for specific link types */
a.btn,
a[role="button"],
.logo a,
.nav-menu a {
  text-decoration: none;
}

/* Form Element Accessibility */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  /* Minimum touch target size */
  min-height: 44px;

  /* Clear visual boundaries */
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-radius: 8px;

  /* Consistent typography */
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;

  /* Adequate padding */
  padding: 12px 16px;

  /* Background and text colors */
  background-color: rgba(30, 41, 59, 0.6);
  color: #e2e8f0;

  /* Transition for smooth interactions */
  transition: all 0.3s ease;

  /* Remove default appearance */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus,
select:focus {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
  border-color: #8b5cf6;
  background-color: rgba(30, 41, 59, 0.8);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
  box-shadow: none;
}

input:invalid,
textarea:invalid,
select:invalid {
  border-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
}

input:invalid:focus,
textarea:invalid:focus,
select:invalid:focus {
  outline-color: #ef4444;
  border-color: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

/* Label and Form Field Associations */
label {
  display: block;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 8px;
  font-size: 1rem;
  line-height: 1.4;
}

.required::after {
  content: " *";
  color: #ef4444;
  font-weight: bold;
}

/* Error and Success Messages */
.error-message,
.success-message,
.info-message,
.warning-message {
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  margin: 16px 0;
  border-left: 4px solid;
  position: relative;
}

.error-message {
  background-color: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-left-color: #ef4444;
}

.success-message {
  background-color: rgba(34, 197, 94, 0.1);
  color: #86efac;
  border-left-color: #22c55e;
}

.info-message {
  background-color: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
  border-left-color: #3b82f6;
}

.warning-message {
  background-color: rgba(245, 158, 11, 0.1);
  color: #fcd34d;
  border-left-color: #f59e0b;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  body {
    background-color: #000000;
    color: #ffffff;
  }

  a {
    color: #ffffff;
    text-decoration: underline;
    text-decoration-thickness: 3px;
  }

  a:hover,
  a:focus {
    background-color: #ffffff;
    color: #000000;
  }

  button,
  .btn,
  input[type="button"],
  input[type="submit"],
  input[type="reset"] {
    background-color: #ffffff;
    color: #000000;
    border: 3px solid #ffffff;
  }

  button:hover,
  .btn:hover,
  input[type="button"]:hover,
  input[type="submit"]:hover,
  input[type="reset"]:hover {
    background-color: #000000;
    color: #ffffff;
    border-color: #ffffff;
  }

  input,
  textarea,
  select {
    background-color: #ffffff;
    color: #000000;
    border: 3px solid #000000;
  }

  input:not([type="checkbox"]):not([type="radio"]):focus,
  textarea:focus,
  select:focus {
    outline: 3px solid #ffffff;
    background-color: #000000;
    color: #ffffff;
  }
}

/* Reduced Motion Support */
@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;
  }

  .skip-link:focus {
    transition: none;
  }
}

/* Large Text Support */
@media (min-resolution: 2dppx) {
  body {
    font-size: 18px;
  }

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

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

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

/* Color Blind Accessibility */
.color-blind-safe {
  /* Use patterns and shapes in addition to color */
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(139, 92, 246, 0.1) 10px,
    rgba(139, 92, 246, 0.1) 20px
  );
}

/* Navigation Accessibility */
nav {
  position: relative;
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

nav li {
  position: relative;
}

nav a {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: #e2e8f0;
  border-radius: 8px;
  transition: all 0.3s ease;
}

nav a:hover,
nav a:focus {
  background-color: rgba(139, 92, 246, 0.2);
  color: #8b5cf6;
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
}

nav a[aria-current="page"] {
  background-color: rgba(139, 92, 246, 0.3);
  color: #a855f7;
  font-weight: 700;
}

/* Mobile Navigation Accessibility */
.mobile-menu-toggle {
  background: rgba(139, 92, 246, 0.1);
  border: 2px solid rgba(139, 92, 246, 0.3);
  color: #8b5cf6;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.mobile-menu-toggle:focus {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
  background: rgba(139, 92, 246, 0.2);
}

.mobile-menu-toggle[aria-expanded="true"] {
  background: rgba(139, 92, 246, 0.3);
  border-color: #8b5cf6;
}

/* Table Accessibility */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 24px 0;
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

th {
  background-color: rgba(139, 92, 246, 0.2);
  color: #e2e8f0;
  font-weight: 700;
}

tr:nth-child(even) {
  background-color: rgba(30, 41, 59, 0.3);
}

tr:hover {
  background-color: rgba(139, 92, 246, 0.1);
}

/* Caption and Description Accessibility */
.wp-caption {
  max-width: 100%;
  margin: 24px 0;
}

.wp-caption img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.wp-caption-text {
  font-size: 0.9rem;
  color: #94a3b8;
  text-align: center;
  padding: 8px 12px;
  margin: 8px 0 0 0;
  font-style: italic;
}

/* Video and Media Accessibility */
video,
audio {
  max-width: 100%;
  height: auto;
}

video:focus,
audio:focus {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
}

/* Loading and Progress Indicators */
.loading,
.progress {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(139, 92, 246, 0.4),
    transparent
  );
  animation: loading 2s infinite;
}

@keyframes loading {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Tooltip Accessibility */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  white-space: nowrap;
  z-index: 1000;
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-tooltip]:hover::before,
[data-tooltip]:focus::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(1px);
  border: 6px solid transparent;
  border-top-color: #1e293b;
  z-index: 1001;
}

/* Print Accessibility */
@media print {
  .skip-links,
  .mobile-menu-toggle,
  nav,
  .sr-only {
    display: none !important;
  }

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

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }
}

/* Focus Trap for Modals and Dropdowns */
.focus-trap {
  position: relative;
}

.focus-trap-start,
.focus-trap-end {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ARIA Live Regions */
.sr-live-region {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Custom Checkbox and Radio Accessibility */
/* NOTE: .remember-me-group checkboxes are excluded and re-styled below */
input[type="checkbox"],
input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

input[type="checkbox"] + label,
input[type="radio"] + label {
  position: relative;
  padding-left: 40px;
  cursor: pointer;
  display: inline-block;
  line-height: 24px;
  min-height: 24px;
}

input[type="checkbox"] + label::before,
input[type="radio"] + label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  border: 2px solid rgba(139, 92, 246, 0.5);
  background: rgba(30, 41, 59, 0.6);
  border-radius: 4px;
  transition: all 0.3s ease;
}

input[type="radio"] + label::before {
  border-radius: 50%;
}

input[type="checkbox"]:checked + label::before,
input[type="radio"]:checked + label::before {
  background: #8b5cf6;
  border-color: #8b5cf6;
}

input[type="checkbox"]:checked + label::after {
  content: "✓";
  position: absolute;
  left: 6px;
  top: 2px;
  color: #ffffff;
  font-weight: bold;
  font-size: 14px;
}

input[type="radio"]:checked + label::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
}

input[type="checkbox"]:focus + label::before,
input[type="radio"]:focus + label::before {
  outline: 3px solid #8b5cf6;
  outline-offset: 2px;
}

/* ─── Remember-me checkbox overrides for login forms ──────────────────────── */
/* These restore native checkbox visibility inside .remember-me-group         */
/* containers, overriding the global hidden-checkbox pattern above.           */

.remember-me-group {
  display: flex !important;
  align-items: center !important;
  text-align: left !important;
}

.remember-me-group input[type="checkbox"] {
  position: static !important;
  opacity: 1 !important;
  width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
  margin: 0 8px 0 0 !important;
  -webkit-appearance: checkbox !important;
  -moz-appearance: checkbox !important;
  appearance: checkbox !important;
  transform: none !important;
  accent-color: #8b5cf6;
  cursor: pointer;
  box-sizing: border-box;
}

.remember-me-group input[type="checkbox"] + label {
  position: static !important;
  padding-left: 0 !important;
  margin: 0 !important;
  display: inline-block !important;
  min-height: auto !important;
  line-height: normal !important;
}

/* Kill ALL pseudo-elements on the label — unchecked, checked, focused */
.remember-me-group input[type="checkbox"] + label::before,
.remember-me-group input[type="checkbox"] + label::after,
.remember-me-group input[type="checkbox"]:checked + label::before,
.remember-me-group input[type="checkbox"]:checked + label::after,
.remember-me-group input[type="checkbox"]:focus + label::before,
.remember-me-group input[type="checkbox"]:focus + label::after {
  content: none !important;
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  border: none !important;
  background: none !important;
  visibility: hidden !important;
  position: absolute !important;
  left: -9999px !important;
}

/* Responsive Text Scaling */
@media (max-width: 768px) {
  body {
    font-size: 18px;
    line-height: 1.7;
  }

  button,
  .btn,
  input,
  textarea,
  select {
    min-height: 48px;
    font-size: 18px;
  }

  a {
    min-height: 48px;
    min-width: 48px;
  }
}
