/* Menu — correcções que o Tailwind pré-compilado não consegue servir.
   O ficheiro tailwind.css é gerado fora deste repositório: qualquer classe
   utilitária nova é descartada em silêncio. Tudo o que for preciso acrescentar
   ao menu vive aqui, com selectores próprios, e é carregado DEPOIS do Tailwind.

   Revisão de 2026-08-24 (os três críticos):
   1. o painel em modo gaveta tapava o botão que o abria — sem saída no telemóvel;
   2. o botão do menu não tinha nome acessível nem estado;
   3. os itens de topo não assinalavam a página actual.
*/

/* ---- 1. gaveta com saída: fundo escurecido + botão de fechar ---- */

#sb-fundo {
  position: fixed;
  inset: 0;
  z-index: 35;                 /* acima do header (30), abaixo do painel (40) */
  background: rgb(15 23 42 / 0.45);
}
#sb-fundo[hidden] { display: none; }

/* O botão de fechar só existe enquanto o menu é gaveta. No ecrã grande o
   painel está sempre presente e fechá-lo não faz sentido. */
.sb-fechar { display: none; }

@media (max-width: 900px) {
  .sb-drawer .sb-fechar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;                /* alvo de toque confortável */
    height: 44px;
    margin: 8px 8px 0 auto;
    border: 1px solid var(--color-slate-200);
    border-radius: var(--radius-lg);
    background: #fff;
    color: var(--color-slate-600);
    flex: none;
  }
  .sb-drawer .sb-fechar:hover { color: var(--color-slate-900); }
  .sb-fechar svg { width: 20px; height: 20px; }
}

/* ---- 2. botão do menu: área de toque de 44px ---- */

#sb-burger {
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}
/* No ecrã grande o Tailwind aplica display:none com !important — este
   inline-flex não o contraria, e a regra acima não o ressuscita. */
#sb-burger { display: inline-flex; }
#sb-burger svg { width: 20px; height: 20px; }

/* ---- foco visível nos controlos novos, no tom já usado em .sb-caphead ---- */

.sb-fechar:focus-visible,
#sb-burger:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 1px;
}

/* 10-10-2026: «estou aqui» — um filete da cor da marca à esquerda, além do fundo e do negrito */
.sb-pag.sb-atual{box-shadow:inset 3px 0 0 var(--color-brand)}

/* 02-11-2026: as Atividades Práticas com relevo próprio no menu — fundo quente muito leve
   e um glifo de bancada à direita; o ícone da esquerda continua a ser o estado da leitura.
   Âmbar e não verde: no menu o verde já diz «lida» e «estou aqui». */
.sb-pag.sb-pratica{background:#fffbeb}
.sb-pag.sb-pratica:hover{background:#fef3c7}
.sb-pratica-glifo{width:12px;height:12px;flex:none;margin-left:auto;color:#b45309}
.sb-pag.sb-pratica.sb-atual .sb-pratica-glifo{color:var(--color-brand)}

/* Referência do dossiê citada numa lição: discreta, para não encher o texto de sublinhados. */
a.ref-dossie {
  white-space: nowrap;
  color: inherit;
  text-decoration: underline dotted;
  text-decoration-color: var(--color-brand);
  text-underline-offset: 2px;
}
a.ref-dossie:hover { color: var(--color-brand); text-decoration-style: solid; }

/* Quem chega por uma ligação não fica com a peça escondida atrás do cabeçalho fixo. */
.cen-peca { scroll-margin-top: 5.5rem; }

/* Cartão de uma referência do dossiê (EVD-006, FCT-010…), aberto por static/js/refs-dossie.js
   ao passar o rato, ao focar ou no primeiro toque. Acima do cabeçalho (30), abaixo do painel (40);
   na projeção, acima da camada da lição (60) e da barra (61). */
.ref-cartao {
  position: fixed; z-index: 38;
  width: min(40rem, calc(100vw - 2rem)); max-height: min(34rem, 70vh); /* o script ajusta ao espaço livre */
  overflow: auto; overscroll-behavior: contain;
  padding: 0.95rem 1.15rem 0;
  background: #fff; color: #1e293b;
  border: 1px solid #e2e8f0; border-left: 3px solid var(--color-brand); border-radius: 0.75rem;
  box-shadow: 0 14px 34px -10px rgba(15, 23, 42, 0.28), 0 2px 6px rgba(15, 23, 42, 0.08);
  font-size: 0.92rem; line-height: 1.55; text-align: left;
  opacity: 0; transform: translateY(4px) scale(0.985);
  transition: opacity 0.14s ease-out, transform 0.14s ease-out;
  pointer-events: none;
}
.ref-cartao.aberto { opacity: 1; transform: none; pointer-events: auto; }
.ref-cartao .cen-peca-cab { margin: 0; }
.ref-cartao-titulo { margin: 0.35rem 0 0.15rem; font-size: 1rem; font-weight: 700; line-height: 1.35; color: #0f172a; }
.ref-cartao .cen-peca-resumo { margin: 0 0 0.6rem; color: #475569; }
.ref-cartao .cen-peca-corpo { overflow-x: auto; }
.ref-cartao .cen-peca-corpo > :first-child { margin-top: 0; }
.ref-cartao .cen-peca-corpo > :last-child { margin-bottom: 0; }
.ref-cartao .cen-peca-corpo table { font-size: 0.85rem; }
.ref-cartao-pe {   /* fica sempre à vista no fundo: diz que há mais e por onde se continua */
  position: sticky; bottom: 0; background: #fff;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.25rem 1rem;
  margin: 0.75rem 0 0; padding: 0.6rem 0 0.8rem; border-top: 1px solid #e2e8f0;
  font-size: 0.8rem; color: #475569;
}
.ref-cartao-pe a { color: var(--color-brand); font-weight: 600; white-space: nowrap; }
.ref-cartao-pe a::after { content: " ↗"; }
.ref-cartao a:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; border-radius: 2px; }
.ref-cartao-estado { margin: 0 0 0.85rem; color: #475569; }
a.ref-dossie[aria-expanded="true"] { color: var(--color-brand); text-decoration-style: solid; }
@media (prefers-reduced-motion: reduce) {
  .ref-cartao { transform: none; transition: opacity 0.1s linear; }
}
.projetar .ref-cartao { z-index: 62; width: min(54rem, calc(100vw - 2rem)); max-height: 70vh; font-size: 1.12rem; }
.projetar .ref-cartao-titulo { font-size: 1.5rem; }
.projetar .ref-cartao .cen-peca-resumo, .projetar .ref-cartao .cen-peca-corpo { font-size: 1.25rem; line-height: 1.45; }
.projetar .ref-cartao .cen-peca-corpo :is(p, li, td, th) { font-size: inherit; }
.projetar .ref-cartao .cen-peca-corpo table { font-size: 1.05rem; }
.projetar .ref-cartao-pe { font-size: 0.95rem; }
@media (max-width: 480px) {   /* no telemóvel, o espaço é da peça; a proveniência está no Dossiê */
  .ref-cartao-pe > span { display: none; }
  .ref-cartao-pe a { padding: 0.45rem 0; }
}
@media print { .ref-cartao { display: none; } }

/* Diagrama de contexto da área, na coluna da direita das lições (08-11-2026), e a janela com o diagrama inteiro. */
.dctx-lado-rot { margin: 0 0 .35rem; font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #475569; }
.dctx-lado-titulo { margin: 0 0 .6rem; font-size: .98rem; font-weight: 700; line-height: 1.3; color: #0f172a; }
.dctx-lado-sub { margin: 0 0 .3rem; font-size: .72rem; font-weight: 700; color: var(--color-brand); }
.dctx-lado-ativ { margin: 0; padding: 0; list-style: none; }
.dctx-lado-ativ li { margin: 0; padding: .32rem 0; border-top: 1px solid #e2e8f0; font-size: .8rem; line-height: 1.4; color: #334155; }
.dctx-lado-ativ li:first-child { border-top: 0; }
.dctx-lado-ativ a { color: var(--color-brand); }
.dctx-lado-acoes { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .75rem; }
.dctx-lado-abrir { min-height: 2.25rem; padding: .4rem .8rem; border: 1px solid var(--color-brand); border-radius: .5rem; background: #fff; color: var(--color-brand); font-size: .8rem; font-weight: 600; cursor: pointer; transition: background-color .15s, color .15s; }
.dctx-lado-abrir:hover { background: var(--color-brand); color: #fff; }
.dctx-lado-abrir:focus-visible, .dctx-lado-pag:focus-visible, .dctx-dialogo-fechar:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.dctx-lado-pag { font-size: .8rem; color: #475569; }
.dctx-dialogo { margin: auto; width: min(78rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: .9rem; box-shadow: 0 24px 60px -12px rgba(15, 23, 42, .4); }
.dctx-dialogo::backdrop { background: rgba(15, 23, 42, .55); }
.dctx-dialogo-cab { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem .75rem 1.25rem; background: #fff; border-bottom: 1px solid #e2e8f0; }
.dctx-dialogo-cab p { margin: 0; font-size: 1rem; line-height: 1.35; font-weight: 700; color: #0f172a; }
.dctx-dialogo-fechar { width: 2.5rem; height: 2.5rem; border: 0; border-radius: .5rem; background: transparent; font-size: 1.6rem; line-height: 1; color: #475569; cursor: pointer; }
.dctx-dialogo-fechar:hover { background: #f1f5f9; }
.dctx-dialogo-corpo { padding: 1rem 1.25rem 0; overflow-x: auto; }
@media (min-width: 900px) { .dctx-dialogo-corpo .dctx { min-width: 56rem; } }
.dctx-dialogo-pe { margin: .75rem 1.25rem 1rem; font-size: .8rem; color: #475569; }
@media (prefers-reduced-motion: no-preference) {
  .dctx-dialogo[open] { animation: dctx-abrir .16s ease-out; }
  @keyframes dctx-abrir { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
.projetar .dctx-lado { display: none; }
@media print { .dctx-lado, .dctx-dialogo { display: none; } }
