/* Story feature — dark theme aligned with IranEscape V3 (#131927 / #1c253a / #00a0aa) */

:root {
  --story-bg: #131927;
  --story-surface: #1c253a;
  --story-surface-2: #243049;
  --story-border: rgba(77, 102, 160, 0.45);
  --story-text: #ebeef5;
  --story-muted: rgba(235, 238, 245, 0.65);
  --story-accent: #00a0aa;
  --story-accent-glow: #00e4f4;
  --story-ring-seen: #3a4c78;
  --story-like: #ff3b5c;
}

#home-stories,
#story-container.story-modal {
  direction: rtl;
  text-align: right;
  color: var(--story-text);
}

/* ========== Preview strip (homepage) ========== */
#home-stories {
  margin: 12px 0 8px;
}

#home-stories .story-strip {
  background: var(--story-surface);
  border: 1px solid var(--story-border);
  border-radius: 10px;
  box-shadow: inset 0 -2px 0 0 rgba(0, 160, 170, 0.35);
  padding: 10px 0 8px;
  position: relative;
}

#home-stories .story-strip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--story-accent-glow);
  opacity: 0.55;
  pointer-events: none;
  border-radius: 0 0 12px 12px;
}

#home-stories .story-strip__viewport {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#home-stories .story-strip__viewport::-webkit-scrollbar {
  display: none;
}

#home-stories .story-strip__track {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 12px;
  direction: rtl;
  padding: 0 12px;
  min-height: 78px;
}

/* Ring item */
#home-stories .story-ring {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  width: 62px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font: inherit;
  color: inherit;
  transition: transform 0.2s ease;
}

#home-stories .story-ring:hover {
  transform: translateY(-2px);
}

#home-stories .story-ring:focus-visible {
  outline: 2px solid var(--story-accent-glow);
  outline-offset: 4px;
  border-radius: 12px;
}

#home-stories .story-ring__ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* ندیده — حلقه رنگی مثل اینستاگرام */
#home-stories .story-ring.is-unseen .story-ring__ring {
  background: conic-gradient(
    from 200deg,
    var(--story-accent-glow) 0deg,
    var(--story-accent) 90deg,
    #4d66a0 180deg,
    var(--story-accent-glow) 270deg,
    var(--story-accent-glow) 360deg
  );
  box-shadow: 0 0 0 1px rgba(0, 228, 244, 0.25), 0 3px 10px rgba(0, 160, 170, 0.22);
}

/* دیده — بدون حلقه رنگی، فقط حاشیه خاکستری نازک */
#home-stories .story-ring.is-seen .story-ring__ring {
  background: transparent;
  border: 1.5px solid var(--story-ring-seen);
  padding: 1.5px;
  box-shadow: none;
}

#home-stories .story-ring--add .story-ring__ring {
  background: var(--story-surface-2);
  border: 1px dashed var(--story-border);
  box-shadow: none;
}

#home-stories .story-ring__thumb {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--story-bg);
  border: 1.5px solid var(--story-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#home-stories .story-ring__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#home-stories .story-ring__plus {
  font-size: 1.35rem;
  line-height: 1;
  color: var(--story-accent-glow);
  font-family: "yekanBakh-Bold", sans-serif;
}

#home-stories .story-ring__name {
  font-family: "yekanBakh-Regular", sans-serif;
  font-size: 10px;
  line-height: 1.3;
  color: var(--story-text);
  text-align: center;
  width: 100%;
  max-width: 62px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#home-stories .story-ring.is-seen .story-ring__name {
  color: var(--story-muted);
}

/* ========== Fullscreen modal ========== */
#story-container.story-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1060;
  background: rgba(0, 0, 0, 0.92);
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

#story-container.story-modal.is-open {
  display: flex;
}

#story-container .story-content {
  position: relative;
  width: min(calc(90dvh * 9 / 16), calc(100vw - 32px), 420px);
  aspect-ratio: 9 / 16;
  max-height: 90dvh;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--story-border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  direction: rtl;
  isolation: isolate;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#story-container.is-story-paused .story-media-stage {
  filter: brightness(0.92);
}

#story-container .story-media-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
  overflow: hidden;
}

#story-container .story-media {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  display: block;
  object-fit: cover;
  object-position: center center;
  background: #000;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

#story-container .progress-container {
  display: flex;
  flex-direction: row;
  direction: rtl;
  gap: 4px;
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: 10px;
  left: 10px;
  z-index: 25;
}

#story-container .progress-wrapper {
  flex: 1;
  height: 3px;
  position: relative;
  border-radius: 2px;
  overflow: hidden;
}

#story-container .progress-bg {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.28);
}

#story-container .progress-bar {
  position: absolute;
  top: 0;
  right: 0;
  left: auto;
  height: 100%;
  width: 0;
  background: var(--story-accent-glow);
  border-radius: 2px;
  z-index: 1;
}

#story-container .story-content-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 20;
  padding: 10px 12px 28px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.18) 55%, transparent 100%);
  pointer-events: none;
}

#story-container .story-content-header * {
  pointer-events: auto;
}

#story-container .story-header-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

#story-container .story-header-meta {
  flex: 1;
  min-width: 0;
}

#story-container .story-content-header .profile-img {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
}

#story-container .story-content-header .profile-img::after {
  display: none;
}

#story-container .story-content-header .AZ-img-container-inner {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
}

#story-container .username {
  font-size: 14px;
  color: var(--story-text);
  margin: 0;
  font-family: "yekanBakh-Bold", sans-serif;
}

#story-container .story-view-count {
  font-size: 11px;
  color: var(--story-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#story-container .close-button {
  background: var(--story-surface);
  color: var(--story-text);
  border: 1px solid var(--story-border);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#story-container .close-button .icon-arrow_forward {
  transform: scaleX(-1);
}

#story-container .story-tap-zones {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: row;
  direction: rtl;
  pointer-events: none;
}

#story-container .story-tap-prev,
#story-container .story-tap-next {
  flex: 1;
  pointer-events: auto;
  cursor: pointer;
}

#story-container .overlay {
  position: absolute !important;
  bottom: 0 !important;
  right: 0 !important;
  left: 0 !important;
  width: 100% !important;
  transform: none !important;
  z-index: 18;
  padding: 28px 12px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.35) 38%, transparent 72%) !important;
  text-align: right !important;
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

#story-container .overlay * {
  pointer-events: auto;
}

#story-container .story-caption-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#story-container .overlay .room-title {
  font-size: 15px;
  margin: 0;
  flex: 1;
  line-height: 1.5;
  font-family: "yekanBakh-Bold", sans-serif;
  color: var(--story-text);
}

#story-container .like-story {
  background: transparent;
  border: none;
  color: var(--story-text);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#story-container .like-story.liked .icon-heart1 {
  color: var(--story-like);
}

#story-container .like-story .like-num {
  font-size: 11px;
}

#story-container .story-product-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 10px;
  background: var(--story-surface) !important;
  border: 1px solid var(--story-border);
  padding: 10px 12px !important;
}

#story-container .story-product-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

#story-container .story-product-text {
  flex: 1;
  min-width: 0;
}

#story-container .story-product-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--story-border);
}

#story-container .overlay .room-name {
  font-size: 14px;
  margin: 0 0 4px;
  font-family: "yekanBakh-Regular", sans-serif;
  color: var(--story-text);
}

#story-container .story-product-price {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

#story-container .overlay .room-price_text {
  font-size: 11px;
  color: var(--story-muted);
  margin: 0;
}

#story-container .overlay .room-price {
  font-size: 12px;
  color: var(--story-accent-glow);
  margin: 0;
  font-family: "yekanBakh-Bold", sans-serif;
}

#story-container .story-reserve-btn {
  white-space: nowrap;
  font-size: 13px;
  padding: 8px 14px;
  flex-shrink: 0;
}

#story-container .nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 22;
  color: var(--story-text);
  background: rgba(28, 37, 58, 0.85);
  border: 1px solid var(--story-border);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#story-container #prev {
  right: 8px;
  left: auto;
}

#story-container #next {
  left: 8px;
  right: auto;
}

body.story-open {
  overflow: hidden;
}

@media screen and (max-width: 480px) {
  #home-stories {
    margin: 12px 0 8px;
  }

  #home-stories .story-strip {
    border-radius: 0;
    margin-left: -12px;
    margin-right: -12px;
    border-left: 0;
    border-right: 0;
  }

  #home-stories .story-strip__track {
    padding: 0 10px;
    gap: 10px;
    min-height: 74px;
  }

  #story-container.story-modal {
    padding: 0;
    align-items: stretch;
    background: #000;
  }

  #story-container .story-content {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    aspect-ratio: unset;
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }

  #story-container .story-product-card {
    flex-direction: column;
    align-items: stretch;
  }

  #story-container .story-reserve-btn {
    width: 100%;
    text-align: center;
  }
}
