/* GD Gallery — core styles */

.gd-gallery {
  --gd-bg: rgba(10, 10, 12, 0.94);
  --gd-fg: #f5f5f7;
  --gd-muted: rgba(245, 245, 247, 0.72);
  --gd-accent: #4da3ff;
  --gd-focus-ring: #8cc4ff;
  --gd-toolbar-height: 56px;
  --gd-btn-size: 44px;
  --gd-btn-bg: rgba(255, 255, 255, 0.06);
  --gd-btn-bg-hover: rgba(255, 255, 255, 0.16);
  --gd-radius: 10px;
  --gd-gap: 8px;
  --gd-slide-gap: 24px;
  --gd-speed: 400ms;
  --gd-easing: cubic-bezier(0.22, 0.61, 0.36, 1);
  --gd-caption-bg: rgba(0, 0, 0, 0.55);
  --gd-thumb-width: 100px;
  --gd-thumb-height: 80px;
  --gd-z-index: 1050;
  --gd-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  position: fixed;
  inset: 0;
  z-index: var(--gd-z-index);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'toolbar toolbar toolbar'
    'side-start stage side-end'
    'footer footer footer';
  color: var(--gd-fg);
  font-family: var(--gd-font);
  font-size: 15px;
  line-height: 1.45;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.gd-gallery[hidden] {
  display: none;
}

.gd-gallery *,
.gd-gallery *::before,
.gd-gallery *::after {
  box-sizing: border-box;
}

.gd-gallery.is-open {
  animation: gd-fade-in var(--gd-speed) var(--gd-easing);
}

.gd-gallery.is-closing {
  opacity: 0;
  transition: opacity var(--gd-speed) var(--gd-easing);
}

@keyframes gd-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gd-gallery__backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--gd-bg);
  opacity: calc(1 - var(--gd-drag-progress, 0));
}

/* ---- toolbar ----------------------------------------------------------- */

.gd-gallery__toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gd-gap);
  min-height: var(--gd-toolbar-height);
  padding: 6px 8px 6px 16px;
  position: relative;
  z-index: 2;
  transition: opacity 250ms ease;
}

.gd-gallery__counter {
  font-variant-numeric: tabular-nums;
  color: var(--gd-muted);
  white-space: nowrap;
}

.gd-gallery__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---- buttons ----------------------------------------------------------- */

.gd-gallery__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--gd-btn-size);
  min-height: var(--gd-btn-size);
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: var(--gd-radius);
  background: var(--gd-btn-bg);
  color: var(--gd-fg);
  font: inherit;
  cursor: pointer;
  transition: background-color 150ms ease, opacity 150ms ease, transform 150ms ease;
}

.gd-gallery__btn:hover {
  background: var(--gd-btn-bg-hover);
}

.gd-gallery__btn:active {
  transform: scale(0.96);
}

.gd-gallery__btn svg {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.gd-gallery__btn[aria-pressed='true'] {
  background: var(--gd-accent);
  color: #06111f;
}

.gd-gallery__btn[aria-expanded='true'] {
  background: var(--gd-btn-bg-hover);
  box-shadow: inset 0 -2px 0 var(--gd-accent);
}

.gd-gallery__btn.is-disabled,
.gd-gallery__btn[aria-disabled='true'] {
  opacity: 0.38;
  cursor: default;
}

.gd-gallery__btn[hidden] {
  display: none;
}

.gd-gallery :focus-visible {
  outline: 3px solid var(--gd-focus-ring);
  outline-offset: 2px;
}

.gd-gallery__btn--prev,
.gd-gallery__btn--next {
  /* Positioned inside the stage's grid area (not the whole viewport), so the
     arrows stay centred on the image as the thumbnail strip opens or closes. */
  grid-area: stage;
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  transition: opacity 250ms ease, background-color 150ms ease;
}

.gd-gallery__btn--prev { left: 12px; }
.gd-gallery__btn--next { right: 12px; }

.gd-gallery__btn--prev:hover,
.gd-gallery__btn--next:hover {
  background: rgba(0, 0, 0, 0.6);
}

/* ---- stage & slides ---------------------------------------------------- */

.gd-gallery__stage {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}

.gd-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(8px, 4vw, 72px);
  visibility: hidden;
  transform: translate3d(calc(var(--gd-pos, 0) * (100% + var(--gd-slide-gap)) + var(--gd-drag-x, 0px)), 0, 0);
}

.gd-slide.is-prev { --gd-pos: -1; }
.gd-slide.is-next { --gd-pos: 1; }

.gd-slide.is-current {
  visibility: visible;
  transform: translate3d(var(--gd-drag-x, 0px), var(--gd-drag-y, 0px), 0);
}

.gd-slide.is-animating,
.gd-gallery.is-dragging .gd-slide {
  visibility: visible;
}

.gd-slide.gd-anim-slide {
  transition: transform var(--gd-speed) var(--gd-easing);
}

/* A drag that did not change the slide glides back into place. */
.gd-gallery.is-settling .gd-slide {
  visibility: visible;
  transition: transform 250ms var(--gd-easing);
}

.gd-gallery.is-settling .gd-gallery__backdrop {
  transition: opacity 250ms var(--gd-easing);
}

/* Fade mode: slides stack in place and cross-fade. */
.gd-mode-fade .gd-slide {
  transform: translate3d(var(--gd-drag-x, 0px), 0, 0);
  opacity: 0;
}

.gd-mode-fade .gd-slide.is-current {
  opacity: 1;
  transform: translate3d(0, var(--gd-drag-y, 0px), 0);
}

.gd-mode-fade .gd-slide.gd-anim-fade {
  transition: opacity var(--gd-speed) var(--gd-easing);
}

.gd-slide__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transform: var(--gd-rotate-transform, none);
  transition: transform 300ms var(--gd-easing);
}

.gd-slide__img,
.gd-slide__poster {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.gd-slide.is-loading .gd-slide__img {
  opacity: 0;
}

.gd-slide.is-loaded .gd-slide__img {
  opacity: 1;
  transition: opacity 200ms ease;
}

.gd-slide__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--gd-fg);
  border-radius: 50%;
  animation: gd-spin 0.9s linear infinite;
}

@keyframes gd-spin {
  to { transform: rotate(360deg); }
}

.gd-slide__error {
  max-width: 28rem;
  padding: 24px;
  border-radius: var(--gd-radius);
  background: rgba(255, 255, 255, 0.06);
  text-align: center;
}

.gd-slide__error p {
  margin: 0 0 16px;
}

.gd-slide__retry {
  min-height: var(--gd-btn-size);
  padding: 0 20px;
  border: 1px solid currentColor;
  border-radius: var(--gd-radius);
  background: transparent;
  color: var(--gd-fg);
  font: inherit;
  cursor: pointer;
}

/* ---- footer & caption -------------------------------------------------- */

.gd-gallery__footer {
  grid-area: footer;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px 12px;
  transition: opacity 250ms ease;
}

/* Spacing as a margin (not flex gap) so a module can animate it away. */
.gd-gallery__footer > :not([hidden]) ~ :not([hidden]) {
  margin-top: var(--gd-gap);
}

.gd-gallery__caption {
  max-width: min(60rem, 100%);
  max-height: 30vh;
  overflow: auto;
  padding: 8px 14px;
  border-radius: var(--gd-radius);
  background: var(--gd-caption-bg);
  text-align: center;
}

.gd-gallery__caption[hidden] {
  display: none;
}

.gd-gallery__caption > :first-child { margin-top: 0; }
.gd-gallery__caption > :last-child { margin-bottom: 0; }

.gd-gallery__caption a {
  color: var(--gd-focus-ring);
}

/* ---- tooltips ---------------------------------------------------------- */

.gd-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  max-width: min(240px, calc(100vw - 16px));
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--gd-tooltip-bg, #f5f5f7);
  color: var(--gd-tooltip-fg, #111114);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: gd-tooltip-in 120ms ease-out;
}

.gd-tooltip[hidden] {
  display: none;
}

@keyframes gd-tooltip-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- auto-hidden chrome ------------------------------------------------ */

.gd-gallery.is-ui-hidden .gd-gallery__toolbar,
.gd-gallery.is-ui-hidden .gd-gallery__footer,
.gd-gallery.is-ui-hidden .gd-gallery__btn--prev,
.gd-gallery.is-ui-hidden .gd-gallery__btn--next {
  opacity: 0;
}

.gd-gallery.is-ui-hidden .gd-tooltip {
  display: none;
}

.gd-gallery.is-ui-hidden { cursor: none; }

/* ---- helpers ----------------------------------------------------------- */

.gd-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html.gd-scroll-locked {
  overscroll-behavior: none;
}

/* ---- small screens ----------------------------------------------------- */

@media (max-width: 600px) {
  .gd-gallery__btn--prev,
  .gd-gallery__btn--next {
    width: var(--gd-btn-size);
    height: var(--gd-btn-size);
    margin-top: calc(var(--gd-btn-size) / -2);
  }

  .gd-gallery__btn--prev { left: 4px; }
  .gd-gallery__btn--next { right: 4px; }
  .gd-slide { padding: 0; }
}

/* ---- user preferences -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .gd-gallery,
  .gd-gallery *,
  .gd-gallery *::before,
  .gd-gallery *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .gd-slide__spinner {
    animation: none !important;
    border-top-color: rgba(255, 255, 255, 0.2);
  }
}

@media (forced-colors: active) {
  .gd-gallery__backdrop { background: Canvas; opacity: 1; }
  .gd-gallery { color: CanvasText; }
  .gd-gallery__btn,
  .gd-slide__retry {
    border: 1px solid ButtonText;
    background: ButtonFace;
    color: ButtonText;
    forced-color-adjust: none;
  }
  .gd-gallery__btn[aria-pressed='true'] {
    background: Highlight;
    color: HighlightText;
  }
  .gd-gallery :focus-visible { outline-color: Highlight; }
  .gd-gallery__caption { border: 1px solid CanvasText; }
  .gd-tooltip {
    forced-color-adjust: none;
    border: 1px solid CanvasText;
    background: Canvas;
    color: CanvasText;
  }
}

/* GD Gallery — Autoplay module */

.gd-autoplay__progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  height: 3px;
  background: var(--gd-accent);
  transform: scaleX(0);
  transform-origin: left center;
  pointer-events: none;
}

.gd-autoplay__progress.is-running {
  animation: gd-autoplay-progress var(--gd-autoplay-interval, 5000ms) linear forwards;
}

@keyframes gd-autoplay-progress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  .gd-autoplay__progress {
    display: none;
  }
}

/* GD Gallery — Fullscreen module */

.gd-gallery.is-fullscreen {
  background: #000;
}

.gd-gallery.is-fullscreen .gd-gallery__backdrop {
  background: #000;
}

/* GD Gallery — Hash module has no visual output. */

/* GD Gallery — Pager module */

.gd-pager__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gd-pager__dot {
  position: relative;
  width: 28px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

/* Small visible dot, full 44px touch target. */
.gd-pager__dot::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--gd-fg);
  opacity: 0.4;
  transition: opacity 150ms ease, transform 150ms ease;
}

.gd-pager__dot:hover::before {
  opacity: 0.75;
}

.gd-pager__dot.is-active::before {
  opacity: 1;
  transform: scale(1.3);
  background: var(--gd-accent);
}

.gd-pager__dot:focus-visible {
  outline-offset: -6px;
  border-radius: 8px;
}

@media (forced-colors: active) {
  .gd-pager__dot::before {
    forced-color-adjust: none;
    background: ButtonText;
  }
  .gd-pager__dot.is-active::before {
    background: Highlight;
    opacity: 1;
  }
}

/* GD Gallery — Rotate module
   The transform lives on .gd-slide__media (--gd-rotate-transform, applied by the
   core stylesheet), so it composes with the Zoom module's transform on the image. */

/* After a quarter turn the image's width must fit the container's height and
   vice versa; container query units express exactly that. */
.gd-slide__media.gd-quarter-turn {
  container-type: size;
}

.gd-slide__media.gd-quarter-turn .gd-slide__img {
  max-width: 100cqh;
  max-height: 100cqw;
}

/* GD Gallery — Share module */

.gd-share__menu {
  position: absolute;
  top: calc(100% - 4px);
  right: 8px;
  z-index: 5;
  min-width: 220px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: var(--gd-radius, 10px);
  background: #1d1d22;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.gd-share__menu[hidden] {
  display: none;
}

.gd-share__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gd-fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.gd-share__item:hover,
.gd-share__item:focus-visible {
  background: rgba(255, 255, 255, 0.1);
}

.gd-share__item:focus-visible {
  outline-offset: -2px;
}

.gd-share__icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

@media (forced-colors: active) {
  .gd-share__menu {
    border: 1px solid CanvasText;
    background: Canvas;
  }
  .gd-share__item {
    color: ButtonText;
  }
}

/* GD Gallery — Thumbs module */

.gd-thumbs {
  --gd-thumb-gap: 6px;
  max-width: 100%;
}

.gd-thumbs[hidden] {
  display: none;
}

/* While sliding open or closed, clip the thumbnails to the animated size. */
.gd-thumbs.is-animating {
  overflow: hidden;
  pointer-events: none;
}

/* The list shrinks with the strip; without this it would flash a scrollbar
   for a few frames. Its scroll position is kept. */
.gd-thumbs.is-animating .gd-thumbs__list {
  overflow: hidden;
}

.gd-thumbs__list {
  display: flex;
  gap: var(--gd-thumb-gap);
  margin: 0;
  padding: 4px;
  list-style: none;
  /* A horizontal strip scrolls only sideways, a vertical one only up and down. */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.gd-thumbs--bottom {
  width: 100%;
  display: flex;
  justify-content: center;
}

.gd-thumbs--left,
.gd-thumbs--right {
  position: relative;
  z-index: 2;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.gd-thumbs--left { grid-area: side-start; padding-left: 8px; }
.gd-thumbs--right { grid-area: side-end; padding-right: 8px; }

.gd-thumbs--left .gd-thumbs__list,
.gd-thumbs--right .gd-thumbs__list {
  flex-direction: column;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.gd-thumbs__item {
  position: relative;
  display: block;
  flex: none;
  width: var(--gd-thumb-width);
  height: var(--gd-thumb-height);
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 150ms ease, box-shadow 150ms ease;
}

.gd-thumbs__item:hover,
.gd-thumbs__item:focus-visible,
.gd-thumbs__item.is-active {
  opacity: 1;
}

.gd-thumbs__item.is-active {
  box-shadow: inset 0 0 0 2px var(--gd-accent), 0 0 0 1px var(--gd-accent);
}

.gd-thumbs__item:focus-visible {
  outline-offset: -3px;
}

.gd-thumbs__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.gd-thumbs__item.is-video::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -5px;
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

@media (max-width: 600px) {

  .gd-thumbs__item {
    width: calc(var(--gd-thumb-width) * 0.7);
    height: calc(var(--gd-thumb-height) * 0.7);
  }
}

@media (forced-colors: active) {
  .gd-thumbs__item.is-active {
    outline: 3px solid Highlight;
    outline-offset: -3px;
  }
}

/* GD Gallery — Video module */

.gd-video__play {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  min-width: 240px;
  min-height: 135px;
  padding: 0;
  border: 0;
  border-radius: var(--gd-radius, 10px);
  overflow: hidden;
  background: #000;
  color: #fff;
  cursor: pointer;
}

.gd-video__play .gd-slide__poster {
  display: block;
  max-width: 100%;
  max-height: 100%;
  opacity: 0.85;
  transition: opacity 200ms ease;
}

.gd-video__play:hover .gd-slide__poster,
.gd-video__play:focus-visible .gd-slide__poster {
  opacity: 1;
}

.gd-video__icon {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
  transition: transform 200ms ease, background-color 200ms ease;
}

.gd-video__icon svg {
  width: 36px;
  height: 36px;
}

.gd-video__play:hover .gd-video__icon,
.gd-video__play:focus-visible .gd-video__icon {
  transform: scale(1.08);
  background: var(--gd-accent, #4da3ff);
}

.gd-video__play:focus-visible {
  outline-offset: 4px;
}

.gd-video {
  width: min(100%, 1280px, calc((100vh - 200px) * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: 100%;
}

.gd-video__frame,
.gd-video__el {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.gd-video--html5 {
  aspect-ratio: auto;
  width: auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gd-video--html5 .gd-video__el {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

@media (forced-colors: active) {
  .gd-video__icon {
    forced-color-adjust: none;
    background: ButtonFace;
    color: ButtonText;
    box-shadow: 0 0 0 2px ButtonText;
  }
}

/* GD Gallery — Zoom module */

/* Specific enough to win over the core fade-in rule on loaded images, which
   would otherwise replace this transition with an opacity-only one. */
.gd-gallery .gd-slide.is-current .gd-slide__img.gd-zoomable {
  transform: var(--gd-zoom-transform);
  transform-origin: center center;
  transition:
    transform var(--gd-zoom-speed, 300ms) var(--gd-easing),
    opacity 200ms ease;
}

/* With the Zoom module the stage handles every touch gesture itself: a pinch
   zooms the image instead of the page. (Without it, the core keeps
   pinch-zoom so users can still magnify the page.) */
.gd-gallery.gd-has-zoom .gd-gallery__stage {
  touch-action: none;
}

/* Panning and pinching follow the pointer directly, without easing. */
.gd-gallery.is-zoom-gesture .gd-slide.is-current .gd-slide__img.gd-zoomable {
  transition: none;
}

.gd-gallery.is-zoomed .gd-slide.is-current .gd-slide__img {
  will-change: transform;
}

.gd-gallery:not(.is-zoomed) .gd-slide.is-current .gd-slide__img {
  cursor: zoom-in;
}

.gd-gallery.is-zoomed .gd-slide.is-current .gd-slide__img {
  cursor: grab;
  touch-action: none;
}

.gd-gallery.is-zoom-gesture .gd-slide.is-current .gd-slide__img {
  cursor: grabbing;
}

/* Let the zoomed image overflow its slide while it is panned. */
.gd-gallery.is-zoomed .gd-slide.is-current .gd-slide__media {
  overflow: visible;
}

.gd-gallery.is-zoomed .gd-gallery__btn--prev,
.gd-gallery.is-zoomed .gd-gallery__btn--next {
  opacity: 0;
  pointer-events: none;
}
