/**
 * SOCIAL VIDEO SLIDER BLOCK
 *
 * Portrait-format (9:16) social media video carousel.
 * Relies on Swiper CSS (swiper.min.css) for core slider styles.
 * Design tokens match the rest of the site (WP preset CSS variables + brand palette).
 */

/* ── Section wrapper ──────────────────────────────────────────────────────── */
.srfx-social-video-slider {
  padding-block: var(--wp--preset--spacing--50, 3rem);
  overflow: hidden;
  /* Ensure full width when NOT inside a constrained layout */
  width: 100%;
  box-sizing: border-box;
}

/*
 * alignfull override:
 * The theme constrains content to contentSize (620px). Using width:100% gives only
 * 620px, so we use 100vw + the 50%/50vw centering trick to break fully out of the
 * constrained layout and span the true viewport width.
 */
.srfx-social-video-slider.alignfull {
  max-width: 100vw !important;
  width: 100vw !important;
  margin-left:  calc(50% - 50vw) !important;
  margin-right: calc(50% - 50vw) !important;
  box-sizing: border-box;
}

.srfx-social-video-slider.svs--bg-warm {
  background-color: #f5e6de;
}

.srfx-social-video-slider.svs--bg-light {
  background-color: var(--wp--preset--color--base-2, #f9f9f9);
}

/* ── Section header ───────────────────────────────────────────────────────── */
.svs__header {
  text-align: center;
  margin-bottom: var(--wp--preset--spacing--40, 2rem);
  max-width: 640px;
  margin-inline: auto;
}

.svs__title {
  font-family: var(--wp--preset--font-family--roboto, sans-serif);
  font-size: var(--wp--preset--font-size--x-large, 2rem);
  font-weight: 700;
  color: var(--wp--preset--color--contrast, #111);
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.svs__subtitle {
  font-size: var(--wp--preset--font-size--medium, 1rem);
  color: var(--wp--preset--color--contrast-2, #555);
  margin: 0;
  line-height: 1.6;
}

/* ── Carousel wrapper (contains Swiper + nav buttons) ─────────────────────── */
.svs__carousel-wrap {
  position: relative;
  /* No padding — Swiper is full width; nav buttons overlay the slides at the edges */
}

/*
 * Hide the carousel area until the IntersectionObserver fires and Swiper is
 * fully initialised + positioned. JS adds .svs--pending on DOMContentLoaded
 * and swaps it for .svs--ready after slideToLoop() completes.
 * This prevents a flash of raw, un-positioned slides.
 */
.js--social-video-slider.svs--pending {
  opacity: 0;
  pointer-events: none;
}
.js--social-video-slider.svs--ready {
  opacity: 1;
  transition: opacity 0.4s ease;
}

/* ── Swiper instance overrides ────────────────────────────────────────────── */
.svs__carousel-wrap .swiper {
  overflow: hidden;
  padding-block: 0.5rem;
}

.svs__carousel-wrap .swiper-wrapper {
  align-items: flex-start;
}

/*
 * srfx-theme.css applies padding-inline to ALL .swiper-slide at ≤575px as a
 * global site rule for text-based sliders. That breaks the video portrait
 * slides (shrinks the frame and creates a visual gap). Zero it out here with
 * enough specificity to win without !important.
 */
.js--social-video-slider .swiper-slide {
  padding-right: 0;
  padding-left: 0;
}

/* ── Individual slide ─────────────────────────────────────────────────────── */
.social-video-slide {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* ── Portrait frame (9:16) ────────────────────────────────────────────────── */
.social-video-slide__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 1rem;
  overflow: hidden;
  background-color: #111;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.18), 0 2px 6px -1px rgba(0, 0, 0, 0.12);
}

.social-video-slide__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 1rem;
}

/* ── Poster / placeholder image ───────────────────────────────────────────── */
.social-video-slide__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 1rem;
  display: block;
}

.social-video-slide__poster-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f5e6de 0%, #e8c9be 100%);
  border-radius: 1rem;
}

.social-video-slide__poster-placeholder .svs-platform-icon {
  width: 3rem;
  height: 3rem;
  opacity: 0.4;
  fill: var(--wp--preset--color--contrast, #111);
}

/* ── GDPR consent overlay ─────────────────────────────────────────────────── */
.social-video-slide__consent {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  border-radius: 1rem;
  overflow: hidden;
  /* Dark gradient from bottom so text is readable over the poster image */
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.82) 0%,
    rgba(0, 0, 0, 0.45) 40%,
    rgba(0, 0, 0, 0) 70%
  );
  z-index: 2;
}

.social-video-slide__consent-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem 1.5rem;
  text-align: center;
  width: 100%;
}

/* ── Platform badge (icon + label) ───────────────────────────────────────────*/
.social-video-slide__platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
}

.social-video-slide__platform-badge .svs-platform-icon {
  width: 1rem;
  height: 1rem;
  fill: white;
  flex-shrink: 0;
}

/* ── Consent copy ─────────────────────────────────────────────────────────── */
.social-video-slide__consent-text {
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.75);
  margin: 0;
  max-width: 220px;
}

.social-video-slide__consent-text strong {
  color: rgba(255, 255, 255, 0.95);
}

/* ── "Video laden" button ─────────────────────────────────────────────────── */
.social-video-slide__consent-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: 2rem;
  background-color: #fff;
  color: #111;
  font-family: var(--wp--preset--font-family--roboto, sans-serif);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.social-video-slide__consent-btn:hover {
  background-color: #f5e6de;
}

.social-video-slide__consent-btn:active {
  transform: scale(0.97);
}

/* ── Caption below the frame ──────────────────────────────────────────────── */
.social-video-slide__caption {
  font-size: 0.8125rem;
  color: var(--wp--preset--color--contrast-2, #555);
  text-align: center;
  margin: 0;
  line-height: 1.4;
  padding-inline: 0.25rem;
}

/* ── Navigation arrows ────────────────────────────────────────────────────── */
.social-video-slider__prev,
.social-video-slider__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  color: var(--wp--preset--color--contrast, #111);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.social-video-slider__prev:hover,
.social-video-slider__next:hover {
  background-color: #f5e6de;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.social-video-slider__prev {
  left: 0.5rem;
}

.social-video-slider__next {
  right: 0.5rem;
}

.social-video-slider__prev svg,
.social-video-slider__next svg {
  width: 1.125rem;
  height: 1.125rem;
  stroke: currentColor;
  display: block;
  flex-shrink: 0;
}

/* Hide arrows when Swiper marks them as disabled */
.social-video-slider__prev.swiper-button-disabled,
.social-video-slider__next.swiper-button-disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* ── Pagination dots ──────────────────────────────────────────────────────── */
.social-video-slider__pagination {
  display: flex;
  justify-content: center;
  gap: 0.375rem;
  margin-top: 1.25rem;
}

.social-video-slider__pagination .swiper-pagination-bullet {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: #c8a09a;
  opacity: 0.4;
  transition: opacity 0.2s ease, transform 0.2s ease;
  cursor: pointer;
  display: inline-block;
}

.social-video-slider__pagination .swiper-pagination-bullet-active {
  opacity: 1;
  transform: scale(1.3);
}

/* ── Platform icon SVG base styles ───────────────────────────────────────────*/
.svs-platform-icon {
  display: inline-block;
  vertical-align: middle;
  fill: currentColor;
}

/* ── Self-hosted local video (<video> tag) ────────────────────────────────── */
.social-video-slide__frame--local {
  background-color: #000;
}

.social-video-slide__local-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 1rem;
  display: block;
}

/* ── Empty block preview (editor only) ───────────────────────────────────────*/
.svs-empty-preview {
  padding: 2rem;
  border: 2px dashed #c8a09a;
  border-radius: 1rem;
  text-align: center;
  color: #c8a09a;
  font-style: italic;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 639px) {
  .social-video-slider__prev {
    left: 0.25rem;
  }

  .social-video-slider__next {
    right: 0.25rem;
  }

  .social-video-slider__prev,
  .social-video-slider__next {
    width: 2rem;
    height: 2rem;
  }

  .social-video-slider__prev svg,
  .social-video-slider__next svg {
    width: 1rem;
    height: 1rem;
  }

  .svs__title {
    font-size: var(--wp--preset--font-size--large, 1.5rem);
  }
}

@media (min-width: 1024px) {
  .social-video-slider__prev {
    left: 0.75rem;
  }

  .social-video-slider__next {
    right: 0.75rem;
  }
}

/* ── Expand (fullscreen) button on each slide ─────────────────────────────── */
.social-video-slide__expand {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  z-index: 3;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease, transform 0.15s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.social-video-slide__expand svg {
  width: 1rem;
  height: 1rem;
  display: block;
  flex-shrink: 0;
}

.social-video-slide__expand:hover {
  background: rgba(0, 0, 0, 0.78);
  transform: scale(1.1);
}

/* Show expand on hover of the frame (local videos always ready) */
.social-video-slide__frame--local:hover .social-video-slide__expand {
  opacity: 1;
}

/* Show expand on hover of activated embed slides */
.social-video-slide.svs-activated .social-video-slide__frame:hover .social-video-slide__expand {
  opacity: 1;
}

/* Pointer cursor on local video frames (entire area is clickable) */
.social-video-slide__frame--local {
  cursor: pointer;
}

/* ── Lightbox modal ───────────────────────────────────────────────────────── */
/* ── Scroll lock (applied to <html> while lightbox is open) ─────────────── */
/* overflow:hidden on <html> (not body) prevents scrolling on all browsers
   including iOS Safari without changing the page's scroll position —
   no position:fixed jump, no scroll restoration needed. */
html.svs-scroll-lock {
  overflow: hidden;
}

/* ── Lightbox overlay ────────────────────────────────────────────────────── */
.svs-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

.svs-lightbox.is-open {
  display: flex;
}

.svs-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Topbar: close button row ─────────────────────────────────────────────── */
.svs-lightbox__topbar {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 100%;
  display: flex;
  justify-content: flex-end;
  /* Push below the notch / status bar; extra right padding so the button
     never clips on rounded-corner devices */
  padding: max(0.625rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.375rem max(0.625rem, env(safe-area-inset-left));
}

/* ── Body: centers the video box ─────────────────────────────────────────── */
.svs-lightbox__body {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Video box: explicit width so aspect-ratio can derive the height ──────── */
.svs-lightbox__box {
  /* Width = the smaller of:
       a) full viewport width minus side breathing room, OR
       b) available viewport height (minus topbar + footer + safe areas) × 9/16
     This matches the original panel-width formula but now lives on the box itself.
     ~7rem = topbar (≈3.125rem) + footer (≈3.5rem) + small buffer              */
  width: min(
    calc(100vw - 1rem),
    calc((100dvh
      - max(0.625rem, env(safe-area-inset-top, 0rem))
      - max(0.5rem,   env(safe-area-inset-bottom, 0rem))
      - 7rem) * 9 / 16)
  );
  aspect-ratio: 9 / 16;
  flex-shrink: 0;
  position: relative;
  border-radius: 1.25rem;
  /* overflow: hidden intentionally omitted — iOS Safari compositing bug:
     overflow:hidden + border-radius on a <video> parent renders frames black. */
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
  background: #000;
}

.svs-lightbox__frame {
  position: absolute;
  inset: 0;
  /* No overflow:hidden here — same iOS black-frame compositing bug. */
}

.svs-lightbox__iframe,
.svs-lightbox__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.svs-lightbox__iframe {
  border-radius: 1.25rem;
  object-fit: cover;
}

.svs-lightbox__unsupported {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  color: #fff;
  background: #1a1a1a;
  border-radius: 1.25rem;
}

.svs-lightbox__unsupported p {
  margin: 0.25rem 0;
  font-size: 1rem;
  line-height: 1.5;
}

.svs-lightbox__unsupported small {
  font-size: 0.875rem;
  opacity: 0.75;
}

/* ── Footer: "View on …" link row ────────────────────────────────────────── */
.svs-lightbox__footer {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  /* Fixed height so the video body always knows how much space is available.
     Empty when there's no external link. */
  min-height: 3.25rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem max(0.5rem, env(safe-area-inset-bottom));
}

/* ── Close button ────────────────────────────────────────────────────────── */
.svs-lightbox__close {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
  padding: 0;
}

.svs-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.32);
  transform: scale(1.08);
}

.svs-lightbox__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.svs-lightbox__close svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  flex-shrink: 0;
}

/* ── "View on [Platform]" pill ───────────────────────────────────────────── */
.svs-lightbox__external {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.6rem 1.5rem;
  border-radius: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: var(--wp--preset--font-family--roboto, sans-serif);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.svs-lightbox__external:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.6);
  color: #fff;
}

.svs-lightbox__external:active {
  transform: scale(0.97);
}
