/* Componentes reutilizáveis: header, botões, cartões, chips, avisos, cookies */

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 100; height: var(--header-h);
  display: flex; align-items: center;
  transition: background-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), backdrop-filter var(--t-med);
}
.site-header.is-scrolled, .site-header--solid {
  background: var(--header-bg); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  box-shadow: 0 1px 0 var(--line);
}
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.site-header__actions { display: flex; align-items: center; gap: var(--space-2); }

.brand { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.brand__logo { display: block; height: 46px; width: auto; transition: filter var(--t-med); }
:root[data-theme="dark"] .brand__logo { filter: invert(1); }
.brand--footer .brand__logo { height: 54px; }

.nav__list { display: flex; gap: .25rem; }
.nav__link { display: block; padding: .5rem .85rem; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; color: var(--text); text-decoration: none; position: relative; }
.nav__link:hover, .nav__link.is-active { color: var(--accent); background: var(--brand-soft); }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); transition: .25s var(--ease);
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold); transform: translateY(-1px); }
.icon-btn--ring { border-color: var(--line-strong); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn .icon { width: 1.25rem; height: 1.25rem; }

/* Alternância de tema: sol no tema escuro, lua no tema claro */
.icon--sun, .icon--moon { position: absolute; transition: transform .5s var(--ease), opacity .3s; }
[data-theme-toggle] { position: relative; overflow: hidden; }
:root[data-theme="light"] .icon--sun { transform: rotate(-90deg) scale(.4); opacity: 0; }
:root[data-theme="dark"] .icon--moon { transform: rotate(90deg) scale(.4); opacity: 0; }

.nav-toggle { display: none; position: relative; }
.nav-toggle .icon--close { opacity: 0; transform: rotate(-90deg); position: absolute; }
.nav-toggle[aria-expanded="true"] .icon--open { opacity: 0; transform: rotate(90deg); }
.nav-toggle[aria-expanded="true"] .icon--close { opacity: 1; transform: none; }

@media (max-width: 960px) {
  .nav-toggle { display: inline-grid; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0; padding: var(--space-4) var(--gutter) var(--space-6);
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-md);
    transform: translateY(-12px); opacity: 0; visibility: hidden; transition: .3s var(--ease);
  }
  .nav.is-open { transform: none; opacity: 1; visibility: visible; }
  .nav__list { flex-direction: column; gap: 0; }
  .nav__link { padding: 1rem .5rem; font-size: 1.05rem; border-radius: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 520px) { .brand__logo { height: 38px; } .site-header__actions .btn--sm { padding-inline: .9rem; } }

/* ---------- Botões ---------- */
.btn {
  --_bg: transparent; --_fg: var(--text); --_bd: var(--line-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  padding: .85rem 1.5rem; border-radius: var(--r-pill); border: 1.5px solid var(--_bd); background: var(--_bg); color: var(--_fg);
  font: 600 1rem/1.2 var(--font-sans); letter-spacing: .01em; text-decoration: none; cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background-color .25s, color .25s, border-color .25s;
  overflow: hidden; isolation: isolate;
}
.btn, .btn:hover, .btn:focus-visible { color: var(--_fg); }   /* vence a regra a:hover e evita texto igual ao fundo */
@media (hover: hover) { .btn:hover { transform: translateY(-2px); } }
.btn:active { transform: translateY(0) scale(.98); }
.btn .icon { transition: transform .25s var(--ease); }
.btn:hover .icon { transform: translateX(3px); }
.btn--primary { --_bg: var(--accent); --_fg: var(--accent-ink); --_bd: var(--accent); box-shadow: 0 6px 16px -8px var(--accent-glow); }
.btn--primary:hover { --_bg: var(--accent-hover); --_bd: var(--accent-hover); --_fg: var(--accent-ink); box-shadow: 0 8px 20px -8px var(--accent-glow); }
.btn--primary::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%); transform: translateX(-120%); }
.btn--primary:hover::after { transform: translateX(120%); transition: transform .8s var(--ease); }
.btn--outline { --_bd: var(--line-strong); }
.btn--outline:hover { --_bd: var(--gold); --_fg: var(--gold); }
.btn--ghost { --_bd: transparent; --_fg: var(--brand); padding-inline: 1rem; }
.btn--ghost:hover { --_fg: var(--gold); }
.btn--lg { padding: 1rem 1.9rem; font-size: 1rem; }
.btn--sm { padding: .6rem 1.1rem; font-size: .88rem; min-height: 44px; }
.btn__spinner { display: none; width: 1.1em; height: 1.1em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.is-loading .btn__spinner { display: inline-block; }
.btn.is-loading { pointer-events: none; opacity: .85; }

/* ---------- Cartões, selos, chips ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.badge {
  display: inline-flex; align-items: center; gap: .55rem; padding: .45rem 1rem; border-radius: var(--r-pill);
  border: 1px solid var(--gold); color: var(--gold); background: var(--gold-soft); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
}
.badge em { font-style: normal; color: var(--text-strong); }
.chip-btn { padding: .65rem 1.2rem; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; transition: .25s var(--ease); }
.chip-btn:hover { border-color: var(--gold); }
.chip-btn[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px -6px var(--accent-glow); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: var(--space-4); }
.chip-tag { padding: .4rem .9rem; border-radius: var(--r-pill); background: var(--brand-soft); color: var(--brand); font-size: var(--fs-sm); font-weight: 500; }

.notice { display: flex; align-items: center; gap: .6rem; padding: .85rem 1.1rem; border-radius: var(--r-md); margin-top: var(--space-4); font-size: var(--fs-sm); border: 1px solid var(--line); background: var(--surface-2); }
.notice--ok { border-color: var(--ok); color: var(--ok); }
.notice--err { border-color: var(--danger); color: var(--danger); }
.notice--warn { border-color: var(--gold); background: var(--gold-soft); color: var(--text); }

/* ---------- CTA fixa em mobile ---------- */
.sticky-cta {
  position: fixed; inset: auto 0 0 0; z-index: 90; padding: .75rem var(--gutter) calc(.75rem + env(safe-area-inset-bottom));
  background: var(--header-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  transform: translateY(110%); transition: transform .4s var(--ease); display: none;
}
.sticky-cta .btn { width: 100%; }
.sticky-cta.is-visible { transform: none; }
@media (max-width: 760px) { .sticky-cta { display: block; } body { padding-bottom: 4.5rem; } }

/* ---------- Banner de cookies ---------- */
.consent { position: fixed; left: var(--gutter); bottom: var(--gutter); z-index: 150; max-width: 380px; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.consent h2 { font-size: 1.3rem; margin-bottom: .4rem; }
.consent p { font-size: var(--fs-sm); color: var(--muted); }
.consent__actions { display: flex; gap: .5rem; margin-top: 1rem; justify-content: flex-end; }
@media (max-width: 760px) { .consent { bottom: 5.2rem; right: var(--gutter); max-width: none; } }

/* Pré-visualização das fases (remover em produção) */
.devbar { position: fixed; right: .75rem; top: calc(var(--header-h) + .5rem); z-index: 160; display: flex; gap: .2rem; align-items: center; padding: .25rem .6rem; border-radius: var(--r-pill); background: #121c38; color: #fff; font-size: .78rem; box-shadow: var(--shadow-md); }
.devbar a { color: #e2c06e; text-decoration: none; padding: .55rem .5rem; border-radius: 6px; }
.devbar a[aria-current] { background: #e2c06e; color: #121c38; }
@media (max-width: 760px) { .devbar { top: auto; bottom: 9.4rem; right: .5rem; } }

/* ---------- Botão com aspeto de ligação, tabelas e rodapé legal ---------- */
.link-btn { padding: 0; border: 0; background: none; color: var(--brand); text-decoration: underline; text-underline-offset: .2em; font: inherit; cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--gold); }
.table-wrap { overflow-x: auto; margin-top: var(--space-4); border: 1px solid var(--line); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: .8rem 1rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table thead th { font-size: var(--fs-xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody th { font-weight: 600; color: var(--text-strong); white-space: nowrap; }
@media (max-width: 720px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table th, .table td { display: block; }
  .table tr { padding: .6rem 0; border-bottom: 1px solid var(--line); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table th, .table td { border: 0; padding: .2rem 1rem; }
  .table td::before { content: attr(data-label) ": "; color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; }
}
.site-footer__inline { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }
.site-footer__inline a { color: var(--text); text-decoration: none; }
.site-footer__inline a:hover { color: var(--gold); }
.site-footer--legal { margin-top: var(--space-8); padding-top: 0; }
.site-footer--legal .site-footer__bottom { margin-top: 0; }

/* Toque: áreas de 44px e sem estados «hover» colados */
@media (pointer: coarse) {
  .site-footer__links a, .site-footer__inline a { min-height: 44px; display: inline-flex; align-items: center; }
  .nav__link { min-height: 44px; }
}

/* ---------- Botão flutuante: voltar ao topo ---------- */
.to-top { --p: 0; position: fixed; right: var(--gutter); bottom: 1.25rem; z-index: 140; width: 52px; height: 52px; padding: 3px; border: 0; border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--line-strong) 0); box-shadow: var(--shadow-md);
  opacity: 0; visibility: hidden; transform: translateY(14px); transition: opacity .25s, transform .25s var(--ease), visibility .25s; }
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top__inner { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: var(--surface); color: var(--text-strong); transition: background-color .2s, color .2s; }
.to-top .icon { width: 1.35rem; height: 1.35rem; stroke-width: 2.2; }
@media (hover: hover) { .to-top:hover .to-top__inner { background: var(--accent); color: var(--accent-ink); } }
.to-top:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
@media (max-width: 760px) { body:not(.page-legal) .to-top { bottom: 5.6rem; } }
