/*
 * Copyright (c) 2026, Allen Ellison-Saavedra
 * All rights reserved.
 *
 * PROPRIETARY AND CONFIDENTIAL
 *
 * Unauthorized copying, modification, distribution, disclosure,
 * or use of this software is strictly prohibited without prior
 * written permission from the copyright holder.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
 * NONINFRINGEMENT.
 *
 * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE COPYRIGHT
 * HOLDER SHALL NOT BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
 * LIABILITY, WHETHER IN CONTRACT, TORT, OR OTHERWISE, ARISING
 * FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR ITS USE.
 */

/* Slideshow component. Markup and options are described in slideshow.js.
   Colors follow the site's tokens when it has them. */

.slideshow {
  --slideshow-speed: 700ms;
  --slideshow-fade: 1000ms;
  --slideshow-accent: var(--color-primary, #1f5fbf);
  --slideshow-ink: var(--color-text, #1d2433);
  --slideshow-surface: var(--color-surface, #ffffff);
  --slideshow-radius: var(--radius, 10px);
  position: relative;
  margin: 1.5rem 0;
  color: var(--slideshow-ink);
}

/* Without the script, slides sit side by side and scroll. */
.slideshow:not(.is-ready) {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.slideshow:not(.is-ready) > .slideshow-slide,
.slideshow:not(.is-ready) > [data-slide] {
  flex: 0 0 100%;
  scroll-snap-align: start;
}

.slideshow-slide {
  margin: 0;
  background: var(--slideshow-surface);
}

.slideshow-slide img,
.slideshow-slide video {
  display: block;
  width: 100%;
  height: auto;
}

.slideshow-caption,
.slideshow-slide figcaption {
  padding: 0.75rem 1rem;
  line-height: 1.5;
}

.slideshow-stage {
  position: relative;
  display: grid;
  overflow: hidden;
  border-radius: var(--slideshow-radius);
  background: var(--slideshow-surface);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 8px 24px rgb(0 0 0 / 0.08);
  touch-action: pan-y;
}

.slideshow.is-ready .slideshow-slide {
  grid-area: 1 / 1;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform var(--slideshow-speed) cubic-bezier(0.22, 0.7, 0.2, 1),
    visibility 0s linear var(--slideshow-speed);
}

.slideshow.is-ready .slideshow-slide.is-active {
  transform: none;
  visibility: visible;
  transition: transform var(--slideshow-speed) cubic-bezier(0.22, 0.7, 0.2, 1), visibility 0s;
}

.slideshow.is-ready .slideshow-slide.is-leaving {
  transform: translateX(-100%);
  visibility: visible;
}

.slideshow.is-ready .slideshow-slide.is-leaving.to-right {
  transform: translateX(100%);
}

.slideshow.is-ready .slideshow-slide.is-entering {
  transform: translateX(100%);
  visibility: visible;
  transition: none;
}

.slideshow.is-ready .slideshow-slide.is-entering.from-left {
  transform: translateX(-100%);
}

.slideshow.is-ready .slideshow-slide.is-instant {
  transition: none;
}

.slideshow-curtain {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--slideshow-fade) ease;
}

.slideshow.is-dark .slideshow-curtain {
  opacity: 1;
}

.slideshow-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.slideshow-controls button {
  font: inherit;
  cursor: pointer;
}

.slideshow-prev,
.slideshow-next {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
}

.slideshow-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 1;
  justify-content: center;
}

.slideshow-dot {
  width: 0.7rem;
  height: 0.7rem;
  padding: 0;
  border: 1px solid var(--slideshow-accent);
  border-radius: 50%;
  background: transparent;
}

.slideshow-dot[aria-current] {
  background: var(--slideshow-accent);
}

.slideshow-counter {
  min-width: 3.5em;
  text-align: center;
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.slideshow-toggle {
  padding: 0.3rem 0.8rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 0.9em;
}

.slideshow-controls button:focus-visible {
  outline: 2px solid var(--slideshow-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .slideshow {
    --slideshow-speed: 1ms;
    --slideshow-fade: 300ms;
  }
}
