/* ==========================================================================
   PRODUCTION-READY ACCESSIBILITY SYSTEM (WCAG 2.2 Level AA Target)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Variables & Root Definitions
   -------------------------------------------------------------------------- */
:root {
  --a11y-primary: #1B6E72;
  --a11y-primary-dark: #0F2E37;
  --a11y-accent: #E67E22;
  --a11y-focus-ring: #F39C12;
  --a11y-panel-bg: #FFFFFF;
  --a11y-panel-text: #1E293B;
  --a11y-panel-border: #E2E8F0;
  --a11y-btn-hover: #F1F5F9;
  --a11y-active-bg: #E0F2FE;
  --a11y-active-border: #0284C7;
  --a11y-active-text: #0369A1;
  --a11y-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --a11y-font-scale: 1;
}

/* --------------------------------------------------------------------------
   2. Keyboard Focus Ring Standards (WCAG 2.2 Target Size & Contrast)
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--a11y-focus-ring) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.3) !important;
}

/* --------------------------------------------------------------------------
   3. Floating Trigger Button (Lower-Left Corner)
   -------------------------------------------------------------------------- */
.a11y-trigger {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99999;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--a11y-primary);
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
  box-shadow: var(--a11y-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease, box-shadow 0.2s ease;
}

.a11y-trigger:hover {
  background: var(--a11y-primary-dark);
  transform: scale(1.08);
  box-shadow: 0 12px 28px rgba(0,0,0,0.3);
}

.a11y-trigger:active {
  transform: scale(0.95);
}

.a11y-trigger svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* --------------------------------------------------------------------------
   4. Off-Canvas Left Slide-Out Panel & Backdrop
   -------------------------------------------------------------------------- */
.a11y-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.a11y-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.a11y-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--a11y-panel-bg);
  color: var(--a11y-panel-text);
  z-index: 999999;
  box-shadow: 8px 0 30px rgba(0, 0, 0, 0.2);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.a11y-panel.is-open {
  transform: translateX(0);
}

/* Panel Header */
.a11y-panel__header {
  padding: 20px 24px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--a11y-panel-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.a11y-panel__title-group h2 {
  margin: 0 0 4px 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--a11y-primary-dark);
  line-height: 1.2;
}

.a11y-panel__title-group p {
  margin: 0;
  font-size: 0.875rem;
  color: #64748B;
  line-height: 1.4;
}

.a11y-panel__close-btn {
  background: transparent;
  border: 1px solid var(--a11y-panel-border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.a11y-panel__close-btn:hover {
  background: #E2E8F0;
  color: #0F172A;
}

/* Panel Content Body */
.a11y-panel__body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.a11y-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.a11y-control-btn {
  background: #F8FAFC;
  border: 2px solid var(--a11y-panel-border);
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 84px;
}

.a11y-control-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.a11y-control-btn:hover {
  background: var(--a11y-btn-hover);
  border-color: #CBD5E1;
  color: #0F172A;
}

.a11y-control-btn[aria-pressed="true"] {
  background: var(--a11y-active-bg);
  border-color: var(--a11y-active-border);
  color: var(--a11y-active-text);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.a11y-control-btn--reset {
  grid-column: span 2;
  background: #FEF2F2;
  border-color: #FCA5A5;
  color: #991B1B;
  margin-top: 8px;
}

.a11y-control-btn--reset:hover {
  background: #FEE2E2;
  border-color: #F87171;
  color: #7F1D1D;
}

/* Panel Footer Note */
.a11y-panel__footer {
  padding: 16px 24px;
  background: #F8FAFC;
  border-top: 1px solid var(--a11y-panel-border);
  font-size: 0.75rem;
  color: #64748B;
  text-align: center;
}

/* --------------------------------------------------------------------------
   5. Accessibility Class Overrides (Applied to <html> / <body>)
   -------------------------------------------------------------------------- */

/* Text Size Controls */
html.a11y-text-lg {
  font-size: 118% !important;
}

html.a11y-text-sm {
  font-size: 92% !important;
}

/* High Contrast Mode */
html.a11y-high-contrast {
  background-color: #000000 !important;
  color: #FFFF00 !important;
}

html.a11y-high-contrast body {
  background-color: #000000 !important;
  color: #FFFF00 !important;
}

html.a11y-high-contrast a {
  color: #00FFFF !important;
  text-decoration: underline !important;
  font-weight: 700 !important;
}

html.a11y-high-contrast button,
html.a11y-high-contrast .btn {
  background: #000000 !important;
  color: #FFFF00 !important;
  border: 3px solid #FFFF00 !important;
}

html.a11y-high-contrast .a11y-panel {
  background: #000000 !important;
  color: #FFFFFF !important;
  border-right: 2px solid #FFFF00 !important;
}

html.a11y-high-contrast .a11y-control-btn {
  background: #000000 !important;
  color: #FFFFFF !important;
  border: 2px solid #FFFFFF !important;
}

html.a11y-high-contrast .a11y-control-btn[aria-pressed="true"] {
  background: #FFFF00 !important;
  color: #000000 !important;
  border-color: #FFFF00 !important;
}

/* Grayscale Mode */
html.a11y-grayscale {
  filter: grayscale(100%) !important;
}

/* Invert Colors Mode */
html.a11y-invert {
  filter: invert(100%) hue-rotate(180deg) !important;
}

html.a11y-invert img,
html.a11y-invert video,
html.a11y-invert iframe {
  filter: invert(100%) hue-rotate(180deg) !important;
}

/* Highlight Links Mode */
html.a11y-highlight-links a {
  background-color: #FEF08A !important;
  color: #000000 !important;
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  font-weight: 700 !important;
  padding: 0 4px !important;
  border-radius: 2px !important;
}

/* Readable Font Mode */
html.a11y-readable-font,
html.a11y-readable-font body,
html.a11y-readable-font h1,
html.a11y-readable-font h2,
html.a11y-readable-font h3,
html.a11y-readable-font h4,
html.a11y-readable-font p,
html.a11y-readable-font a,
html.a11y-readable-font span {
  font-family: Arial, Helvetica, Verdana, sans-serif !important;
  letter-spacing: 0.02em !important;
  word-spacing: 0.05em !important;
  line-height: 1.7 !important;
}

/* Pause Animations Mode */
html.a11y-pause-animations *,
html.a11y-pause-animations *::before,
html.a11y-pause-animations *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001s !important;
  scroll-behavior: auto !important;
}

/* Bigger Cursor Mode */
html.a11y-big-cursor,
html.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 24 24' fill='%231B6E72' stroke='%23FFFFFF' stroke-width='2'%3E%3Cpath d='M3 3l7 18 3-7 7-3L3 3z'/%3E%3C/svg%3E"), auto !important;
}

/* --------------------------------------------------------------------------
   6. Mobile & Reduced Motion Responsive Overrides
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .a11y-trigger {
    bottom: 16px;
    left: 16px;
    width: 48px;
    height: 48px;
  }
  
  .a11y-panel {
    width: 100vw;
    max-width: 100vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .a11y-panel,
  .a11y-backdrop,
  .a11y-trigger {
    transition: none !important;
  }
}
