/*
 * carousel.css — shared carousel + lightbox for theorganist24-web.
 *
 * Ported from the Wardrobe suite's cs- component set. The key design
 * decision is a transform-based slider (translateX) rather than native
 * overflow scroll: the .page wrapper uses backdrop-filter, which creates
 * a stacking/containing context that breaks both position:fixed overlays
 * and reliable overflow scrolling. The slider avoids native scroll
 * entirely, and the lightbox lives OUTSIDE .page (see base.html overlay
 * block) so it can use position:fixed correctly.
 *
 * Namespace: cs- to avoid collisions with area-level styles.
 *
 * Tokens: uses theorganist24's variables (--accent, --cream, --rule,
 * --muted, --space-*) with fallbacks for safety.
 */

/* ============================================================
   CAROUSEL  (horizontal sliding strip)
   ============================================================ */

.cs-carousel {
  position: relative;
  user-select: none;
  margin-bottom: var(--space-lg, 2rem);
}

.cs-carousel-wrap {
  overflow: hidden;
  border-radius: 2px;
  position: relative;
}

.cs-track {
  display: flex;
  transition: transform 0.3s ease;
}

.cs-slide {
  flex: 0 0 var(--cs-slide-w, 220px);
  width: var(--cs-slide-w, 220px);
  margin-right: 10px;
  cursor: zoom-in;
  position: relative;
  flex-shrink: 0;
}

.cs-slide img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-radius: 2px;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

/* Larger variant — for finished/product photos. The hero shot: exactly
   one slide visible at a time, arrows step through. The wrap is capped to
   the slide width and centred on the page, so the slider shows one clean
   image with no sliver of the next. */
.cs-carousel--large {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cs-carousel--large .cs-carousel-wrap {
  width: var(--cs-slide-w, 360px);
  max-width: 100%;
  position: relative;
}

.cs-carousel--large .cs-slide {
  flex: 0 0 var(--cs-slide-w, 360px);
  width: var(--cs-slide-w, 360px);
  max-width: 100%;
  margin-right: 0;
}

.cs-carousel--large .cs-slide img {
  aspect-ratio: 3 / 4;
}

/* Arrows sit just inside the capped wrap on the large variant */
.cs-carousel--large .cs-arrow--prev { left:  0.4rem; }
.cs-carousel--large .cs-arrow--next { right: 0.4rem; }

.cs-slide:hover img,
.cs-slide.cs-slide--active img {
  border-color: var(--accent, #2a4d3a);
}

.cs-slide figcaption {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--muted, #6b6259);
  margin-top: 0.25rem;
}

/* Arrow buttons */
.cs-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.88);
  border: none;
  width: 2.5rem;
  height: 4rem;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--accent, #2a4d3a);
  border-radius: 2px;
  z-index: 2;
  padding: 0;
  transition: opacity 0.15s, background 0.15s;
  opacity: 1;
  min-width: 44px;
  min-height: 44px;
}

@media (hover: hover) and (pointer: fine) {
  .cs-arrow { opacity: 0; }
  .cs-carousel:hover .cs-arrow { opacity: 1; }
}

.cs-arrow:hover  { background: rgba(255, 255, 255, 0.98); }
.cs-arrow--prev  { left:  0.4rem; }
.cs-arrow--next  { right: 0.4rem; }

.cs-carousel-empty {
  font-style: italic;
  color: var(--muted, #6b6259);
  font-size: 0.9rem;
}


/* ============================================================
   LIGHTBOX  (shared singleton — lives outside .page)
   ============================================================ */

.cs-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  overscroll-behavior: contain;
}

.cs-lightbox[hidden] { display: none; }

.cs-lb-img {
  max-width: min(92vw, 760px);
  max-height: 85dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 2px;
  -webkit-user-drag: none;
  user-select: none;
}

.cs-lb-close {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1.25rem, env(safe-area-inset-right));
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 1001;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cs-lb-close:hover { color: #fff; }

.cs-lb-prev,
.cs-lb-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 2.5rem;
  width: 3rem;
  height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 2px;
  padding: 0;
  transition: background 0.15s;
  z-index: 1001;
  min-width: 44px;
  min-height: 44px;
}
.cs-lb-prev:hover,
.cs-lb-next:hover { background: rgba(255, 255, 255, 0.22); }
.cs-lb-prev { left:  max(0.5rem, env(safe-area-inset-left)); }
.cs-lb-next { right: max(0.5rem, env(safe-area-inset-right)); }

.cs-lb-counter {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  z-index: 1001;
  pointer-events: none;
}
