/* Rumagem — site público
   Estrutura: .fundo (oceano fixo) · .palco (topo, conteúdo, entradas) · .rodape
   ------------------------------------------------------------------------ */

@font-face {
  font-family: 'Montserrat';
  src: url('/assets/fonts/montserrat-latin-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/assets/fonts/cormorant-garamond-latin-var.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --abissal: #08182b;
  --abissal-fundo: #0a1d31;
  --papel: #f2efe8;
  --papel-linha: rgba(8, 24, 43, 0.14);
  --branco: #ffffff;
  --branco-texto: rgba(255, 255, 255, 0.84);
  --branco-suave: rgba(255, 255, 255, 0.72);

  --sans: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;

  --lado: max(clamp(1.25rem, 0.5rem + 2.5vw, 2.5rem), env(safe-area-inset-left), env(safe-area-inset-right));
  --curva: cubic-bezier(0.22, 0.61, 0.36, 1);
  --lento: 900ms;

  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--abissal);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--abissal);
  color: var(--branco);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
video,
svg { display: block; max-width: 100%; }

a { color: inherit; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus { outline: none; }
:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 5px;
  border-radius: 2px;
}
/* Depois de cada navegação interna, o título recebe o foco por script (para
   leitores de ecrã). Não é interativo, por isso fica sem contorno; ligações e
   botões mantêm o contorno de foco por teclado. */
[tabindex='-1']:focus-visible { outline: none; }

.saltar {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  left: var(--lado);
  z-index: 20;
  padding: 0.6rem 1rem;
  background: var(--papel);
  color: var(--abissal);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transform: translateY(-200%);
}
.saltar:focus-visible { transform: none; outline-color: var(--abissal); outline-offset: 2px; }

/* ------------------------------------------------------------------------
   Fundo: imagem imediata, vídeo por cima quando (e se) estiver pronto
   ------------------------------------------------------------------------ */

.fundo {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh; /* não redimensiona quando as barras do browser móvel aparecem/desaparecem */
  overflow: hidden;
  background: var(--abissal-fundo);
  pointer-events: none;
  view-transition-name: fundo;
}

.fundo__imagem,
.fundo__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}

.fundo__video {
  opacity: 0;
  transition: opacity 1.4s var(--curva);
}
.fundo--video .fundo__video { opacity: 1; }
/* Esbatimento antes do recomeço do loop: revela o poster (que é o 1.º fotograma). */
.fundo--video .fundo__video.a-recomecar { opacity: 0; transition-duration: 1.1s; }

.fundo__veu,
.fundo__sombra {
  position: absolute;
  inset: 0;
}

.fundo__veu {
  background:
    linear-gradient(180deg,
      rgba(5, 15, 28, 0.62) 0%,
      rgba(5, 15, 28, 0.16) 26%,
      rgba(5, 15, 28, 0.12) 58%,
      rgba(5, 15, 28, 0.66) 100%),
    rgba(8, 24, 43, 0.3);
}

/* Camada extra nas páginas interiores: o mar recua, o texto avança. */
.fundo__sombra {
  background: rgba(6, 17, 31, 0.5);
  opacity: 0;
  transition: opacity var(--lento) var(--curva);
}
[data-pagina='interior'] .fundo__sombra { opacity: 1; }
[data-pagina='legal'] .fundo__sombra { opacity: 1; background: rgba(6, 17, 31, 0.72); }

/* ------------------------------------------------------------------------
   Palco
   ------------------------------------------------------------------------ */

.palco {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    max(1.5rem, env(safe-area-inset-top)) var(--lado) 0;
}

.topo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  padding-top: clamp(0.5rem, 2.2vh, 1.5rem);
}

.marca {
  display: flex;
  align-items: center;
  /* mesma altura que o logótipo anterior ocupava, para o cabeçalho não mudar */
  min-height: clamp(1.875rem, 1.5rem + 1.1vw, 2.625rem);
  color: var(--branco);
  text-decoration: none;
  view-transition-name: marca;
}
/* Lettering "e-rumagem" em PNG transparente (800×132, inclui margem de segurança).
   Maior do que o lockup anterior, mas a altura nunca excede a reservada em .marca,
   para o cabeçalho não mudar. O "g" desce abaixo da linha de base: o translate
   centra opticamente a altura-x (e não a caixa) com "Início" e o botão de pausa. */
.marca img {
  width: clamp(6.75rem, -1rem + 36vw, 9.5rem);
  height: auto;
  transform: translateY(13.4%);
}
@media (min-width: 40.0625rem) {
  .marca img { width: clamp(9.5rem, 4rem + 12vw, 15.5rem); }
}

/* Homepage: a marca é texto, com a mesma família, peso e estilo das entradas
   (.entradas a: var(--sans), 500, normal), mas em minúsculas e com espaçamento
   adaptado ao tamanho maior. O tamanho segue o do lettering anterior (altura-x
   ≈ 0,088 × largura); a altura da linha não excede a reservada em .marca. */
.marca__nome {
  display: block;
  font-family: var(--sans);
  font-weight: 500;
  font-style: normal;
  font-size: clamp(1.146rem, -0.17rem + 6.11vw, 1.613rem);
  line-height: 0.9;
  letter-spacing: 0.05em;
  margin-right: -0.05em; /* compensa o espaçamento final, como nas entradas */
  text-transform: none;
  white-space: nowrap;
  color: var(--branco);
  /* centra opticamente a altura-x (o "g" desce abaixo da linha de base) */
  transform: translateY(-0.1em);
}
@media (min-width: 40.0625rem) {
  .marca__nome { font-size: clamp(1.613rem, 0.679rem + 2.04vw, 2.632rem); }
}

.topo__voltar,
.som {
  position: absolute;
  top: 50%;
  margin-top: calc(clamp(0.5rem, 2.2vh, 1.5rem) / 2);
  transform: translateY(-50%);
}

.topo__voltar {
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding-right: 0.5rem;
  color: var(--branco-suave);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 300ms var(--curva);
}
.topo__voltar svg { width: 0.95rem; height: 0.95rem; transition: transform 300ms var(--curva); }
.topo__voltar:hover { color: var(--branco); }
.topo__voltar:hover svg { transform: translateX(-3px); }

/* Botão discreto de pausa / retoma do vídeo de fundo */
.som {
  right: 0;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--branco-suave);
  cursor: pointer;
  transition: color 300ms var(--curva);
}
.som::before {
  content: '';
  position: absolute;
  inset: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  transition: border-color 300ms var(--curva);
}
.som:hover { color: var(--branco); }
.som:hover::before { border-color: rgba(255, 255, 255, 0.7); }
.som svg { width: 0.625rem; height: 0.625rem; }
.som:focus-visible { outline-offset: 0; border-radius: 50%; }
.som .icone-tocar { display: none; }
.som[data-estado='parado'] .icone-pausa { display: none; }
.som[data-estado='parado'] .icone-tocar { display: block; }
[data-pagina='legal'] .som { display: none; }

.conteudo {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(2.5rem, 8vh, 5rem);
}

/* ------------------------------------------------------------------------
   Entradas (navegação principal)
   ------------------------------------------------------------------------ */

.entradas {
  view-transition-name: entradas;
  padding-bottom: max(clamp(1rem, 4vh, 2.5rem), env(safe-area-inset-bottom));
}

.entradas ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 clamp(1.25rem, 5vw, 4.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.entradas a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: 0.25rem;
  color: var(--branco-texto);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  /* compensa o espaçamento final para o texto ficar opticamente centrado */
  margin-right: -0.24em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 300ms var(--curva);
}

.entradas a::after {
  content: '';
  position: absolute;
  left: 0.25rem;
  right: calc(0.25rem + 0.24em);
  bottom: 0.55rem;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transition: transform 450ms var(--curva);
}
.entradas a:hover { color: var(--branco); }
.entradas a:hover::after { transform: scaleX(1); }
.entradas a[aria-current='page'] { color: var(--branco); }
.entradas a[aria-current='page']::after { transform: scaleX(1); opacity: 0.6; }

/* ------------------------------------------------------------------------
   Páginas interiores (Essência, Perspetiva, Contacto, 404)
   ------------------------------------------------------------------------ */

.nota {
  width: 100%;
  max-width: 32rem;
  margin-inline: auto;
  /* ligeiramente acima do centro óptico */
  margin-bottom: clamp(0rem, 4vh, 3rem);
}

.nota__marca {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 clamp(1.5rem, 4vh, 2.25rem);
  color: var(--branco-suave);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
/* o nome da marca escreve-se sempre em minúsculas: e-rumagem */
.nome-marca { text-transform: none; }
.nota__marca::before {
  content: '';
  width: 2rem;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}
/* Sobre e Abordagem: só o nome da página, sem o traço antes */
.nota__marca--sem-traco::before { content: none; }

.nota__titulo {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.875rem, 2rem + 3.6vw, 5.25rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
/* Em ecrãs largos, os títulos podem estender-se para a direita (40rem) sem
   mudar o alinhamento à esquerda do bloco: títulos longos ficam em duas linhas. */
@media (min-width: 64rem) {
  .nota__titulo { margin-right: -8rem; }
}

.nota__texto {
  margin: clamp(1.5rem, 4vh, 2.25rem) 0 0;
  color: var(--branco-texto);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  font-weight: 400;
  line-height: 1.8;
  text-wrap: pretty;
}

.nota__email {
  display: inline-block;
  margin-top: clamp(2rem, 5vh, 3rem);
  padding-block: 0.5rem;
  color: var(--branco);
  font-family: var(--serif);
  font-size: clamp(1.5rem, 1.3rem + 0.9vw, 2rem);
  font-weight: 400;
  letter-spacing: 0.005em;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  text-decoration-color: rgba(255, 255, 255, 0.4);
  transition: text-decoration-color 300ms var(--curva);
}
.nota__email:hover { text-decoration-color: var(--branco); }

.nota__ligacao {
  display: inline-block;
  margin-top: clamp(2rem, 5vh, 3rem);
  padding-block: 0.5rem;
  color: var(--branco);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.6em;
  text-decoration-color: rgba(255, 255, 255, 0.4);
}
.nota__ligacao:hover { text-decoration-color: var(--branco); }

/* ------------------------------------------------------------------------
   Páginas legais (Privacidade, Termos)
   ------------------------------------------------------------------------ */

.folha {
  width: 100%;
  max-width: 46rem;
  margin: clamp(1rem, 5vh, 3rem) auto clamp(2.5rem, 8vh, 4.5rem);
  padding: clamp(2rem, 1rem + 5vw, 4.5rem) clamp(1.375rem, 0.5rem + 5vw, 4.5rem);
  background: var(--papel);
  color: var(--abissal);
  color-scheme: light;
}

.folha .nota__marca { color: rgba(8, 24, 43, 0.66); margin-bottom: 1.5rem; }

.folha h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.5rem, 2rem + 2.4vw, 3.75rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.folha__data {
  margin: 1rem 0 0;
  color: rgba(8, 24, 43, 0.68);
  font-size: 0.8125rem;
}

.folha__corpo {
  margin-top: clamp(2rem, 5vh, 3rem);
  padding-top: clamp(1.5rem, 4vh, 2.5rem);
  border-top: 1px solid var(--papel-linha);
  font-size: 0.96875rem;
  line-height: 1.8;
}

.folha h2 {
  margin: 2.5rem 0 0.75rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.25;
}
.folha__corpo > h2:first-child { margin-top: 0; }

.folha p,
.folha ul { margin: 0 0 1rem; text-wrap: pretty; }
.folha ul { padding-left: 1.25rem; }
.folha li { margin-bottom: 0.35rem; }
.folha li::marker { color: rgba(8, 24, 43, 0.45); }
.folha a {
  color: var(--abissal);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.folha :focus-visible { outline-color: var(--abissal); }

/* ------------------------------------------------------------------------
   Rodapé
   ------------------------------------------------------------------------ */

.rodape {
  --rodape-tinta: #09223a; /* azul-marinho da identidade (logótipo) */
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  background: #fff;
  color: var(--rodape-tinta);
  color-scheme: light;
  view-transition-name: rodape;
}

/* Desktop: CONTACTO à esquerda, LEGAL ao centro, redes sociais à direita */
.rodape__grelha {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  column-gap: 2.5rem;
  padding:
    1.75rem var(--lado) max(1.5rem, env(safe-area-inset-bottom));
}

.rodape__titulo {
  margin: 0 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.rodape__lista {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rodape__lista a {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  color: inherit;
  font-size: 0.8125rem;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px;
  background-position: 0 calc(50% + 0.75em);
  background-repeat: no-repeat;
  transition: background-size 400ms var(--curva);
}
.rodape__lista a:hover,
.rodape__lista a[aria-current='page'] { background-size: 100% 1px; }

.rodape__grupo--redes {
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  /* a linha de ícones fica centrada com a 1.ª linha de ligações dos outros grupos */
  padding-top: calc(0.6875rem * 1.4 + 0.375rem + 0.875rem - 1.25rem);
}

.rodape__redes {
  display: flex;
  gap: 0.25rem;
  margin: 0 -0.625rem 0 0; /* o último ícone alinha com a margem direita */
  padding: 0;
  list-style: none;
}
.rodape__redes a {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  color: inherit;
  border-radius: 50%;
  transition: opacity 300ms var(--curva);
}
.rodape__redes a:hover { opacity: 0.65; }
.rodape__redes svg { width: 1.25rem; height: 1.25rem; fill: currentColor; }
/* compensação óptica: o quadrado do LinkedIn parece maior do que os círculos */
.rodape__redes [data-rede='linkedin'] svg { width: 1.125rem; height: 1.125rem; }

.rodape__ano {
  margin: 0;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: rgba(9, 34, 58, 0.72);
}

.rodape :focus-visible { outline-color: var(--rodape-tinta); outline-offset: 2px; }

/* ------------------------------------------------------------------------
   Transições
   ------------------------------------------------------------------------ */

/* Todas as animações partem de um estado "from" e terminam no estado normal:
   se não correrem (ou falharem), o conteúdo fica simplesmente visível. */
@keyframes surgir { from { opacity: 0; transform: translateY(0.5rem); } }
@keyframes aparecer { from { opacity: 0; } }

/* Primeira carga */
.js:not(.navegado) .marca img,
.js:not(.navegado) .marca__nome { animation: aparecer 1.2s var(--curva) 0.1s both; }
.js:not(.navegado) .entradas ul { animation: aparecer 1.2s var(--curva) 0.35s both; }
.js:not(.navegado) .conteudo > * { animation: surgir 900ms var(--curva) 0.2s both; }

/* Navegação interna sem View Transitions API */
.conteudo.a-entrar > * { animation: surgir 600ms var(--curva) both; }

/* Navegação interna com View Transitions API (cross-fade sem atraso) */
.conteudo { view-transition-name: conteudo; }
.topo__voltar { view-transition-name: voltar; }
.som { view-transition-name: som; }

::view-transition-group(*) {
  animation-duration: 480ms;
  animation-timing-function: var(--curva);
}
/* O fundo continua vivo durante a transição; só o véu muda (por transição CSS). */
::view-transition-old(fundo) { display: none; }
::view-transition-new(fundo) { animation: none; }

/* ------------------------------------------------------------------------
   Responsivo
   ------------------------------------------------------------------------ */

@media (max-width: 40rem) {
  .entradas a { font-size: 0.71875rem; letter-spacing: 0.18em; margin-right: -0.18em; }
  .entradas a::after { right: calc(0.25rem + 0.18em); }
  .entradas ul { gap: 0 clamp(0.875rem, 5vw, 1.75rem); }

  .topo__voltar { letter-spacing: 0.16em; gap: 0.4rem; }

  /* Um só ecrã: cabeçalho, texto, entradas e rodapé cabem sem scroll sempre que
     possível. Os espaços e o título acompanham a altura visível (svh, com as
     barras do browser visíveis); o conteúdo continua centrado no espaço que sobra. */
  .palco { padding-top: max(1.25rem, env(safe-area-inset-top)); }
  .topo { min-height: 2.75rem; padding-top: 0; }
  .topo__voltar,
  .som { margin-top: 0; }
  .conteudo { padding-block: clamp(0.625rem, 2.5svh, 2rem); }
  .nota { margin-bottom: clamp(0rem, 2svh, 1.5rem); }
  .nota__marca { margin-bottom: clamp(0.75rem, 2.5svh, 1.5rem); }
  .nota__titulo { font-size: clamp(2.125rem, 6.4svh, 2.875rem); }
  .nota__texto { margin-top: clamp(0.75rem, 2.5svh, 1.5rem); line-height: 1.65; }
  .nota__email { margin-top: clamp(1rem, 3svh, 2rem); }
  .entradas { padding-bottom: max(clamp(0.25rem, 1.5svh, 1rem), env(safe-area-inset-bottom)); }

  /* Rodapé: CONTACTO e LEGAL lado a lado (ou empilhados, se não couberem);
     redes sociais e © numa linha final */
  .rodape__grelha {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.875rem 1.25rem;
    padding-top: 1.25rem;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  }
  .rodape__grupo--redes {
    flex-basis: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-top: 0;
  }
  .rodape__redes { margin: 0 0 0 -0.625rem; }

  .folha { margin-inline: calc(var(--lado) * -1); width: auto; }
}

/* Telemóveis estreitos: as três entradas continuam numa só linha. */
@media (max-width: 23.5rem) {
  .entradas ul { gap: 0 0.625rem; }
  .entradas a { letter-spacing: 0.13em; margin-right: -0.13em; padding-inline: 0.125rem; }
  .entradas a::after { left: 0.125rem; right: calc(0.125rem + 0.13em); }
}

/* Ecrãs baixos (telemóvel na horizontal): menos ar vertical. */
@media (max-height: 30rem) {
  .conteudo { padding-block: 1.5rem; }
  .nota__titulo { font-size: clamp(2.25rem, 1.5rem + 3vw, 3rem); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
    transition-duration: 1ms !important;
  }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

@media (forced-colors: active) {
  .fundo { display: none; }
  .som::before { border-color: CanvasText; }
}
