/* ==========================================================================
   FamilyHub.lu — Camada de acessibilidade
   Foco visível, modos alternativos (dislexia, sensorial, escuro, texto grande),
   respeito às preferências do sistema.
   ========================================================================== */

/* ---------- Fonte OpenDyslexic (carregada só quando o modo é ativado) ---------- */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/woff/OpenDyslexic-Regular.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/woff/OpenDyslexic-Bold.woff') format('woff');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

/* ---------- Foco visível SEMPRE (navegação por teclado) ---------- */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Sem outline duplicado para quem usa rato */
:focus:not(:focus-visible) { outline: none; }

/* ---------- Preferência do sistema: menos movimento ---------- */
@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;
  }
}

/* ---------- Preferência do sistema: mais contraste ---------- */
@media (prefers-contrast: more) {
  :root {
    --color-primary: #003366;
    --color-text: #000000;
    --color-border: #333333;
  }
}

/* ---------- MODO DISLEXIA ---------- */
body.dyslexia-mode {
  font-family: 'OpenDyslexic', 'Comic Sans MS', var(--font-family);
  letter-spacing: 0.08em;
  word-spacing: 0.16em;
  line-height: 1.8;
}
body.dyslexia-mode p,
body.dyslexia-mode li,
body.dyslexia-mode label { max-width: 60ch; }

/* ---------- MODO SENSORIAL SUAVE ---------- */
body.sensory-mode {
  --color-primary: #5B7B9A;
  --color-primary-dark: #46617C;
  --color-accent: #9A8B5B;
  --color-success: #4C7A50;
  --color-success-bg: #F0F4F0;
  --color-error: #9A5B5B;
  --color-bg: #F4F4F2;
}
body.sensory-mode *,
body.sensory-mode *::before,
body.sensory-mode *::after {
  animation: none !important;
  transition: none !important;
}

/* ---------- MODO ESCURO ---------- */
body.dark-mode {
  --color-bg: #14171C;             /* não preto puro (menos cansaço) */
  --color-surface: #1E2229;
  --color-border: #4A515C;
  --color-text: #E4E7EB;           /* não branco puro */
  --color-text-soft: #B0B7C0;
  --color-primary: #7FB3E0;        /* claro para contraste sobre escuro */
  --color-primary-dark: #A5CCEE;
  --color-success: #7FCB84;
  --color-success-bg: #1D2B1E;
  --color-error: #F28B82;
  --color-error-bg: #2B1D1D;
  --color-warning: #E0C077;
}
body.dark-mode .tab.active,
body.dark-mode .radio-option:has(input:checked),
body.dark-mode .view-tab.active,
body.dark-mode .btn-secondary:hover,
body.dark-mode .step-dot.active {
  background: #26303C;
}
body.dark-mode .step-dot { background: #262B33; color: var(--color-text-soft); }
body.dark-mode .tab:hover { background: #262B33; }
body.dark-mode kbd { background: #262B33; }
body.dark-mode .progress-bar-track { background: #333A44; }
body.dark-mode .btn-primary { background: #2C5F8A; }
body.dark-mode .btn-primary:hover { background: #3A75A8; }
body.dark-mode .creche-item:hover { background: #232B35; }
body.dark-mode .detail-row { border-bottom-color: #333A44; }

/* ---------- TEXTO GRANDE ---------- */
body.bigtext-mode { font-size: 1.25rem; }
body.bigtext-mode h1 { font-size: 2.4rem; }
body.bigtext-mode .btn,
body.bigtext-mode input,
body.bigtext-mode select { font-size: 1.2rem; }

/* ---------- Marcadores do mapa acessíveis ---------- */
.map-marker-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px !important;
  height: 48px !important;
  font-size: 1.3rem;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.map-marker-btn.affordable { background: var(--color-success); }
.map-marker-btn.over { background: var(--color-warning); }

.leaflet-popup-content { font-family: var(--font-family); font-size: 1rem; }
.leaflet-popup-content .btn { margin-top: 8px; }

/* ---------- Splash de idioma (multilíngue) ---------- */
#fh-lang-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 26, 40, 0.97);
  opacity: 1;
  transition: opacity 0.4s ease;
  padding: 16px;
  overflow: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#fh-lang-overlay.fh-hide {
  opacity: 0;
  pointer-events: none;
}
body.fh-lang-modal-open {
  overflow: hidden;
  height: 100vh;
}

#fh-lang-box {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 2rem 2.5rem 2.5rem;
  max-width: 620px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0,0,0,0.6);
  margin: auto;
}
#fh-lang-box h1 { font-size: 1.7rem; margin: 0 0 0.3rem; color: #1F2430; }
#fh-lang-box p { color: #444B57; font-size: 0.95rem; margin: 0 0 1.4rem; }

#fh-lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Mobile: 1 ou 2 colunas */
@media (max-width: 480px) {
  #fh-lang-box {
    padding: 1.5rem 1.5rem 2rem;
  }
  #fh-lang-box h1 { font-size: 1.4rem; }
  #fh-lang-box p { font-size: 0.9rem; }
  #fh-lang-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 50vh;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  #fh-lang-box {
    padding: 1.8rem 2rem 2rem;
  }
  #fh-lang-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
}

.fh-lang-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: #1F2430;
  background: #F4F6F9;
  border: 2px solid #C4C9D0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.fh-lang-btn:hover, .fh-lang-btn:focus-visible {
  border-color: #2C5F8A;
  background: #E3ECF4;
}
.fh-lang-btn .fh-flag { font-size: 1.4rem; flex-shrink: 0; }
