/* Story Carousel - Filmstrip Layout */

.story-carousel {
  position: relative;
  width: 100%;
  margin-bottom: 1.75rem; /* Space for controls below */
  /* River inset effect - depressed into the page */
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.03) 0px,
    rgba(0, 0, 0, 0.01) 4px,
    transparent 8px,
    transparent calc(100% - 8px),
    rgba(255, 255, 255, 0.5) calc(100% - 4px),
    rgba(255, 255, 255, 0.3) 100%
  );
}

/* Full-bleed when inside content area (e.g., blog posts)
   Must break out of both receipt__content (9px/15px) AND recipe-detail (16px/16px) padding */
.story-block .story-carousel,
.recipe-detail .story-carousel {
  width: calc(100% + var(--margin-left) + var(--margin-right) + var(--spacing-md) + var(--spacing-md));
  margin-left: calc(-1 * (var(--margin-left) + var(--spacing-md)));
  margin-right: calc(-1 * (var(--margin-right) + var(--spacing-md)));
}

/* Controls Group - Bottom Right */
.story-carousel__controls {
  position: absolute;
  bottom: -1.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: lowercase;
}

.story-carousel__nav,
.story-carousel__expand {
  background: none;
  border: none;
  color: #000;
  cursor: pointer;
  padding: 0.25rem 0;
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
}

.story-carousel__nav:hover,
.story-carousel__expand:hover {
  text-decoration: underline;
}

.story-carousel__nav:disabled {
  opacity: 0.3;
  cursor: default;
  text-decoration: none;
}

/* Scrollable Strip */
.story-carousel__strip {
  display: flex;
  justify-content: safe center;
  gap: 1rem;
  height: 300px;
  margin: 1rem 0; /* Match horizontal gap between videos */
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.story-carousel__strip::-webkit-scrollbar { display: none; }

/* Media Cards */
.story-carousel__card {
  flex-shrink: 0;
  height: 100%;
  position: relative;
  scroll-snap-align: start;
  cursor: pointer;
  overflow: hidden;
  background: #000;
}
.story-carousel__card--image {
  cursor: default;
}

.story-carousel__thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-carousel__player {
  /* Fill container completely (matches thumbnail positioning) */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  --controls: none;
  /* Keep player in layout to prevent size flicker on play */
  visibility: hidden;
}
.story-carousel__card--playing .story-carousel__player,
.story-carousel__card--paused .story-carousel__player {
  visibility: visible;
}
.story-carousel__card--playing .story-carousel__thumb,
.story-carousel__card--paused .story-carousel__thumb {
  visibility: hidden;
}

/* Duration Badge */
.story-carousel__duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 5;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 3px;
  pointer-events: none;
  user-select: none;
}
.story-carousel__card--playing .story-carousel__duration,
.story-carousel__card--paused .story-carousel__duration {
  display: none;
}
@media (max-width: 480px) {
  .story-carousel__duration {
    font-size: 9px;
    padding: 2px 5px;
    bottom: 6px;
    right: 6px;
  }
}

/* Progress Bar */
.story-carousel__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  opacity: 0;
}
.story-carousel__card--playing .story-carousel__progress,
.story-carousel__card--paused .story-carousel__progress { opacity: 1; }

.story-carousel__progress-fill {
  height: 100%;
  width: 0%;
  background: white;
}

@media (prefers-reduced-motion: reduce) {
  .story-carousel__strip { scroll-behavior: auto; }
}

/* Loading State */
.story-carousel__card--loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: white;
  border-radius: 50%;
  z-index: 10;
  animation: carousel-spinner 0.7s linear infinite;
}

.story-carousel__card--loading .story-carousel__thumb {
  opacity: 0.5;
}

@keyframes carousel-spinner {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .story-carousel__card--loading::after { animation: none; }
}
