/* =====================================================================
   Vessel slideshow — capability showcase for vessel detail pages.

   Progressive enhancement: without vessel-slideshow.js the markup is a
   plain stacked gallery (image + caption, one under the other), so every
   render and every caption is still readable with JavaScript off. The
   script adds .js-ready, which collapses the stack into a single
   cross-fading stage and reveals the control bar.
   ===================================================================== */

.vslide {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--navy-dark);
  box-shadow: var(--shadow-card);
}

/* --- No-JS / pre-JS: a plain stack -------------------------------- */
.vslide:not(.js-ready) .vslide-track {
  display: grid;
  gap: 2px;
}
.vslide:not(.js-ready) .vslide-controls,
.vslide:not(.js-ready) .vslide-counter { display: none; }
/* display:flex below would otherwise beat the hidden attribute, flashing the
   empty control bar between first paint and the script running. */
.vslide-controls[hidden] { display: none; }

/* --- Stage -------------------------------------------------------- */
.vslide-stage { position: relative; }

.vslide.js-ready .vslide-track {
  display: grid;                 /* every slide shares one grid cell */
}
.vslide.js-ready .vslide-slide {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  transition: opacity 560ms ease, visibility 0s linear 560ms;
  pointer-events: none;
}
.vslide.js-ready .vslide-slide.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity 560ms ease;
  pointer-events: auto;
}

.vslide-slide { margin: 0; }

.vslide-img {
  position: relative;
  background: var(--navy-dark);
  overflow: hidden;
}
.vslide-img img {
  display: block;
  width: 100%;
  /* The slides carry width/height attributes for the intrinsic ratio, and
     the height attribute is a presentational hint — without height:auto it
     wins, the box gets a definite height and aspect-ratio never applies. */
  height: auto;
  aspect-ratio: 16 / 9;
  /* Full 16:9 on a laptop puts the caption and controls below the fold, so
     cap the stage and let object-fit crop the render instead. */
  max-height: 62vh;
  object-fit: cover;
}
/* Slow push-in on the slide that is showing — the renders are stills, so
   the drift is what stops the stage reading as a static picture. */
.vslide.js-ready .vslide-slide.is-active .vslide-img img {
  animation: vslideDrift 9s ease-out both;
}
@keyframes vslideDrift {
  from { transform: scale(1.06); }
  to   { transform: scale(1); }
}

/* --- Caption ------------------------------------------------------ */
.vslide-cap {
  position: relative;
  padding: 20px 26px 22px;
  background: var(--navy-dark);
  color: #fff;
  border-top: 2px solid var(--teal);
}
.vslide-tag {
  display: inline-block;
  font-family: var(--font-mono, 'Space Mono'), monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--teal-light);
  margin-bottom: 8px;
}
.vslide-cap h3 {
  font-family: var(--font-display);
  font-size: clamp(21px, 2.4vw, 28px);
  line-height: 1.05;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  margin: 0 0 8px;
}
.vslide-cap h3 span { color: var(--teal-light); }
.vslide-cap p {
  font-size: 14px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.82);
  margin: 0;
  max-width: 76ch;
}
.vslide.js-ready .vslide-slide.is-active .vslide-cap > * {
  animation: vslideCapIn 520ms cubic-bezier(.22,.61,.36,1) both;
}
.vslide.js-ready .vslide-slide.is-active .vslide-cap > *:nth-child(1) { animation-delay: 80ms; }
.vslide.js-ready .vslide-slide.is-active .vslide-cap > *:nth-child(2) { animation-delay: 150ms; }
.vslide.js-ready .vslide-slide.is-active .vslide-cap > *:nth-child(3) { animation-delay: 215ms; }
@keyframes vslideCapIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* --- Counter, over the image -------------------------------------- */
.vslide-counter {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 3;
  font-family: var(--font-mono, 'Space Mono'), monospace;
  font-size: 11.5px;
  letter-spacing: 1.2px;
  color: #fff;
  background: rgba(0, 51, 89, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 5px 12px;
}
.vslide-counter .cur { color: var(--teal-light); font-weight: 700; }

/* --- Control bar: arrows, play/pause, thumbnails ------------------ */
.vslide-controls {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #00294a;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.vslide-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;       /* 44px minimum touch target */
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}
.vslide-btn:hover { background: var(--teal); border-color: var(--teal); }
.vslide-btn:focus-visible { outline: 3px solid var(--teal-light); outline-offset: 2px; }
.vslide-play .icon-pause { display: block; }
.vslide-play .icon-play  { display: none; }
.vslide.is-paused .vslide-play .icon-pause { display: none; }
.vslide.is-paused .vslide-play .icon-play  { display: block; }

.vslide-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding: 2px;
  margin-left: 4px;
}
.vslide-thumbs::-webkit-scrollbar { display: none; }
.vslide-thumb {
  flex: 0 0 auto;
  width: 96px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 5px;
  overflow: hidden;
  background: none;
  cursor: pointer;
  opacity: 0.5;
  scroll-snap-align: start;
  transition: opacity 200ms ease, border-color 200ms ease;
}
.vslide-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.vslide-thumb:hover { opacity: 0.85; }
.vslide-thumb[aria-selected="true"] {
  opacity: 1;
  border-color: var(--teal);
}
.vslide-thumb:focus-visible { outline: 3px solid var(--teal-light); outline-offset: 2px; }

/* --- Autoplay progress, across the top of the control bar --------- */
.vslide-progress {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.vslide-progress .bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--teal);
  transform: scaleX(0);
  transform-origin: left center;
}
.vslide-progress .bar.run {
  animation: vslideProgress var(--vslide-dur, 6500ms) linear both;
}
.vslide.is-paused .vslide-progress .bar { animation-play-state: paused; }
@keyframes vslideProgress {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* --- Hint line under the stage ------------------------------------ */
.vslide-note {
  font-size: 12px;
  color: var(--fg3);
  margin: 12px 0 0;
}

/* --- Responsive --------------------------------------------------- */
@media (max-width: 720px) {
  .vslide-cap { padding: 16px 18px 18px; }
  .vslide-cap p { font-size: 13.5px; }
  .vslide-controls { gap: 8px; padding: 10px; }
  .vslide-thumb { width: 74px; }
}

/* --- Reduced motion ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .vslide.js-ready .vslide-slide,
  .vslide.js-ready .vslide-slide.is-active { transition: none; }
  .vslide.js-ready .vslide-slide.is-active .vslide-img img { animation: none; }
  .vslide.js-ready .vslide-slide.is-active .vslide-cap > * { animation: none; }
  .vslide-progress .bar.run { animation: none; }
}
