/* Página de case: visualizador de slides em tela cheia, como um
   overlay aberto por cima da home. Carregado depois de styles.css —
   reusa os tokens (--bg, --fg, --panel, --panel-inset, --border…). */

.viewer-page {
  overflow: hidden;
}

.viewer {
  height: 100vh;
  height: 100dvh;
  display: grid;
  /* minmax(0, 1fr): sem isso a coluna cresce até a largura somada dos
     slides/miniaturas e a página inteira fica mais larga que a janela */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
  color: var(--fg);
  animation: viewer-in 500ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes viewer-in {
  from { opacity: 0; transform: translateY(0.75rem) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Barra do topo ---------- */

.viewer-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: calc(var(--panel-inset) + env(safe-area-inset-top)) var(--panel-inset) var(--panel-inset);
  font-size: var(--fs-body);
  line-height: 200%;
}

.viewer-title {
  display: flex;
  gap: 0.5rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-title .muted,
.viewer-count {
  opacity: 0.5;
}

.viewer-count {
  font-variant-numeric: tabular-nums;
}

.viewer-close {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--panel);
  color: var(--fg);
  transition: background-color 200ms ease;
}

.viewer-close:hover {
  opacity: 1;
  background: var(--shot);
}

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

.viewer-stage {
  position: relative;
  min-height: 0;
}

.viewer-track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  outline: none;
}

.viewer-track::-webkit-scrollbar {
  display: none;
}

/* Cada slide ocupa a largura toda do palco; o quadro 16:9 dentro dele
   encaixa pela menor dimensão (cqw/cqh do container). */
.viewer-slide {
  flex: 0 0 100%;
  height: 100%;
  margin: 0;
  padding: 0 clamp(var(--panel-inset), 5vw, 5rem);
  scroll-snap-align: center;
  scroll-snap-stop: always;
  container-type: size;
  display: grid;
  place-items: center;
}

.viewer-frame {
  width: min(100cqw, 100cqh * 16 / 9);
  aspect-ratio: 16 / 9;
  background: var(--panel);
  overflow: hidden;
}

.viewer-frame img,
.viewer-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-top: -1.25rem;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  transition: background-color 200ms ease, opacity 200ms ease;
}

.viewer-nav:hover {
  background: var(--shot);
}

.viewer-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.viewer-prev { left: var(--panel-inset); }
.viewer-next { right: var(--panel-inset); }

.viewer-close:focus-visible,
.viewer-nav:focus-visible,
.viewer-thumb:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}

@media (hover: none), (max-width: 640px) {
  .viewer-nav {
    display: none;
  }

  .viewer-slide {
    padding: 0 var(--panel-inset);
  }
}

/* ---------- Miniaturas ---------- */

.viewer-thumbs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: var(--panel-inset) var(--panel-inset) calc(var(--panel-inset) + env(safe-area-inset-bottom));
  scrollbar-width: none;
}

.viewer-thumbs::-webkit-scrollbar {
  display: none;
}

/* Centraliza quando cabe; rola a partir da borda quando não cabe */
.viewer-thumb:first-child { margin-left: auto; }
.viewer-thumb:last-child  { margin-right: auto; }

.viewer-thumb {
  flex: 0 0 auto;
  width: clamp(4rem, 7vw, 7rem);
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  background: var(--panel);
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 200ms ease;
}

.viewer-thumb:hover {
  opacity: 0.7;
}

.viewer-thumb[aria-current='true'] {
  opacity: 1;
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}

.viewer-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
