/* ==========================================================================
   ELITECARE CUSTOM ACCESSIBILITY SUITE
   Fully Mobile-Friendly, Accessible, Glassmorphic & High-Contrast Capable
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* --- Root Variable Adjustments --- */
:root {
  --a11y-font-scale: 1;
}

html {
  font-size: calc(100% * var(--a11y-font-scale, 1));
  transition: font-size 0.2s ease;
}

/* --- Dyslexia-Friendly Font Override --- */
html[data-a11y-font="dyslexic"],
html[data-a11y-font="dyslexic"] body,
html[data-a11y-font="dyslexic"] p,
html[data-a11y-font="dyslexic"] h1,
html[data-a11y-font="dyslexic"] h2,
html[data-a11y-font="dyslexic"] h3,
html[data-a11y-font="dyslexic"] h4,
html[data-a11y-font="dyslexic"] h5,
html[data-a11y-font="dyslexic"] h6,
html[data-a11y-font="dyslexic"] a,
html[data-a11y-font="dyslexic"] button,
html[data-a11y-font="dyslexic"] input,
html[data-a11y-font="dyslexic"] select,
html[data-a11y-font="dyslexic"] textarea {
  font-family: 'Atkinson Hyperlegible', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* --- High Contrast Mode --- */
html[data-a11y-contrast="high"] {
  background-color: #000000 !important;
  color: #ffff00 !important;
}

html[data-a11y-contrast="high"] body,
html[data-a11y-contrast="high"] main,
html[data-a11y-contrast="high"] section,
html[data-a11y-contrast="high"] header,
html[data-a11y-contrast="high"] footer,
html[data-a11y-contrast="high"] div,
html[data-a11y-contrast="high"] article,
html[data-a11y-contrast="high"] nav,
html[data-a11y-contrast="high"] card {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #ffff00 !important;
}

html[data-a11y-contrast="high"] h1,
html[data-a11y-contrast="high"] h2,
html[data-a11y-contrast="high"] h3,
html[data-a11y-contrast="high"] h4,
html[data-a11y-contrast="high"] h5,
html[data-a11y-contrast="high"] h6,
html[data-a11y-contrast="high"] strong,
html[data-a11y-contrast="high"] b {
  color: #ffff00 !important;
}

html[data-a11y-contrast="high"] a {
  color: #00ffff !important;
  text-decoration: underline !important;
  font-weight: 700 !important;
}

html[data-a11y-contrast="high"] button,
html[data-a11y-contrast="high"] .btn,
html[data-a11y-contrast="high"] .cta-button {
  background-color: #ffff00 !important;
  color: #000000 !important;
  border: 3px solid #ffffff !important;
  font-weight: 800 !important;
}

/* --- Color Invert Mode --- */
html[data-a11y-contrast="invert"] {
  filter: invert(1) hue-rotate(180deg);
}

html[data-a11y-contrast="invert"] img,
html[data-a11y-contrast="invert"] video,
html[data-a11y-contrast="invert"] iframe,
html[data-a11y-contrast="invert"] .a11y-modal-card,
html[data-a11y-contrast="invert"] .a11y-trigger-btn {
  filter: invert(1) hue-rotate(180deg);
}

/* --- Highlight Links --- */
html[data-a11y-links="highlight"] a {
  background-color: #ffeb3b !important;
  color: #000000 !important;
  font-weight: 700 !important;
  text-decoration: underline 3px #000000 !important;
  padding: 2px 5px !important;
  border-radius: 4px !important;
  box-shadow: 0 0 0 2px #000000 !important;
}

/* --- Expanded Line & Letter Spacing --- */
html[data-a11y-spacing="large"] p,
html[data-a11y-spacing="large"] li,
html[data-a11y-spacing="large"] span,
html[data-a11y-spacing="large"] a {
  line-height: 2.1 !important;
  letter-spacing: 0.12em !important;
  word-spacing: 0.18em !important;
}

/* --- Pause Animations / Reduced Motion --- */
html[data-a11y-motion="reduced"] *,
html[data-a11y-motion="reduced"] *::before,
html[data-a11y-motion="reduced"] *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001s !important;
  scroll-behavior: auto !important;
}

/* --- Reading Guide Ruler --- */
#a11y-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  height: 24px;
  background: rgba(255, 235, 59, 0.35);
  border-top: 3px solid #f57f17;
  border-bottom: 3px solid #f57f17;
  pointer-events: none;
  z-index: 999999;
  display: none;
  transform: translateY(-50%);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

html[data-a11y-ruler="true"] #a11y-reading-guide {
  display: block;
}

/* --- Screen Reader Only Announcement Region --- */
.a11y-sr-only {
  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;
}

/* ==========================================================================
   UI WIDGET STYLES (Floating Button & Modal Sheet)
   ========================================================================== */

/* Floating Trigger Button */
.a11y-trigger-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0B3C5D 0%, #1D70B8 100%);
  color: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 8px 24px rgba(11, 60, 93, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 99990;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease;
}

.a11y-trigger-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 30px rgba(11, 60, 93, 0.5);
}

.a11y-trigger-btn:focus-visible {
  outline: 3px solid #ffeb3b;
  outline-offset: 3px;
}

.a11y-trigger-btn .a11y-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background-color: #2e7d32;
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: none;
}

.a11y-trigger-btn.has-active-settings .a11y-badge {
  display: block;
}

/* Overlay & Backdrop */
.a11y-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 24px;
}

.a11y-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Modal Card */
.a11y-modal-card {
  background: #ffffff;
  color: #1e293b;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 48px);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(226, 232, 240, 0.9);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.a11y-modal-overlay.active .a11y-modal-card {
  transform: translateY(0) scale(1);
}

/* Mobile Pull Handle */
.a11y-mobile-handle {
  display: none;
  width: 40px;
  height: 5px;
  background: #cbd5e1;
  border-radius: 3px;
  margin: 10px auto 0;
}

/* Card Header */
.a11y-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.a11y-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.a11y-title-group i {
  font-size: 22px;
  color: #0B3C5D;
  background: #e0f2fe;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.a11y-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.a11y-header p {
  font-size: 0.8rem;
  color: #64748b;
  margin: 2px 0 0;
}

.a11y-close-btn {
  background: #f1f5f9;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #475569;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.a11y-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.a11y-close-btn:focus-visible {
  outline: 2px solid #0B3C5D;
  outline-offset: 2px;
}

/* Card Body & Controls */
.a11y-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.a11y-section-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 8px;
}

/* Text Size Scaler */
.a11y-scale-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.a11y-scale-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}

.a11y-scale-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.a11y-scale-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.a11y-scale-btn:hover {
  border-color: #0B3C5D;
  color: #0B3C5D;
}

.a11y-scale-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #0B3C5D;
  min-width: 44px;
  text-align: center;
}

/* Grid of Toggle Feature Cards */
.a11y-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.a11y-toggle-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
  user-select: none;
  text-align: left;
}

.a11y-toggle-card:hover {
  border-color: #93c5fd;
  background: #f0f9ff;
}

.a11y-toggle-card.active {
  background: #e0f2fe;
  border-color: #0284c7;
}

.a11y-toggle-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.a11y-toggle-top i {
  font-size: 16px;
  color: #0B3C5D;
}

.a11y-toggle-card.active .a11y-toggle-top i {
  color: #0284c7;
}

.a11y-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: background 0.2s ease;
}

.a11y-toggle-card.active .a11y-status-dot {
  background: #0284c7;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.5);
}

.a11y-toggle-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.a11y-toggle-sub {
  font-size: 0.72rem;
  color: #64748b;
  line-height: 1.2;
}

/* Card Footer */
.a11y-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
  display: flex;
  gap: 10px;
}

.a11y-reset-btn {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.a11y-reset-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* Responsive Mobile Bottom Sheet Overrides */
@media (max-width: 768px) {
  .a11y-trigger-btn {
    bottom: calc(75px + env(safe-area-inset-bottom));
    left: 16px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .a11y-modal-overlay {
    padding: 0;
    align-items: flex-end;
    justify-content: center;
  }

  .a11y-modal-card {
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    max-height: 85vh;
    transform: translateY(100%);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .a11y-modal-overlay.active .a11y-modal-card {
    transform: translateY(0);
  }

  .a11y-mobile-handle {
    display: block;
  }

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