/* ---- LOGO: html[data-theme] vale 'light' ou 'dark' (o modo Sistema também é resolvido para um dos dois) ---- */
/* ---- MODO CLARO (PADRÃO) ---- */
/* Esconde o logo para fundo escuro */
.navbar-brand .logo-dark {
    display: none !important;
}
/* Exibe o logo para fundo claro */
.navbar-brand .logo-light {
    display: inline-block !important;
}

/* ---- MODO ESCURO (ATIVADO) ---- */
/* Esconde o logo claro quando o html tiver o atributo dark */
html[data-theme="dark"] .navbar-brand .logo-light {
    display: none !important;
}
/* Exibe o logo escuro quando o html tiver o atributo dark */
html[data-theme="dark"] .navbar-brand .logo-dark {
    display: inline-block !important;
}

/* ---- TABELAS LARGAS (páginas de regras) ---- */
/* O servidor (mudtheme.php) envolve cada tabela em .table-scroll. No celular a tabela rola na horizontal dentro dele em vez de
   ser cortada; acessibilidade.js dá foco de teclado e nome ao quadro quando ele de fato rola. A tabela mantém display:table,
   para os leitores de tela não perderem a semântica. */
.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    margin-bottom: var(--pico-spacing, 1rem);
}
.table-scroll > table {
    display: table;
    width: auto;
    max-width: none;
    margin-bottom: 0;
}

/* ---- MENU SUPERIOR: 8 itens numa linha só ---- */
/* Espaçamento menor entre itens e dentro de cada item (o quark2 usa 0.9375rem de padding e 0.5rem de gap) */
#header .navbar {
    gap: 1rem;
}
.desktop-menu {
    gap: 0.5rem;
}
.dropmenu > ul,
.dropmenu ul.navigation {
    gap: 0.125rem;
    flex-wrap: nowrap;
}
.dropmenu > ul > li > a {
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    gap: 0.25rem;
}
/* Abaixo de 1100px os 8 itens não cabem em uma linha: usa o menu hambúrguer (o quark2 só o usa abaixo de 860px).
   Em em, não em px: quem aumenta o tamanho da fonte do navegador (ou do Android) ganha o menu hambúrguer mais cedo, em vez de
   o cabeçalho passar da largura da tela (WCAG 1.4.4). 68,75em = 1100px com a fonte padrão de 16px. */
@media (max-width: 68.75em) {
    .desktop-menu {
        display: none;
    }
    .mobile-menu {
        display: block;
    }
    .mobile-container {
        display: block;
    }
    #header .navbar {
        min-height: 64px;
    }
    .header-animated.scrolled .mobile-menu {
        top: 8px;
    }
    .navbar-section.actions {
        display: none;
    }
}

/* ---- TESTE DE BARTLE (templates/bartle.html.twig + js/bartle.js) ---- */
.bt { margin: 1.5rem 0 2.5rem; scroll-margin-top: 6rem; }
.bt-card {
    background: var(--q2-bg-elev);
    border: 1px solid var(--q2-divider);
    border-radius: var(--q2-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.bt-h, .bt-q, .bt-big { margin-top: 0; }
.bt-big { font-size: clamp(1.8rem, 5vw, 2.6rem); }
.bt-q { font-size: clamp(1.25rem, 3.4vw, 1.6rem); line-height: 1.35; margin-bottom: 1.25rem; }
.bt-q:focus, .bt-big:focus, .bt-h:focus { outline: none; }
.bt-h3 { margin-top: 0; font-size: 1.15rem; }
.bt-prog { margin: 0 0 .5rem; color: var(--q2-text-muted); font-size: .9rem; }
.bt-small, .bt-hint { color: var(--q2-text-muted); font-size: .85rem; }
.bt-hint { margin-left: .25rem; }

.bt-bar {
    height: 8px;
    background: var(--q2-bg-muted);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.bt-bar-lg { height: 12px; margin: .25rem 0; }
.bt-fill { display: block; height: 100%; background: var(--q2-accent); border-radius: 999px; }

.bt-opts { display: grid; gap: 1.5rem; margin: 1.5rem 0; }
.bt-opt {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    margin: 0;
    text-align: left;
    padding: 1.1rem 1.4rem;
    background: var(--q2-bg);
    color: var(--q2-text);
    border: 1px solid var(--q2-divider);
    border-radius: var(--q2-radius);
    font: inherit;
    line-height: 1.45;
    cursor: pointer;
}
.bt-opt:hover { border-color: var(--q2-accent); }
.bt-opt:focus-visible, .bt-btn:focus-visible { outline: 2px solid var(--q2-focus-ring); outline-offset: 2px; }
.bt-key {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 1px solid var(--q2-divider);
    border-radius: 50%;
    background: var(--q2-bg-muted);
    color: var(--q2-text-muted);
    font-size: .95rem;
    font-weight: 600;
}
.bt-opt-text { flex: 1; min-width: 0; }

.bt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; margin-top: 1.5rem; }
.bt-btn {
    width: auto;
    margin: 0;
    padding: .65rem 1.4rem;
    background: var(--q2-accent);
    color: var(--q2-text-inverse);
    border: 1px solid var(--q2-accent);
    border-radius: var(--q2-radius);
    font: inherit;
    cursor: pointer;
}
.bt-btn.bt-sec { background: transparent; color: var(--q2-text); border-color: var(--q2-divider); }
.bt-btn:disabled { opacity: .45; cursor: not-allowed; }
a.bt-btn { display: inline-block; text-decoration: none; }
a.bt-btn:hover { text-decoration: none; color: var(--q2-text-inverse); }
.bt-done .md-alert--tip { display: none; }

.bt-row { margin-bottom: 1rem; }
.bt-row-top { display: flex; justify-content: space-between; font-weight: 600; }

.bt-chart-box { max-width: 420px; margin: 1rem auto; }
.bt-chart { width: 100%; height: auto; display: block; }
.bt-box { fill: none; stroke: var(--q2-divider); stroke-width: 1.5; }
.bt-quad { fill: var(--q2-accent); stroke: none; }
.bt-axis { stroke: var(--q2-text-muted); stroke-opacity: .45; stroke-width: 1; stroke-dasharray: 4 4; }
.bt-lab { fill: var(--q2-text-muted); font-size: 13px; text-anchor: middle; }
.bt-lab.bt-lab-start { text-anchor: start; }
.bt-lab.bt-lab-end { text-anchor: end; }
.bt-corner { fill: var(--q2-text); font-size: 15px; font-weight: 700; }
.bt-pctlab { fill: var(--q2-text); font-size: 15px; }
.bt-dot { fill: var(--q2-accent); stroke: var(--q2-bg); stroke-width: 3; }
.bt-you { fill: var(--q2-text); font-size: 15px; font-weight: 700; paint-order: stroke; stroke: var(--q2-bg-elev); stroke-width: 4px; stroke-linejoin: round; }

.bt-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; margin-top: 1rem; }
.bt-list ul { margin: 0; padding-left: 1.1rem; }
.bt-list li { margin-bottom: .5rem; }

@media (max-width: 600px) {
    .bt-card { padding: 1rem; }
    .bt-opt { padding: 1rem; gap: 1rem; }
}

/* Botões "Jogar no navegador" (home e clientes) */
.play-buttons { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0 1.5rem; }
.play-buttons a.play-btn.play-btn {
    display: inline-block;
    padding: .7rem 1.4rem;
    background: var(--q2-accent) none;
    color: var(--q2-text-inverse);
    border: 1px solid var(--q2-accent);
    border-radius: var(--q2-radius);
    font-weight: 600;
    text-decoration: none;
}
.play-buttons a.play-btn.play-btn.play-sec { background: transparent none; color: var(--q2-text); border-color: var(--q2-divider); }
.play-buttons a.play-btn.play-btn:hover { filter: brightness(1.1); text-decoration: none; }
.play-buttons a.play-btn.play-btn:not(.play-sec):hover { color: var(--q2-text-inverse); }

/* ---- BUSCA DO CABEÇALHO (templates/partials/header-search.html.twig): a lupa é um link para /search ---- */
a.header-search {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--q2-radius-pill);
    color: var(--q2-text-strong);
    font-size: 16px;
    line-height: 1;
    text-decoration: none;
    flex: 0 0 auto;
    transition: background 0.15s ease;
}
a.header-search:hover {
    background: var(--q2-bg-muted);
    color: var(--q2-text-strong);
}
a.header-search:focus-visible {
    outline: 2px solid var(--q2-focus-ring);
    outline-offset: 2px;
}
/* No menu do celular a lupa vem com o texto, logo abaixo do logo */
a.header-search--labeled {
    order: -1;
    width: 100%;
    height: auto;
    justify-content: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--q2-border-strong);
    font-size: 1rem;
    color: var(--q2-text-muted);
}
.overlay > div:last-child {
    display: contents;
}
.overlay .mobile-logo {
    order: -2;
}
.overlay .theme-toggle {
    margin-top: 2rem;
}

/* ---- RODAPÉ ---- */
.site-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    color: var(--q2-text-muted);
    font-size: 0.85rem;
}
.site-footer p {
    margin: 0;
    max-width: 46rem;
}
.site-footer .site-footer-main {
    color: var(--q2-text);
    font-size: 0.95rem;
}
.site-footer code {
    font-size: 0.85em;
}
.site-footer a {
    color: inherit;
    text-decoration: underline;
}

/* ---- PÁGINA DE RESULTADOS DA BUSCA ---- */
.simplesearch .search-path {
    margin: 0 0 0.25rem;
    color: var(--q2-text-muted);
    font-size: 0.8rem;
}

/* ---- CAPAS DE LIVROS NAS TABELAS (página Tormenta: Jambô Editora) ---- */
.content-item table img {
    display: block;
    width: 110px;
    max-width: none;
    height: auto;
    border-radius: var(--q2-radius-sm);
    box-shadow: var(--q2-shadow-card);
}

/* ---- NOVIDADES: seletor de anos (templates/novidades.html.twig + js/novidades.js) ---- */
.news-years {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
    margin: 1.5rem 0 2rem;
}
.news-years button {
    margin: 0;
    padding: 0.4rem 0.95rem;
    width: auto;
    border: 1px solid var(--q2-border-strong);
    border-radius: var(--q2-radius-pill);
    background: transparent;
    color: var(--q2-text);
    font-size: 0.95rem;
    line-height: 1.2;
    box-shadow: none;
    cursor: pointer;
}
.news-years button:hover {
    background: var(--q2-bg-muted);
}
.news-years button.active {
    background: var(--q2-accent);
    border-color: var(--q2-accent);
    color: #fff;
}
:root[data-theme='dark'] .news-years button.active {
    color: #111111;
}
.news-year[hidden] {
    display: none;
}

/* ===== TEMA CLARO MAIS SUAVE: cinza claro no lugar do branco puro (só o modo claro) ===== */
:root[data-theme="light"] {
  --q2-bg: #e4e6ea; /* fundo da página */
  --q2-bg-elev: #eef0f3; /* cartões e superfície do conteúdo */
  --q2-bg-muted: #dde0e5; /* áreas rebaixadas e hover */
  --q2-text-muted: #5a5f68; /* texto secundário: 4,85:1 ou mais sobre os três fundos do tema (era #666a72, 4,1:1 sobre #dde0e5) */
  --q2-border-ring: rgba(34, 42, 53, 0.12);
  --q2-border-strong: rgba(34, 42, 53, 0.2);
  --q2-divider: rgba(34, 42, 53, 0.12);
  --q2-nav-bg: rgba(238, 240, 243, 0.82);
  --q2-nav-border: rgba(34, 42, 53, 0.12);
}

/* ---- ACESSIBILIDADE ---- */
/* Texto só para leitores de tela (legenda das tabelas) */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Submenu do cabeçalho fechado com Esc: fica fechado até o foco ou o mouse saírem e voltarem */
.dropmenu li.menu-dismissed ul {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Botão "Copiar" dos blocos de código. O bloco é claro nos dois temas, então o botão tem cor própria (contraste ~11:1) e
   alvo de pelo menos 24x24 px */
div.code-toolbar > .toolbar > .toolbar-item > button {
    background: #E5E5E6 !important;
    color: #2B2F38 !important;
    border: 1px solid #6B7280 !important;
    min-width: 24px;
    min-height: 24px;
    padding: 0.2em 0.7em !important;
    font-size: 0.85em !important;
    line-height: 1.2 !important;
    cursor: pointer;
}
div.code-toolbar > .toolbar > .toolbar-item > button:hover,
div.code-toolbar > .toolbar > .toolbar-item > button:focus-visible {
    background: #FFFFFF !important;
}

/* ---- CONTRASTE (WCAG 1.4.3 / 1.4.11) ---- */
/* Foco: anel sólido, 3px, com contraste de pelo menos 3:1 em cada tema (o quark2 usava o accent a 45% de opacidade) */
:root {
    --q2-focus-ring: #B83500;
}
:root[data-theme='dark'] {
    --q2-focus-ring: #FF8A63;
    /* texto escuro sobre o accent mais claro do modo escuro (4,9:1; o branco dava 2,6:1) */
    --q2-accent-contrast: #111111;
}
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--q2-focus-ring);
    outline-offset: 2px;
}

/* `code` no texto: cinza com contraste ~5,9:1 sobre o fundo do trecho */
code:not(pre code) {
    color: #4B5262;
}
:root[data-theme='dark'] code:not(pre code) {
    color: #A3ABBA;
}

/* Avisos (Nota, Dica, Importante, Aviso, Cuidado): títulos com 4,5:1 ou mais sobre o cartão */
html[data-theme='light'] {
    --gh-alert-note-title-color: #2A5DB0;
    --gh-alert-tip-title-color: #2B6E31;
    --gh-alert-important-title-color: #6E40C9;
    --gh-alert-warning-title-color: #7A5500;
    --gh-alert-caution-title-color: #B3261E;
}
html[data-theme='dark'] {
    --gh-alert-note-title-color: #6CA2F0;
    --gh-alert-tip-title-color: #5FBF6A;
    --gh-alert-important-title-color: #B497F0;
    --gh-alert-warning-title-color: #E0B050;
    --gh-alert-caution-title-color: #FF8A80;
}

/* ---- LINK "PULAR PARA O CONTEÚDO" (WCAG 2.4.1): aparece só quando recebe foco ---- */
.skip-link {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10000;
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    background: var(--q2-bg-elev, #fff);
    color: var(--q2-link, #B83500);
    border: 2px solid var(--q2-focus-ring);
    font-weight: 600;
    transform: translateY(-300%);
}
.skip-link:focus,
.skip-link:focus-visible {
    transform: none;
}
main:focus {
    outline: none;
}

/* ---- REALCE DE CÓDIGO (Prism One Light, fundo #FAFAFA): cores originais com 2,5 a 4:1; estas dão 4,9:1 ou mais ---- */
pre[class*="language-"] .token.comment,
pre[class*="language-"] .token.prolog,
pre[class*="language-"] .token.cdata {
    color: #6A6C74;
}
pre[class*="language-"] .token.attr-name,
pre[class*="language-"] .token.class-name,
pre[class*="language-"] .token.boolean,
pre[class*="language-"] .token.constant,
pre[class*="language-"] .token.number,
pre[class*="language-"] .token.atrule {
    color: #8A5A00;
}
pre[class*="language-"] .token.property,
pre[class*="language-"] .token.tag,
pre[class*="language-"] .token.symbol,
pre[class*="language-"] .token.deleted,
pre[class*="language-"] .token.important {
    color: #B83527;
}
pre[class*="language-"] .token.selector,
pre[class*="language-"] .token.string,
pre[class*="language-"] .token.char,
pre[class*="language-"] .token.builtin,
pre[class*="language-"] .token.inserted,
pre[class*="language-"] .token.regex,
pre[class*="language-"] .token.attr-value,
pre[class*="language-"] .token.attr-value > .token.punctuation {
    color: #3A7B39;
}
pre[class*="language-"] .token.variable,
pre[class*="language-"] .token.operator,
pre[class*="language-"] .token.function {
    color: #2F5ECC;
}
pre[class*="language-"] .token.url {
    color: #006E9C;
}

/* ---- ALTO CONTRASTE DO SISTEMA (Windows "forced-colors"): bordas visíveis onde o fundo some ---- */
@media (forced-colors: active) {
    .skip-link,
    .md-alert,
    .bt-opt,
    .bt-btn,
    .news-years button,
    div.code-toolbar > .toolbar > .toolbar-item > button {
        border: 2px solid ButtonText;
    }
    .news-years button.active {
        border-color: Highlight;
        outline: 2px solid Highlight;
    }
    .table-scroll:focus-visible,
    pre:focus-visible {
        outline: 3px solid Highlight;
    }
}

/* ---- LISTAS DO CONTEÚDO: marcador desenhado, não texto ---- */
/* O marcador nativo (list-style: square do Pico) é lido pelo VoiceOver como texto ("■ Ano 632.■ Ocorre…"), repetido a cada trecho
   do item. Aqui o quadradinho vem de um ::before vazio (só fundo colorido), que nenhum leitor fala. A semântica de lista volta
   com role="list", que mudtheme.php põe nos <ul> do conteúdo (o Safari tira o papel de lista de quem usa list-style: none). */
.content-item ul > li {
    list-style: none;
    position: relative;
    padding-inline-start: 0.2em;
}
.content-item ul > li::before {
    content: "";
    position: absolute;
    inset-inline-start: -1.1em;
    top: 0.62em;
    width: 0.42em;
    height: 0.42em;
    background: currentColor;
}

/* ---- CAMPO DE BUSCA (WCAG 1.4.11): a borda precisa de 3:1 contra o entorno em cada tema ---- */
.simplesearch .search-input,
.simplesearch input.search-input {
    border: 2px solid var(--q2-text-muted);
    background: var(--q2-bg-elev);
    color: var(--q2-text);
}
.simplesearch .search-input::placeholder {
    color: var(--q2-text-muted);
    opacity: 1;
}

/* Logo da página inicial: decorativa (alt vazio), alinhada à esquerda como o subtítulo. Ela mostra o nome do site, então
   o h1 que vem logo depois ("TormentaMUD") fica só para leitores de tela e buscadores: continua sendo o título da página,
   mas sem repetir o nome na tela. */
img.home-logo {
    display: block;
    width: min(100%, 40rem);
    height: auto;
    margin: 0;
}
p:has(> img.home-logo) {
    margin: 0 0 1.5rem;
}
p:has(> img.home-logo) + h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
