/**
 * ZMCOR Accessibility Styles
 * Enhanced focus indicators, high contrast mode, reduced motion
 */

/* ===== Skip Links ===== */
.skip-links {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10001;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 0.75rem 1.5rem;
  background: var(--color-brand-primary, #0066cc);
  color: white;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm, 0.375rem) 0;
  box-shadow: var(--shadow-md);
  transform: translateY(-100%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  top: 0;
  transform: translateY(0);
  outline: 3px solid var(--color-brand-secondary, #00c853);
  outline-offset: 2px;
}

/* ===== Enhanced Focus Indicators ===== */
.keyboard-user *:focus {
  outline: 3px solid var(--focus-ring-color, rgba(0, 102, 204, 0.5));
  outline-offset: 2px;
}

.keyboard-user button:focus,
.keyboard-user a:focus,
.keyboard-user input:focus,
.keyboard-user select:focus,
.keyboard-user textarea:focus {
  outline: 3px solid var(--focus-ring-color, rgba(0, 102, 204, 0.5));
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.15);
}

/* Dark backgrounds need different focus color */
.header .keyboard-user *:focus,
.footer .keyboard-user *:focus,
[class*="dark"] .keyboard-user *:focus {
  outline-color: rgba(255, 255, 255, 0.8);
}

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

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: more) {
  :root {
    --color-brand-primary: #0044cc;
    --color-neutral-600: #333333;
    --color-neutral-400: #555555;
    --shadow-sm: 0 0 0 1px #000;
    --shadow-md: 0 0 0 2px #000;
  }
}

.high-contrast {
  --color-brand-primary: #0044cc;
  --color-neutral-900: #000000;
  --color-neutral-600: #333333;
  --color-neutral-400: #555555;
  --color-neutral-200: #cccccc;
  --color-neutral-100: #f0f0f0;
  --color-neutral-0: #ffffff;
}

.high-contrast body {
  background: white;
  color: black;
}

.high-contrast a {
  color: #0044cc;
  text-decoration: underline;
}

.high-contrast button,
.high-contrast .btn {
  border: 2px solid currentColor;
}

.high-contrast img {
  filter: contrast(1.1);
}

.high-contrast .card,
.high-contrast .plan-card,
.high-contrast .resource-card {
  border: 2px solid #333;
}

/* ===== Service Worker Update Notification ===== */
.sw-update-notification {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--color-neutral-900, #101828);
  color: white;
  border-radius: var(--radius-lg, 0.75rem);
  box-shadow: var(--shadow-xl);
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 9999;
}

.sw-update-notification--visible {
  transform: translateY(0);
  opacity: 1;
}

.sw-update-notification__content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9375rem;
}

.sw-update-notification__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sw-update-notification__refresh {
  padding: 0.5rem 1rem;
  background: var(--color-brand-primary, #0066cc);
  color: white;
  border: none;
  border-radius: var(--radius-sm, 0.375rem);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sw-update-notification__refresh:hover {
  background: var(--color-brand-dark, #004c99);
}

.sw-update-notification__dismiss {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  color: var(--color-neutral-400, #98a2b3);
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.sw-update-notification__dismiss:hover {
  color: white;
}

/* ===== Live Region for Announcements ===== */
#a11y-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Improved Link Visibility ===== */
a:not(.btn):not(.nav-link):not(.logo) {
  text-decoration-skip-ink: auto;
}

a:not(.btn):not(.nav-link):not(.logo):hover {
  text-decoration: underline;
}

/* ===== Better Form Accessibility ===== */
input:invalid,
select:invalid,
textarea:invalid {
  border-color: var(--color-error, #d92d20);
}

input:invalid:focus,
select:invalid:focus,
textarea:invalid:focus {
  outline-color: var(--color-error, #d92d20);
  box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.15);
}

/* Error messages */
.field-error {
  color: var(--color-error, #d92d20);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.field-error::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--color-error, #d92d20);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Required field indicator */
label[required]::after,
.required::after {
  content: " *";
  color: var(--color-error, #d92d20);
}

/* ===== Touch Target Sizes (WCAG 2.5.5) ===== */
@media (pointer: coarse) {
  button,
  a,
  input[type="checkbox"],
  input[type="radio"],
  select {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-link {
    padding: 0.75rem 1rem;
  }
}

/* ===== Print Styles for Accessibility ===== */
@media print {
  .skip-links,
  .sw-update-notification,
  .exit-popup,
  .share-bar-floating {
    display: none !important;
  }

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

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