/* ReelShop – Frontend Styles v1.0.1
   Mobile-first, vertical video feed (9:16 Reels / Shorts style)
   ================================================================ */

/* ── CSS Custom Properties ────────────────────────────────────────── */
:root {
  --rs-accent:        #e53935;
  --rs-accent-hover:  #c62828;
  --rs-overlay-bg:    linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.4) 50%, transparent 100%);
  --rs-text:          #ffffff;
  --rs-subtext:       rgba(255,255,255,.85);
  --rs-icon-size:     26px;
  --rs-action-size:   48px;
  --rs-radius:        16px;
  --rs-shadow:        0 8px 40px rgba(0,0,0,.35);
  --rs-transition:    .22s cubic-bezier(.4,0,.2,1);
  --rs-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Feed Wrapper ──────────────────────────────────────────────────── */
.rs-feed-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.rs-feed-container {
  position: relative;
  width: 100%;
  max-width: 390px;
  height: 700px;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-radius: var(--rs-radius);
  box-shadow: var(--rs-shadow);
  background: #000;
  /* REMOVED: isolation:isolate — was creating stacking context that
     prevented z-index from working correctly on action buttons */
}

.rs-feed-container::-webkit-scrollbar { display: none; }

/* ── Feed Track ─────────────────────────────────────────────────────── */
.rs-feed-track {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ── Reel Item ─────────────────────────────────────────────────────── */
.rs-reel-item {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 700px;      /* explicit height so it fills the container */
  min-height: 700px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #111;
  overflow: hidden;
  user-select: none;
}

/* ── Video ─────────────────────────────────────────────────────────── */
.rs-reel-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.rs-reel-no-video {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255,255,255,.3);
  font-size: 14px;
  font-family: var(--rs-font);
}

/* ── Tap overlay ───────────────────────────────────────────────────── */
/* CRITICAL FIX: pointer-events on the tap overlay must not block
   the action buttons (z-index 25). Tap overlay is z-index 5,
   action buttons are z-index 25, so they sit above it. */
.rs-tap-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  /* pointer-events:auto is correct here — buttons above it will intercept */
}

.rs-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 64px;
  height: 64px;
  background: rgba(0,0,0,.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  transition: transform .18s cubic-bezier(.34,1.56,.64,1), opacity .18s;
  opacity: 0;
  line-height: 1;
}

.rs-reel-item.is-paused .rs-play-icon {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* ── Overlay ───────────────────────────────────────────────────────── */
.rs-reel-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;              /* above tap overlay (5), below action buttons (25) */
  padding: 60px 16px 18px;  /* extra top padding so gradient extends higher */
  background: var(--rs-overlay-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;     /* let taps pass through gradient to video */
}

/* Re-enable pointer events only on interactive children */
.rs-reel-overlay .rs-buy-btn,
.rs-reel-overlay .rs-product-info { pointer-events: auto; }

/* ── Product Info ──────────────────────────────────────────────────── */
.rs-product-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: calc(100% - 70px); /* leave room for action buttons column */
}

.rs-product-name {
  margin: 0;
  padding: 0;
  font-family: var(--rs-font);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--rs-text);
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rs-product-desc {
  margin: 0;
  padding: 0;
  font-family: var(--rs-font);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--rs-subtext);
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Buy Now Button ────────────────────────────────────────────────── */
.rs-buy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 9px 18px;
  background: var(--rs-accent);
  color: #fff !important;
  font-family: var(--rs-font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  text-decoration: none !important;
  border-radius: 30px;
  border: none;
  cursor: pointer;
  outline: none;
  transition: transform var(--rs-transition), filter var(--rs-transition), box-shadow var(--rs-transition);
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 21;
}

.rs-buy-btn:hover,
.rs-buy-btn:focus-visible {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
}

.rs-buy-btn:active { transform: scale(.97); }

.rs-btn-arrow {
  flex-shrink: 0;
  transition: transform var(--rs-transition);
}

.rs-buy-btn:hover .rs-btn-arrow { transform: translateX(3px); }

/* ── Right Action Buttons ──────────────────────────────────────────── */
/* CRITICAL FIX: z-index 25 — above tap overlay (5) and overlay (20) */
.rs-actions {
  position: absolute;
  right: 10px;
  bottom: 100px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  pointer-events: auto; /* explicitly enable — parent overlay has pointer-events:none */
}

.rs-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.rs-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--rs-action-size);
  height: var(--rs-action-size);
  background: rgba(0,0,0,.45);   /* darker bg for better icon contrast */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255,255,255,.25);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--rs-transition), transform var(--rs-transition);
  -webkit-tap-highlight-color: transparent;
  /* Ensure minimum 44×44 touch target (Apple HIG) */
  min-width: 44px;
  min-height: 44px;
}

.rs-action-btn:hover,
.rs-action-btn:focus-visible {
  background: rgba(0,0,0,.65);
  transform: scale(1.08);
  border-color: rgba(255,255,255,.5);
}

.rs-action-btn:active { transform: scale(.92); }

/* ── SVG Icons ─────────────────────────────────────────────────────── */
/* CRITICAL FIX: ensure SVG strokes are visible.
   Force currentColor (inherits white from parent button) */
.rs-icon {
  width: var(--rs-icon-size);
  height: var(--rs-icon-size);
  display: block;
  flex-shrink: 0;
  pointer-events: none;
  stroke: currentColor;
  fill: none;
  overflow: visible;
}

/* Heart fill override for wishlisted state */
.rs-icon-heart { fill: none; stroke: #fff; }
.rs-wishlist-btn.is-wishlisted .rs-icon-heart {
  fill: #e53935;
  stroke: #e53935;
}

/* Cart and share inherit white from button */
.rs-icon-cart,
.rs-icon-share { stroke: #fff; }

/* Wishlist active state */
.rs-wishlist-btn.is-wishlisted {
  background: rgba(229,57,53,.3);
  border-color: rgba(229,57,53,.6);
}

.rs-wishlist-btn.is-wishlisted .rs-icon-heart {
  animation: rs-heartbeat .35s cubic-bezier(.34,1.56,.64,1);
}

@keyframes rs-heartbeat {
  0%   { transform: scale(1);    }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(.9);   }
  100% { transform: scale(1);    }
}

.rs-action-count {
  font-family: var(--rs-font);
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  line-height: 1;
  letter-spacing: .01em;
  min-height: 12px; /* reserve space even when empty */
}

/* Cart icon style */
.rs-cart-btn { background: rgba(0,0,0,.45); }

/* ── Mute Button ───────────────────────────────────────────────────── */
/* CRITICAL FIX: z-index 25, same layer as action buttons */
.rs-mute-btn {
  position: absolute;
  top: 14px;
  right: 12px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1.5px solid rgba(255,255,255,.25);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: background var(--rs-transition), transform var(--rs-transition);
  -webkit-tap-highlight-color: transparent;
}

.rs-mute-btn:hover { background: rgba(0,0,0,.7); transform: scale(1.05); }
.rs-mute-btn:active { transform: scale(.92); }

.rs-mute-btn .rs-icon-sound-on,
.rs-mute-btn .rs-icon-sound-off {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
}

.rs-mute-btn.is-muted .rs-icon-sound-on  { display: none; }
.rs-mute-btn.is-muted .rs-icon-sound-off { display: block !important; }

/* ── Progress Bar ──────────────────────────────────────────────────── */
.rs-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 22;
  height: 3px;
  background: rgba(255,255,255,.2);
  overflow: hidden;
  pointer-events: none;
}

.rs-progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width .1s linear;
  transform-origin: left;
}

/* ── Watermark ─────────────────────────────────────────────────────── */
/* Default hidden; the PHP-injected <style> tag overrides this */
.rs-watermark {
  display: none;
}

/* When enabled, PHP injects a <style> that overrides the above.
   These properties ensure it always renders correctly in the feed. */
.rs-reel-item .rs-watermark[src] {
  pointer-events: none;
  z-index: 18;
}

/* ── Loader ────────────────────────────────────────────────────────── */
.rs-loader {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: transparent;
}

.rs-loader.is-loading { display: flex; }

.rs-loader-ring {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rs-spin .75s linear infinite;
}

@keyframes rs-spin { to { transform: rotate(360deg); } }

/* ── End of Feed ───────────────────────────────────────────────────── */
.rs-end-of-feed {
  text-align: center;
  padding: 20px;
  color: rgba(255,255,255,.5);
  font-family: var(--rs-font);
  font-size: 13px;
  background: #000;
}

/* ── Empty State ───────────────────────────────────────────────────── */
.rs-empty-feed {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 700px;
  color: rgba(255,255,255,.4);
  font-family: var(--rs-font);
  font-size: 14px;
  text-align: center;
  padding: 24px;
  background: #111;
}

/* ── Elementor Editor Placeholder ─────────────────────────────────── */
.rs-feed-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  gap: 12px;
  color: rgba(255,255,255,.4);
  font-family: var(--rs-font);
  text-align: center;
  padding: 24px;
  background: #111;
}

.rs-feed-placeholder svg { opacity: .5; }
.rs-feed-placeholder p { font-size: 15px; font-weight: 600; margin: 0; color: rgba(255,255,255,.6); }
.rs-feed-placeholder span { font-size: 12px; }

/* ── Share Modal ───────────────────────────────────────────────────── */
.rs-share-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;  /* above everything including WP admin bar */
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: rs-fade-in .2s ease;
}

@keyframes rs-fade-in { from { opacity: 0; } to { opacity: 1; } }

.rs-share-modal {
  background: #1a1a1a;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 8px 0 max(24px, env(safe-area-inset-bottom));
  animation: rs-slide-up .25s cubic-bezier(.4,0,.2,1);
}

@keyframes rs-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

.rs-share-modal-handle {
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,.2);
  border-radius: 2px;
  margin: 10px auto 16px;
}

.rs-share-modal h4 {
  margin: 0 0 12px;
  padding: 0 20px;
  font-family: var(--rs-font);
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,.6);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.rs-share-options {
  display: flex;
  padding: 0 16px;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.rs-share-options::-webkit-scrollbar { display: none; }

.rs-share-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 64px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: 12px;
  transition: background var(--rs-transition);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.rs-share-option:hover { background: rgba(255,255,255,.08); }

.rs-share-option-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.rs-share-option-label {
  font-family: var(--rs-font);
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
}

.rs-share-modal-close {
  display: block;
  width: calc(100% - 32px);
  margin: 16px 16px 0;
  padding: 14px;
  background: rgba(255,255,255,.1);
  border: none;
  border-radius: 12px;
  font-family: var(--rs-font);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: background var(--rs-transition);
  -webkit-tap-highlight-color: transparent;
}

.rs-share-modal-close:hover { background: rgba(255,255,255,.15); }

/* ── Stock Alert Form ──────────────────────────────────────────────── */
.rs-stock-alert-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 26;
  background: rgba(0,0,0,.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 14px 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: none;
}

.rs-stock-alert-inner p {
  margin: 0 0 8px;
  font-family: var(--rs-font);
  font-size: 13px;
  color: rgba(255,255,255,.8);
}

.rs-stock-alert-form {
  display: flex;
  gap: 8px;
}

.rs-stock-email {
  flex: 1;
  padding: 9px 12px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  color: #fff;
  font-family: var(--rs-font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--rs-transition);
}

.rs-stock-email:focus { border-color: rgba(255,255,255,.5); }
.rs-stock-email::placeholder { color: rgba(255,255,255,.4); }

.rs-stock-submit {
  padding: 9px 16px;
  background: var(--rs-accent);
  color: #fff;
  font-family: var(--rs-font);
  font-size: 12px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter var(--rs-transition);
  -webkit-tap-highlight-color: transparent;
}

.rs-stock-submit:hover { filter: brightness(1.1); }

/* ── Category Tabs ─────────────────────────────────────────────────── */
.rs-category-tabs {
  display: flex;
  gap: 8px;
  padding: 0 4px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  align-items: center;
}

.rs-category-tabs::-webkit-scrollbar { display: none; }

.rs-cat-tab {
  flex: 0 0 auto;
  padding: 7px 18px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1.5px solid rgba(255,255,255,.18);
  border-radius: 30px;
  color: rgba(255,255,255,.75);
  font-family: var(--rs-font);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--rs-transition), border-color var(--rs-transition), color var(--rs-transition);
  -webkit-tap-highlight-color: transparent;
}

.rs-cat-tab:hover { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.35); }

.rs-cat-tab.is-active {
  background: var(--rs-accent);
  border-color: var(--rs-accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(229,57,53,.45);
}

.rs-cat-tab.is-loading { opacity: .6; pointer-events: none; }

/* Reel fade-in after category switch */
@keyframes rs-reel-fadein {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rs-reel-item.rs-animate-in {
  animation: rs-reel-fadein .28s cubic-bezier(.4,0,.2,1) both;
}

/* ── Accessibility ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .rs-feed-container {
    max-width: 100% !important;
    border-radius: 0 !important;
    height: 100svh !important; /* use small viewport height on mobile */
  }
  .rs-reel-item {
    height: 100svh !important;
    min-height: 100svh !important;
  }
  .rs-empty-feed { height: 100svh; }
}

/* Safe area support for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .rs-reel-overlay {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

/* ── Product name clickable hint (feed view) ───────────────────────── */
.rs-product-name {
    cursor: pointer;
    text-decoration: none;
}

.rs-product-name:hover {
    text-decoration: underline;
    text-decoration-color: rgba(255,255,255,.5);
    text-underline-offset: 3px;
}

/* ── Single reel: make overlay sit higher so nav is visible ─────────── */
.rs-feed-container[data-single] .rs-reel-overlay {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* ── Double-tap hint tooltip ───────────────────────────────────────── */
.rs-double-tap-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(.8);
    z-index: 30;
    background: rgba(0,0,0,.7);
    color: #fff;
    font-family: var(--rs-font);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.rs-reel-item.show-hint .rs-double-tap-hint {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
