/* vup_2018_child — components/gallery-ui.css
 * Clean build: centered stage, exact N thumbnails, contain-by-default, cover opt-in.
 * Honors center-column gutters (no overflow).
 */

/* ========== TOKENS / KNOBS (scoped to each gallery) ========== */
.vu-gallery {
  /* Stage sizing (defaults can be overridden per gallery) */
  --stage-w: min(1100px, 90vw);
  --stage-ar: 16/9;

  /* Spacing + visuals */
  --stage-pad: var(--gallery-stage-pad, 10px);
  --stage-rad: var(--gallery-stage-rad, 12px);
  --thumb-underlap: 32px;
  --ui-gap: 10px;
  --ui-bg: transparent;
  --ui-ink: #ffffff;
  --accent: var(--loc-accent, var(--vu-gold));

  /* Dots */
  --dot: 25px;
  --dot-height: 7px;

  /* Thumbnails */
  --thumbs-per: 7;
  --thumb-gap: 6px;
  --thumb-gap-top: 30px;
  --thumb-ar: 2/1;
  --thumb-strip-scale: .75;
  --thumb-frame: rgba(255, 255, 255, .25);
  --thumb-frame-active: var(--accent);
  display: block;
  margin: clamp(10px, 2.4vw, 20px) 0;
  color: var(--ui-ink);
}

/* ========== STAGE (bounded by column, centered) ========== */
.vu-gallery .gal-stage {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--stage-w);
  margin-inline: auto;

  position: relative;
  padding: var(--stage-pad);
  padding-bottom: calc(var(--stage-pad) + var(--thumb-underlap));
  touch-action: pan-y;
}

.vu-gallery .gal-stage::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: calc(-1 * var(--thumb-underlap));
  background: var(--ui-bg);
  border-radius: var(--stage-rad);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .12);
  z-index: -1;
}

/* Stage canvas uses aspect-ratio (no vh clamps) */
.vu-gallery .gal-canvas {
  aspect-ratio: var(--stage-ar);
  height: auto;
  min-height: 0;
  overflow: hidden;
  border-radius: calc(var(--stage-rad) - 4px);
  display: block;
  /* avoid grid shrink on tall viewports */
  position: relative;
  cursor: pointer;
}

/* Hover helper: softly light the half the pointer sits on */
.vu-gallery .gal-canvas::before,
.vu-gallery .gal-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
  z-index: 2;
}

.vu-gallery .gal-canvas::before {
  background: var(--grad-gallery-fade-light, linear-gradient(to right, rgba(255, 255, 255, .35), transparent 55%));
}

.vu-gallery .gal-canvas::after {
  background: var(--grad-gallery-fade-light-rev, linear-gradient(to left, rgba(255, 255, 255, .35), transparent 55%));
}

.vu-gallery.is-hover-left .gal-canvas::before {
  opacity: 1;
}

.vu-gallery.is-hover-right .gal-canvas::after {
  opacity: 1;
}

/* ========== SLIDES (default CONTAIN) ========== */
.vu-gallery .gal-slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transform: translateX(0);
  transition: opacity .28s ease, transform .28s ease;
  will-change: transform, opacity;
}

.vu-gallery .gal-slide.is-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

/* Drag preview: JS sets --drag-x on active slide inline or on canvas */
.vu-gallery .gal-slide.is-active {
  transform: translateX(var(--drag-x, 0px));
}

.vu-gallery .gal-slide .gal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* default */
  border-radius: 10px;
  -webkit-user-select: none;
  user-select: none;
  background: var(--ui-bg);
}

/* ========== BLUR-UP (uses --lqip inline style) ========== */
.vu-gallery .gal-slide.is-loading .gal-img {
  background-image: var(--lqip);
  background-size: cover;
  background-position: center;
  filter: saturate(120%) contrast(105%) blur(12px);
}

.vu-gallery .gal-slide:not(.is-loading) .gal-img {
  filter: none;
  background-image: none;
  transition: filter .25s ease, opacity .2s ease, background-image .2s;
}

/* ========== CAPTION (hover reveal) ========== */
.vu-gallery .gal-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: .4rem .8rem;
  font-size: .9rem;
  line-height: 1.25;
  background: rgba(255, 255, 255, .8);
  color: #111;
  opacity: 0;
  transition: opacity .25s;
}

.vu-gallery .gal-slide:is(:hover, :focus-within) .gal-cap {
  opacity: 1;
}

/* ========== DOTS ========== */
.vu-gallery .gal-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: var(--ui-gap);
}

.vu-gallery .gal-dot {
  width: var(--dot);
  height: var(--dot-height);
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, .35);
  cursor: pointer;
}

.vu-gallery .gal-dot.is-active {
  background: var(--accent);
}

/* ========== THUMB STRIP (centered, exact N per view) ========== */
.vu-gallery .gal-thumbs {
  box-sizing: border-box;
  width: 100%;
  max-width: calc(var(--stage-w) * var(--thumb-strip-scale));
  margin: calc(var(--thumb-gap-top) - var(--thumb-underlap)) auto 0;

  position: relative;
  display: flex;
  gap: var(--thumb-gap);
  overflow-x: auto;
  padding: 6px 0 8px;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 50%;
  overscroll-behavior-x: contain;
  scrollbar-gutter: stable both-edges;
  -ms-overflow-style: none;
  touch-action: pan-x;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.vu-gallery .gal-thumbs::-webkit-scrollbar {
  display: none;
}

.vu-gallery .gal-thumb {
  flex: 0 0 calc((100% - ((var(--thumbs-per) - 1) * var(--thumb-gap))) / var(--thumbs-per));
  aspect-ratio: var(--thumb-ar);
  height: auto;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  cursor: grab;
  scroll-snap-align: center;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.vu-gallery .gal-thumb.is-active {
  border-color: var(--thumb-frame-active);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .25);
}

.vu-gallery .gal-thumb:hover {
  border-color: var(--thumb-frame);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}

.vu-gallery .gal-thumb:active {
  cursor: grabbing;
}

.vu-gallery .gal-thumb:focus-visible {
  outline: none;
  border-color: var(--thumb-frame);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}

.vu-gallery .gal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

.vu-gallery .gal-thumbs::before {
  left: 0;
  background: var(--grad-gallery-fade-dark, linear-gradient(to right, rgba(0, 0, 0, .45), transparent));
}

.vu-gallery .gal-thumbs::after {
  right: 0;
  background: var(--grad-gallery-fade-dark-rev, linear-gradient(to left, rgba(0, 0, 0, .45), transparent));
}

@supports (-webkit-user-drag: none) {

  .vu-gallery .gal-slide .gal-img,
  .vu-gallery .gal-thumb img {
    -webkit-user-drag: none;
  }
}

@supports (scrollbar-width: none) {
  .vu-gallery .gal-thumbs {
    scrollbar-width: none;
  }
}

/* ========== RESPONSIVE KNOBS ONLY (no selector duplication) ========== */
@media (max-width:1024px) {
  .vu-gallery {
    --thumbs-per: 5;
    --thumb-strip-scale: .88;
  }
}

@media (max-width:640px) {
  .vu-gallery {
    --thumbs-per: 3;
    --thumb-strip-scale: 1;
    --thumb-scale: .9;
    --thumb-scale-active: 1.05;
  }
}

/* ========== COVER MODE (wins last) ========== */
.vu-gallery.vu-cover {
  --stage-pad: 0;
}

.vu-gallery.vu-cover .gal-stage {
  padding: var(--stage-pad);
}

.vu-gallery.vu-cover .gal-canvas {
  aspect-ratio: var(--stage-ar);
}

.vu-gallery.vu-cover .gal-slide {
  margin: 0;
}

.vu-gallery.vu-cover .gal-slide .gal-img {
  object-fit: cover;
  /* fill + crop */
}

/* OPTIONAL: keep portraits readable in cover mode (commented out) */
/*
.vu-gallery.vu-cover .gal-slide .gal-img[data-orient="portrait"]{
  object-fit:contain;
}
*/

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .vu-gallery * {
    transition: none;
    animation: none;
    scroll-behavior: auto;
  }
}