/* Header homepage */
:root {
  --side-pad: 24px;
  --header-h: 62px;
  --header-top: 10px;
}

@media (max-width: 768px) {
  :root {
    --side-pad: 12px;
  }
}

.site-header {
  position: fixed;
  top: 25px;
  left: 50%;
  transform: translate3d(-50%, 0, 0);
  width: 80vw;
  z-index: 20;
  border-radius: 44px;
  background-color: transparent;
  box-shadow: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: background-color 180ms ease, box-shadow 180ms ease, transform 220ms ease, opacity 180ms ease, width 220ms ease;
}

.site-header.is-hidden {
  transform: translateX(-50%) translateY(calc(-100% - 16px));
  opacity: 0;
  pointer-events: none;
}

.site-header.is-scrolled {
  width: 80vw;
  min-width: 80vw;
  background-color: #f6f1e8;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
}

/* Internas: mesma largura ao scroll (shell não anima width por JS). */
body:not(.pagina-home) .site-header.is-scrolled {
  width: 80vw;
  min-width: 80vw;
}

/*
 * Internas: fundo/sombra só no .b-header__box (já definido abaixo).
 * Sem isto, com scroll o .site-header.is-scrolled ganha o mesmo estilo e parecem 2 headers.
 */
body.pagina-interna .site-header.is-scrolled {
  background-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.b-header__box {
  min-height: var(--header-h);
  padding: 15px 30px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  position: relative;
}

/* Páginas internas: o header já começa com estilo sólido */
body.pagina-interna .b-header__box {
  min-height: var(--header-h);
  padding: 15px 30px;
  border-radius: 999px;
  background-color: #f6f1e8;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  position: relative;
}

.b-header__wrapper-logo {
  display: inline-flex;
  align-items: center;
}

.b-header__box-logo {
  display: inline-flex;
  align-items: center;
  position: relative;
  width: 140px;
  height: 50px;
}

/* Homepage: logo principal maior */
body.pagina-home .b-header__box-logo {
  width: 150px;
  height: 58px;
}

.b-header__logo {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 110px;
  height: auto;
  display: block;
  opacity: 0.95;
  transition: opacity 160ms ease, transform 220ms ease;
}

body.pagina-home .b-header__logo--default {
  width: 150px;
}

.b-header__logo--small {
  width: 50px;
  opacity: 0;
  transform: translateY(-50%) scale(0.98);
}

.site-header.is-scrolled .b-header__logo--default {
  opacity: 0;
}

.site-header.is-scrolled .b-header__logo--small {
  opacity: 1;
  width: 50px;
  transform: translateY(-50%) scale(1);
}

/* Entre 769px e 1299px (tablet): logo compacto logo-small.png; em ≤768 o móvel mantém o par grande/pequeno só com .is-scrolled. */
@media (min-width: 769px) and (max-width: 1299px) {
  .b-header__logo--default {
    opacity: 0;
  }

  .b-header__logo--small {
    opacity: 1;
    width: 50px;
    transform: translateY(-50%) scale(1);
  }

  .b-header__box-logo {
    width: 50px;
    height: 42px;
  }

  body.pagina-home .b-header__box-logo {
    width: 50px;
    height: 42px;
  }
}

.b-header__wrapper-burger-button {
  display: none;
}

.b-header__burger-button {
  width: 36px;
  height: 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
}

.b-header__burger-line {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  border-radius: 99px;
  background: #111;
  transition: transform 180ms ease, opacity 160ms ease, top 180ms ease;
}

.b-header__burger-line--1 { top: 6px; }
.b-header__burger-line--2 { top: 13px; }
.b-header__burger-line--3 { top: 20px; }

.site-header.is-open .b-header__burger-line--1 {
  top: 13px;
  transform: rotate(45deg);
}

.site-header.is-open .b-header__burger-line--2 {
  opacity: 0;
}

.site-header.is-open .b-header__burger-line--3 {
  top: 13px;
  transform: rotate(-45deg);
}

.b-header__wrapper-menu {
  display: contents;
}

.b-header__menu {
  display: block;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 50%;
  translate: 0 -50%;
  z-index: 1;
}

.b-header__list-menu {
  list-style: none;
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 34px);
  padding: 0;
  margin: 0;
}

.b-header__list-menu > li {
  flex-shrink: 0;
}

.b-header__item-menu {
  margin: 0;
}

.b-header__link-menu {
  text-decoration: none;
  color: #090909;
  font-size: 16px;
  letter-spacing: 0.01em;
  font-weight: 300;
  transition: color 160ms ease, opacity 160ms ease;
  white-space: nowrap;
}

.b-header__menu .b-header__list-menu a {
  color: #090909;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.site-header:not(.is-scrolled) .b-header__link-menu {
  color: #090909;
}

.site-header:not(.is-scrolled) .b-header__menu .b-header__list-menu a {
  color: #f6f1e8;
}

/* Páginas internas: topo sem hero escuro — menu em preto desde o início */
body.pagina-interna .site-header:not(.is-scrolled) .b-header__link-menu,
body.pagina-interna .site-header:not(.is-scrolled) .b-header__menu .b-header__list-menu a {
  color: #090909;
}

.site-header.is-scrolled .b-header__menu .b-header__list-menu a {
  color: #090909;
  font-weight: 500;
}

.b-header__link-menu:hover {
  color: #F05134;
}

.b-header__wrapper-book-button {
  display: flex;
  align-items: center;
  justify-self: end;
  grid-column: 3;
}

.b-header__book-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 218px;
  overflow: hidden;
  text-decoration: none;
  color: #fff;
  border: 1px solid #F05134;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 16px;
  letter-spacing: 0.03em;
  font-weight: 400;
  background: #F05134;
  transition: background 220ms ease, color 220ms ease, border-color 220ms ease,
    width 220ms ease, height 220ms ease, padding 220ms ease, gap 220ms ease,
    border-radius 220ms ease;
}


.b-header__book-icon {
  display: none;
  font-size: 18px;
  line-height: 1;
  font-weight: 500;
  opacity: 0;
  transform: scale(0.7) rotate(-20deg);
  transition: opacity 180ms ease, transform 220ms ease;
}

.b-header__book-label {
  opacity: 1;
  transform: translateY(0);
  white-space: nowrap;
  transition: opacity 180ms ease, transform 220ms ease;
}

.site-header.is-scrolled .b-header__book-button {
  width: 40px;
  height: 40px;
  padding: 0;
  gap: 0;
  border-radius: 8px;
}

.site-header.is-scrolled .b-header__book-label {
  opacity: 0;
  transform: translateY(-6px);
  width: 0;
  overflow: hidden;
}

.site-header.is-scrolled .b-header__book-icon {
  display: inline-block;
  opacity: 1;
  transform: scale(1) rotate(0deg);
  animation: bookIconSpinPulse 6s ease-in-out infinite;
}

@keyframes bookIconSpinPulse {
  0%, 72%, 100% { transform: scale(1) rotate(0deg); }
  78% { transform: scale(1.06) rotate(22deg); }
  84% { transform: scale(1) rotate(-12deg); }
  90% { transform: scale(1.03) rotate(10deg); }
}

/* Abaixo de 1300px (exceto móvel ≤768): botão só com «+», como no estado com scroll em desktop. */
@media (max-width: 1299px) and (min-width: 769px) {
  .b-header__book-button {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    gap: 0;
    border-radius: 8px;
  }

  .b-header__book-label {
    opacity: 0;
    transform: translateY(-6px);
    width: 0;
    max-width: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    pointer-events: none;
    white-space: nowrap;
  }

  .b-header__book-icon {
    display: inline-block;
    opacity: 1;
    transform: scale(1) rotate(0deg);
    font-size: 18px;
    line-height: 1;
    animation: bookIconSpinPulse 6s ease-in-out infinite;
  }
}

.idioma-botoes.idioma-banner {
  position: fixed;
  left: var(--side-pad);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  padding: 10px 8px;
  flex-direction: column;
  gap: 10px;
  z-index: 1;
  border-radius: 999px;
  transition: background-color 180ms ease, box-shadow 180ms ease, padding 180ms ease;
}

.idioma-botoes.idioma-banner.is-scrolled {
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(8px);
  padding: 10px 8px;
}

.idioma-botoes.idioma-banner.is-scrolled .idioma-botao,
.idioma-botoes.idioma-banner.is-scrolled .idioma-botao.ativo {
  color: #000;
}

/* Em fundo vermelho global, manter os idiomas em claro */
body.list-section-active .idioma-botoes.idioma-banner .idioma-botao,
body.list-section-active .idioma-botoes.idioma-banner .idioma-botao.ativo,
body.list-section-active .idioma-botoes.idioma-banner.is-scrolled .idioma-botao,
body.list-section-active .idioma-botoes.idioma-banner.is-scrolled .idioma-botao.ativo,
body.equipa-mid-theme .idioma-botoes.idioma-banner .idioma-botao,
body.equipa-mid-theme .idioma-botoes.idioma-banner .idioma-botao.ativo,
body.equipa-mid-theme .idioma-botoes.idioma-banner.is-scrolled .idioma-botao,
body.equipa-mid-theme .idioma-botoes.idioma-banner.is-scrolled .idioma-botao.ativo,
body.sobre-nos-mid-theme .idioma-botoes.idioma-banner .idioma-botao,
body.sobre-nos-mid-theme .idioma-botoes.idioma-banner .idioma-botao.ativo,
body.sobre-nos-mid-theme .idioma-botoes.idioma-banner.is-scrolled .idioma-botao,
body.sobre-nos-mid-theme .idioma-botoes.idioma-banner.is-scrolled .idioma-botao.ativo {
  color: #f6f1e8;
}

a.idioma-botao {
  text-decoration: none;
  color: inherit;
}

.idioma-botao {
  cursor: pointer;
  user-select: none;
  text-align: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: clamp(0.75rem, 0.9vw, 1rem);
  line-height: 1.1;
  letter-spacing: 0.2px;
  opacity: 0.9;
  color: #fff;
  background: transparent;
  border: 0;
  display: inline-block;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  transition: color 160ms ease, opacity 160ms ease;
}

.idioma-botao:hover {
  color: rgba(255, 230, 160, 1);
  opacity: 1;
}

.idioma-botao.ativo {
  color: rgba(255, 245, 220, 1);
  background: transparent;
  border: 0;
  opacity: 0.9;
}

/* Wrapper: no desktop não altera o layout (o botão continua fixed na viewport). */
.back-to-top-slot {
  display: contents;
}

/* Botão «voltar ao topo»: todas as páginas com este header (desktop: fixo; estilos mobile na @media acima) */
.back-to-top {
  position: fixed;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  right: calc(32px + env(safe-area-inset-right, 0px));
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #fdd704 0%, #f8981c 40%, #f05133 75%, #ab0534 100%);
  border: none;
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(240, 81, 52, 0.35);
  -webkit-tap-highlight-color: transparent;
  pointer-events: none;
  transition: box-shadow 0.2s ease;
  box-sizing: border-box;
}

.back-to-top:hover {
  box-shadow: 0 6px 24px rgba(240, 81, 52, 0.55);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
  color: #fff;
  flex-shrink: 0;
  display: block;
}

.back-to-top.is-visible {
  pointer-events: auto;
}

.ver-mais {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 2;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  text-decoration: none;
  color: rgba(255, 245, 220, 0.98);
  font-size: clamp(1.05rem, 2.1vw, 1.55rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  animation: verMaisReveal 900ms cubic-bezier(0.16, 1, 0.3, 1) 200ms forwards;
  transition: color 0.2s ease, transform 0.2s ease;
}

.ver-mais:hover,
.ver-mais:focus-visible {
  color: #fff;
}

.ver-mais:focus-visible {
  outline: 2px solid rgba(255, 245, 220, 0.65);
  outline-offset: 4px;
  border-radius: 4px;
}

.ver-mais__label {
  display: block;
  line-height: 1.15;
}

.ver-mais__chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  line-height: 0;
  animation: verMaisChevron 1.85s ease-in-out infinite;
}

.ver-mais__chevron svg {
  width: 1.35em;
  height: 1.35em;
  display: block;
  opacity: 0.92;
}

.ver-mais:hover .ver-mais__chevron svg,
.ver-mais:focus-visible .ver-mais__chevron svg {
  opacity: 1;
}

@media (max-width: 1024px) {
  .b-header__list-menu {
    gap: 12px;
  }

  .b-header__link-menu,
  .b-header__menu .b-header__list-menu a,
  .b-header__book-button {
    font-size: 15px;
  }
}

@media (min-width: 769px) and (max-width: 900px) {
  .b-header__list-menu {
    gap: 8px;
  }

  .b-header__link-menu,
  .b-header__menu .b-header__list-menu a,
  .b-header__book-button {
    font-size: 14px;
  }
}

@media (max-width: 768px) {
  body.menu-open {
    overflow: hidden;
  }

  .site-header {
    top: calc(8px + env(safe-area-inset-top, 0px));
    width: 100vw;
    max-width: calc(100vw - 2 * var(--side-pad, 12px));
    min-width: 0;
    border-radius: 20px;
    z-index: 100;
  }

  .site-header.is-scrolled {
    width: 90vw;
    min-width: 0;
  }

  body:not(.pagina-home) .site-header.is-scrolled {
    width: 100vw;
    max-width: calc(100vw - 2 * var(--side-pad, 12px));
    min-width: 0;
  }

  body.pagina-interna .b-header__box {
    border-radius: 20px;
    /* Sobrepõe o padding 30px do desktop: burger encostado ao máximo à direita */
    padding: 8px 6px 8px 12px;
    gap: 12px;
  }

  .b-header__box {
    grid-template-columns: auto auto;
    justify-content: space-between;
    min-height: 56px;
    padding: 8px 6px 8px 12px;
    gap: 12px;
  }

  .b-header__wrapper-burger-button {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    margin-right: 0;
    padding-right: 0;
  }

  .b-header__wrapper-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px 18px;
    border-radius: 12px;
    background: rgba(246, 241, 232, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(9, 9, 9, 0.08);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
    transform-origin: top center;
    transform: translateY(-10px) scaleY(0.88);
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    min-height: 0;
    height: auto;
    overflow: hidden;
    transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1),
      opacity 220ms ease, max-height 320ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .b-header__menu {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    translate: none;
    width: 100%;
  }

  .site-header.is-open .b-header__wrapper-menu {
    transform: translateY(0) scaleY(1);
    opacity: 1;
    pointer-events: auto;
    max-height: min(92dvh, 560px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .b-header__list-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    flex: 0 0 auto;
  }

  .b-header__list-menu li {
    width: 100%;
  }

  .b-header__list-menu a {
    display: block;
    width: 100%;
    padding: 10px 0;
    border-bottom: 1px solid rgba(9, 9, 9, 0.1);
    color: #090909 !important;
    font-size: 1.125rem;
    font-weight: 400;
    letter-spacing: 0.01em;
  }

  .b-header__wrapper-book-button {
    width: 100%;
    justify-content: stretch;
    margin-top: 4px;
    grid-column: auto;
  }

  .b-header__book-button {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    padding: 12px 16px;
    min-height: 48px;
    font-size: 16px;
    border-color: #f05134;
    background: #f05134;
    color: #fff;
  }

  /*
   * No drawer móvel, ignorar o modo compacto do header com scroll (desktop):
   * senão o texto "Fale connosco" fica com width:0/opacity:0 e o botão parece vazio.
   */
  .site-header.is-scrolled .b-header__book-button,
  .site-header.is-scrolled.is-open .b-header__book-button {
    width: 100%;
    height: auto;
    min-height: 48px;
    padding: 12px 16px;
    gap: 8px;
    border-radius: 12px;
  }

  .site-header.is-scrolled .b-header__book-label,
  .site-header.is-scrolled.is-open .b-header__book-label {
    display: inline;
    opacity: 1;
    transform: none;
    width: auto;
    max-width: none;
    overflow: visible;
    white-space: normal;
  }

  .site-header.is-scrolled .b-header__book-icon,
  .site-header.is-scrolled.is-open .b-header__book-icon {
    display: none;
  }

  .idioma-botoes.idioma-banner {
    left: 50%;
    top: auto;
    bottom: max(20px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(9, 13, 24, 0.5);
    border-radius: 999px;
    max-width: calc(100vw - 32px);
  }

  .idioma-botoes.idioma-banner .idioma-botao {
    writing-mode: horizontal-tb;
    transform: none;
    flex-shrink: 0;
    padding: 6px 8px;
    font-size: clamp(0.7rem, 3.2vw, 0.85rem);
  }

  /* Fundo escuro na pill: texto claro (o global .is-scrolled usa #000 para desktop) */
  .idioma-botoes.idioma-banner.is-scrolled .idioma-botao,
  .idioma-botoes.idioma-banner.is-scrolled .idioma-botao.ativo {
    color: rgba(255, 255, 255, 0.95);
  }

  /*
   * Voltar ao topo na pill (mobile): o slot anima largura no flex (sem saltos
   * absolute/relative). Colapso do flex gap quando o slot está fechado.
   */
  .idioma-botoes.idioma-banner .back-to-top-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    width: 0;
    max-width: 0;
    max-height: 0;
    padding: 0;
    margin: 0;
    margin-left: -10px;
    box-sizing: border-box;
    transition:
      max-width 0.45s cubic-bezier(0.33, 1, 0.68, 1),
      width 0.45s cubic-bezier(0.33, 1, 0.68, 1),
      max-height 0.45s cubic-bezier(0.33, 1, 0.68, 1),
      margin-left 0.45s cubic-bezier(0.33, 1, 0.68, 1);
  }

  .idioma-botoes.idioma-banner .back-to-top-slot:has(.back-to-top.is-visible) {
    width: 40px;
    max-width: 40px;
    border-radius: 100%;
    max-height: 40px;
    margin-left: 0;
  }

  .idioma-botoes.idioma-banner .back-to-top {
    position: relative;
    inset: auto;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    margin: 0;
    overflow: visible;
    flex-shrink: 0;
    z-index: 2;
    pointer-events: none;
    box-shadow: none;
    border: none;
  }

  .idioma-botoes.idioma-banner .back-to-top.is-visible {
    pointer-events: auto;
    box-shadow: 0 3px 14px rgba(240, 81, 52, 0.35);
  }

  .idioma-botoes.idioma-banner .back-to-top svg {
    width: 16px;
    height: 16px;
  }

  .idioma-botoes.idioma-banner.is-over-footer .idioma-botao,
  .idioma-botoes.idioma-banner.is-over-footer .idioma-botao.ativo {
    color: #f6f1e8;
  }

  .ver-mais {
    display: none;
  }
}

/* História (≤1024): pill de idiomas acima da faixa século/ano — regra aqui para vencer a ordem do wp_head */
@media (max-width: 1024px) {
  body.pagina-historia-body .idioma-botoes.idioma-banner {
    z-index: 99 !important;
    isolation: isolate;
  }
}

@keyframes verMaisReveal {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-28px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes verMaisChevron {
  0%,
  100% {
    transform: translateY(0);
  }
  45% {
    transform: translateY(6px);
  }
  55% {
    transform: translateY(6px);
  }
}
