/*
 * YouTube Shorts Slider - Front-end styles
 * Version: 1.6.0
 */

.ytss-slider {
  --ytss-gap: 24px;
  --ytss-slide-width: 30%;
  --ytss-radius: 4px;
  --ytss-max-height: 78vh; /* slides never grow taller than this */

  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 24px 4%;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  outline: none;
  /* Horizontal gestures belong to the slider; vertical stays native page scroll. */
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

/* Transparent layer above each iframe so touches/clicks reach the slider
   instead of being swallowed by YouTube's embed. Sits below the unmute
   button and nav arrows (z-index 12) and the status icon (z-index 8). */
.ytss-touch {
  position: absolute;
  inset: 0;
  z-index: 4;
}

/* When YouTube's own controls are enabled, keep the gesture layer clear
   of the bottom control bar so the scrubber stays usable. */
.ytss-slider[data-controls="1"] .ytss-touch {
  bottom: 46px;
}

/* Center status icon: play when paused, replay when the video has ended. */
.ytss-status-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease, transform 200ms ease;
  backdrop-filter: blur(4px);
}

.ytss-slide.is-active.is-paused .ytss-status-icon,
.ytss-slide.is-active.is-ended .ytss-status-icon {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.ytss-status-icon svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

.ytss-status-play,
.ytss-status-replay {
  display: none;
  line-height: 0;
}

.ytss-slide.is-paused:not(.is-ended) .ytss-status-play {
  display: block;
}

.ytss-slide.is-ended .ytss-status-replay {
  display: block;
}

.ytss-viewport {
  width: 100%;
  overflow: hidden;
}

.ytss-track {
  display: flex;
  align-items: center;
  gap: var(--ytss-gap);
  margin: 0;
  padding: 0;
  list-style: none;
  transition: transform 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.ytss-slide {
  /* Cap slide width so a 9:16 slide never exceeds --ytss-max-height tall. */
  flex: 0 0 min(var(--ytss-slide-width), calc(var(--ytss-max-height) * 9 / 16));
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: var(--ytss-radius);
  overflow: hidden;
  background: #000;
  opacity: 0.55;
  filter: brightness(0.92);
  cursor: pointer;
  transition: opacity 420ms ease, filter 420ms ease;
  box-sizing: border-box;
}

.ytss-slide.is-active {
  opacity: 1;
  filter: none;
  z-index: 2;
  cursor: default;
}

.ytss-slide iframe {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: inherit;
}

/*
 * Thumbnails: the portrait oar2.jpg fills the 9:16 frame naturally.
 * When the JS falls back to a landscape hqdefault.jpg, contain it
 * instead of cropping two-thirds of it away.
 */
.ytss-slide .ytss-thumb {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: inherit;
  object-fit: cover;
}

.ytss-slide .ytss-thumb.is-landscape-fallback {
  object-fit: contain;
  background: #000;
}

.ytss-slider[data-fit="contain"] .ytss-slide .ytss-thumb.is-landscape-fallback {
  object-fit: contain;
}

.ytss-slider[data-fit="cover"] .ytss-slide .ytss-thumb {
  object-fit: cover;
}

/* Prev / next arrows */
.ytss-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12;
  transition: background 200ms ease, transform 200ms ease, opacity 200ms ease;
  backdrop-filter: blur(4px);
}

.ytss-nav:hover,
.ytss-nav:focus-visible {
  background: rgba(0, 0, 0, 0.8);
  transform: translateY(-50%) scale(1.06);
}

.ytss-nav[disabled] {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.ytss-nav svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  pointer-events: none;
}

.ytss-nav--prev {
  left: 12px;
}

.ytss-nav--next {
  right: 12px;
}

.ytss-unmute {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12;
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 220ms ease, transform 220ms ease;
  backdrop-filter: blur(4px);
}

.ytss-slide.is-active .ytss-unmute {
  opacity: 1;
  visibility: visible;
}

/* Nudge the mute button above YouTube's control bar when it is shown. */
.ytss-slider[data-controls="1"] .ytss-unmute {
  bottom: 54px;
}

.ytss-unmute.is-unmuted {
  background: rgba(0, 0, 0, 0.5);
}

.ytss-unmute:hover,
.ytss-unmute:focus {
  transform: scale(1.08);
  background: rgba(0, 0, 0, 0.85);
}

.ytss-unmute svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  pointer-events: none;
}

.ytss-error {
  padding: 18px 22px;
  background: #fff0f0;
  border-left: 4px solid #d93025;
  color: #5f1818;
  border-radius: 4px;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.5;
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .ytss-track,
  .ytss-slide,
  .ytss-nav,
  .ytss-unmute {
    transition: none;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .ytss-slider {
    --ytss-slide-width: 42%;
    --ytss-gap: 16px;
    padding: 18px 3%;
  }

  .ytss-nav {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 480px) {
  .ytss-slider {
    --ytss-slide-width: 58%;
    --ytss-gap: 12px;
    padding: 14px 2%;
  }

  /* Arrows get in the way on small screens; swipe works instead */
  .ytss-nav {
    display: none;
  }
}
