/* ════════════════════════════════════════════════════════════
   comunicado-galeria.css — tela cheia das fotos/vídeos do comunicado
   (Etapa 3.7, 09/11/2026; board ComunicadoTelaCheia). Compartilhada
   pelo dashboard e pela página /comunicados (window.ComGaleria).

   · abre a partir da miniatura (elemento compartilhado: transform +
     opacity calculados no JS — 120 Hz suave, sem animar layout);
   · deslizar troca (scroll-snap nativo); arrastar para baixo fecha
     (elástico + velocidade); Esc/setas no PC; foco preso e devolvido;
   · reduced-motion = só fade; dobráveis de duas telas: a galeria fica
     numa tela só (não atravessa a dobra);
   · áreas seguras (env(safe-area-inset-*)) nos controles.
   Usa os tokens de comunicado-cartao.css (.com37).
   ════════════════════════════════════════════════════════════ */

.cg {
  position: fixed; inset: 0; z-index: 2500; display: block; color: #fff;
  font-family: var(--c-fonte, -apple-system, BlinkMacSystemFont, "Inter Variable", sans-serif);
  overscroll-behavior: contain; -webkit-tap-highlight-color: transparent;
}
.cg[hidden] { display: none; }
.cg-fundo { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 260ms var(--c-ease, cubic-bezier(0.23, 1, 0.32, 1)); }
.cg.is-aberta .cg-fundo { opacity: 1; }
.cg.is-arrastando .cg-fundo { transition: none; }

.cg-palco { position: absolute; inset: 0; }
.cg-trilho {
  display: flex; width: 100%; height: 100%; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain;
  touch-action: pan-x pinch-zoom;
}
.cg-trilho::-webkit-scrollbar { display: none; }
.cg-slide {
  position: relative; flex: 0 0 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always;
  /* flex (não grid): o max-height de 100% da foto vale contra a altura do slide */
  display: flex; align-items: center; justify-content: center; overflow: hidden; box-sizing: border-box;
  /* espaço dos controles: a foto nunca fica embaixo deles */
  padding: calc(64px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px))
           calc(84px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
}
.cg-img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; min-width: 0; min-height: 0; flex: 0 1 auto;
  -webkit-user-drag: none; user-select: none; transform-origin: 0 0; will-change: transform;
  transition: transform 300ms var(--c-ease, cubic-bezier(0.23, 1, 0.32, 1)), opacity 200ms ease;
}
.cg-slide.is-carregando::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: cg-gira 800ms linear infinite;
}
@keyframes cg-gira { to { transform: rotate(360deg); } }
.cg-video { position: relative; width: min(100%, calc((100dvh - 150px) * 16 / 9)); aspect-ratio: 16 / 9; max-height: 100%; border-radius: 12px; overflow: hidden; }
.cg-video .cc-vid { border-radius: 12px; }

.cg-topo {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 10px calc(12px + env(safe-area-inset-left, 0px));
  opacity: 0; transition: opacity 220ms ease;
}
.cg.is-aberta .cg-topo, .cg.is-aberta .cg-baixo, .cg.is-aberta .cg-seta { opacity: 1; }
.cg.is-arrastando .cg-topo, .cg.is-arrastando .cg-baixo, .cg.is-arrastando .cg-seta { opacity: 0; transition-duration: 120ms; }
.cg-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: rgba(255, 255, 255, 0.14); -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%);
  transition: transform 120ms var(--c-ease, cubic-bezier(0.23, 1, 0.32, 1)), background-color 160ms ease;
}
.cg-btn:active { transform: scale(0.94); }
.cg-cont { flex: 1; text-align: center; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cg-esp { width: 44px; flex: none; }
.cg-dica {
  position: absolute; left: 50%; top: calc(64px + env(safe-area-inset-top, 0px)); z-index: 3; transform: translateX(-50%);
  height: 30px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; white-space: nowrap;
  font-size: 13px; font-weight: 600; background: rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); pointer-events: none;
  opacity: 0; transition: opacity 300ms ease;
}
.cg-dica.is-on { opacity: 1; }

.cg-baixo {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 12px calc(20px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  opacity: 0; transition: opacity 220ms ease; pointer-events: none;
}
.cg-legenda b { display: block; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-legenda span { display: block; margin-top: 2px; font-size: 13px; color: rgba(255, 255, 255, 0.72); }
.cg-pontos { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.cg-pontos i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); transition: transform 200ms var(--c-ease, ease), background-color 200ms ease; }
.cg-pontos i.is-on { background: #fff; transform: scale(1.2); }

.cg-seta {
  position: absolute; top: 50%; z-index: 3; margin-top: -22px; display: none; opacity: 0; transition: opacity 200ms ease, transform 120ms ease;
}
.cg-seta.is-ant { left: calc(16px + env(safe-area-inset-left, 0px)); }
.cg-seta.is-prox { right: calc(16px + env(safe-area-inset-right, 0px)); }
.cg-seta[disabled] { visibility: hidden; }
@media (hover: hover) and (pointer: fine) {
  .cg-seta { display: grid; }
  .cg-btn:hover { background: rgba(255, 255, 255, 0.24); }
}

/* Vídeo com capa (Etapa 4b — mídia do evento): a capa é a foto do slide;
   o <video> só nasce no toque, no lugar dela, do mesmo tamanho. */
.cg-play {
  position: absolute; left: 50%; top: 50%; z-index: 2; width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: transform 140ms var(--c-ease, cubic-bezier(0.23, 1, 0.32, 1)), opacity 180ms ease;
  touch-action: manipulation;
}
.cg-play svg { margin-left: 3px; }
.cg-play:active { transform: scale(0.94); }
.cg-slide.is-tocando .cg-play { opacity: 0; pointer-events: none; }
.cg-slide.is-video.is-carregando-video .cg-play::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff; animation: cg-gira 800ms linear infinite;
}
.cg-capa-neutra {
  width: min(100%, calc((100dvh - 150px) * 16 / 9)); max-height: 100%; aspect-ratio: 16 / 9; border-radius: 12px;
  background: radial-gradient(120% 90% at 30% 20%, #3a3a40 0%, #1b1b1f 55%, #0d0d10 100%);
}
.cg-vid {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; min-width: 0; min-height: 0;
  background: #000; border-radius: 6px;
}
@media (hover: hover) and (pointer: fine) {
  .cg-play:hover { transform: scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
  .cg-slide.is-video.is-carregando-video .cg-play::after { animation-duration: 1600ms; }
}

/* Dobrável de duas telas lado a lado: a galeria ocupa só a tela da direita */
@media (horizontal-viewport-segments: 2) {
  .cg { left: env(viewport-segment-left 1 0, 0px); }
}
/* Meio dobrado (melhoria progressiva): mídia na metade de cima */
@media (device-posture: folded) and (orientation: portrait) {
  .cg-slide { padding-bottom: 50dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .cg-img { transition: opacity 160ms ease; }
  .cg-fundo { transition: opacity 160ms ease; }
}
@media (prefers-reduced-transparency: reduce) {
  .cg-btn, .cg-dica { background: rgba(60, 60, 64, 0.95); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
