/* ============================================================
   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 — genérico para todas as páginas
   ---------------------------------------------------------- */
body.high-contrast {
  background: #000 !important;
}

body.high-contrast .section--white,
body.high-contrast .section--subtle,
body.high-contrast .section--cream {
  background: #111 !important;
}

body.high-contrast h1,
body.high-contrast h2,
body.high-contrast h3,
body.high-contrast h4 {
  color: #ffffff !important;
}

body.high-contrast p,
body.high-contrast li,
body.high-contrast span:not(.nav__logo-name):not(.nav__logo-tagline),
body.high-contrast address {
  color: #e0e0e0 !important;
}

body.high-contrast .site-header {
  background: #000 !important;
  border-color: #555 !important;
}

body.high-contrast .nav__link,
body.high-contrast .nav__logo-name,
body.high-contrast .nav__logo-tagline {
  color: #fff !important;
}

body.high-contrast .site-footer {
  background: #000 !important;
}

body.high-contrast .card {
  background: #1a1a1a !important;
  border-color: #555 !important;
}

body.high-contrast .card__text,
body.high-contrast .card__role {
  color: #ccc !important;
}

body.high-contrast .field__input,
body.high-contrast .field__textarea {
  background: #111 !important;
  color: #fff !important;
  border-color: #666 !important;
}

body.high-contrast .btn--primary {
  background: #AFCF1E !important;
  color: #000 !important;
}

body.high-contrast .btn--dark,
body.high-contrast .btn--outline-dark {
  background: #fff !important;
  color: #000 !important;
  border-color: #fff !important;
}

body.high-contrast .missao__statement,
body.high-contrast .lead {
  color: #e0e0e0 !important;
}

body.high-contrast .section-label {
  color: #AFCF1E !important;
}
