/* ==========================================================
   SANCTUARY 2.0 — LAYOUT
   Header sticky, footer, grid helpers, breakpoints
   ========================================================== */

/* ===== HEADER STICKY ===== */
.site-header {
  position: sticky;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  padding-top: var(--safe-top);
  z-index: var(--z-header);
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  transition: transform var(--t-normal), background var(--t-normal);
}

.site-header.is-hidden { transform: translateY(-100%); }

.header__inner {
  max-width: 1280px;
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: 0 var(--s-5);
}

/* ===== BRAND ===== */
.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  text-decoration: none;
  color: var(--text-main);
}

.brand__icon {
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  background: var(--grad-dourado);
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.1rem;
  box-shadow: 0 4px 16px var(--halo-gold);
  animation: float 6s ease-in-out infinite;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand__name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.15rem;
}

.brand__sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--gold-sacred);
  text-transform: uppercase;
}

/* ===== NAV MENU (Desktop) ===== */
.nav-menu {
  display: flex;
  gap: var(--s-2);
  margin-left: var(--s-5);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
  transition: all var(--t-fast);
}

.nav-link:hover {
  background: var(--halo-gold-soft);
  color: var(--gold-sacred);
}

.nav-link i { font-size: 0.9rem; }

/* ===== NAV ACTIONS (ícones) ===== */
.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.icon-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-main);
  display: grid;
  place-items: center;
  font-size: 1rem;
  transition: all var(--t-fast);
}

.icon-btn:hover {
  background: var(--halo-gold-soft);
  color: var(--gold-sacred);
  transform: translateY(-2px);
}

.icon-btn--gold {
  background: var(--grad-dourado);
  color: white;
  box-shadow: 0 4px 14px var(--halo-gold);
}

.icon-btn--gold:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 20px var(--halo-gold);
}

.icon-btn--lg {
  width: 44px; height: 44px;
  font-size: 1.15rem;
  border-radius: var(--r-sm);
}

.badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-sm);
  background: var(--gold-sacred);
  color: white;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 1px solid var(--bg-card);
}

.menu-toggle { display: none; }

/* ===== MAIN PADDING ===== */
.site-main {
  padding-top: var(--s-4);
  padding-bottom: 0;
  position: relative;
  z-index: var(--z-base);
}

@media (max-width: 767px) {
  .site-main {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-4));
  }
}

/* ===== FOOTER =====
   Sanctuary 2.0 — Rodapé contemplativo com versículo, marca,
   links, ações rápidas e créditos. Sempre visível e legível. */
.site-footer {
  position: relative;
  margin-top: var(--s-7);
  padding: var(--s-7) var(--s-5) var(--s-5);
  background: linear-gradient(180deg, transparent, var(--halo-gold-soft) 40%, var(--bg-card));
  border-top: 1px solid var(--border);
  text-align: center;
  z-index: var(--z-base);
}

.footer__inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-5);
}

.footer__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  text-align: left;
}
.footer__brand-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--grad-dourado);
  color: white;
  display: grid;
  place-items: center;
  font-size: 1rem;
  box-shadow: 0 4px 14px var(--halo-gold);
}
.footer__brand-name {
  display: block;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
  line-height: 1.1;
}
.footer__brand-sub {
  display: block;
  font-family: var(--font-cinzel);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--gold-sacred);
  text-transform: uppercase;
  margin-top: 2px;
}

.footer__verse {
  font-family: var(--font-verse);
  font-style: italic;
  font-size: clamp(1.05rem, 2.3vw, 1.4rem);
  color: var(--text-main);
  line-height: 1.6;
  margin: 0;
  padding: 0 var(--s-3);
  max-width: 600px;
}
.footer__verse cite {
  display: block;
  margin-top: var(--s-2);
  font-family: var(--font-cinzel);
  font-size: 0.75rem;
  font-style: normal;
  letter-spacing: 0.2em;
  color: var(--gold-sacred);
  text-transform: uppercase;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  width: 100%;
}
.footer__links a {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--t-fast);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.footer__links a:hover { color: var(--gold-sacred); }

.footer__social {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
}
.footer__social-link {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-main);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  transition: all var(--t-fast);
  cursor: pointer;
}
.footer__social-link:hover {
  background: var(--grad-dourado);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--halo-gold);
}

.footer__copy {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0;
}
.footer__heart { color: #ef4444; }

/* ===== GRID HELPERS ===== */
.grid { display: grid; gap: var(--s-5); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-center { text-align: center; }

/* ===== BREAKPOINTS RESPONSIVOS ===== */
@media (max-width: 1024px) {
  .nav-menu { display: none; }
}

@media (max-width: 767px) {
  :root { --header-h: 64px; }
  .brand__sub { display: none; }
  .brand__name { font-size: 1rem; }
  .brand__icon { width: 38px; height: 38px; font-size: 1rem; }
}

/* ==========================================================
   CANONICAL ECOSYSTEM HEADER STYLING & COMPACT GHOST BUTTONS
   ========================================================== */
header.phm-ecosystem-header {
  margin-bottom: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  height: auto !important;
  min-height: 64px !important;
  box-sizing: border-box !important;
  padding: 0 !important;
}

.phm-ecosystem-header .phm-ecosystem-header__inner {
  max-width: 1280px !important;
  margin: 0 auto !important;
  box-sizing: border-box !important;
}

/* 4 Botões Utilitários Compactos Ghost (34×34px desktop / 30×30px mobile, cantos de 4px, borda 1px) */
.phm-ecosystem-header .nav-pref-trigger,
.phm-ecosystem-header .phm-projects-menu > summary,
.phm-ecosystem-header .phm-hub-back,
.phm-ecosystem-header .menu-toggle {
  display: inline-flex !important;
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 4px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-light, #94a3b8) !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

/* Ocultar caret nativo e textos extras do launcher e voltar ao hub */
.phm-ecosystem-header .phm-projects-menu > summary::-webkit-details-marker {
  display: none !important;
}

.phm-ecosystem-header .phm-projects-menu > summary span,
.phm-ecosystem-header .phm-projects-menu > summary svg:last-child,
.phm-ecosystem-header .phm-hub-back span {
  display: none !important;
}

.phm-ecosystem-header .phm-projects-menu > summary svg:first-child,
.phm-ecosystem-header .phm-hub-back svg {
  margin: 0 !important;
}

/* Hover e estados ativos - Dark (Default) */
.phm-ecosystem-header .nav-pref-trigger:hover,
.phm-ecosystem-header .phm-projects-menu > summary:hover,
.phm-ecosystem-header .phm-projects-menu[open] > summary,
.phm-ecosystem-header .phm-hub-back:hover,
.phm-ecosystem-header .menu-toggle:hover {
  border-color: rgba(212, 175, 55, 0.5) !important;
  background: rgba(212, 175, 55, 0.12) !important;
  color: var(--gold-solar, #F4C430) !important;
}

/* Ações locais: Busca e Favoritos */
.phm-ecosystem-header .btn-header-action {
  height: 34px !important;
  padding: 0 10px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 0.8rem !important;
  border-radius: 4px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-light, #94a3b8) !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.phm-ecosystem-header .btn-header-action:hover {
  border-color: rgba(212, 175, 55, 0.5) !important;
  background: rgba(212, 175, 55, 0.12) !important;
  color: var(--gold-solar, #F4C430) !important;
}

.phm-ecosystem-header .btn-header-action .badge {
  margin-left: 2px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(212, 175, 55, 0.2);
  color: var(--gold-sacred, #C9A84C);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Abas Editoriais - Santuário Dourado */
.phm-ecosystem-header .header-editorial-nav a {
  border-radius: 4px !important;
  transition: all 0.15s ease;
}

.phm-ecosystem-header .header-editorial-nav a:hover {
  color: var(--gold-solar, #F4C430) !important;
  background: rgba(212, 175, 55, 0.1) !important;
}

.phm-ecosystem-header .header-editorial-nav a.active {
  background: rgba(212, 175, 55, 0.18) !important;
  color: var(--gold-solar, #F4C430) !important;
  border: 1px solid rgba(212, 175, 55, 0.4) !important;
}

[data-theme="light"] .phm-ecosystem-header .header-editorial-nav a:hover {
  color: var(--gold-sacred, #704F08) !important;
  background: rgba(244, 196, 48, 0.12) !important;
}

[data-theme="light"] .phm-ecosystem-header .header-editorial-nav a.active {
  background: rgba(244, 196, 48, 0.22) !important;
  color: var(--gold-sacred, #704F08) !important;
  border: 1px solid rgba(212, 175, 55, 0.5) !important;
}

[data-theme="sepia"] .phm-ecosystem-header .header-editorial-nav a:hover {
  color: var(--gold-sacred, #704F08) !important;
  background: rgba(122, 90, 10, 0.1) !important;
}

[data-theme="sepia"] .phm-ecosystem-header .header-editorial-nav a.active {
  background: rgba(122, 90, 10, 0.18) !important;
  color: var(--gold-sacred, #704F08) !important;
  border: 1px solid rgba(122, 90, 10, 0.35) !important;
}

/* Tema Claro (Light) */
[data-theme="light"] .phm-ecosystem-header .nav-pref-trigger,
[data-theme="light"] .phm-ecosystem-header .phm-projects-menu > summary,
[data-theme="light"] .phm-ecosystem-header .phm-hub-back,
[data-theme="light"] .phm-ecosystem-header .menu-toggle,
[data-theme="light"] .phm-ecosystem-header .btn-header-action {
  border-color: var(--border, #E2E8F0) !important;
  color: var(--text-muted, #475569) !important;
}

[data-theme="light"] .phm-ecosystem-header .nav-pref-trigger:hover,
[data-theme="light"] .phm-ecosystem-header .phm-projects-menu > summary:hover,
[data-theme="light"] .phm-ecosystem-header .phm-projects-menu[open] > summary,
[data-theme="light"] .phm-ecosystem-header .phm-hub-back:hover,
[data-theme="light"] .phm-ecosystem-header .menu-toggle:hover,
[data-theme="light"] .phm-ecosystem-header .btn-header-action:hover {
  background: rgba(244, 196, 48, 0.15) !important;
  border-color: rgba(212, 175, 55, 0.4) !important;
  color: var(--gold-sacred, #704F08) !important;
}

[data-theme="light"] .phm-ecosystem-header .btn-header-action .badge {
  background: rgba(112, 79, 8, 0.15);
  color: var(--gold-sacred, #704F08);
}

/* Tema Sépia (Sepia) */
[data-theme="sepia"] .phm-ecosystem-header .nav-pref-trigger,
[data-theme="sepia"] .phm-ecosystem-header .phm-projects-menu > summary,
[data-theme="sepia"] .phm-ecosystem-header .phm-hub-back,
[data-theme="sepia"] .phm-ecosystem-header .menu-toggle,
[data-theme="sepia"] .phm-ecosystem-header .btn-header-action {
  border-color: var(--border, #DDD1B8) !important;
  color: var(--text-light, #4A3825) !important;
}

[data-theme="sepia"] .phm-ecosystem-header .nav-pref-trigger:hover,
[data-theme="sepia"] .phm-ecosystem-header .phm-projects-menu > summary:hover,
[data-theme="sepia"] .phm-ecosystem-header .phm-projects-menu[open] > summary,
[data-theme="sepia"] .phm-ecosystem-header .phm-hub-back:hover,
[data-theme="sepia"] .phm-ecosystem-header .menu-toggle:hover,
[data-theme="sepia"] .phm-ecosystem-header .btn-header-action:hover {
  background: rgba(122, 90, 10, 0.12) !important;
  border-color: rgba(122, 90, 10, 0.35) !important;
  color: var(--gold-sacred, #704F08) !important;
}

[data-theme="sepia"] .phm-ecosystem-header .btn-header-action .badge {
  background: rgba(112, 79, 8, 0.15);
  color: var(--gold-sacred, #704F08);
}

/* Menu Hambúrguer Móvel e Gaveta Editorial */
.phm-ecosystem-header .menu-toggle {
  display: none !important;
}

@media (max-width: 900px) {
  .phm-ecosystem-header .menu-toggle {
    display: inline-flex !important;
  }
  .phm-ecosystem-header .header-editorial-nav {
    display: none !important;
  }
  .phm-ecosystem-header .header-editorial-nav.open {
    display: flex !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--bg-card, #0b1329);
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    padding: 1rem 1.25rem;
    gap: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    z-index: 999;
  }
  .phm-ecosystem-header .header-editorial-nav.open a {
    padding: 0.65rem 0.85rem !important;
    font-size: 0.85rem !important;
    border-radius: 4px !important;
  }
  [data-theme="light"] .phm-ecosystem-header .header-editorial-nav.open {
    background: #ffffff;
    border-bottom-color: var(--border, #E2E8F0);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  }
  [data-theme="sepia"] .phm-ecosystem-header .header-editorial-nav.open {
    background: #FAF4E6;
    border-bottom-color: var(--border, #DDD1B8);
    box-shadow: 0 10px 25px rgba(67, 52, 34, 0.12);
  }
}

/* Contenção Móvel e Eliminação de Overflow Horizontal */
body.special-profile,
body {
  overflow-x: hidden;
}

@media (max-width: 640px) {
  .phm-ecosystem-header .phm-ecosystem-header__inner {
    padding-inline: 0.35rem !important;
    gap: 0.2rem !important;
  }
  .phm-ecosystem-header .nav-left-cluster {
    flex-shrink: 1 !important;
    min-width: 0 !important;
  }
  .phm-ecosystem-header .app-logo-wordmark {
    height: 20px !important;
    max-width: 95px !important;
    width: auto !important;
  }
  .phm-ecosystem-header .nav-cluster-divider {
    display: none !important;
  }
  .phm-ecosystem-header .phm-ecosystem-header__actions {
    gap: 0.15rem !important;
    flex-shrink: 0 !important;
  }
  .phm-ecosystem-header .nav-pref-trigger,
  .phm-ecosystem-header .phm-projects-menu > summary,
  .phm-ecosystem-header .phm-hub-back,
  .phm-ecosystem-header .menu-toggle {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 !important;
    border-radius: 4px !important;
    justify-content: center !important;
  }
  .phm-ecosystem-header .btn-header-action {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 !important;
    border-radius: 4px !important;
    justify-content: center !important;
    position: relative !important;
  }
  .phm-ecosystem-header .btn-header-action span:not(.badge) {
    display: none !important;
  }
  .phm-ecosystem-header .btn-header-action .badge {
    position: absolute;
    top: -3px;
    right: -3px;
    font-size: 0.65rem;
    padding: 1px 4px;
    line-height: 1;
  }
}

@media (max-width: 360px) {
  .phm-ecosystem-header .app-logo-wordmark {
    max-width: 75px !important;
  }
  .phm-ecosystem-header .phm-ecosystem-header__actions {
    gap: 2px !important;
  }
  .phm-ecosystem-header .nav-pref-trigger,
  .phm-ecosystem-header .phm-projects-menu > summary,
  .phm-ecosystem-header .phm-hub-back,
  .phm-ecosystem-header .menu-toggle,
  .phm-ecosystem-header .btn-header-action {
    width: 28px !important;
    min-width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
  }
}

/* Salvaguarda de Acessibilidade: Skip Link fora do fluxo visual quando não focado */
.phm-skip-link {
  position: absolute !important;
  top: -9999px !important;
  left: 1rem !important;
  z-index: 999999 !important;
  padding: 0.5rem 1rem !important;
  background: var(--bg-card, #0b1329) !important;
  color: var(--gold-solar, #F4C430) !important;
  border: 1px solid var(--gold-sacred, #D4AF37) !important;
  border-radius: 4px !important;
  font-family: var(--font-body, system-ui, sans-serif) !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.phm-skip-link:focus,
.phm-skip-link:focus-visible {
  top: 1rem !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  outline: 2px solid var(--gold-solar, #F4C430) !important;
}
