/*
 * WP Reels Story Module — Frontend Styles
 *
 * YouTube-Shorts / Instagram-Reels style carousel.
 * Matches the Stitch "Reels Ad Module — Desktop" reference design.
 * All rules scoped under .reels-wrapper to avoid collisions.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   0. Tokens
   ═══════════════════════════════════════════════════════════════════════════ */

.reels-wrapper {
  --reel-radius: 12px;
  --reel-gap: 24px;
  --reel-card-w: 280px;
  --reel-overlay-gradient: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.42) 0%,
    rgba(0, 0, 0, 0.2) 24%,
    rgba(0, 0, 0, 0.08) 40%,
    transparent 58%
  );
  --reel-accent: #a7a5ff;
  --reel-accent-dim: #645efb;
  --reel-accent-on: #000;
  --reel-surface: #141f38;
  --reel-surface-bright: #1f2b49;
  --reel-text-dim: #a3aac4;
  --reel-font:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ═══════════════════════════════════════════════════════════════════════════
   1. Wrapper
   ═══════════════════════════════════════════════════════════════════════════ */

.reels-wrapper {
  font-family: var(--reel-font);
  margin: 0 0 2.5em;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. Section Header — title + nav arrows
   ═══════════════════════════════════════════════════════════════════════════ */

.reels-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.reels-header__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--reel-text-dim);
}

.reels-header__icon {
  font-size: 16px;
  color: var(--reel-accent);
}

.reels-header__nav {
  display: flex;
  gap: 8px;
}

.reels-nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: var(--reel-accent);
  color: var(--reel-accent-on);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  padding: 0;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.reels-nav-btn:hover {
  background: var(--reel-accent-dim);
  color: #fff;
}

.reels-nav-btn:active {
  transform: scale(0.96);
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. Container — horizontal scroll, snap
   ═══════════════════════════════════════════════════════════════════════════ */

.reels-container {
  display: flex;
  gap: var(--reel-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 16px;
  cursor: grab;
  user-select: none;

  /* Hide scrollbar across browsers */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.reels-container::-webkit-scrollbar {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   4. Reel Card — 9:16 portrait
   ═══════════════════════════════════════════════════════════════════════════ */

.reel-card {
  position: relative;
  flex: 0 0 var(--reel-card-w);
  aspect-ratio: 9 / 16;
  border-radius: var(--reel-radius);
  overflow: hidden;
  background: #000;
  scroll-snap-align: start;
  cursor: pointer;
  transition:
    transform 0.3s,
    box-shadow 0.3s;
}

.reel-card:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* ── Media ─────────────────────────────────────────────────────────────── */

.reel-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   5. Overlay — gradient + text
   ═══════════════════════════════════════════════════════════════════════════ */

.reel-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--reel-overlay-gradient);
  pointer-events: none;
  z-index: 2;
}

/* ── Top bar: AD badge ─────────────────────────────────────────────────── */

.reel-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 16px 0;
}

.reel-ad-label {
  background: var(--reel-accent);
  color: var(--reel-accent-on);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 12px;
  border-radius: 9999px;
  pointer-events: none;
  line-height: 1;
}

/* Badge style modifiers */
.reel-ad-label--pill  { border-radius: 9999px; }
.reel-ad-label--square { border-radius: 4px; }
.reel-ad-label--soft  { border-radius: 8px; }

/* Info icon button */
.reel-info-btn {
  background: rgba(0, 0, 0, 0.35);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s, opacity 0.2s;
}

.reel-info-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.reel-info-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ── Bottom content ────────────────────────────────────────────────────── */

.reel-bottom {
  padding: 0 20px 24px;
  display: flex;
  flex-direction: column;
}

.reel-caption {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* CTA button — prominent */
.reel-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  border-radius: 9999px;
  background: var(--reel-accent);
  color: var(--reel-accent-on);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
  pointer-events: auto;
  transition:
    background 0.2s,
    transform 0.15s;
  box-shadow: 0 8px 24px rgba(167, 165, 255, 0.2);
}

/* CTA button style modifiers */
.reel-cta--solid {
  background: var(--reel-accent);
  color: var(--reel-accent-on);
  border: 2px solid transparent;
}
.reel-cta--outline {
  background: transparent;
  color: #fff;
  border: 2px solid var(--reel-accent);
  box-shadow: none;
}
.reel-cta--outline:hover {
  background: var(--reel-accent);
  color: var(--reel-accent-on);
}
.reel-cta--ghost {
  background: transparent;
  color: #fff;
  border: 2px solid transparent;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reel-cta--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.reel-cta:hover {
  background: var(--reel-accent-dim);
  transform: scale(1.02);
}

/* ═══════════════════════════════════════════════════════════════════════════
   6. Play / Pause toggle (video cards only)
   ═══════════════════════════════════════════════════════════════════════════ */

.reel-play-toggle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  background: rgba(0, 0, 0, 0.35);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s;
  padding: 0;
}

.reel-card:hover .reel-play-toggle {
  opacity: 1;
}

/* Show/hide the correct icon via state class set by JS */
.reel-card .reel-icon-pause {
  display: none;
}
.reel-card.is-playing .reel-icon-play {
  display: none;
}
.reel-card.is-playing .reel-icon-pause {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Progress Indicator — hidden on desktop
   ═══════════════════════════════════════════════════════════════════════════ */

.reels-progress {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile Nav Arrows — hidden on desktop
   ═══════════════════════════════════════════════════════════════════════════ */

.reels-mobile-nav {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   7. Mobile — horizontal full-width Stories with progress indicator
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  .reels-wrapper {
    margin-left: -16px;
    margin-right: -16px;
    position: relative;
  }

  /* Hide desktop header on mobile */
  .reels-header {
    display: none;
  }

  /* ── Progress indicator bars ───────────────────────────────────────── */
  .reels-progress {
    display: flex;
    gap: 4px;
    padding: 12px 12px 8px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
  }

  .reels-progress__bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
    overflow: visible;
    position: relative;
    cursor: pointer;
    border: none;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
  }

  .reels-progress__bar:focus,
  .reels-progress__bar:focus-visible,
  .reels-progress__bar:active {
    outline: none;
    box-shadow: none;
    border: none;
  }

  .reels-progress__fill {
    width: 0%;
    height: 100%;
    background: transparent;
    border-radius: 9999px;
    transition: width 0.3s ease;
  }

  .reels-progress__bar--active {
    background: var(--reel-accent);
    box-shadow:
      0 0 6px var(--reel-accent),
      0 0 14px rgba(167, 165, 255, 0.5);
  }

  .reels-progress__bar--done {
    background: rgba(255, 255, 255, 0.55);
  }

  /* ── Horizontal container — one card per screen ───────────────────── */
  .reels-container {
    gap: 0;
    padding: 0;
    scroll-snap-type: x mandatory;
    overflow-x: auto;
    overflow-y: hidden;
    cursor: auto;
    user-select: auto;
  }

  .reel-card {
    flex: 0 0 100%;
    width: 100%;
    aspect-ratio: 9 / 16;
    border-radius: 0;
    scroll-snap-align: start;
  }

  .reel-card:hover {
    transform: none;
    box-shadow: none;
  }

  /* AD badge — glassmorphism style on mobile */
  .reel-ad-label {
    background: rgba(25, 37, 64, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #dee5ff;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* Push top bar below progress indicator */
  .reel-top-bar {
    padding-top: 32px;
  }

  /* Enlarge touch target on progress container */
  .reels-progress {
    padding: 16px 12px 12px;
  }

  /* ── Mobile nav arrows — left & right edges, vertically centered ─── */
  .reels-mobile-nav {
    display: contents;
  }

  .reels-mobile-nav__btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: var(--reel-accent);
    color: var(--reel-accent-on);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    outline: none;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
    transition:
      background 0.2s,
      transform 0.15s;
  }

  .reels-mobile-nav__btn--prev {
    left: 8px;
  }

  .reels-mobile-nav__btn--next {
    right: 8px;
  }

  .reels-mobile-nav__btn:active {
    transform: translateY(-50%) scale(0.92);
    background: var(--reel-accent-dim);
    color: #fff;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   8. Larger desktop — wider cards
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 1200px) {
  .reels-wrapper {
    --reel-card-w: 300px;
  }
}
