/* story-premium.css — لایه‌ی بصری حرفه‌ای روی ساختار موجود */
/* فقط این فایل را در index.html بعد از story-system.css اضافه کن */

/* ══════════════════════════════════════════
   ۱. نوار استوری — حلقه‌های gradient
══════════════════════════════════════════ */

.story-bar {
  padding: 1rem 1rem 0.8rem;
  gap: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

/* حلقه‌ی gradient برای استوری‌های ندیده */
.story-bar__item.is-unread .story-bar__ring,
.story-bar__item.is-unread .story-ring {
  background: linear-gradient(135deg, #f9ce34, #ee2a7b, #6228d7) border-box;
  border: none !important;
  padding: 2.5px;
  border-radius: 50%;
  position: relative;
}

.story-bar__item.is-unread .story-bar__ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #f9ce34, #ee2a7b, #6228d7);
  z-index: -1;
  animation: story-ring-spin 3s linear infinite;
  opacity: 0.6;
  filter: blur(4px);
}

@keyframes story-ring-spin {
  0%   { transform: rotate(0deg);   }
  100% { transform: rotate(360deg); }
}

/* حلقه‌ی خاکستری برای دیده‌شده */
.story-bar__item.is-read .story-bar__ring,
.story-bar__item.is-read .story-ring {
  background: rgba(128,128,128,0.25) border-box;
  border: 2px solid rgba(128,128,128,0.4) !important;
  padding: 2px;
  opacity: 0.75;
}

/* حلقه‌ی ایجاد استوری */
.story-bar__ring--create {
  background: linear-gradient(135deg, rgba(96,165,250,0.15), rgba(167,139,250,0.15)) !important;
  border: 1.5px dashed rgba(96,165,250,0.6) !important;
}

/* آواتار داخل حلقه */
.story-bar__avatar {
  border-radius: 50%;
  object-fit: cover;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: block;
  border: 2.5px solid var(--bg-main, #0f1117);
  transition: transform 0.2s ease;
}

.story-bar__item:active .story-bar__avatar {
  transform: scale(0.92);
}

/* اسم زیر آواتار */
.story-bar__label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-main, #e2e8f0);
  text-align: center;
  max-width: 4.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.9;
}

/* نشانگر آنلاین */
.story-bar__item--mine .story-bar__ring::after {
  content: '';
  position: absolute;
  bottom: 2px; right: 2px;
  width: 12px; height: 12px;
  background: #22c55e;
  border: 2px solid var(--bg-main, #0f1117);
  border-radius: 50%;
}

/* ══════════════════════════════════════════
   ۲. Viewer — ارتقای بصری
══════════════════════════════════════════ */

.story-viewer {
  background: #000 !important;
  display: flex;
  flex-direction: column;
}

/* backdrop blur برای header */
.story-viewer__chrome {
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
  backdrop-filter: blur(0px);
  position: relative;
  z-index: 10;
}

/* progress bars */
.story-progress {
  display: flex;
  gap: 3px;
  padding: 10px 10px 6px;
}

.story-progress__segment {
  flex: 1;
  height: 2.5px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.story-progress__fill {
  position: absolute;
  inset: 0;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
  will-change: transform;
  transition: none;
}

.story-progress__segment.is-done .story-progress__fill {
  transform: scaleX(1);
}

/* header */
.story-viewer__header {
  padding: 4px 12px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-viewer__host {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-viewer__host .story-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.2);
}

.story-viewer__name {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.story-viewer__time {
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  margin-top: 1px;
}

.story-viewer__close {
  background: rgba(0,0,0,0.3);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}

.story-viewer__close:hover { background: rgba(0,0,0,0.6); }

/* viewport و مدیا */
.story-viewer__viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-vertical-feed {
  display: flex;
  flex-direction: row; /* افقی مثل اینستاگرام (هماهنگ با translateX) */
  flex-wrap: nowrap;
  width: 100%;
  height: 100dvh;
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.story-card {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* blur پس‌زمینه (مانند اینستاگرام) */
.story-card::before {
  content: '';
  position: absolute;
  inset: -20px;
  background: var(--story-bg-image, none) center/cover no-repeat;
  filter: blur(20px) brightness(0.5) saturate(1.2);
  transform: scale(1.1);
  z-index: 0;
}

.story-card img,
.story-card video {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0;
}

/* footer */
.story-viewer__footer {
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  padding: 12px 12px 20px;
  position: relative;
  z-index: 10;
}

.story-caption {
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  margin-bottom: 10px;
  direction: rtl;
}

/* دکمه‌های action */
.story-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.story-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  color: #fff;
  padding: 7px 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s;
  font-size: 12px;
  flex-direction: row;
  gap: 5px;
}

.story-action-btn:active { transform: scale(0.92); }

.story-action-btn.is-active {
  background: rgba(239,68,68,0.3);
  border-color: rgba(239,68,68,0.5);
  color: #fca5a5;
}

.story-action-btn__count {
  font-size: 12px;
  font-weight: 600;
  min-width: 16px;
  text-align: center;
}

/* ══════════════════════════════════════════
   ۳. Floating Heart انیمیشن
══════════════════════════════════════════ */

.story-heart-float {
  position: fixed;
  pointer-events: none;
  font-size: 28px;
  z-index: 99999;
  animation: heart-float-up 0.9s ease-out forwards;
  user-select: none;
}

@keyframes heart-float-up {
  0%   { opacity: 1;   transform: translateY(0)    scale(1);    }
  50%  { opacity: 0.8; transform: translateY(-60px) scale(1.3); }
  100% { opacity: 0;   transform: translateY(-120px) scale(0.8); }
}

/* ══════════════════════════════════════════
   ۴. Slide Transition بین کاربران
══════════════════════════════════════════ */

.story-viewer.is-sliding-next .story-vertical-feed {
  animation: slide-left 0.32s cubic-bezier(0.4,0,0.2,1) forwards;
}

.story-viewer.is-sliding-prev .story-vertical-feed {
  animation: slide-right 0.32s cubic-bezier(0.4,0,0.2,1) forwards;
}

@keyframes slide-left  { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes slide-right { from { transform: translateX(0); } to { transform: translateX(100%);  } }

/* ══════════════════════════════════════════
   ۵. Story Creator — editor کامل
══════════════════════════════════════════ */

#story-creator-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: flex;
  flex-direction: column;
  color: #fff;
  font-family: 'Vazir', 'Segoe UI', sans-serif;
}

#story-creator-overlay.hidden { display: none; }

/* canvas پیش‌نمایش */
#sc-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

#sc-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

#sc-preview {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* overlay متن‌های draggable */
.sc-text-overlay {
  position: absolute;
  z-index: 10;
  cursor: move;
  user-select: none;
  touch-action: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  direction: rtl;
}

/* نوار ابزار بالا */
#sc-toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
}

#sc-toolbar-top button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
  font-family: inherit;
}

#sc-toolbar-top button:hover { background: rgba(255,255,255,0.25); }
#sc-btn-publish { background: #3b82f6 !important; font-weight: 600; }

/* نوار ابزار پایین */
#sc-toolbar-bottom {
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  padding: 10px 0 20px;
}

/* تب‌های ابزار */
#sc-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 0 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 10px;
}

.sc-tab {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.2s;
  font-family: inherit;
}

.sc-tab.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.sc-tab-icon { font-size: 18px; }

/* پنل‌های محتوا */
.sc-panel { display: none; padding: 0 16px; }
.sc-panel.active { display: block; }

/* رنگ‌های متن */
#sc-colors {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 8px 0;
}

.sc-color-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.sc-color-dot.active, .sc-color-dot:hover {
  transform: scale(1.25);
  border-color: rgba(255,255,255,0.8);
}

/* فیلترها */
#sc-filters {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 0;
  scrollbar-width: none;
}

#sc-filters::-webkit-scrollbar { display: none; }

.sc-filter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}

.sc-filter-thumb {
  width: 52px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid transparent;
  transition: all 0.2s;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}

.sc-filter-btn.active .sc-filter-thumb,
.sc-filter-btn:hover .sc-filter-thumb { border-color: #3b82f6; }

.sc-filter-label { font-size: 10px; color: rgba(255,255,255,0.6); }

/* استیکرها */
#sc-stickers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-height: 100px;
  overflow-y: auto;
  padding: 4px;
}

.sc-sticker-btn {
  font-size: 28px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 10px;
  width: 48px; height: 48px;
  cursor: pointer;
  transition: transform 0.15s;
  display: flex; align-items: center; justify-content: center;
}

.sc-sticker-btn:active { transform: scale(1.3); }

/* input متن */
#sc-text-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

#sc-text-input {
  flex: 1;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  color: #fff;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
  direction: rtl;
  font-family: inherit;
}

#sc-text-add-btn {
  background: #3b82f6;
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* گرادیان‌های پس‌زمینه */
#sc-gradients {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 0;
  scrollbar-width: none;
}
#sc-gradients::-webkit-scrollbar { display: none; }

.sc-grad-btn {
  width: 52px; height: 52px;
  border-radius: 10px;
  border: 3px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, border-color 0.15s;
}

.sc-grad-btn:hover, .sc-grad-btn.active {
  transform: scale(1.1);
  border-color: #fff;
}

/* privacy selector */
#sc-privacy-wrap {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
}

.sc-privacy-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.sc-privacy-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
  font-weight: 600;
}

/* upload trigger */
#sc-media-trigger {
  display: none;
}

/* loading overlay */
#sc-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 30;
  backdrop-filter: blur(4px);
}

#sc-loading.hidden { display: none; }

.sc-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sc-spin 0.8s linear infinite;
}

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

/* ══════════════════════════════════════════
   ۶. Swipe-up insights sheet
══════════════════════════════════════════ */

.story-comment-sheet {
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}

.story-comment-sheet[aria-hidden="true"] {
  display: none !important;
}
.story-comment-sheet[aria-hidden="false"] {
  display: block !important;
  transform: translateY(0) !important;
}

/* ══════════════════════════════════════════
   ۷. Tap zone های چپ/راست (invisible)
══════════════════════════════════════════ */

.story-tap-prev,
.story-tap-next {
  position: absolute;
  top: 10%;
  bottom: 20%;
  width: 35%;
  z-index: 5;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.story-tap-prev { left: 0; }
.story-tap-next { right: 0; }

/* انیمیشن باز و بسته شدن viewer */
#story-viewer-wrapper {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
}

#story-viewer {
  transform: scale(0.92);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1), opacity 0.28s ease;
  pointer-events: none;
}

#story-viewer:not([hidden]) {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* blur backdrop */
.story-viewer__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* انیمیشن حلقه‌ی استوری هنگام کلیک */
.story-bar__item:active .story-bar__ring {
  transform: scale(0.88);
  transition: transform 0.15s ease;
}

/* نوار استوری: فاصله و سایه بهتر */
.story-bar__item.is-unread .story-bar__ring {
  box-shadow: 0 0 0 3px var(--bg-main,#0f1117), 0 0 0 5px transparent;
  background: linear-gradient(135deg,#f9ce34,#ee2a7b,#6228d7) border-box;
  border: none !important;
  padding: 3px;
}

/* swipe indicator */
#sc-swipe-indicator {
  animation: bounce-up 1.5s ease-in-out infinite;
}
@keyframes bounce-up {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-6px); }
}
