/* components/content-gallery.css — the sideways-scrolling gallery that
   content-gallery.js builds between two marker snippets: images at one
   height and natural widths, captions underneath, arrows top right.
   Every selector starts with .post-content to beat ghost-content.css (which
   loads later) on specificity. Without JS the cards stay a normal stack. */

/* Full-bleed. --gallery-inset aligns the first image with the site
   container's content edge (100vw, since % would resolve against
   .post-content). */
.post-content > .gallery {
  --gallery-inset: max(
    var(--gutter),
    calc((100vw - var(--container-site)) / 2 + var(--gutter))
  );
  width: 100vw;
  max-width: 100vw;
  margin-inline: calc(50% - 50vw);
  margin-block: var(--space-12);
}

/* Arrows top right, on the container edge. */
.post-content .gallery__controls {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-6);
  padding-inline: var(--gallery-inset);
  margin-block-end: var(--space-6);
}

/* Everything fits: no arrows. */
.post-content .gallery[data-gallery-static] .gallery__controls {
  display: none;
}

.post-content .gallery__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-ui);
  font-size: var(--text-2xl);
  line-height: 1;
  color: inherit;
  cursor: pointer;
}

/* At either end. Colour, not opacity, so the focus ring doesn't fade. */
.post-content .gallery__button:disabled {
  color: var(--color-fg-muted);
  cursor: default;
}

/* The strip: items hang from one top line; proximity snapping so editors
   can stop between variable-width items. */
.post-content .gallery__track {
  display: flex;
  align-items: start;
  gap: var(--space-20);
  padding-inline: var(--gallery-inset);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline-start: var(--gallery-inset);
  /* The track takes focus for keyboard paging; ring outside the images. */
  outline-offset: var(--focus-offset);
  scrollbar-width: none;
}

.post-content .gallery__track::-webkit-scrollbar {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .post-content .gallery__track {
    scroll-behavior: smooth;
  }
}

/* Undo .post-content's measure clamp; grid so the caption is its own row. */
.post-content .gallery__track > * {
  flex: 0 0 auto;
  display: grid;
  gap: var(--space-4);
  max-width: none;
  margin-block: 0;
  scroll-snap-align: start;
}

/* One height, natural widths. --gallery-height is a design-layer hook. */
.post-content .gallery__track :is(img, video) {
  height: var(--gallery-height, min(70vh, 40rem));
  width: auto;
  max-width: none;
}

/* Video: Ghost positions it absolutely, which collapses its container to 0
   width in the strip. Back in flow; the overlays still cover it. */
.post-content .gallery__track .kg-video-card video {
  position: static;
}

/* Captions left under their image. width: 0 + min-width: 100% keeps a long
   caption from widening the item, so it wraps at the image's edge. */
.post-content .gallery__track figcaption {
  width: 0;
  min-width: 100%;
  max-width: none;
  margin-inline: 0;
  text-align: start;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  color: var(--color-fg-muted);
}

/* Markers: hidden on the site (visible in the editor), even if JS didn't
   run — an orphaned marker mustn't print its label. */
.post-content .gallery-marker {
  display: none;
}
