/*
  static/css/gallery.css
  ──────────────────────────────────────────────────────────────────────────────
  Gallery slider + lightbox styles for hugo-mana-theme.

  Every colour/spacing value uses a variable already defined in theme.css
  so the gallery automatically matches the current dark/light theme.

  HOW TO INCLUDE:
    Add ONE line to your site's layouts/partials/head-extra.html
    (create that file at that path in your SITE ROOT if it doesn't exist,
    then check what the Mana theme calls for extra head content — look in
    themes/mana/layouts/partials/head.html for a reference to "head-extra"
    or similar). The simplest approach is to override head.html:

    Create:  layouts/partials/head.html  (copy from themes/mana/layouts/partials/head.html)
    Then add inside <head> at the bottom:
      <link rel="stylesheet" href="/css/gallery.css">

    OR — just drop this into your existing site CSS if you have one.
  ──────────────────────────────────────────────────────────────────────────────
*/

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   SLIDER
   The .gallery-slider also carries .post-image-single from the Mana theme,
   so it gets the same border, shadow, border-radius, and margin-bottom
   automatically. We only add the slider-specific pieces here.
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.gallery-slider {
  position: relative;       /* anchor for absolute-positioned buttons/dots   */
  overflow: hidden;         /* clip the sliding track                         */
  /* aspect-ratio keeps the slider a consistent height regardless of image
     dimensions — 16:9 is a sensible default; change to 4:3 if you prefer  */
  aspect-ratio: 16 / 9;
  cursor: grab;             /* hint that the slider is draggable              */
  /* Inherit .post-image-single's padding:0.25rem — override to 0 so the
     track fills the full box edge-to-edge                                  */
  padding: 0 !important;
}

.gallery-slider:active {
  cursor: grabbing;
}

/* ── Track: holds all slides in a horizontal row ─────────────────────────── */
.gallery-slider-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Individual slide ────────────────────────────────────────────────────── */
.gallery-slide {
  flex: 0 0 100%;           /* each slide takes exactly 100% of track width  */
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;        /* fill the slide, cropped — same as post images  */
  display: block;
  border-radius: 0.375rem;  /* matches .post-image-single img border-radius   */
  pointer-events: none;     /* prevent drag-on-image from interfering         */
}

/* Caption strip at bottom of each slide */
.gallery-slide-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.5rem 1rem 0.625rem;
  background: linear-gradient(transparent, rgba(2, 6, 23, 0.75));
  color: var(--text-primary);
  font-size: 0.875rem;
  line-height: 1.4;
  opacity: 0;
  transition: opacity var(--transition-base);
  border-radius: 0 0 0.375rem 0.375rem;
}

.gallery-slide:hover .gallery-slide-caption,
.gallery-slide:focus-within .gallery-slide-caption {
  opacity: 1;
}

/* ── Prev / Next arrow buttons ───────────────────────────────────────────── */
.gallery-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* hidden by default — JS adds .visible once it knows slide count */
  opacity: 0;
  pointer-events: none;
}

.gallery-slider:hover .gallery-btn,
.gallery-slider:focus-within .gallery-btn {
  opacity: 1;
  pointer-events: auto;
}

.gallery-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.gallery-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  opacity: 1;
  pointer-events: auto;
}

.gallery-btn-prev { left:  0.75rem; }
.gallery-btn-next { right: 0.75rem; }

/* Disabled state (at first/last slide) */
.gallery-btn:disabled {
  opacity: 0.25 !important;
  pointer-events: none;
}

/* ── Dot indicators ──────────────────────────────────────────────────────── */
.gallery-dots {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.375rem;
  z-index: 10;
}

.gallery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-fast);
}

.gallery-dot.active {
  background: var(--accent-primary);
  transform: scale(1.3);
  box-shadow: 0 0 6px var(--accent-primary-rgba-05);
}

.gallery-dot:hover:not(.active) {
  background: rgba(255, 255, 255, 0.7);
}

/* ── Counter badge (top-right) ───────────────────────────────────────────── */
.gallery-counter {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 0.2rem 0.55rem;
  border-radius: 1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  line-height: 1.6;
}

/* ── Expand / fullscreen button (top-left) ───────────────────────────────── */
.gallery-expand-btn {
  position: absolute;
  top: 0.625rem;
  left: 0.625rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 0.375rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
}

.gallery-slider:hover .gallery-expand-btn,
.gallery-slider:focus-within .gallery-expand-btn {
  opacity: 1;
}

.gallery-expand-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.gallery-expand-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  opacity: 1;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   LIGHTBOX
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(2, 6, 23, 0.95);   /* --bg-deep at 95% */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* [hidden] blocks display:flex — override so we can animate */
.gallery-lightbox[hidden] {
  display: flex !important;
}

.gallery-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.gallery-lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 92vw;
  max-height: 92vh;
  margin: 0;
}

#lb-img {
  max-width: 90vw;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  transition: opacity 0.2s ease;
}

#lb-img.is-swapping {
  opacity: 0;
}

.gallery-lightbox-caption {
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: center;
  max-width: 60ch;
  font-family: var(--font-body);
}

/* Shared button base for lightbox controls */
.gallery-lightbox-close,
.gallery-lightbox-prev,
.gallery-lightbox-next {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 50%;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9001;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-prev:hover,
.gallery-lightbox-next:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.gallery-lightbox-close:focus-visible,
.gallery-lightbox-prev:focus-visible,
.gallery-lightbox-next:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 3px;
}

.gallery-lightbox-close { top: 1rem;  right: 1rem; }
.gallery-lightbox-prev  { left: 1rem; top: 50%; transform: translateY(-50%); }
.gallery-lightbox-next  { right: 1rem; top: 50%; transform: translateY(-50%); }

.gallery-lightbox-prev:hover { transform: translateY(-50%) scale(1.1); }
.gallery-lightbox-next:hover { transform: translateY(-50%) scale(1.1); }

.gallery-lightbox-prev:disabled,
.gallery-lightbox-next:disabled {
  opacity: 0.25;
  pointer-events: none;
}

/* ── Responsive tweaks ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .gallery-slider {
    aspect-ratio: 4 / 3;
  }

  .gallery-btn {
    width: 2rem;
    height: 2rem;
  }

  .gallery-btn-prev { left:  0.375rem; }
  .gallery-btn-next { right: 0.375rem; }

  .gallery-lightbox-prev,
  .gallery-lightbox-next {
    top: auto;
    bottom: 1rem;
    transform: none;
  }
  .gallery-lightbox-prev:hover,
  .gallery-lightbox-next:hover {
    transform: scale(1.1);
  }
  .gallery-lightbox-prev { left: 1rem; }
  .gallery-lightbox-next { right: 1rem; }
}
