/* ==========================================================================
   GURIA @ UBI — Guia para a Utilização Responsável da Inteligência Artificial
   Folha de estilos principal
   Identidade visual UBI · grelha de 8 pt · WCAG 2.1 AA
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens de design
   -------------------------------------------------------------------------- */
:root {
  /* Cor primária institucional */
  /* Preenchimentos e superfícies com a cor institucional */
  --ubi-blue:        #0c2340;
  --ubi-blue-hover:  #0a1b32;
  --ubi-blue-active: #071426;
  --ubi-blue-soft:   #e8edf4;

  /* Cor de acento aplicada a TEXTO e ícones. Distinta do preenchimento porque
     texto exige 4.5:1 e um preenchimento apenas 3:1 (WCAG 1.4.3 vs 1.4.11). */
  --accent-text:     #0c2340;   /* 15.8:1 sobre branco */
  --link:            #0c2340;
  --link-hover:      #0a1b32;

  /* Superfícies e texto (modo claro) */
  --surface:         #ffffff;
  --surface-alt:     #f5f7fa;
  --surface-card:    #ffffff;
  --border:          #dde3ec;
  --border-strong:   #c3ccdb;   /* separadores decorativos */
  --border-control:  #6e7888;   /* contorno de controlos: 4.5:1 sobre branco */

  --text:            #1a1a1a;
  --text-soft:       #333333;
  --text-muted:      #5a5a5a;   /* 6.5:1 sobre branco */
  --text-on-primary: #ffffff;

  /* Semântica */
  --ok:              #1b7a3d;   /* 5.4:1 sobre branco */
  --ok-bg:           #eaf6ee;
  --ok-border:       #b9e0c8;
  --stop:            #b3261e;   /* 6.6:1 sobre branco */
  --stop-bg:         #fdeceb;
  --stop-border:     #f3c2be;
  --surface-quote:   #eef2f8;

  --focus:           #0c2340;

  /* Faixas azuis institucionais (cabeçalho e rodapé). São azuis nos DOIS
     temas, pelo que estes tokens são fixos e não são redefinidos no bloco do
     modo escuro. Rácios calculados sobre #0c2340. */
  --brand-bg:          #0c2340;
  --brand-text:        rgba(255, 255, 255, .86);  /* 11.0:1 */
  --brand-text-soft:   rgba(255, 255, 255, .72);  /*  8.7:1 */
  --brand-line:        rgba(255, 255, 255, .45);  /*  4.2:1 — contornos */
  --brand-line-strong: rgba(255, 255, 255, .55);  /*  5.7:1 */
  --brand-hover-bg:    rgba(255, 255, 255, .10);
  --brand-active-bg:   rgba(255, 255, 255, .16);
  --brand-divider:     rgba(255, 255, 255, .18);  /* filetes internos */
  --shadow-sm:  0 1px 2px rgba(12, 35, 64, .06), 0 2px 8px rgba(12, 35, 64, .06);
  --shadow-md:  0 4px 12px rgba(12, 35, 64, .10), 0 12px 32px rgba(12, 35, 64, .08);

  /* Escala de espaçamento — múltiplos de 8 px */
  --s-1:  8px;  --s-2: 16px; --s-3: 24px; --s-4: 32px;
  --s-5: 40px;  --s-6: 48px; --s-8: 64px; --s-10: 80px; --s-12: 96px;

  --radius:    6px;   /* 4–8 px, consistente em todos os componentes */
  --radius-lg: 8px;

  --section-y: 96px;  /* 80–120 px em desktop */
  /* Altura do cabeçalho fixo. Serve de recurso: o script mede a altura real e
     reescreve esta variável, para que as ligações de âncora não aterrem por
     baixo do cabeçalho quando o conteúdo da barra mudar. */
  --header-h:  104px;
}

[data-bs-theme="dark"] {
  --ubi-blue:        #2a6dbb;   /* 3.6:1 sobre #121212, 3.2:1 sobre #1e1e1e; texto branco 5.3:1 */
  --ubi-blue-hover:  #3179cc;
  --ubi-blue-active: #21579a;
  --ubi-blue-soft:   #14263c;

  --accent-text:     #8ab4f8;   /* 9.1:1 sobre #121212 */
  --link:            #8ab4f8;
  --link-hover:      #aecbfa;

  --surface:         #121212;
  --surface-alt:     #1a1a1a;
  --surface-card:    #1e1e1e;
  --border:          #333a44;
  --border-strong:   #4a525e;
  --border-control:  #6e7888;   /* 4.2:1 sobre #121212, 3.7:1 sobre #1e1e1e */

  --text:            #e6e6e6;   /* 15:1 sobre #121212 */
  --text-soft:       #dcdcdc;
  --text-muted:      #b0b0b0;   /* 8.7:1 sobre #121212 */
  --text-on-primary: #ffffff;

  --ok:              #7ee2a8;
  --ok-bg:           #14261c;
  --ok-border:       #2c5a3f;
  --stop:            #ff8a80;
  --stop-bg:         #2a1614;
  --stop-border:     #6b332e;
  --surface-quote:   #16202e;

  --focus:           #8ab4f8;
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, .40), 0 2px 8px rgba(0, 0, 0, .30);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, .50), 0 12px 32px rgba(0, 0, 0, .40);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 24px); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  font-family: "Roboto Slab", Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { color: var(--text); line-height: 1.25; text-wrap: balance; }

h1, .h1 { font-size: clamp(2rem, 1.45rem + 2.2vw, 2.5rem); font-weight: 700; letter-spacing: -.02em; }
h2, .h2 { font-size: clamp(1.625rem, 1.35rem + 1.1vw, 2rem);  font-weight: 600; letter-spacing: -.01em; }
h3, .h3 { font-size: clamp(1.25rem, 1.13rem + .5vw, 1.5rem);  font-weight: 600; }
h4, .h4 { font-size: 1.125rem; font-weight: 600; }

small, .small, .text-small { font-size: .875rem; font-weight: 300; }

p { margin-bottom: var(--s-3); }
p:last-child { margin-bottom: 0; }

/* A cor das ligações vem de um token, e não de uma regra específica do tema:
   assim os componentes que definem a sua própria cor (.btn, .card-ubi) não são
   sobrepostos pela especificidade de [data-bs-theme="dark"] a { … }. */
a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }

strong, b { font-weight: 700; }

hr { border-color: var(--border); opacity: 1; }

/* O rosa por omissão do Bootstrap para <code> fica em 4.19:1 sobre o cinzento
   das secções alternadas, abaixo dos 4.5:1 exigidos. */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .875em; color: var(--text);
  background: var(--surface-alt); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 4px;
  overflow-wrap: anywhere;
}

::selection { background: var(--ubi-blue); color: #fff; }

/* Foco visível — navegação por teclado */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}
.btn:focus-visible, .nav-link:focus-visible, .form-control:focus-visible, .form-select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: none;
}
/* Sobre o azul institucional o anel de foco passa a branco, para se manter visível. */
.hero :focus-visible, .cta-band :focus-visible { outline-color: #fff; }

/* Ligação de salto para o conteúdo */
.skip-link {
  position: absolute; top: -100px; left: var(--s-2); z-index: 2000;
  padding: 12px 24px; border-radius: var(--radius);
  background: #fff; color: var(--brand-bg); font-weight: 600; text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
}
.skip-link:focus { top: var(--s-2); color: var(--brand-bg); }

/* --------------------------------------------------------------------------
   3. Grelha — 12 / 8 / 4 colunas · gutters 24 / 16 / 16 px
   -------------------------------------------------------------------------- */
.container, .container-fluid, .container-lg, .container-xl, .container-xxl { --bs-gutter-x: 1.5rem; }

@media (max-width: 991.98px) {
  .container, .container-fluid, .container-lg, .container-xl, .container-xxl { --bs-gutter-x: 1rem; }
  .row { --bs-gutter-x: 1rem; }
  :root { --section-y: 56px; }
}

/* --------------------------------------------------------------------------
   4. Cabeçalho / navegação
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 1030;
  background: var(--brand-bg);   /* recurso para navegadores sem color-mix() */
  background: color-mix(in srgb, var(--brand-bg) 94%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  transition: box-shadow .2s ease;
}
@supports not (backdrop-filter: blur(1px)) { .site-header { background: var(--brand-bg); } }

/* Sem contorno enquanto está no topo, para o cabeçalho fluir para dentro do
   hero azul da página inicial. Ao deslocar, ganha sombra e separa-se do
   conteúdo — o que também resolve a fraca separação, no modo escuro, entre o
   azul institucional e o fundo quase preto da página. */
.site-header.is-scrolled {
  box-shadow: 0 1px 0 var(--brand-divider), 0 6px 20px rgba(0, 0, 0, .28);
}

/* Sobre o azul institucional o anel de foco tem de ser branco. */
.site-header :focus-visible { outline-color: #fff; }

.navbar { padding-top: var(--s-1); padding-bottom: var(--s-1); }

/* Logótipo — área de proteção equivalente à altura da letra «U» (≈16 px).
   No cabeçalho é sempre usada a versão negativa (branca), independentemente
   do tema: o fundo é azul nos dois casos. */
.navbar-brand {
  display: inline-flex; align-items: center;
  padding: 16px; margin-left: -16px;
  min-height: 44px;
}
.navbar-brand img { height: 40px; width: auto; display: block; }
.navbar-brand .brand-sep {
  width: 1px; height: 32px; margin: 0 var(--s-2);
  background: var(--brand-line); flex: 0 0 auto;
}
.navbar-brand .brand-name {
  font-size: .9375rem; font-weight: 700; line-height: 1.2;
  color: #fff; letter-spacing: .01em;
}
.navbar-brand .brand-tag {
  display: block; font-size: .75rem; font-weight: 300;
  color: var(--brand-text-soft); letter-spacing: .04em; text-transform: uppercase;
}
.navbar-brand:hover .brand-tag { color: #fff; }

.navbar-nav { gap: 2px; }
.navbar .nav-link {
  font-size: .9375rem; font-weight: 400; color: var(--brand-text);
  padding: 12px 16px; border-radius: var(--radius);
  min-height: 44px; display: flex; align-items: center; gap: 8px;
}
.navbar .nav-link:hover, .navbar .nav-link:focus { color: #fff; background: var(--brand-hover-bg); }
.navbar .nav-link.active,
.navbar .nav-link[aria-current="page"] { color: #fff; font-weight: 700; background: var(--brand-active-bg); }

.navbar .nav-link.nav-download {
  color: #fff; font-weight: 600;
  border: 1px solid var(--brand-line);
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.navbar .nav-link.nav-download:hover { background: #fff; color: var(--brand-bg); border-color: #fff; }
.navbar .nav-link.nav-download.active,
.navbar .nav-link.nav-download[aria-current="page"] { background: #fff; color: var(--brand-bg); border-color: #fff; }

.navbar-toggler {
  min-width: 44px; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--brand-line); border-radius: var(--radius);
  color: #fff; box-shadow: none;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.navbar-toggler:focus { box-shadow: none; }
.navbar-toggler:hover { background: #fff; color: var(--brand-bg); border-color: #fff; }

.theme-toggle {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--brand-line); border-radius: var(--radius);
  background: transparent; color: #fff;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.theme-toggle:hover { background: #fff; color: var(--brand-bg); border-color: #fff; }

/* Menu aberto em ecrãs estreitos: separa-se da barra com um filete claro. */
@media (max-width: 1199.98px) {
  .navbar-collapse.show, .navbar-collapse.collapsing {
    border-top: 1px solid var(--brand-hover-bg);
    margin-top: var(--s-1);
  }
}

/* Em ecrãs estreitos a marca é compactada para que os botões caibam na mesma
   linha, evitando um cabeçalho fixo de duas linhas. A área de proteção do
   logótipo desce para 12 px, mantendo-se proporcional à altura de 32 px. */
@media (max-width: 575.98px) {
  .navbar-brand { padding: 12px; margin-left: -12px; }
  .navbar-brand img { height: 32px; }
  .navbar-brand .brand-tag { display: none; }
  .navbar-brand .brand-sep { height: 24px; margin: 0 12px; }
  :root { --header-h: 80px; }
}

@media (min-width: 1200px) {
  .navbar .nav-link.nav-download {
    width: 44px; min-width: 44px; height: 44px; padding: 0;
    justify-content: center;
  }
  /* Equivalente a .visually-hidden, mas aplicável só a partir deste ponto de
     quebra: o rótulo deixa de se ver sem deixar de ser lido. */
  .navbar .nav-link.nav-download .nav-download__label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}

/* Abaixo desse ponto o menu é uma lista de texto: o botão mantém o rótulo,
   para não ficar um ícone solitário entre itens escritos por extenso. */
@media (max-width: 1199.98px) {
  .navbar-collapse { padding-top: var(--s-2); padding-bottom: var(--s-1); }
  .navbar-nav { gap: 4px; }
  .navbar .nav-link.nav-download { margin-top: var(--s-1); justify-content: center; }
}

/* --------------------------------------------------------------------------
   5. Secções
   -------------------------------------------------------------------------- */
.section { padding-block: var(--section-y); }
.section--tight { padding-block: var(--s-6); }
.section--alt { background: var(--surface-alt); }

.section-label {
  display: inline-block; margin-bottom: var(--s-2);
  font-size: .8125rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-text);
}
.section-lead { font-size: 1.125rem; color: var(--text-soft); max-width: 68ch; }

.rule {
  width: 56px; height: 4px; border-radius: 2px;
  background: var(--ubi-blue); margin-bottom: var(--s-3);
}

/* --------------------------------------------------------------------------
   6. Hero
   -------------------------------------------------------------------------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--ubi-blue); color: #fff;
  padding-block: clamp(56px, 8vw, 120px);
}
[data-bs-theme="dark"] .hero { background: #0c2340; }

.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 90% at 82% 12%, rgba(255,255,255,.10), transparent 60%),
    radial-gradient(45% 70% at 8% 92%, rgba(255,255,255,.06), transparent 60%);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; }
.hero p { color: rgba(255,255,255,.88); }
.hero .hero-lead { font-size: 1.1875rem; max-width: 62ch; }
.hero a:not(.btn) { color: #fff; }

.hero-eyebrow {
  font-size: .8125rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255,255,255,.78);
}

.page-hero { background: var(--surface-alt); border-bottom: 1px solid var(--border); padding-block: var(--s-8); }
.page-hero h1 { margin-bottom: var(--s-2); }
.page-hero .section-lead { margin-bottom: 0; }

.breadcrumb { font-size: .875rem; font-weight: 300; margin-bottom: var(--s-2); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--ubi-blue); text-decoration: underline; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text-soft); }

/* --------------------------------------------------------------------------
   7. Botões
   -------------------------------------------------------------------------- */
.btn {
  --bs-btn-focus-box-shadow: none;
  font-family: inherit; font-weight: 600; font-size: 1rem;
  padding: 14px 32px; border-radius: var(--radius);
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.btn-sm { padding: 12px 24px; font-size: .9375rem; min-height: 44px; }

.btn-ubi {
  background: var(--ubi-blue); border: 1px solid var(--ubi-blue); color: var(--text-on-primary);
}
.btn-ubi:hover { background: var(--ubi-blue-hover); border-color: var(--ubi-blue-hover); color: var(--text-on-primary); box-shadow: var(--shadow-md); }
.btn-ubi:active { background: var(--ubi-blue-active) !important; border-color: var(--ubi-blue-active) !important; color: #fff !important; box-shadow: none; }
.btn-ubi:disabled, .btn-ubi.disabled { background: #d5dae2; border-color: #d5dae2; color: #6a7280; box-shadow: none; opacity: 1; }
[data-bs-theme="dark"] .btn-ubi:disabled { background: #2a2f38; border-color: #2a2f38; color: #8b939f; }

/* O contorno usa currentColor: a cor do texto já cumpre 4.5:1, pelo que a
   fronteira do controlo cumpre automaticamente os 3:1 da WCAG 1.4.11. */
.btn-ubi-outline {
  background: transparent; border: 1px solid currentColor; color: var(--accent-text);
}
.btn-ubi-outline:hover { background: var(--ubi-blue); border-color: var(--ubi-blue); color: var(--text-on-primary); box-shadow: var(--shadow-md); }
.btn-ubi-outline:active { background: var(--ubi-blue-active) !important; border-color: var(--ubi-blue-active) !important; color: #fff !important; }

/* Sobre fundo azul institucional, o botão primário inverte-se: um preenchimento
   azul sobre azul não atingiria o contraste mínimo de 3:1 exigido pela WCAG 1.4.11. */
.hero .btn-ubi,
.cta-band .btn-ubi { background: #fff; border-color: #fff; color: #0c2340; }
.hero .btn-ubi:hover,
.cta-band .btn-ubi:hover { background: #e8edf4; border-color: #e8edf4; color: #0c2340; }
.hero .btn-ubi:active,
.cta-band .btn-ubi:active { background: #c8d2e0 !important; border-color: #c8d2e0 !important; color: #0c2340 !important; }

.hero .btn-ubi-outline,
.cta-band .btn-ubi-outline { border-color: rgba(255,255,255,.55); color: #fff; }
.hero .btn-ubi-outline:hover,
.cta-band .btn-ubi-outline:hover { background: #fff; border-color: #fff; color: #0c2340; }
.hero .btn-ubi-outline:active,
.cta-band .btn-ubi-outline:active { background: #e8edf4 !important; border-color: #e8edf4 !important; color: #0c2340 !important; }

/* --------------------------------------------------------------------------
   8. Cartões
   -------------------------------------------------------------------------- */
.card-ubi {
  height: 100%;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
@media (min-width: 992px) { .card-ubi { padding: var(--s-5); } }

.card-ubi h3, .card-ubi h4 { margin-bottom: var(--s-2); }
.card-ubi p { color: var(--text-soft); }

/* height:100% equaliza cartões lado a lado numa grelha. Numa coluna estreita
   ao lado de outra muito mais alta, esticaria o cartão para além do conteúdo —
   nesses casos usa-se este modificador. */
.card-ubi--auto { height: auto; }

a.card-ubi { display: block; text-decoration: none; color: inherit; }
a.card-ubi:hover, .card-ubi--hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--ubi-blue);
}
a.card-ubi:hover h3, a.card-ubi:hover h4 { color: var(--accent-text); }

.card-icon {
  width: 48px; height: 48px; margin-bottom: var(--s-3);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-size: 1.25rem;
  background: var(--ubi-blue-soft); color: var(--accent-text);
}

.card-link-cue { font-size: .9375rem; font-weight: 600; color: var(--accent-text); margin-top: var(--s-3); display: inline-flex; align-items: center; gap: 8px; }
/* Quando é a própria ligação (e não uma pista dentro de um cartão clicável),
   precisa dos 44 px de altura mínima de área de toque. */
a.card-link-cue { min-height: 44px; padding-block: 8px; }
a.card-ubi:hover .card-link-cue i { transform: translateX(4px); }
.card-link-cue i { transition: transform .2s ease; }

/* Imagem de cartão — 16:9 por defeito */
.card-media { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; }
.card-media--4x3 { aspect-ratio: 4 / 3; }

/* --------------------------------------------------------------------------
   9. Princípios · estatísticas
   -------------------------------------------------------------------------- */
.principle-num {
  font-size: .8125rem; font-weight: 700; letter-spacing: .1em;
  color: var(--text-muted); display: block; margin-bottom: var(--s-1);
}

.stat { text-align: center; padding: var(--s-3) var(--s-2); }
.stat-value { font-size: 2.5rem; font-weight: 700; line-height: 1; color: var(--accent-text); display: block; }
.stat-label { font-size: .875rem; font-weight: 300; color: var(--text-muted); margin-top: var(--s-1); display: block; }

/* --------------------------------------------------------------------------
   10. Citação institucional
   -------------------------------------------------------------------------- */
.quote-ubi {
  position: relative;
  background: var(--surface-quote);
  border-left: 4px solid var(--ubi-blue);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: var(--s-4);
  margin: 0;
}
@media (min-width: 992px) { .quote-ubi { padding: var(--s-5) var(--s-6); } }
.quote-ubi p { font-size: 1.1875rem; font-weight: 400; color: var(--text); }
.quote-ubi cite { display: block; margin-top: var(--s-2); font-size: .875rem; font-weight: 300; font-style: normal; color: var(--text-muted); }

/* --------------------------------------------------------------------------
   11. Boas práticas e linhas vermelhas
   -------------------------------------------------------------------------- */
.rule-card {
  height: 100%;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  padding: var(--s-4);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: calc(var(--header-h) + 32px);
}
@media (min-width: 992px) { .rule-card { padding: var(--s-4) var(--s-5); } }

.rule-card--ok   { border-left-color: var(--ok); }
.rule-card--stop { border-left-color: var(--stop); }

.rule-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); margin-bottom: var(--s-2); }

.rule-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font-size: .8125rem; font-weight: 700; letter-spacing: .02em;
}
.rule-badge--ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-border); }
.rule-badge--stop { background: var(--stop-bg); color: var(--stop); border: 1px solid var(--stop-border); }

.tag {
  display: inline-flex; align-items: center;
  padding: 5px 12px; border-radius: 999px;
  font-size: .75rem; font-weight: 400; letter-spacing: .02em;
  background: var(--surface-alt); color: var(--text-muted);
  border: 1px solid var(--border);
}
[data-bs-theme="dark"] .tag { background: #262b33; }

.rule-card p { color: var(--text-soft); }
.rule-card p + p { margin-top: var(--s-2); }

/* Filtros */
.filter-bar {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-3);
  box-shadow: var(--shadow-sm);
}
@media (min-width: 992px) { .filter-bar { padding: var(--s-4); } }

.filter-chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border: 1px solid var(--border-control); border-radius: 999px;
  background: transparent; color: var(--text-soft);
  font-size: .9375rem; font-weight: 400;
  transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}
.filter-chip:hover { background: var(--ubi-blue-soft); color: var(--accent-text); border-color: var(--accent-text); }
.filter-chip[aria-pressed="true"] {
  background: var(--ubi-blue); border-color: var(--ubi-blue);
  color: var(--text-on-primary); font-weight: 600;
}

.form-control, .form-select {
  font-family: inherit; font-size: 1rem; min-height: 48px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-control); color: var(--text);
}
.form-control::placeholder { color: var(--text-muted); opacity: 1; }
.form-control:focus, .form-select:focus { background: var(--surface); color: var(--text); border-color: var(--accent-text); }
.form-label { font-size: .875rem; font-weight: 600; margin-bottom: var(--s-1); color: var(--text-soft); }

.filter-status { font-size: .9375rem; font-weight: 300; color: var(--text-muted); }

.no-results {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: var(--s-6) var(--s-4); text-align: center; color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   12. Índice lateral (sumário da página)
   -------------------------------------------------------------------------- */
.toc { position: sticky; top: calc(var(--header-h) + 24px); }
.toc h2 {
  font-size: .8125rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: var(--s-2);
}
.toc ul { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.toc a {
  display: flex; align-items: center; min-height: 44px;
  padding: 10px 16px; margin-left: -2px;
  border-left: 2px solid transparent;
  font-size: .9375rem; font-weight: 300; color: var(--text-muted); text-decoration: none;
}
.toc a:hover { color: var(--accent-text); border-left-color: var(--border-strong); }
.toc a.is-active { color: var(--accent-text); font-weight: 600; border-left-color: var(--accent-text); }

/* --------------------------------------------------------------------------
   13. Conteúdo longo
   -------------------------------------------------------------------------- */
.prose { max-width: 72ch; }
.prose--wide { max-width: none; }
.prose > h2 { margin-top: var(--s-8); margin-bottom: var(--s-3); scroll-margin-top: calc(var(--header-h) + 32px); }
.prose > h2:first-child { margin-top: 0; }
.prose > h3 { margin-top: var(--s-5); margin-bottom: var(--s-2); scroll-margin-top: calc(var(--header-h) + 32px); }
.prose ul, .prose ol { margin-bottom: var(--s-3); padding-left: var(--s-3); }
.prose li { margin-bottom: var(--s-1); color: var(--text-soft); }
.prose li::marker { color: var(--accent-text); }

.note {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-3);
  font-size: .9375rem;
  color: var(--text-soft);
}
.note--placeholder { border-style: dashed; }

.snippet {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
}
.snippet p { font-size: .9375rem; color: var(--text-soft); }
/* O botão flutua em vez de ser posicionado em absoluto: assim o texto contorna-o
   e nunca fica por baixo, seja qual for a largura ou o comprimento da citação. */
.snippet .btn-copy { float: right; margin: 0 0 var(--s-2) var(--s-2); min-height: 44px; padding: 10px 16px; font-size: .8125rem; }
.snippet--with-copy::after { content: ""; display: block; clear: both; }

/* Referências */
.ref-list { list-style: none; padding: 0; margin: 0; }
.ref-list li {
  padding: var(--s-2) 0 var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  font-size: .9375rem; font-weight: 300; color: var(--text-soft); line-height: 1.6;
}
.ref-list li:last-child { border-bottom: 0; }
.ref-list li:hover { border-left-color: var(--ubi-blue); }

/* Ferramentas */
.tool-card__meta { font-size: .8125rem; font-weight: 300; color: var(--text-muted); letter-spacing: .02em; }

/* Descargas */
.download-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3);
  background: var(--surface-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--s-4); box-shadow: var(--shadow-sm);
}
@media (min-width: 992px) { .download-item { padding: var(--s-5); } }
.download-item__icon {
  width: 56px; height: 56px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-size: 1.5rem;
  background: var(--ubi-blue-soft); color: var(--accent-text);
}
.download-item__body { flex: 1 1 320px; min-width: 0; }
.download-item__body h3 { margin-bottom: 4px; }

.meta-row { display: flex; flex-wrap: wrap; gap: var(--s-2); font-size: .875rem; font-weight: 300; color: var(--text-muted); }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }

/* --------------------------------------------------------------------------
   14. Faixa de apelo à ação
   -------------------------------------------------------------------------- */
.cta-band {
  background: var(--ubi-blue); color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--s-5) var(--s-4);
}
@media (min-width: 992px) { .cta-band { padding: var(--s-8); } }
[data-bs-theme="dark"] .cta-band { background: #0c2340; border: 1px solid #1f3b5e; }
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.88); }

/* --------------------------------------------------------------------------
   15. Rodapé
   -------------------------------------------------------------------------- */
.site-footer {
  background: var(--brand-bg);
  /* O espaço inferior é maior do que o superior de propósito: reserva a faixa
     onde assenta o botão flutuante «voltar ao topo» (48 px de altura a 24 px
     do fundo), que de outro modo taparia a linha de créditos. */
  padding-block: var(--s-8) var(--s-12);
}
/* Sobre o azul institucional o anel de foco tem de ser branco. */
.site-footer :focus-visible { outline-color: #fff; }

.site-footer img { height: 40px; width: auto; }

/* O rodapé é azul nos dois temas, pelo que o utilitário de texto esbatido
   (pensado para fundos claros) tem de ser reinterpretado aqui. */
.site-footer .text-muted-ubi { color: var(--brand-text-soft) !important; }

.site-footer h2 {
  font-size: .8125rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand-text-soft); margin-bottom: var(--s-2);
}
.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links li { margin-bottom: 0; }
.footer-links a {
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: .9375rem; font-weight: 300; color: var(--brand-text); text-decoration: none;
}
.footer-links a:hover { color: #fff; text-decoration: underline; }

.footer-bottom {
  margin-top: var(--s-5); padding-top: var(--s-3);
  border-top: 1px solid var(--brand-divider);
  font-size: .875rem; font-weight: 300; color: var(--brand-text-soft);
}

/* Voltar ao topo */
.back-to-top {
  position: fixed; right: var(--s-3); bottom: var(--s-3); z-index: 1040;
  width: 48px; height: 48px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ubi-blue); color: #fff;
  /* O contorno branco garante os 3:1 tanto sobre o conteúdo claro como sobre
     o rodapé azul, onde o preenchimento sozinho desapareceria. */
  border: 2px solid #fff;
  box-shadow: var(--shadow-md);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease, background-color .2s ease;
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.back-to-top:hover { background: var(--ubi-blue-hover); color: #fff; }

/* --------------------------------------------------------------------------
   16. Utilitários
   -------------------------------------------------------------------------- */
.text-muted-ubi { color: var(--text-muted) !important; }
.bg-alt { background: var(--surface-alt); }
.border-ubi { border-color: var(--border) !important; }
.max-68 { max-width: 68ch; }
.max-44 { max-width: 44ch; }
.mt-section { margin-top: var(--section-y); }

@media print {
  .site-header, .site-footer, .back-to-top, .filter-bar, .toc, .skip-link { display: none !important; }
  body { color: #000; background: #fff; font-size: 11pt; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; }
}
