/* ================================================================
   components.css — Header, menu mobile (drawer), Footer e VLibras
   ----------------------------------------------------------------
   Único lugar do projeto com o CSS desses componentes. O HTML vem de
   layout/header.html e layout/footer.html (veja scripts/build-layout.mjs).
   Carregue DEPOIS de base.css e ANTES do CSS da página.

   Breakpoint único: 768px
     < 768px  -> mobile: logo | "Jogar agora" + hambúrguer; menu em drawer
     >= 768px -> desktop: logo | menu centralizado | "Jogar agora"

   Camadas (z-index):
     conteúdo < 900 widget VLibras < 1000 header (com drawer e backdrop)
     < 3000 barra de progresso < 4000 skip-link
   ================================================================ */

:root {
  --header-h: 64px;
  --header-px: clamp(16px, 4vw, 48px);
  --container-max: 1280px;

  --c-ink: #2d223c;
  --c-cream: #f8f4ef;
  --c-red: #dc3545;
  --c-red-dark: #d32436;
  --c-focus: #7460c6;
  --c-footer: #161126;

  --z-widget: 900;
  --z-header: 1000;
}

@media (min-width: 768px) {
  :root { --header-h: 72px; }
}

/* Header e footer sempre na largura total, mesmo que o body da página seja um
   flex em coluna com align-items: center (caso de personagens.html) */
.site-header,
.site-footer { align-self: stretch; width: 100%; }

/* Mesma fonte em todas as páginas (cada body define a sua) */
.site-header,
.site-footer,
.site-nav,
.site-header button { font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif); }

/* Âncoras (#termos-de-uso etc.) não ficam escondidas atrás do header fixo */
html { scroll-padding-top: calc(var(--header-h) + 16px); }


/* ================================================================
   1. HEADER
   ================================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  height: var(--header-h);
}

/* Fundo + blur num pseudo-elemento: backdrop-filter direto no <header> criaria
   um "containing block" e o drawer (position: fixed) ficaria preso dentro dele. */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(248, 244, 239, 0.94);
  border-bottom: 1px solid rgba(116, 96, 198, 0.16);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: box-shadow 0.25s ease;
}
.site-header.scrolled::before { box-shadow: 0 6px 20px rgba(23, 19, 37, 0.08); }

.site-header__bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--header-px);
}

.site-header__brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
}
.site-header__brand img {
  display: block;
  height: 46px;
  width: auto;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

@media (min-width: 768px) {
  .site-header__brand img { height: 54px; }
}


/* ================================================================
   2. NAVEGAÇÃO (desktop) + indicador da página atual
   ================================================================ */
.site-nav {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.site-nav__list {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 36px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-nav__link {
  position: relative;
  display: inline-block;
  padding: 10px 2px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--c-ink);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 6px;
  transition: color 0.2s ease;
}

/* Ponto vermelho: o link tem a largura exata do texto (inline-block) e o ponto
   fica em left:50%, então está sempre centralizado embaixo da palavra.
   O selo "Em dev" é irmão do link, por isso não desloca o centro. */
.site-nav__link::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c-red);
  transform: translateX(-50%) scale(0);
  transition: transform 0.25s ease;
}
.site-nav__link:hover { color: var(--c-red-dark); }
.site-nav__link[aria-current="page"] { color: var(--c-red-dark); }
.site-nav__link[aria-current="page"]::after { transform: translateX(-50%) scale(1); }

.site-nav__badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--c-red-dark);
  white-space: nowrap;
  background: #fff;
  border: 1px solid var(--c-red);
  border-radius: 999px;
}

@keyframes siteBadgePulse { 50% { box-shadow: 0 0 0 4px rgba(211, 36, 54, 0.12); } }
@media (prefers-reduced-motion: no-preference) {
  .site-nav__badge { animation: siteBadgePulse 2.2s ease-in-out infinite; }
}


/* ================================================================
   3. BOTÃO "JOGAR AGORA" e BOTÃO HAMBÚRGUER
   ================================================================ */
.btn-jogar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  white-space: nowrap;
  text-decoration: none;
  background: var(--c-red);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.22);
  cursor: pointer;
}
.btn-jogar:hover { background: #c62839; }

@media (min-width: 768px) {
  .btn-jogar { min-height: 42px; padding: 0 22px; font-size: 13px; }
}

/* "Entrar": botão secundário (contorno) à esquerda do "Jogar agora" */
.btn-entrar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  color: var(--c-ink);
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
  border: 1.5px solid rgba(45, 34, 60, 0.3);
  border-radius: 999px;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.btn-entrar:hover,
.btn-entrar[aria-current="page"] {
  color: var(--c-red-dark);
  border-color: var(--c-red);
}
.btn-entrar__icon { display: none; flex: 0 0 auto; }

@media (min-width: 768px) {
  .site-header__actions { gap: 10px; }
  .btn-entrar { min-height: 42px; padding: 0 20px; font-size: 13px; }
}

/* Telas muito estreitas (<= 340px): só o ícone, para o header não estourar.
   O texto continua disponível para leitores de tela. */
@media (max-width: 340px) {
  .btn-entrar { width: 38px; padding: 0; }
  .btn-entrar__icon { display: block; }
  .btn-entrar__label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}

.menu-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 0 0 auto;
  width: 44px;   /* alvo de toque recomendado (WCAG 2.5.8 / iOS) */
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.menu-toggle__bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--c-ink);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.menu-toggle.open .menu-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open .menu-toggle__bar:nth-child(2) { opacity: 0; }
.menu-toggle.open .menu-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Foco visível, igual em todo o header e rodapé */
.site-header a:focus-visible,
.site-header button:focus-visible,
.site-footer a:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 3px;
}


/* ================================================================
   4. MENU MOBILE — drawer lateral com fundo escurecido
   position: fixed => abre POR CIMA da página, sem empurrar nada.
   ================================================================ */
.nav-backdrop { display: none; }

@media (max-width: 767.98px) {
  .menu-toggle { display: inline-flex; }

  .nav-backdrop {
    display: block;
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    background: rgba(23, 19, 37, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
  }
  html.nav-open .nav-backdrop {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s;
  }

  .site-nav {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    z-index: 3;
    display: block;
    width: min(86vw, 340px);
    padding: 20px 28px calc(28px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--c-cream);
    box-shadow: -18px 0 40px rgba(23, 19, 37, 0.18);
    clip-path: inset(0 0 0 -48px); /* a sombra só vaza para a esquerda, não suja a barra do header */
    transform: translateX(100%);
    visibility: hidden; /* fechado: fora do Tab e dos leitores de tela */
    transition: transform 0.32s cubic-bezier(0.22, 0.8, 0.3, 1), visibility 0s linear 0.32s;
  }
  .site-nav.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.32s cubic-bezier(0.22, 0.8, 0.3, 1), visibility 0s;
  }

  .site-nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .site-nav__item {
    justify-content: flex-start;
    gap: 10px;
    border-bottom: 1px solid rgba(45, 34, 60, 0.08);
  }
  .site-nav__item:last-child { border-bottom: 0; }

  .site-nav__link {
    padding: 16px 2px;
    font-size: 18px;
  }
  .site-nav__link::after { bottom: 6px; }

  /* Menu aberto: a página atrás não rola */
  html.nav-open,
  html.nav-open body { overflow: hidden; }
}


/* ================================================================
   5. FOOTER — mobile-first (coluna única) -> grid no desktop
   ================================================================ */
.site-footer {
  color: rgba(255, 255, 255, 0.86);
  background: var(--c-footer);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.site-footer ul { margin: 0; padding: 0; list-style: none; }
.site-footer a { color: inherit; text-decoration: none; }

.site-footer__inner,
.site-footer__legal {
  width: min(calc(100% - 2 * var(--header-px)), var(--container-max));
  margin-inline: auto;
}

/* --- Mobile: seções empilhadas e centralizadas --- */
.site-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px 0 32px;
}

/* Logos SENAI + Social Lab direto sobre o fundo do rodapé (sem caixa clara) */
.site-footer__brand {
  display: flex;
  align-items: center;
  padding: 0;
  background: none;
}
.site-footer__brand img { display: block; height: 36px; width: auto; }

/* Grid 2x2 */
.site-footer__nav { width: 100%; max-width: 340px; }
.site-footer__nav-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.site-footer__nav-list a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.site-footer__nav-list a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.32);
}
.site-footer__nav-list a[aria-current="page"] {
  color: #fff;
  border-color: rgba(220, 53, 69, 0.9);
}

/* Redes sociais: uma linha, centralizada */
.site-footer__social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.site-footer__social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  cursor: default; /* links "em breve" */
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.site-footer__social a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.32);
}
.site-footer__social svg { display: block; }

/* Linha divisória + seção legal */
.site-footer__legal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 0 calc(24px + 64px + env(safe-area-inset-bottom)); /* folga p/ o botão do VLibras */
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.site-footer__copy { margin: 0; color: rgba(255, 255, 255, 0.78); }
.site-footer__legal-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 20px;
}
.site-footer__legal-list a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: rgba(255, 255, 255, 0.86);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, 0.35);
}
.site-footer__legal-list a:hover { color: #fff; text-decoration-color: #fff; }

/* --- Tablet (768px+): logo e redes na 1ª linha, links na 2ª --- */
@media (min-width: 768px) {
  .site-footer__inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand social"
      "nav   nav";
    align-items: center;
    gap: 24px 32px;
    padding: 40px 0 28px;
  }
  .site-footer__brand  { grid-area: brand; justify-self: start; }
  .site-footer__social { grid-area: social; justify-self: end; }
  .site-footer__nav    { grid-area: nav; max-width: none; }

  .site-footer__nav-list {
    display: flex;
    justify-content: center;
    gap: 8px 12px;
  }
  .site-footer__nav-list a {
    min-height: 40px;
    padding: 0 16px;
    border-color: transparent;
  }

  .site-footer__legal {
    flex-direction: row;
    justify-content: space-between;
    padding-bottom: 28px;
    text-align: left;
  }
}

/* --- Desktop largo (1024px+): tudo na mesma linha --- */
@media (min-width: 1024px) {
  .site-footer__inner {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand nav social";
  }
}


/* ================================================================
   6. WIDGET DE ACESSIBILIDADE (VLibras)
   O botão azul flutuante fica no canto inferior direito, com margem de
   segurança, ABAIXO do header/drawer e some enquanto o menu está aberto.
   Seletores do plugin: div[vw] e [vw-access-button] (padrão do gov.br).
   Se o plugin mudar o HTML, ajuste só este bloco.
   ================================================================ */
div[vw] { z-index: var(--z-widget) !important; }

div[vw] [vw-access-button] {
  position: fixed !important;
  top: auto !important;
  left: auto !important;
  right: max(12px, env(safe-area-inset-right)) !important;
  bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  z-index: var(--z-widget) !important;
  transform-origin: bottom right;
  transition: opacity 0.2s ease;
}

@media (max-width: 767.98px) {
  div[vw] [vw-access-button] { transform: scale(0.82); }
  html.nav-open div[vw] [vw-access-button] {
    opacity: 0 !important;
    pointer-events: none !important;
  }
  /* A notificação (toast) sobe para não ficar embaixo do botão */
  .sl-toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
}
