/* ═══════════════════════════════════════════════════════════
   HANAPBUHAY — Accessibility CSS
   Handles: Dark Mode, High Contrast, Text Size, Dyslexia Font,
            Reduced Motion, Focus Indicators, Saturation
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables (Light defaults) ─────────────────────── */
:root {
  --a11y-bg: #f9fafb;
  --a11y-surface: #ffffff;
  --a11y-text: #111827;
  --a11y-muted: #6b7280;
  --a11y-border: #e5e7eb;
  --a11y-primary: #0038a8;
  --a11y-primary-bg: #eff4ff;
  --a11y-shadow: rgba(0,0,0,0.08);
}

/* ── Dark Mode ───────────────────────────────────────────── */
html.a11y-dark {
  --a11y-bg: #0f172a;
  --a11y-surface: #1e293b;
  --a11y-text: #f1f5f9;
  --a11y-muted: #94a3b8;
  --a11y-border: #334155;
  --a11y-primary: #3b6fd4;
  --a11y-primary-bg: #0a1628;
  --a11y-shadow: rgba(0,0,0,0.4);
}
html.a11y-dark body                            { background-color:#0f172a !important; color:#f1f5f9 !important; }
html.a11y-dark .bg-white                       { background-color:#1e293b !important; }
html.a11y-dark .bg-gray-50                     { background-color:#0f172a !important; }
html.a11y-dark .bg-gray-100                    { background-color:#1e293b !important; }
html.a11y-dark .bg-gray-200                    { background-color:#334155 !important; }
html.a11y-dark .text-gray-900                  { color:#f1f5f9 !important; }
html.a11y-dark .text-gray-800                  { color:#e2e8f0 !important; }
html.a11y-dark .text-gray-700                  { color:#cbd5e1 !important; }
html.a11y-dark .text-gray-600                  { color:#94a3b8 !important; }
html.a11y-dark .text-gray-500                  { color:#64748b !important; }
html.a11y-dark .text-gray-400                  { color:#475569 !important; }
html.a11y-dark .border-gray-100                { border-color:#334155 !important; }
html.a11y-dark .border-gray-200                { border-color:#334155 !important; }
html.a11y-dark .divide-gray-100>*              { border-color:#334155 !important; }
html.a11y-dark .divide-gray-50>*               { border-color:#1e293b !important; }
html.a11y-dark input, html.a11y-dark textarea,
html.a11y-dark select                          { background-color:#0f172a !important; color:#f1f5f9 !important; border-color:#334155 !important; }
html.a11y-dark .bg-indigo-50                   { background-color:#1e1b4b !important; }
html.a11y-dark .bg-indigo-600                  { background-color:#0038a8 !important; }
html.a11y-dark nav, html.a11y-dark header      { background-color:#1e293b !important; border-color:#334155 !important; }
html.a11y-dark footer                          { background-color:#020617 !important; }
html.a11y-dark .bg-gray-900                    { background-color:#020617 !important; }
html.a11y-dark .shadow-sm,
html.a11y-dark .shadow-lg,
html.a11y-dark .shadow-xl                      { box-shadow:0 2px 16px rgba(0,0,0,0.5) !important; }

/* ── High Contrast ───────────────────────────────────────── */
html.a11y-contrast body                { background:#000 !important; color:#fff !important; }
html.a11y-contrast .bg-white,
html.a11y-contrast .bg-gray-50,
html.a11y-contrast .bg-gray-100        { background:#000 !important; }
html.a11y-contrast *                   { border-color:#fff !important; outline-color:#ff0 !important; }
html.a11y-contrast a                   { color:#ff0 !important; text-decoration:underline !important; }
html.a11y-contrast button,
html.a11y-contrast [type=submit]       { background:#ff0 !important; color:#000 !important; border:2px solid #fff !important; }
html.a11y-contrast .text-gray-400,
html.a11y-contrast .text-gray-500,
html.a11y-contrast .text-gray-600,
html.a11y-contrast .text-gray-700,
html.a11y-contrast .text-gray-800,
html.a11y-contrast .text-gray-900      { color:#fff !important; }
html.a11y-contrast .gradient-hero      { background:#000 !important; border-bottom:3px solid #ff0 !important; }
html.a11y-contrast nav                 { background:#000 !important; border-bottom:2px solid #ff0 !important; }
html.a11y-contrast input,
html.a11y-contrast textarea,
html.a11y-contrast select              { background:#000 !important; color:#fff !important; border:2px solid #fff !important; }

/* ── Text Sizes ──────────────────────────────────────────── */
html.a11y-text-sm  body { font-size:14px !important; }
html.a11y-text-md  body { font-size:16px !important; }
html.a11y-text-lg  body { font-size:18px !important; }
html.a11y-text-xl  body { font-size:21px !important; }
html.a11y-text-xxl body { font-size:24px !important; }

/* ── Dyslexia-friendly Font ──────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');
html.a11y-dyslexia body,
html.a11y-dyslexia input,
html.a11y-dyslexia textarea,
html.a11y-dyslexia select,
html.a11y-dyslexia button  {
  font-family: 'Lexend', sans-serif !important;
  letter-spacing: 0.03em !important;
  word-spacing: 0.1em !important;
  line-height: 1.8 !important;
}

/* ── Reduced Motion ──────────────────────────────────────── */
html.a11y-no-motion *,
html.a11y-no-motion *::before,
html.a11y-no-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ── Enhanced Focus Indicators ───────────────────────────── */
html.a11y-focus-ring *:focus {
  outline: 3px solid #f59e0b !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(245,158,11,0.25) !important;
  border-radius: 4px !important;
}

/* ── Line Height (Readability) ───────────────────────────── */
html.a11y-line-loose body,
html.a11y-line-loose p,
html.a11y-line-loose li  { line-height: 2 !important; }

/* ── Word Spacing ────────────────────────────────────────── */
html.a11y-word-space body { word-spacing: 0.2em !important; }

/* ── Saturation ──────────────────────────────────────────── */
/* Applied to a wrapper div — NOT body, because filter:* on body breaks position:fixed */
#a11y-grayscale-wrap { filter: grayscale(100%); }
html.a11y-grayscale #a11y-widget { filter: none !important; }

/* ── Skip to content link ────────────────────────────────── */
.skip-to-main {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.75rem 1.5rem;
  background: #0038a8;
  color: #fff;
  font-weight: 700;
  border-radius: 0 0 0.75rem 0.75rem;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-to-main:focus { top: 0; }

/* ── Accessibility Widget — fully protected ─────────────── */
#a11y-widget { font-family: Inter, system-ui, sans-serif !important; }

/* Trigger button: always fixed, always visible */
#a11y-trigger {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  z-index: 99999 !important;
  display: flex !important;
  width: 52px !important;
  height: 52px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #0038a8, #002d8a) !important;
  color: #fff !important;
  border: none !important;
  cursor: pointer !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 22px !important;
  box-shadow: 0 4px 20px rgba(0,56,168,0.5) !important;
  filter: none !important;
}

/* Panel: always fixed, always above everything */
#a11y-panel {
  position: fixed !important;
  bottom: 88px !important;
  right: 24px !important;
  z-index: 99998 !important;
  width: 300px !important;
  max-height: 80vh !important;
  overflow-y: auto !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2) !important;
  border-radius: 20px !important;
  filter: none !important;
}

/* Dark mode panel overrides */
html.a11y-dark #a11y-panel { background:#1e293b !important; border-color:#334155 !important; color:#f1f5f9 !important; }
html.a11y-dark #a11y-panel .a11y-sec-label { color:#94a3b8 !important; }
html.a11y-dark #a11y-panel .a11y-note { color:#64748b !important; }

/* High contrast: protect widget from being inverted */
html.a11y-contrast #a11y-trigger { background:linear-gradient(135deg,#0038a8,#002d8a) !important; color:#fff !important; }

/* No motion: keep widget snappy */
html.a11y-no-motion #a11y-trigger,
html.a11y-no-motion #a11y-panel { transition: none !important; animation: none !important; }
