/* =====================================================================
   ANJE — Header institucional em três níveis (proposta B)
   1. Utilidades (grafite) · 2. Marca + pesquisa + acções · 3. Separadores com painéis
   Em scroll, os níveis 1–2 recolhem e fica apenas a barra de separadores compacta.
   ===================================================================== */

/* ---- Nível 1: utilidades ---- */
.hx-util { background: var(--ink); color: #d9d0d5; font-size: var(--fs-xs); }
.hx-util-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 36px; }
.hx-clock { font-variant-numeric: tabular-nums; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hx-util-links { display: flex; align-items: center; gap: 4px; }
.hx-ulink { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; font: inherit; color: #d9d0d5; padding: 6px 9px; border-radius: 6px; cursor: pointer; text-decoration: none; }
.hx-ulink:hover, .hx-ulink[aria-expanded="true"] { background: rgba(255,255,255,.08); color: #fff; }
.hx-ulink svg { width: 14px; height: 14px; }
.hx-lang select { font: inherit; color: #fff; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); border-radius: 6px; padding: 3px 6px; max-width: 150px; }
.hx-lang option { color: var(--ink); }

/* ---- Contentor fixo ---- */
.hx { position: sticky; top: 0; z-index: 50; background: #fff; transition: box-shadow .2s; }
.hx.is-compact { box-shadow: 0 8px 24px -16px rgba(35,26,36,.45); }

/* ---- Nível 2: marca, pesquisa, acções ---- */
.hx-main { border-bottom: 1px solid var(--line-2); transition: max-height .25s ease, opacity .2s; max-height: 120px; overflow: visible; }
.hx-main-in { display: flex; align-items: center; gap: 24px; min-height: 80px; }
.hx-logo img { height: 50px; width: auto; }
.hx-search { position: relative; flex: 1; max-width: 560px; display: flex; align-items: center; }
.hx-search svg { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.hx-search input { width: 100%; font: inherit; font-size: var(--fs-sm); padding: 13px 46px 13px 46px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft); transition: border-color .15s, box-shadow .15s, background .15s; }
.hx-search input:focus { outline: none; background: #fff; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(200,20,42,.12); }
.hx-search kbd { position: absolute; right: 14px; font: inherit; font-size: .7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; background: #fff; }
.hx-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.hx-ai { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s; }
.hx-ai:hover, .hx-ai[aria-current] { border-color: var(--brand); box-shadow: var(--shadow-sm); color: var(--ink); }
.hx-ai-badge { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 800; font-size: .72rem; background: conic-gradient(from 210deg, var(--brand), #6d1222, var(--brand)); }
.hx-ai-txt { display: flex; flex-direction: column; line-height: 1.15; }
.hx-ai-txt b { font-size: var(--fs-sm); }
.hx-ai-txt small { font-size: .68rem; color: var(--muted); }

.hx-account { position: relative; }
.hx-avatar-btn { display: inline-flex; align-items: center; gap: 9px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 5px; cursor: pointer; font: inherit; color: var(--ink); }
.hx-avatar-btn:hover, .hx-avatar-btn[aria-expanded="true"] { border-color: var(--ink-2); }
.hx-avatar-btn > svg { width: 12px; height: 12px; }
.hx-avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--ink); color: #fff; font-weight: 800; font-size: .85rem; }
.hx-acc-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.hx-acc-txt b { font-size: var(--fs-sm); }
.hx-acc-txt small { font-size: .68rem; color: var(--muted); }
.hx-account-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; display: none; z-index: 60; }
.hx-account-menu.open { display: block; animation: hxpop .16s ease-out; }
.hx-account-menu a, .hx-account-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; font: inherit; font-size: var(--fs-sm); color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer; }
.hx-account-menu a:hover, .hx-account-menu button:hover { background: var(--bg-tint); }
.hx-account-menu form { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 6px; }

.hx-burger { display: none; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 9px; cursor: pointer; color: var(--ink); }
.hx-burger svg { width: 22px; height: 22px; display: block; }

/* ---- Nível 3: separadores ---- */
.hx-nav { position: relative; background: #fff; border-bottom: 1px solid var(--line); }
.hx-nav-in { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.hx-mini-logo, .hx-mini-cta { display: none; }
.hx-mini-logo img { height: 30px; width: 30px; }
.hx-tabs { list-style: none; display: flex; gap: 2px; margin: 0; padding: 0; flex: 1; }
.hx-tab { position: relative; display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; font: inherit; font-size: var(--fs-sm); font-weight: 650; color: var(--ink-2); padding: 15px 12px; cursor: pointer; white-space: nowrap; }
.hx-tab svg { width: 12px; height: 12px; transition: transform .2s; opacity: .6; }
.hx-tab::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; transition: background .15s; }
.hx-tab:hover { color: var(--ink); }
.hx-tab:hover::after { background: var(--line); }
.hx-tab.is-active { color: var(--brand-700); }
.hx-tab.is-active::after { background: var(--brand); }
.hx-tab[aria-expanded="true"] { color: var(--ink); }
.hx-tab[aria-expanded="true"]::after { background: var(--ink); }
.hx-tab[aria-expanded="true"] svg { transform: rotate(180deg); }

/* ---- Painéis de largura total ---- */
.hx-panel { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 30px 60px -30px rgba(35,26,36,.45); z-index: 55; }
.hx-panel:not([hidden]) { animation: hxdrop .18s ease-out; }
.hx-panel-in { display: grid; grid-template-columns: 260px 1fr 280px; gap: 32px; padding-top: 28px; padding-bottom: 32px; }
.hx-intro h2 { font-size: 1.35rem; margin: 12px 0 8px; }
.hx-intro p { color: var(--muted); font-size: var(--fs-sm); }
.hx-intro-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.hx-intro-ic svg { width: 24px; height: 24px; }
.hx-links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; align-content: start; }
.hx-links a { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--ink); transition: background .12s; }
.hx-links a:hover, .hx-links a:focus-visible { background: var(--bg-tint); }
.hx-links a[aria-current] { background: var(--brand-50); }
.hx-links b { display: block; font-size: var(--fs-sm); }
.hx-links small { display: block; font-size: var(--fs-xs); color: var(--muted); }
.hx-li-ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-soft); border: 1px solid var(--line-2); color: var(--ink-2); }
.hx-li-ic svg { width: 17px; height: 17px; }
.hx-links a:hover .hx-li-ic { color: var(--brand); border-color: var(--brand-100); background: #fff; }
.hx-feature { display: flex; flex-direction: column; gap: 6px; padding: 22px; border-radius: var(--radius); text-decoration: none; color: #f2e9ed; background: linear-gradient(150deg, #231a24 0%, #4a1c27 70%, #c8142a 140%); position: relative; overflow: hidden; }
.hx-feature::after { content: ""; position: absolute; right: -50px; bottom: -50px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.06); }
.hx-feature b { color: #fff; font-size: 1.05rem; }
.hx-feature span { font-size: var(--fs-sm); }
.hx-feature-go { margin-top: auto; padding-top: 10px; font-weight: 700; color: #fff; }
.hx-feature:hover { color: #fff; }
.hx-feature:hover .hx-feature-go { text-decoration: underline; }

.hx-scrim { position: fixed; inset: 0; background: rgba(25,19,26,.35); z-index: 45; }

/* ---- Modo compacto (após scroll) ---- */
.hx.is-compact .hx-main { max-height: 0; opacity: 0; overflow: hidden; border-bottom-color: transparent; }
.hx.is-compact .hx-mini-logo, .hx.is-compact .hx-mini-cta { display: inline-flex; }
.hx.is-compact .hx-tab { padding-top: 13px; padding-bottom: 13px; }

/* ---- Gaveta móvel ---- */
.hx-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: #fff; z-index: 70; display: flex; flex-direction: column; box-shadow: -20px 0 60px -20px rgba(35,26,36,.5); }
.hx-drawer:not([hidden]) { animation: hxslide .22s ease-out; }
.hx-drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.hx-drawer-head .hx-burger { display: inline-flex; }
.hx-search-drawer { margin: 14px 16px 6px; max-width: none; }
.hx-drawer-body { flex: 1; overflow-y: auto; padding: 6px 8px 16px; }
.hx-drawer details { border-bottom: 1px solid var(--line-2); }
.hx-drawer summary { display: flex; align-items: center; gap: 12px; padding: 12px 8px; font-weight: 700; cursor: pointer; list-style: none; }
.hx-drawer summary::-webkit-details-marker { display: none; }
.hx-drawer summary > svg { margin-left: auto; width: 14px; height: 14px; transition: transform .2s; }
.hx-drawer details[open] summary > svg { transform: rotate(180deg); }
.hx-drawer details a { display: block; padding: 10px 12px 10px 54px; color: var(--ink-2); text-decoration: none; border-radius: 8px; font-size: var(--fs-sm); }
.hx-drawer details a:hover, .hx-drawer details a[aria-current] { background: var(--bg-tint); color: var(--ink); }
.hx-drawer-ai { display: flex; align-items: center; gap: 12px; margin: 14px 8px 0; padding: 12px; border-radius: 14px; background: var(--brand-50); color: var(--brand-700); font-weight: 700; text-decoration: none; }
.hx-drawer-foot { display: grid; gap: 8px; padding: 14px 16px 18px; border-top: 1px solid var(--line-2); }
body.hx-locked { overflow: hidden; }

@keyframes hxpop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes hxdrop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes hxslide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Responsivo ---- */
@media (max-width: 1240px) {
  .hx-panel-in { grid-template-columns: 220px 1fr; }
  .hx-feature { display: none; }
  .hx-tab { padding-left: 9px; padding-right: 9px; }
  .hx-ai-txt { display: none; }
  .hx-ai { padding-right: 6px; }
}
@media (max-width: 1100px) {
  .hx-nav { display: none; }
  .hx-burger { display: inline-flex; }
  .hx-main-in { min-height: 70px; gap: 16px; }
  .hx-search kbd { display: none; }
  .hx-acc-txt { display: none; }
}
@media (max-width: 860px) {
  .hx-main-in > .hx-search { display: none; }
  .hx-hide-md { display: none !important; }
}
@media (max-width: 640px) {
  .hx-hide-sm { display: none !important; }
  .hx-logo img { height: 40px; }
  .hx-clock { font-size: .7rem; }
}
@media (max-width: 420px) {
  .hx-hide-xs { display: none !important; }
  .hx-ulink span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hx-main, .hx-panel, .hx-drawer, .hx-account-menu { transition: none !important; animation: none !important; }
}

/* O atributo hidden prevalece sobre display:flex/grid */
.hx-drawer[hidden], .hx-scrim[hidden], .hx-panel[hidden] { display: none !important; }
/* O modo compacto só existe quando a barra de separadores está visível */
@media (max-width: 1100px) { .hx.is-compact .hx-main { max-height: none; opacity: 1; overflow: visible; border-bottom-color: var(--line-2); } }

/* ---- Selector de idioma com bandeiras ---- */
.hx-lang { position: relative; }
.hx-lang-btn { display: inline-flex; align-items: center; gap: 7px; list-style: none; cursor: pointer; padding: 5px 9px; border-radius: 6px; color: #fff; font-weight: 700; letter-spacing: .03em; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); }
.hx-lang-btn::-webkit-details-marker { display: none; }
.hx-lang-btn:hover, .hx-lang[open] .hx-lang-btn { background: rgba(255,255,255,.14); }
.hx-lang-btn svg { width: 11px; height: 11px; opacity: .8; transition: transform .2s; }
.hx-lang[open] .hx-lang-btn svg { transform: rotate(180deg); }
.hx-flag { display: inline-block; width: 20px; height: 14px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); flex: none; }
.hx-lang-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 290px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; z-index: 80; animation: hxpop .16s ease-out; }
.hx-lang-title { margin: 4px 8px 6px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.hx-lang-menu ul { list-style: none; margin: 0; padding: 0; max-height: min(470px, 68vh); overflow-y: auto; }
.hx-lang-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.hx-lang-menu button:hover, .hx-lang-menu button:focus-visible { background: var(--bg-tint); }
.hx-lang-menu button[aria-current] { background: var(--brand-50); }
.hx-lang-menu .hx-flag { width: 22px; height: 16px; }
.hx-lang-name { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.hx-lang-name b { font-size: var(--fs-sm); font-weight: 650; }
.hx-lang-name small { font-size: .66rem; color: var(--muted); letter-spacing: .05em; }
.hx-lang-check { color: var(--brand); font-weight: 800; }
.hx-lang-st { font-size: .62rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--bg-tint); color: var(--muted); white-space: nowrap; }
.hx-lang-st.is-partial { background: var(--warn-bg); color: var(--warn); }
.hx-lang-note { margin: 8px 8px 4px; font-size: .68rem; color: var(--muted); line-height: 1.4; }
@media (max-width: 420px) { .hx-lang-menu { width: calc(100vw - 32px); right: -8px; } }

/* ---- Ajustes para ecrãs estreitos ---- */
.hx-clock { min-width: 0; flex: 1 1 auto; }
.hx-util-links { flex: none; }
.hx-main-in { min-width: 0; }
.hx-logo { flex: none; }
@media (max-width: 640px) {
  .hx-util-in { gap: 8px; }
  .hx-ulink { padding: 6px; }
  .hx-ulink span { display: none; }
  .hx-actions .btn { display: none; }
  .hx-main-in { gap: 12px; }
}
@media (max-width: 380px) { .hx-clock { font-size: .64rem; } }
