/* The original event photographs lead; the viewer uses the existing theme. */
body.event-gallery-open { overflow: hidden; }

#event-gallery-dialog {
  width: min(1120px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  max-height: calc(100svh - 32px);
  padding: 0;
  margin: auto;
  border: 0;
  border-radius: 16px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 80px rgb(0 0 0 / .4);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#event-gallery-dialog::backdrop {
  background: color-mix(in srgb, var(--page) 84%, transparent);
  backdrop-filter: blur(10px);
}
#event-gallery-dialog[data-motion-state="opening"]::backdrop {
  animation: event-gallery-backdrop-in .3s ease-out both;
}
#event-gallery-dialog[data-motion-state="closing"]::backdrop {
  animation: event-gallery-backdrop-out .23s ease-in both;
}
@keyframes event-gallery-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes event-gallery-backdrop-out { from { opacity: 1; } to { opacity: 0; } }

#event-gallery-dialog .event-gallery-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 20px;
  min-width: 0;
}

#event-gallery-dialog .dialog-close {
  position: relative;
  inset: auto;
  grid-column: 2;
  grid-row: 1;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 11px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  line-height: 1;
}
#event-gallery-dialog .dialog-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

#event-gallery-count {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
#event-gallery-image {
  grid-column: 1 / -1;
  grid-row: 2;
  display: block;
  width: 100%;
  min-width: 0;
  height: auto;
  /* Reserve room for the header, caption and both controls before sizing media. */
  max-height: min(800px, max(120px, calc(100svh - 280px)));
  object-fit: contain;
  background: var(--page);
}
#event-gallery-dialog[data-image-state="loading"] #event-gallery-image { opacity: .65; }
#event-gallery-dialog[data-image-state="error"] #event-gallery-image { display: none; }
#event-gallery-caption {
  grid-column: 1 / -1;
  grid-row: 3;
  margin: 0;
  max-width: 70ch;
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
#event-gallery-caption:empty { display: none; }

#event-gallery-dialog .event-gallery-controls {
  grid-column: 1 / -1;
  grid-row: 4;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 4px;
}
#event-gallery-dialog :is([data-gallery-prev], [data-gallery-next]) {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--text);
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  transition: color .16s ease, background-color .16s ease, border-color .16s ease;
}
#event-gallery-dialog :is(.dialog-close, [data-gallery-prev], [data-gallery-next]):hover {
  color: var(--page);
  background: var(--text);
  border-color: var(--text);
}
#event-gallery-dialog button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
#event-gallery-dialog button:disabled { opacity: .45; cursor: default; }
#event-gallery-dialog button:disabled:hover { color: var(--text); background: transparent; border-color: var(--line); }

@media (max-width: 600px) {
  #event-gallery-dialog {
    width: calc(100% - 20px);
    max-width: calc(100% - 20px);
    max-height: calc(100svh - 20px);
    border-radius: 12px;
  }
  #event-gallery-dialog .event-gallery-shell { gap: 14px; padding: 14px; }
  #event-gallery-image { max-height: max(120px, calc(100svh - 280px)); }
  #event-gallery-caption { font-size: 15px; }
  #event-gallery-dialog .event-gallery-controls { gap: 10px; }
}

@media (max-width: 380px) {
  #event-gallery-image { max-height: max(120px, calc(100svh - 340px)); }
  #event-gallery-dialog .event-gallery-controls { flex-direction: column; }
  #event-gallery-dialog :is([data-gallery-prev], [data-gallery-next]) { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  #event-gallery-dialog::backdrop { animation: none !important; }
  #event-gallery-dialog button { transition: none; }
}
#event-gallery-dialog[data-motion="reduced"]::backdrop { animation: none; }
.static-motion #event-gallery-dialog::backdrop { animation: none; }
.static-motion #event-gallery-dialog button { transition: none; }
