/*
  museu.css — página Museu virtual: palco 3D em tela cheia e a interface
  por cima dele (entrada com a marca e o carregamento, ajuda, botão de sair,
  rótulo, ficha da obra, percurso).

  Durante a visita (body.imersivo) o cabeçalho do site sai de cena e os
  controles ficam em botões escuros translúcidos, para não tirar a atenção
  das obras. Não cuida do 3D (isso está nos módulos js/museu-*.js).
*/

/* O cabeçalho fica por cima do palco, que ocupa a tela toda: ao entrar no museu ele sobe e some,
   sem o 3D mudar de tamanho. */
.pagina-museu .cabecalho {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
}

.pagina-museu.imersivo .cabecalho {
  transform: translateY(-100%);
  visibility: hidden;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.6s;
}

.definicoes-svg {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.museu {
  position: relative;
  height: 100vh;
  height: 100dvh;
  min-height: 420px;
  overflow: hidden;
  background: var(--cor-museu-escuro);
}

.museu-palco {
  position: absolute;
  inset: 0;
}

.museu-palco canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.museu-palco canvas.arrastando {
  cursor: grabbing;
}

/* Bordas um pouco mais escuras, como numa sala de luz baixa; o topo, um pouco mais, para a marca
   e os botões se lerem sobre o teto claro. */
.museu-vinheta {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(18, 8, 4, 0.32), transparent 130px),
    radial-gradient(130% 95% at 50% 45%, transparent 55%, rgba(18, 8, 4, 0.45) 100%);
}

/* --- Controles da visita: aparecem ao entrar --- */

.museu-marca,
.museu-topo,
.museu-percurso {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease 0.3s, visibility 0s 0.9s;
}

.imersivo .museu-marca,
.imersivo .museu-topo,
.imersivo .museu-percurso {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease 0.3s, visibility 0s;
}

.botao-vidro {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(30, 18, 12, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font: 500 13px var(--fonte);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.botao-vidro:hover {
  background: rgba(30, 18, 12, 0.7);
  border-color: rgba(255, 255, 255, 0.5);
}

.botao-vidro:focus-visible,
.museu-percurso button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Marca no canto, como a da instituição nas exposições virtuais. */
.museu-marca {
  position: absolute;
  top: 22px;
  left: 22px;
  z-index: 12;
  width: 150px;
  height: auto;
  aspect-ratio: 640 / 108;
  color: rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 1px 8px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.examinando .museu-marca {
  opacity: 0;
}

.museu-topo {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
}

.museu-sair {
  width: 44px;
  height: 44px;
  padding: 0;
}

.museu-sair svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.examinando #botao-ajuda,
.examinando .museu-ajuda {
  display: none;
}

/* --- Ajuda --- */

.museu-ajuda {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 290px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(30, 18, 12, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
}

.museu-ajuda ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.museu-ajuda-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -4px -8px 8px 0;
}

.museu-ajuda-topo p {
  margin: 0;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.museu-ajuda-fechar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.museu-ajuda-fechar:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.museu-ajuda-fechar:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.museu-ajuda-fechar svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.museu-ajuda li + li {
  margin-top: 6px;
}

.museu-ajuda kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom-width: 2px;
  border-radius: 3px;
  font: 500 11px var(--fonte);
  text-align: center;
}

.so-toque,
.toque .so-mouse {
  display: none;
}

.toque li.so-toque {
  display: list-item;
}

.toque p.so-toque {
  display: block;
}

/* --- Nome da obra sob o mouse --- */

.museu-rotulo {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 15;
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(30, 18, 12, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
}

/* --- Entrada: marca, carregamento e convite --- */

.museu-entrada {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--altura-cabecalho) + 24px) var(--margem) 32px;
  overflow-y: auto;
  background: var(--cor-museu-escuro);
  color: #fff;
  transition: opacity 0.8s ease, background-color 1.4s ease;
}

/* Com as obras prontas, a sala aparece de leve por trás. */
.museu-entrada.pronta {
  background: rgba(34, 24, 19, 0.74);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.museu-entrada.oculta {
  opacity: 0;
  pointer-events: none;
}

.museu-entrada-caixa {
  width: min(540px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.museu-entrada-marca {
  width: min(300px, 72vw);
  height: auto;
  aspect-ratio: 640 / 108;
  color: #fff;
  animation: marca-aparece 1.4s ease 0.1s both;
}

@keyframes marca-aparece {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Carregamento e texto abrem e fecham pela altura (grade de 0fr a 1fr), sem pulos. */
.museu-carga,
.museu-entrada-texto {
  display: grid;
  width: 100%;
  transition: grid-template-rows 1s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.7s ease;
}

.museu-carga > div,
.museu-entrada-texto > div {
  overflow: hidden;
}

.museu-carga {
  grid-template-rows: 1fr;
  animation: marca-aparece 1.4s ease 0.4s both;
}

.museu-carga > div {
  padding-top: 40px;
}

.museu-carga-barra {
  width: 180px;
  height: 1px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.18);
}

.museu-carga-barra span {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
  transition: width 0.5s ease;
}

.museu-carga p {
  margin: 14px 0 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.museu-entrada-texto {
  grid-template-rows: 0fr;
  opacity: 0;
}

.museu-entrada.pronta .museu-carga {
  grid-template-rows: 0fr;
  opacity: 0;
}

.museu-entrada.pronta .museu-entrada-texto,
.museu-entrada.sem-3d .museu-entrada-texto {
  grid-template-rows: 1fr;
  opacity: 1;
  transition-delay: 0.15s;
}

.museu-entrada.sem-3d .museu-carga-barra {
  display: none;
}

.museu-entrada h1 {
  margin: 44px 0 14px;
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.museu-entrada-texto p {
  max-width: 32em;
  margin: 0 auto 32px;
  font-size: 16px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.74);
}

.botao-entrar {
  min-height: 50px;
  padding: 0 34px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: 500 15px var(--fonte);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s;
}

.botao-entrar:hover,
.botao-entrar:focus-visible {
  background: #fff;
  color: var(--cor-museu-escuro);
}

.botao-entrar:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.museu-entrada .link-alternativo {
  display: block;
  margin-top: 18px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.62);
}

.museu-entrada .link-alternativo:hover {
  color: #fff;
}

/* --- Ficha da obra examinada ---
   Segue a linguagem do museu, não a do site: texto claro direto sobre a penumbra da sala, numa
   sombra quente que se desfaz para a direita (no celular, uma folha de vidro escuro), título grande
   e leve como nas exposições virtuais editoriais, botões de vidro iguais aos da visita. */

.museu-ficha {
  --largura-ficha-museu: min(460px, 40%);
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  width: var(--largura-ficha-museu);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(24px, 4vw, 60px) 96px;
  color: #fff;
  /* Entra enquanto a câmera chega à obra (a viagem dura ~2 s). */
  animation: ficha-entra 1s cubic-bezier(0.22, 1, 0.36, 1) 0.6s both;
}

/* A sombra fica num fundo à parte, que passa da borda e se apaga aos poucos (a máscara não pode
   pegar o texto). O desfoque é leve: a sala continua visível por trás. */
.museu-ficha::before {
  content: "";
  position: absolute;
  inset: 0 -28% 0 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(22, 13, 8, 0.86) 0%, rgba(22, 13, 8, 0.72) 55%, rgba(22, 13, 8, 0) 100%);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  -webkit-mask-image: linear-gradient(90deg, #000 62%, transparent);
  mask-image: linear-gradient(90deg, #000 62%, transparent);
  pointer-events: none;
}

.museu-ficha.saindo {
  animation: ficha-sai 0.5s ease both;
}

@keyframes ficha-sai {
  to { opacity: 0; transform: translateX(-24px); }
}

.museu-ficha[hidden] {
  display: none;
}

@keyframes ficha-entra {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: none; }
}

.museu-ficha-registro {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cor-terracota-clara);
}

/* Fio terracota antes do número, como a cor das paredes. */
.museu-ficha-registro::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--cor-terracota-clara);
}

.museu-ficha h2 {
  margin: 0 0 22px;
  font-size: clamp(34px, 3.8vw, 58px);
  font-weight: 300;
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-wrap: balance;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.35);
}

.museu-ficha-procedencia,
.museu-ficha-medidas {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.museu-ficha-resumo {
  margin: 22px 0 0;
  max-width: 30em;
  font-size: 16px;
  font-weight: 300;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.86);
}

.museu-ficha-resumo:empty {
  display: none;
}

.museu-ficha-dica {
  margin: 26px 0 0;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.5);
}

.museu-ficha-acoes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.museu-ficha-acoes .botao-vidro {
  height: 44px;
  padding: 0 20px;
  font-size: 14px;
  text-decoration: none;
}

/* O caminho principal: contorno claro, que se enche de branco ao passar o mouse (como "Entrar"). */
.museu-ficha-link {
  border-color: rgba(255, 255, 255, 0.75);
}

.museu-ficha-link:hover,
.museu-ficha-link:focus-visible {
  background: #fff;
  border-color: #fff;
  color: var(--cor-museu-escuro);
}

/* Com a ficha aberta, o percurso fica no centro da área livre, à direita. */
.examinando .museu-percurso {
  left: calc(min(460px, 40%) + (100% - min(460px, 40%)) / 2);
}

@media (max-width: 760px) {
  .museu-ficha {
    top: auto;
    right: 0;
    bottom: 72px;
    width: auto;
    max-height: 48%;
    overflow-y: auto;
    justify-content: flex-start;
    margin: 0 12px;
    padding: 16px 16px 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 18px;
    background: rgba(30, 18, 12, 0.72);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    animation-name: ficha-sobe;
  }

  .museu-ficha::before {
    display: none;
  }

  .museu-ficha.saindo {
    animation-name: ficha-desce;
  }

  @keyframes ficha-desce {
    to { opacity: 0; transform: translateY(24px); }
  }

  @keyframes ficha-sobe {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }

  .museu-ficha-registro {
    margin-bottom: 8px;
    font-size: 11px;
  }

  .museu-ficha-registro::before {
    width: 18px;
  }

  .museu-ficha h2 {
    margin: 0 0 8px;
    font-size: 26px;
  }

  .museu-ficha-procedencia,
  .museu-ficha-medidas {
    font-size: 11px;
    line-height: 1.6;
  }

  .museu-ficha-resumo {
    display: none;
  }

  .museu-ficha-dica {
    margin-top: 10px;
    font-size: 12px;
  }

  .museu-ficha-acoes {
    margin-top: 12px;
    gap: 8px;
  }

  .museu-ficha-acoes .botao-vidro {
    flex: 1;
    height: 40px;
    padding: 0 12px;
    font-size: 13px;
  }

  .examinando .museu-percurso {
    left: 12px;
  }
}

/* --- Percurso (anterior / próxima) --- */

.museu-percurso {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(30, 18, 12, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.museu-percurso button {
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s;
}

.museu-percurso button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.museu-percurso p {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .museu-marca {
    top: 18px;
    left: 16px;
    width: 112px;
  }

  .museu-percurso {
    left: 12px;
    right: 12px;
    transform: none;
  }

  .museu-percurso button {
    flex: 1;
    padding: 0 8px;
  }

  .museu-percurso p {
    padding: 0 8px;
  }
}
