/* ============================================================
   EGBÉ YPÒ ÒRUN — Acessibilidade (WCAG 2.1 AA)
   Carregado antes de qualquer CSS de componente ou página.
   ============================================================ */

/* ----------------------------------------------------------
   Skip Navigation Link
   ---------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-6);
  background: var(--bg-dark);
  color: var(--text-on-dark);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-4);
}

/* ----------------------------------------------------------
   Foco Visível — Estilo Customizado
   NUNCA usar outline: none sem substituto.
   ---------------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--color-green);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Remove outline padrão apenas quando :focus-visible está disponível */
:focus:not(:focus-visible) {
  outline: none;
}

/* Foco em links dentro de seções escuras */
.section--dark :focus-visible,
header :focus-visible,
footer :focus-visible,
.nav :focus-visible {
  outline-color: var(--color-green);
}

/* ----------------------------------------------------------
   Visualmente Oculto (acessível a leitores de tela)
   ---------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only:focus,
.sr-only:active {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: inherit;
}

/* ----------------------------------------------------------
   Texto de Alto Contraste (forçar visibilidade)
   ---------------------------------------------------------- */
@media (forced-colors: active) {
  .skip-link {
    border: 2px solid ButtonText;
  }
  :focus-visible {
    outline: 3px solid Highlight;
  }
}

/* ----------------------------------------------------------
   Movimento Reduzido
   ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .skip-link {
    transition: none;
  }
}

/* ----------------------------------------------------------
   Indicadores de status para formulários
   ---------------------------------------------------------- */
[aria-invalid="true"] {
  border-color: #c0392b !important;
}

[aria-describedby] + .field-error {
  color: #c0392b;
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

/* ----------------------------------------------------------
   Contorno de foco em elementos interativos de vídeo
   ---------------------------------------------------------- */
iframe:focus-visible {
  outline: 3px solid var(--color-green);
  outline-offset: 4px;
}

/* ----------------------------------------------------------
   Barra de acessibilidade — controles de legibilidade
   Fixa, canto inferior direito, presente em todas as páginas.
   ---------------------------------------------------------- */
.a11y-bar {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  background: var(--bg-dark);
  border: 1px solid rgba(175, 207, 30, 0.4);
  border-radius: var(--radius-lg);
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-lg);
}

.a11y-bar__label {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(246, 240, 216, 0.5);
  margin-right: 0.125rem;
  white-space: nowrap;
}

.a11y-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 0.25rem;
}

.a11y-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  color: var(--text-on-dark);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: var(--weight-bold);
  padding: 0.375rem 0.625rem;
  cursor: pointer;
  min-width: 32px;
  text-align: center;
  transition: background var(--transition-fast);
  line-height: 1;
}

.a11y-btn:hover,
.a11y-btn:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  outline: 2px solid var(--color-green);
  outline-offset: 2px;
}

.a11y-btn[aria-pressed="true"] {
  background: var(--color-green);
  color: var(--color-brown-dark);
  border-color: var(--color-green);
}

@media (max-width: 640px) {
  .a11y-bar {
    bottom: var(--space-4);
    right: var(--space-4);
    padding: 0.375rem 0.625rem;
    gap: 0.375rem;
  }
  .a11y-bar__label {
    display: none;
  }
}

/* ----------------------------------------------------------
   Alto contraste — modo escuro completo para todas as páginas
   Estratégia: sobrescreve design tokens via CSS custom props
   (funciona em inline styles com var() também) +
   overrides pontuais apenas para valores hardcoded.
   ---------------------------------------------------------- */

/* --- 1. Redefinição dos tokens de superfície e texto --- */
body.high-contrast {
  --bg-page:        #141414;  /* fundo base das seções brancas */
  --bg-subtle:      #1c1c1c;  /* seções "subtle" levemente elevadas (mais claras) */
  --bg-cream:       #1a1500;  /* seções creme — tom escuro-avermelhado */
  --bg-dark:        #000000;
  --bg-mid:         #2a2a2a;

  --text-on-light:  #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted:     #808080;

  --border-light:   rgba(255, 255, 255, 0.12);
  --border-mid:     rgba(255, 255, 255, 0.22);

  --accent-text:    #AFCF1E;
  --accent-dark:    #AFCF1E;

  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.6);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.7);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.8);
  --shadow-xl:  0 16px 48px rgba(0, 0, 0, 0.9);

  background-color: #000 !important;
  color: #e0e0e0 !important;
}

/* --- 2. Fallback para títulos com cor hardcoded ---
   Cobre páginas de projetos (eko-pelu, itans) que definem cor via CSS
   hardcoded (#1F2937, #374151) fora das CSS custom properties.
   NÃO inclui p/span/li: o sistema de variáveis já adapta corretamente,
   e a regra genérica destruiria a hierarquia visual dos componentes.
   ---------------------------------------------------------- */
body.high-contrast h1,
body.high-contrast h2,
body.high-contrast h3,
body.high-contrast h4,
body.high-contrast h5,
body.high-contrast h6 {
  color: #e0e0e0 !important;
}

/* Exceção: rótulos de seção devem manter verde lima */
body.high-contrast .section-label {
  color: #AFCF1E !important;
}

/* --- 4. Navegação --- */

/* Logo: nome usa --color-brown-dark (não sobrescrito pela variável) */
body.high-contrast .nav__logo-name {
  color: #e0e0e0 !important;
}

/* Link ativo e hover no nav também usam --color-brown-dark */
body.high-contrast .nav__link:hover {
  color: #ffffff !important;
}
body.high-contrast .nav__link[aria-current="page"] {
  color: #e0e0e0 !important;
}

/* Hamburguer */
body.high-contrast .nav__toggle {
  border-color: rgba(255, 255, 255, 0.22) !important;
}
body.high-contrast .nav__toggle-bar {
  background-color: #e0e0e0 !important;
}

/* Chevron do dropdown: SVG embutido com cor hardcoded */
body.high-contrast .nav__link--has-dropdown::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23e0e0e0' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
}

/* Links de projeto no submenu: cores hardcoded */
body.high-contrast .nav__dropdown-link[href*="eko-pelu"]:hover,
body.high-contrast .nav__dropdown-link[href*="eko-pelu"][aria-current="page"] {
  color: #7eb8d8 !important;
  background-color: rgba(79, 126, 163, 0.15) !important;
}
body.high-contrast .nav__dropdown-link[href*="eko-pelu"]:hover span {
  color: #7eb8d8 !important;
}
body.high-contrast .nav__dropdown-link[href*="itans"]:hover,
body.high-contrast .nav__dropdown-link[href*="itans"][aria-current="page"] {
  color: #6dbf7d !important;
  background-color: rgba(47, 107, 64, 0.15) !important;
}
body.high-contrast .nav__dropdown-link[href*="itans"]:hover span {
  color: #6dbf7d !important;
}

/* --- 5. Botões --- */

/* btn--outline-dark: borda e texto escuros num fundo agora escuro */
body.high-contrast .btn--outline-dark {
  color: #e0e0e0 !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  background-color: transparent !important;
}
body.high-contrast .btn--outline-dark:hover {
  background-color: rgba(255, 255, 255, 0.10) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.70) !important;
}

/* btn--dark: inverte para tom neutro */
body.high-contrast .btn--dark {
  background-color: rgba(255, 255, 255, 0.10) !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  color: #e0e0e0 !important;
}
body.high-contrast .btn--dark:hover {
  background-color: rgba(255, 255, 255, 0.18) !important;
}

/* btn--ghost hover: dark green → verde lima */
body.high-contrast .btn--ghost:hover {
  color: #AFCF1E !important;
}

/* --- 6. Cards --- */

/* card__link hover: dark brown → verde lima */
body.high-contrast .card__link:hover {
  color: #AFCF1E !important;
}

/* Cards gerais: surface levemente mais clara que a seção para criar separação visual.
   Em dark mode, a diferença de fundo é o único indicador de profundidade quando
   a borda sutil não é suficiente por si só.                                        */
body.high-contrast .card {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

/* Leadership: sem fundo sólido (foto circular como protagonista) */
body.high-contrast .card--leadership {
  background-color: transparent !important;
  border-color: transparent !important;
}

/* Pilar: mesma superfície elevada */
body.high-contrast .card--pillar {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}
body.high-contrast .card--pillar:hover {
  border-color: rgba(175, 207, 30, 0.50) !important;
}

/* --- 7. Estatísticas (stat__number usa --color-brown-dark) --- */
body.high-contrast .stat__number {
  color: #e0e0e0 !important;
}

/* --- 8. Badges --- */
body.high-contrast .badge--gira {
  background-color: rgba(175, 207, 30, 0.15) !important;
  color: #AFCF1E !important;
  border-color: rgba(175, 207, 30, 0.30) !important;
}
body.high-contrast .badge--ajodun {
  background-color: rgba(248, 239, 27, 0.12) !important;
  color: #d8c800 !important;
  border-color: rgba(248, 239, 27, 0.30) !important;
}
body.high-contrast .badge--oficina {
  background-color: rgba(116, 6, 130, 0.20) !important;
  color: #c060d0 !important;
  border-color: rgba(116, 6, 130, 0.40) !important;
}
body.high-contrast .badge--projeto {
  background-color: rgba(246, 240, 216, 0.08) !important;
  color: #c8a87a !important;
  border-color: rgba(246, 240, 216, 0.20) !important;
}
body.high-contrast .badge--evento {
  background-color: rgba(175, 207, 30, 0.15) !important;
  color: #AFCF1E !important;
  border-color: rgba(175, 207, 30, 0.35) !important;
}

/* --- 9. Ícones de informação (fundos rgba hardcoded) --- */
body.high-contrast .transparencia-item__icon,
body.high-contrast .contato-info-item__icon,
body.high-contrast .apoio-card__icon {
  background-color: rgba(175, 207, 30, 0.10) !important;
}

/* Cards de apoio mensal — superfície elevada + borda clara no fundo --bg-cream escuro */
body.high-contrast .apoio-card {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.30) !important;
}

/* Card de apoio destaque — borda verde (mesma opção A do light mode) */
body.high-contrast .apoio-card--destaque {
  background-color: #2a2a2a !important;
  border-color: rgba(175, 207, 30, 0.80) !important;
}
body.high-contrast .apoio-card--destaque .apoio-card__icon {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: #e0e0e0 !important;
}

/* Valor monetário (usa --color-brown-dark) */
body.high-contrast .apoio-card__amount {
  color: #e0e0e0 !important;
}

/* --- 10. Formulários --- */

/* Fundo dos inputs — forms.css usa var(--bg-white) que não existe → fallback transparent.
   No modo escuro, inputs transparentes ficam invisíveis sobre o fundo da seção.   */
body.high-contrast .field__input,
body.high-contrast .field__textarea,
body.high-contrast .field__select {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
  color: #e0e0e0 !important;
}
/* Labels: override explícito para garantir leitura (var pode herdar tom marrom em alguns contextos) */
body.high-contrast .field__label {
  color: #e0e0e0 !important;
}

body.high-contrast .field__input:focus,
body.high-contrast .field__textarea:focus,
body.high-contrast .field__select:focus {
  border-color: rgba(175, 207, 30, 0.75) !important;
  box-shadow: 0 0 0 3px rgba(175, 207, 30, 0.15) !important;
}

body.high-contrast .field__input::placeholder,
body.high-contrast .field__textarea::placeholder {
  color: rgba(255, 255, 255, 0.30) !important;
}
body.high-contrast .field__hint {
  color: #808080 !important;
}
body.high-contrast .form__status--success {
  background-color: rgba(175, 207, 30, 0.12) !important;
  color: #AFCF1E !important;
  border-color: rgba(175, 207, 30, 0.25) !important;
}
body.high-contrast .form__status--error {
  background-color: rgba(255, 80, 80, 0.12) !important;
  color: #ff8888 !important;
  border-color: rgba(255, 80, 80, 0.25) !important;
}

/* --- 11. Details / Summary (FAQ, transparência, apoie) --- */
body.high-contrast details summary::after {
  color: #AFCF1E !important;
}
body.high-contrast details[open] summary {
  border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}

/* --- 12. Calendário (agenda.css) --- */
/* (background e border do calendário estão consolidados na seção 12b abaixo) */
body.high-contrast .cal-day--today {
  background-color: rgba(175, 207, 30, 0.15) !important;
}
body.high-contrast .cal-day--has-events:hover {
  background-color: rgba(175, 207, 30, 0.10) !important;
}
body.high-contrast .cal-prev:hover,
body.high-contrast .cal-next:hover {
  background-color: rgba(175, 207, 30, 0.10) !important;
  border-color: rgba(175, 207, 30, 0.40) !important;
}

/* Event cards: superfície elevada para separar do fundo da seção */
body.high-contrast .event-card {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}
/* Divisor interno data | conteúdo — replicando o mesmo contraste dos evento-items da home */
body.high-contrast .event-card__date {
  border-right-color: rgba(255, 255, 255, 0.22) !important;
}

/* Evento items da home (agenda seção off-white) */
body.high-contrast .evento-item {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

/* Calendário: superfície elevada */
body.high-contrast #agenda-calendar {
  background-color: #222222 !important;
}

/* --- 13. Memória institucional (agenda) --- */
body.high-contrast .memory-entry {
  border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}

/* --- 14. Eventos com animação (highlight) --- */
@keyframes eventHighlightHC {
  0%   { background: rgba(175, 207, 30, 0.20); border-color: rgba(175, 207, 30, 0.60); }
  80%  { background: rgba(175, 207, 30, 0.08); }
  100% { background: var(--bg-page); border-color: var(--border-light); }
}
body.high-contrast .event-card--highlight {
  animation: eventHighlightHC 1.2s ease forwards !important;
}

/* --- 15. Details summary hover — mais claro (não mais escuro) no modo escuro --- */
body.high-contrast details summary:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

/* --- 16. Boxes informativos da contribuicao-grid (apoie.html) ---
   background-color explícito (não via variável) como fallback absoluto.
   Sem este override, --bg-subtle via inline style pode não ganhar do fundo da seção.
   ---------------------------------------------------------- */
body.high-contrast .contribuicao-grid [role="listitem"] {
  background-color: #1c1c1c !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
}

/* --- 17. Cards de consultas (apoie.html) — superfície elevada, sem classe CSS */
body.high-contrast article[style*="border:1px solid var(--border-light)"],
body.high-contrast article[style*="border: 1px solid var(--border-light)"] {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
}

/* --- 18. Botão outline no hero da projetos — visível no fundo escuro --- */
body.high-contrast .page-hero .btn--outline-dark {
  color: #e0e0e0 !important;
  border-color: rgba(255, 255, 255, 0.50) !important;
}
body.high-contrast .page-hero .btn--outline-dark:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}

/* --- 19. Ícone no apoio-card destaque: cor no modo escuro --- */
body.high-contrast .apoio-card__icon svg {
  stroke: var(--accent-text);
}
body.high-contrast .apoio-card--destaque .apoio-card__icon svg {
  stroke: #e0e0e0;
}

/* --- 20. Ícones inline sem classe CSS (contato.html, apoie.html) ---
   Cobre divs com background:rgba(26,101,25,...) inseridos como inline style.
   Seletor de atributo targeta o valor hardcoded antes que seja computado.   */
body.high-contrast [style*="background:rgba(26,101,25"],
body.high-contrast [style*="background: rgba(26,101,25"] {
  background-color: rgba(175, 207, 30, 0.12) !important;
}

/* --- 21. Links de download PDF (Estatuto, Ata de Assembleia) --- */
body.high-contrast a[href$=".pdf"],
body.high-contrast a[href*=".pdf"] {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.30) !important;
}
/* Texto "PDF · Download" — --text-muted (#808080) tem contraste insuficiente em #222222 */
body.high-contrast a[href$=".pdf"] span,
body.high-contrast a[href*=".pdf"] span {
  color: #b0b0b0 !important;
}

/* --- 21b. Boxes PIX (apoie.html) — divs com background:var(--bg-page) inline em section--subtle ---
   --bg-page (#141414) fica MAIS ESCURO que --bg-subtle (#1c1c1c) da seção,
   criando aparência "afundada". Override explícito eleva para superfície de card.   */
body.high-contrast div[style*="background:var(--bg-page)"][style*="border:1px solid var(--border-light)"] {
  background-color: #222222 !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
}

/* --- 22. Artigos "Espaços de Ancestralidade" (index.html) ---
   border-left verde em section--cream. Fundo precisa contrastar com #1a1500.  */
body.high-contrast article[style*="border-left:3px solid var(--border-green)"],
body.high-contrast article[style*="border-left: 3px solid var(--border-green)"] {
  background-color: #222222 !important;
  border-left-color: rgba(175, 207, 30, 0.65) !important;
}

/* --- 23. Calendário — border visível (background já na seção 12b) --- */
body.high-contrast #agenda-calendar {
  border-color: rgba(255, 255, 255, 0.20) !important;
}
