/* ==========================================================================
   WP Stories – Frontend Styles
   Version: 1.0
   Author:  Alejandro Pantoja Malatesta / seekingdog.com
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  --wps-circle-size:  72px;
  --wps-ring-start:   #f09433;
  --wps-ring-end:     #c13584;
  --wps-ring-width:   3px;
  --wps-ring-gap:     2px;
  --wps-firefox-scrollbar-width: thin;
  --wps-scrollbar-display: block;
}

/* --------------------------------------------------------------------------
   Stories Row
   -------------------------------------------------------------------------- */
.wps-stories-widget { width: 100%; }

.wps-stories-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 16px;
  overflow-x: auto;
  overflow-y: visible;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: var(--wps-firefox-scrollbar-width, thin);
  scrollbar-color: rgba(255,255,255,0.34) transparent;
  background: #1a1a1a;
  padding: 12px 16px 14px;
  box-sizing: border-box;
}
.wps-stories-row::-webkit-scrollbar {
  display: var(--wps-scrollbar-display, block);
  height: 6px;
}
.wps-stories-row::-webkit-scrollbar-track {
  background: transparent;
}
.wps-stories-row::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.28);
  border-radius: 999px;
}
.wps-stories-row::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.42);
}

/* --------------------------------------------------------------------------
   Story Circle Button – hard theme resets
   -------------------------------------------------------------------------- */
.wps-story-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  width: calc(
    var(--wps-circle-size) +
    var(--wps-ring-width) +
    var(--wps-ring-width) +
    var(--wps-ring-gap) +
    var(--wps-ring-gap) +
    24px
  );
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0;
  cursor: pointer;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.wps-story-circle:hover,
.wps-story-circle:focus,
.wps-story-circle:active {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none;
}
.wps-story-circle:focus-visible .wps-ring-wrap {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
.wps-story-circle.wps-no-slides { opacity: 0.45; cursor: default; }

/* Ring wrap */
.wps-ring-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(
    var(--wps-circle-size) +
    var(--wps-ring-width) +
    var(--wps-ring-width) +
    var(--wps-ring-gap) +
    var(--wps-ring-gap)
  );
  height: calc(
    var(--wps-circle-size) +
    var(--wps-ring-width) +
    var(--wps-ring-width) +
    var(--wps-ring-gap) +
    var(--wps-ring-gap)
  );
  border-radius: 50%;
  background: linear-gradient( 45deg, var(--wps-ring-start), var(--wps-ring-end) );
  padding: var(--wps-ring-width);
  box-sizing: border-box;
  transition: transform 0.18s ease;
}
.wps-story-circle:hover .wps-ring-wrap,
.wps-story-circle:active .wps-ring-wrap { transform: scale(1.07); }
.wps-ring-wrap::before {
  content: '';
  position: absolute;
  inset: var(--wps-ring-width);
  border-radius: 50%;
  background: #1a1a1a;
  pointer-events: none;
}

/* Avatar */
.wps-avatar {
  position: relative;
  width:  var(--wps-circle-size);
  height: var(--wps-circle-size);
  border-radius: 50%;
  overflow: hidden;
  z-index: 1;
  background: #333;
}
.wps-avatar img {
  width: 100%; height: 100%;
  display: block;
  pointer-events: none; user-select: none; -webkit-user-drag: none;
  /* border-radius is intentionally NOT set here — the parent's overflow:hidden
     + border-radius:50% handles the circular crop without sub-pixel artifacts. */
  object-fit: cover !important;
  object-position: var(--wps-av-x, 50%) var(--wps-av-y, 50%);
}
.wps-avatar-placeholder {
  display: block; width: 100%; height: 100%;
  background: #555; border-radius: 50%;
}

/* Username label */
.wps-story-label {
  display: -webkit-box;
  color: #fff;
  font-size: 11px; line-height: 1.25; text-align: center;
  width: 100%;
  max-width: 100%;
  min-height: 2.5em;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 0; padding: 0; font-weight: 400;
  pointer-events: none;
  background: transparent !important;
}

/* Seen ring */
.wps-story-circle.wps-seen .wps-ring-wrap {
  background: linear-gradient(45deg, #888, #666);
}

/* --------------------------------------------------------------------------
   Viewer Overlay
   -------------------------------------------------------------------------- */
.wps-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.wps-viewer-overlay.wps-visible {
  opacity: 1;
  pointer-events: all;
}

/* --------------------------------------------------------------------------
   Viewer Inner – flex row
   -------------------------------------------------------------------------- */
.wps-viewer-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  height: 100%;
  padding: 0;
  box-sizing: border-box;
}

/* Full-screen mobile stage and 3D cube container. */
.wps-cube-stage {
  --wps-cube-depth: 50vw;
  position: relative;
  width: 100vw;
  height: 100dvh;
  flex: 0 0 auto;
  perspective: 1200px;
  transform: scale(0.98);
  transition: transform 0.22s ease;
}
.wps-viewer-overlay.wps-visible .wps-cube-stage { transform: scale(1); }
.wps-cube-rotator {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: translateZ(calc(var(--wps-cube-depth) * -1));
  transition: transform 0.52s cubic-bezier(.65,0,.2,1);
}
.wps-cube-rotator.wps-cube-turn-left {
  transform: translateZ(calc(var(--wps-cube-depth) * -1)) rotateY(-90deg);
}
.wps-cube-rotator.wps-cube-turn-right {
  transform: translateZ(calc(var(--wps-cube-depth) * -1)) rotateY(90deg);
}
.wps-cube-rotator.wps-cube-reset { transition: none !important; }

/* --------------------------------------------------------------------------
   Story Viewport
   -------------------------------------------------------------------------- */
.wps-story-viewport,
.wps-cube-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  border-radius: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.wps-story-viewport { transform: rotateY(0deg) translateZ(var(--wps-cube-depth)); }
.wps-cube-face-right { transform: rotateY(90deg) translateZ(var(--wps-cube-depth)); }
.wps-cube-face-left { transform: rotateY(-90deg) translateZ(var(--wps-cube-depth)); }
.wps-cube-face-image {
  width: 100%; height: 100%; display: block;
  object-position: center; background: #111;
}
.wps-cube-face-progress,
.wps-cube-face-header { z-index: 3; }

@media (min-width: 640px) {
  .wps-viewer-inner { padding: 0 12px; }
  .wps-cube-stage {
    --wps-cube-depth: calc(min(390px, 100vw) / 2);
    width: min(390px, 100vw);
    height: min(692px, 100dvh);
  }
  .wps-story-viewport,
  .wps-cube-face { border-radius: 14px; }
}

/* --------------------------------------------------------------------------
   Side Previews (desktop)
   -------------------------------------------------------------------------- */
.wps-side-preview {
  flex-shrink: 0;
  width: 130px;
  height: 230px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: #1a1a1a;
  opacity: 0.55;
  transform: scale(0.94);
  transition: opacity 0.2s, transform 0.2s;
  display: none;
}
.wps-side-preview:hover { opacity: 0.8; transform: scale(0.97); }
@media (min-width: 860px)  { .wps-side-preview { display: block; } }
@media (min-width: 1100px) { .wps-side-preview { width: 160px; height: 284px; } }

.wps-side-preview > img {
  width: 100%; height: 100%; object-fit: cover; object-position: center center; display: block;
}
.wps-side-preview-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 28px 8px 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
  display: flex; align-items: flex-end; gap: 6px;
}
.wps-side-preview-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.7); background: #333;
}
.wps-side-preview-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center center; display: block; }
.wps-side-preview-name {
  color: #fff; font-size: 11px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6); line-height: 1.2;
}

/* --------------------------------------------------------------------------
   Story Images
   -------------------------------------------------------------------------- */
.wps-story-image {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 1;
}
.wps-story-image.wps-active { opacity: 1; pointer-events: all; }
.wps-story-image img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center center;
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}

/* --------------------------------------------------------------------------
   Link Button – Wallapop/Instagram style (white pill, dark text + icon)
   All colour/size values are overridden by inline styles from JS config.
   -------------------------------------------------------------------------- */
.wps-link-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;           /* above tap zones (z-5) */

  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;

  /* Default: white pill with dark text (Wallapop look) */
  bottom: 15%;
  color: #1a1a1a;
  background: #ffffff;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 22px;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);

  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.wps-link-btn:hover  { opacity: 0.88; box-shadow: 0 4px 18px rgba(0,0,0,0.25); }
.wps-link-btn:active { opacity: 0.72; }
.wps-link-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Icon wrapper */
.wps-link-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.15em;
  height: 1.15em;
}
.wps-link-btn-icon svg,
.wps-link-icon {
  width: 1.15em; height: 1.15em;
  display: block;
  vertical-align: middle;
}
/* For class-based icons (Font Awesome, Eicons) */
.wps-link-btn .wps-link-icon {
  font-size: inherit;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Text Overlay
   -------------------------------------------------------------------------- */
.wps-text-overlay {
  position: absolute;
  z-index: 6;           /* above image, pointer-events none → taps pass through */
  pointer-events: none;

  /* Defaults (overridden by inline styles from config) */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  color: #fff;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
  padding: 12px 16px;
  border-radius: 8px;
  box-sizing: border-box;
  word-break: break-word;
}
/* Allow links and interactive elements inside text overlay */
.wps-text-overlay a {
  pointer-events: all;
  color: inherit;
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Progress Bar
   -------------------------------------------------------------------------- */
.wps-progress-bar {
  position: absolute;
  top: 10px; left: 8px; right: 8px;
  display: flex; gap: 3px;
  z-index: 10;
}
.wps-progress-segment {
  flex: 1; height: 2px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden; position: relative;
}
.wps-progress-fill {
  position: absolute; top: 0; left: 0;
  height: 100%; width: 0%;
  background: #fff; border-radius: 2px;
}
.wps-progress-fill.wps-done { width: 100%; transition: none; }

/* --------------------------------------------------------------------------
   Story Header
   -------------------------------------------------------------------------- */
.wps-story-header {
  position: absolute;
  top: 22px; left: 10px; right: 50px;
  display: flex; align-items: center; gap: 10px;
  z-index: 10; pointer-events: none;
}
.wps-story-header-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  overflow: hidden; border: 1.5px solid rgba(255,255,255,0.7);
  flex-shrink: 0; background: #333;
}
.wps-story-header-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center center; display: block; }
.wps-story-header-name {
  color: #fff; font-size: 13px; font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Close Button
   -------------------------------------------------------------------------- */
.wps-close-btn {
  position: absolute !important;
  top: 12px; right: 12px;
  z-index: 20;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
  width: 32px !important; height: 32px !important;
  min-width: 32px !important; max-width: 32px !important;
  min-height: 32px !important; max-height: 32px !important;
  aspect-ratio: 1 / 1;
  padding: 0 !important; line-height: 0 !important;
  border-radius: 999px !important;
  background: rgba(0,0,0,0.32) !important;
  border: none !important;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  display: flex !important; align-items: center !important; justify-content: center !important;
  font-size: 0 !important;
  text-align: center !important;
  text-indent: 0 !important;
  -webkit-appearance: none; appearance: none;
}
.wps-close-btn:hover, .wps-close-btn:focus, .wps-close-btn:active {
  background: rgba(0,0,0,0.55) !important; outline: none;
}
.wps-viewer-overlay .wps-close-btn svg {
  width: 22px !important; height: 22px !important; display: block !important;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

/* --------------------------------------------------------------------------
   Desktop Nav Arrows
   -------------------------------------------------------------------------- */
.wps-nav-btn {
  flex-shrink: 0;
  z-index: 20;
  background: rgba(26,26,26,0.78) !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 999px !important;
  width: 48px !important; height: 48px !important;
  min-width: 48px !important; max-width: 48px !important;
  min-height: 48px !important; max-height: 48px !important;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  display: none !important;
  align-items: center !important; justify-content: center !important;
  color: #fff;
  font-size: 0 !important;
  text-align: center !important;
  text-indent: 0 !important;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none; appearance: none;
  padding: 0 !important;
}
.wps-nav-btn:hover  { background: rgba(55,55,55,0.96) !important; border: none !important; }
.wps-nav-btn:focus,
.wps-nav-btn:active { background: rgba(26,26,26,0.78) !important; outline: none; }
.wps-viewer-overlay .wps-nav-btn svg { width: 25px !important; height: 25px !important; }

/* Prevent Elementor/themes from shifting the icons inside their circles. */
.wps-viewer-overlay .wps-close-btn svg,
.wps-viewer-overlay .wps-nav-btn svg {
  position: static !important;
  inset: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  translate: none !important;
  flex: 0 0 auto !important;
  vertical-align: middle !important;
  box-sizing: content-box !important;
  line-height: 1 !important;
}

/* Higher specificity than common `.elementor button` rules. */
.wps-viewer-overlay .wps-close-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}
.wps-viewer-overlay .wps-nav-btn {
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}
@media (min-width: 640px) { .wps-viewer-overlay .wps-nav-btn { display: flex !important; } }

/* --------------------------------------------------------------------------
   Tap Zones – completely invisible (hard theme reset)
   -------------------------------------------------------------------------- */
.wps-tap-prev,
.wps-tap-next {
  position: absolute !important;
  top: 0 !important; bottom: 0 !important;
  z-index: 5;
  cursor: pointer;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important; margin: 0 !important;
  color: transparent !important;
  -webkit-appearance: none !important; appearance: none !important;
  -webkit-tap-highlight-color: transparent;
}
.wps-tap-prev:hover, .wps-tap-prev:focus, .wps-tap-prev:active,
.wps-tap-next:hover, .wps-tap-next:focus, .wps-tap-next:active {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important; box-shadow: none !important; outline: none !important;
}
.wps-tap-prev { left: 0;  width: 35% !important; }
.wps-tap-next { right: 0; width: 65% !important; }

@media (min-width: 640px) {
  /* Keep the desktop close control just outside the story instead of over it. */
  .wps-close-btn {
    top: calc(50% - min(346px, 50dvh) + 2px);
    right: auto;
    left: calc(50% + min(195px, 50vw) + 14px);
    width: 44px !important; height: 44px !important;
    min-width: 44px !important; max-width: 44px !important;
    min-height: 44px !important; max-height: 44px !important;
    background: rgba(0,0,0,0.38) !important;
    border: 1px solid rgba(255,255,255,0.72) !important;
  }
  .wps-close-btn:hover, .wps-close-btn:focus, .wps-close-btn:active { border: 1px solid #fff !important; }
  .wps-viewer-overlay .wps-close-btn svg { width: 25px !important; height: 25px !important; }
}

/* Swipe-to-close drag */
.wps-story-viewport.wps-dragging { transition: none !important; }

/* --------------------------------------------------------------------------
   Body lock
   -------------------------------------------------------------------------- */
body.wps-open { overflow: hidden; touch-action: none; }

/* --------------------------------------------------------------------------
   Elementor Editor Preview Mode
   – Full-screen overlay inside the iframe, same as frontend.
     The Elementor panel sidebar is outside the iframe so it is never covered.
     Side previews and nav arrows are hidden to keep it compact.
   -------------------------------------------------------------------------- */
.wps-viewer-overlay.wps-edit-mode .wps-side-preview,
.wps-viewer-overlay.wps-edit-mode .wps-nav-btn {
  display: none !important;
}
