/**
 * Ziyo International - Accessibility Styles
 * WCAG 2.1 AA Compliant Enhancements
 * Version: 1.0
 */

/* ============================================
   SKIP LINKS
   ============================================ */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--copper-gradient);
  color: var(--dark-primary);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  font-weight: 600;
  z-index: 10000;
  transition: top 0.3s ease;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-md);
  outline: 3px solid var(--copper-gold);
  outline-offset: 2px;
}

/* ============================================
   FOCUS INDICATORS
   ============================================ */
:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--copper-gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Enhanced focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--copper-gold);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(184, 115, 51, 0.2);
}

/* Focus styles for buttons */
.btn-ziyo:focus-visible {
  outline: 3px solid var(--copper-gold);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(184, 115, 51, 0.25);
}

/* Focus styles for form inputs */
.form-control-ziyo:focus-visible {
  outline: none;
  border-color: var(--copper-gold);
  box-shadow: 0 0 0 4px rgba(184, 115, 51, 0.15);
}

/* Focus styles for cards */
.card-ziyo:focus-visible,
.feature-card:focus-visible {
  outline: 3px solid var(--copper-gold);
  outline-offset: 4px;
}

/* Focus styles for navigation links */
.nav-link-ziyo:focus-visible {
  outline: 2px solid var(--copper-gold);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

/* ============================================
   HIGH CONTRAST MODE SUPPORT
   ============================================ */
@media (prefers-contrast: high) {
  :root {
    --dark-primary: #000000;
    --dark-secondary: #0a0a0a;
    --dark-tertiary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --copper-gold: #ffa500;
  }

  .card-ziyo,
  .feature-card,
  .metric-card {
    border-width: 2px;
  }

  .btn-ziyo {
    border: 2px solid currentColor;
  }

  .nav-link-ziyo::after {
    height: 3px;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@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;
  }

  /* Disable parallax */
  .hero-background {
    transform: none !important;
  }

  /* Disable hover effects */
  .card-ziyo:hover,
  .feature-card:hover {
    transform: none !important;
  }

  /* Disable cursor trailer */
  .cursor-trail-dot {
    display: none !important;
  }

  /* Disable magnetic effects */
  .magnetic {
    transform: none !important;
  }

  /* Disable fade animations */
  .fade-up,
  .fade-in,
  .slide-in-left,
  .slide-in-right {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  /* Disable loading animations */
  .skeleton,
  .skeleton-shimmer,
  .loading-spinner {
    animation: none !important;
  }

  /* Instant page transitions */
  .page-transition {
    transition: none !important;
  }
}

/* ============================================
   TEXT SIZING AND READABILITY
   ============================================ */
/* Minimum touch target size (44x44 px) */
button,
a,
input[type="button"],
input[type="submit"],
input[type="reset"],
[role="button"] {
  min-height: 44px;
  min-width: 44px;
}

/* Ensure adequate line height for readability */
body {
  line-height: 1.6;
}

p,
li,
dd {
  line-height: 1.7;
}

/* Text spacing for cognitive accessibility */
.accessible-text {
  letter-spacing: 0.12em;
  word-spacing: 0.16em;
  line-height: 1.8;
}

/* Large text option */
.text-large {
  font-size: 1.25em;
  line-height: 1.8;
}

/* ============================================
   SCREEN READER UTILITIES
   ============================================ */
/* Visually hidden but accessible to screen readers */
.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: 0;
}

/* Show on focus (for skip links) */
.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Hide from screen readers */
.aria-hidden {
  speak: none;
}

/* ============================================
   LANDMARK REGIONS
   ============================================ */
/* Visual indicators for landmark regions in high contrast */
@media (prefers-contrast: high) {
  main {
    border-top: 1px solid var(--dark-border);
    border-bottom: 1px solid var(--dark-border);
  }

  nav[aria-label] {
    border-bottom: 2px solid var(--copper-gold);
  }

  footer {
    border-top: 2px solid var(--copper-gold);
  }
}

/* ============================================
   FORM ACCESSIBILITY
   ============================================ */
/* Required field indicator */
.required-field::after {
  content: " *";
  color: #ff6b6b;
  font-weight: bold;
}

/* Error states */
.field-error {
  border-color: #ff6b6b !important;
  background-color: rgba(255, 107, 107, 0.05);
}

.error-message {
  color: #ff6b6b;
  font-size: var(--text-sm);
  margin-top: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.error-message::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ff6b6b'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
  background-size: contain;
  flex-shrink: 0;
}

/* Success states */
.field-success {
  border-color: #50C878 !important;
}

.success-message {
  color: #50C878;
  font-size: var(--text-sm);
  margin-top: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.success-message::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2350C878'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
  background-size: contain;
  flex-shrink: 0;
}

/* Helper text */
.form-helper {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-xs);
}

/* Label associations */
label {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--text-secondary);
  cursor: pointer;
}

/* Fieldset and legend styling */
fieldset {
  border: 1px solid var(--dark-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

legend {
  color: var(--text-primary);
  font-weight: 600;
  padding: 0 var(--space-sm);
}

/* ============================================
   LINK ACCESSIBILITY
   ============================================ */
/* External link indicator */
a[target="_blank"]::after {
  content: " ";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  vertical-align: middle;
  opacity: 0.7;
}

/* Skip external indicator on specific elements */
.no-external-icon[target="_blank"]::after,
.footer-social a[target="_blank"]::after,
.social-link[target="_blank"]::after {
  display: none;
}

/* Link underlines for better visibility */
main a:not(.btn-ziyo):not([class*="card"]) {
  text-decoration: underline;
  text-underline-offset: 3px;
}

main a:not(.btn-ziyo):not([class*="card"]):hover {
  text-decoration-thickness: 2px;
}

/* ============================================
   COLOR BLIND SUPPORT
   ============================================ */
/* Add patterns/icons to color-coded elements */
.status-success::before {
  content: "\2713 "; /* Checkmark */
}

.status-error::before {
  content: "\2717 "; /* X mark */
}

.status-warning::before {
  content: "\26A0 "; /* Warning */
}

.status-info::before {
  content: "\2139 "; /* Info */
}

/* ============================================
   TABLE ACCESSIBILITY
   ============================================ */
table {
  border-collapse: collapse;
  width: 100%;
}

table caption {
  text-align: left;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

th {
  text-align: left;
  font-weight: 600;
  padding: var(--space-md);
  background: var(--dark-tertiary);
}

td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--dark-border);
}

/* Row hover for better tracking */
tbody tr:hover {
  background: rgba(184, 115, 51, 0.05);
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  /* Hide non-essential elements */
  nav,
  footer,
  .btn-back-to-top,
  .mobile-menu-overlay,
  .mobile-menu-toggle,
  .cursor-trail-dot,
  .lang-toggle {
    display: none !important;
  }

  /* Ensure text is visible */
  body {
    color: #000 !important;
    background: #fff !important;
  }

  /* Print links with URLs */
  main a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Avoid page breaks in cards */
  .card-ziyo,
  .feature-card {
    break-inside: avoid;
  }

  /* Ensure images print */
  img {
    max-width: 100%;
    page-break-inside: avoid;
  }
}

/* ============================================
   DARK MODE TOGGLE SUPPORT (if needed)
   ============================================ */
@media (prefers-color-scheme: light) {
  /* The site is primarily dark, but support light mode if needed */
  .light-mode-support {
    --dark-primary: #ffffff;
    --dark-secondary: #f5f5f5;
    --dark-tertiary: #e0e0e0;
    --dark-card: #ffffff;
    --dark-border: #d0d0d0;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #6a6a6a;
  }
}

/* ============================================
   KEYBOARD NAVIGATION INDICATORS
   ============================================ */
/* Show keyboard focus differently from mouse focus */
body.keyboard-nav *:focus {
  outline: 3px solid var(--copper-gold);
  outline-offset: 2px;
}

body:not(.keyboard-nav) *:focus {
  outline: none;
}

/* Tab focus ring */
.tab-ring {
  position: relative;
}

.tab-ring::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid transparent;
  border-radius: inherit;
  pointer-events: none;
  transition: border-color 0.2s;
}

.tab-ring:focus-visible::before {
  border-color: var(--copper-gold);
}

/* ============================================
   LIVE REGIONS
   ============================================ */
[aria-live="polite"],
[aria-live="assertive"] {
  position: relative;
}

/* Announcement styling */
.sr-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ============================================
   LOADING STATES
   ============================================ */
[aria-busy="true"] {
  cursor: wait;
  opacity: 0.7;
}

[aria-busy="true"]::after {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: 0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   DIALOG/MODAL ACCESSIBILITY
   ============================================ */
[role="dialog"],
[role="alertdialog"] {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  max-height: 90vh;
  overflow-y: auto;
}

/* Modal backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
}

/* Trap focus visual indicator */
[data-focus-trap="active"] {
  outline: 2px dashed var(--copper-gold);
  outline-offset: 4px;
}
