/* ==========================================================================
   ELEGANT E-COMMERCE STORIES TRAY & VIEWER
   Design: Borderless Canvas, Brand-Adaptive Rings, Vazirmatn Typography
   ========================================================================== */

/* Tray Wrapper & Canvas */
.story-tray-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
}

/* Horizontal Scroll Container */
.story-tray-container {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  width: 100%;
  padding: 4px 2px;
}

.story-tray-container::-webkit-scrollbar {
  display: none;
}

/* Story Bubble Item */
.story-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  scroll-snap-align: start;
  text-decoration: none;
  width: 68px;
  outline: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 768px) {
  .story-bubble {
    width: 76px;
    gap: 7px;
  }
}

.story-bubble:hover {
  transform: translateY(-2px);
}

.story-bubble:active {
  transform: scale(0.95);
}

/* Story Ring Base */
.story-ring {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  /* Mehgis luxury rose-gold dual-ring */
  background: linear-gradient(135deg, #f43f5e 0%, #fb7185 50%, #fda4af 100%);
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.22);
  transition: all 0.3s ease;
}

@media (min-width: 768px) {
  .story-ring {
    width: 68px;
    height: 68px;
  }
}

/* Avashop Theme (Indigo/Violet/Rose Luxury Theme) */
.theme-avashop .story-ring {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}

/* Muted Seen State */
.story-bubble.seen .story-ring {
  background: #cbd5e1;
  box-shadow: none;
}

.story-avatar-wrap {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ffffff;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.story-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  transition: opacity 0.25s ease;
}

.story-bubble.seen .story-avatar {
  opacity: 0.85;
}

/* Floating Micro-Badge */
.story-badge {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #e11d48, #f43f5e);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 9999px;
  border: 1.5px solid #ffffff;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  line-height: 1.3;
}

.theme-avashop .story-badge {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* Label Typography */
.story-title {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
  font-family: inherit;
  line-height: 1.3;
}

.story-bubble.seen .story-title {
  color: #94a3b8;
  font-weight: 500;
}

/* Desktop Scroll Chevron Buttons */
.story-nav-btn {
  display: none;
}

@media (min-width: 1024px) {
  .story-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #e2e8f0;
    color: #475569;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    z-index: 10;
  }

  .story-nav-btn:hover {
    background: #ffffff;
    color: #0f172a;
    border-color: #cbd5e1;
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  }
}

/* ==========================================================================
   FULLSCREEN STORY VIEWER MODAL
   ========================================================================== */
.story-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background-color: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-in-out;
}

.story-viewer-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.story-viewer-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 880px;
  background-color: #020617;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

@media (min-width: 640px) {
  .story-viewer-card {
    border-radius: 36px;
    height: 90vh;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
}

/* Progress Bars */
.story-progress-row {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 30;
  display: flex;
  gap: 5px;
  height: 3px;
}

.story-progress-bar {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.28);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.story-progress-fill {
  height: 100%;
  width: 0%;
  background-color: #ffffff;
  border-radius: 9999px;
}

.story-progress-bar.completed .story-progress-fill {
  width: 100%;
}

/* Top Header Ribbon */
.story-header {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 12px);
  left: 16px;
  right: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.story-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.story-header-title {
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.story-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  font-size: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.15s ease;
}

.story-close-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.05);
}

/* Media Viewport */
.story-media-view {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000000;
}

.story-media-view img,
.story-media-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Tap Control Zones */
.story-tap-zone {
  position: absolute;
  top: 70px;
  bottom: 120px;
  z-index: 25;
  width: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.story-tap-left {
  left: 0;
}

.story-tap-right {
  right: 0;
}

/* Bottom Glassy CTA Area */
.story-cta-bar {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.story-product-card {
  width: 100%;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 22px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  text-decoration: none;
}

.story-product-card img {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.story-product-info {
  flex: 1;
  margin: 0 12px;
  text-align: right;
}

.story-product-title {
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-product-price {
  color: #fda4af;
  font-size: 12px;
  font-weight: 900;
  margin-top: 2px;
}

.story-cta-btn {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  padding: 8px 16px;
  border-radius: 14px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.35);
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.story-cta-btn.unavailable {
  background: #475569;
  box-shadow: none;
  cursor: not-allowed;
}

.story-generic-cta {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  padding: 10px 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
