/* =============================================
   SQUARE — Stories Viewer
============================================= */

.stories-viewer {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: #000;
  /* Full screen by default (mobile) */
  width: 100%;
  max-width: 100%;
  left: 0;
  transform: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: none; /* GSAP handles this */
  overflow: hidden;
}
.stories-viewer.open {
  pointer-events: all;
}

/* Desktop: centered card */
@media (min-width: 900px) {
  .stories-viewer {
    max-width: var(--max-w);
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--r-xl);
    top: var(--s-4);
    bottom: var(--s-4);
  }
}

/* ---- Progress bars ---- */
.story-progress-bars {
  position: absolute;
  top: 0;
  left: 0; right: 0;
  display: flex;
  gap: 4px;
  padding: 12px 12px 0;
  z-index: 10;
}
.story-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
  overflow: hidden;
}
.story-progress-bar .bar-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  width: 0%;
  transition: none;
}
.story-progress-bar.completed .bar-fill { width: 100%; }
.story-progress-bar.active .bar-fill { /* GSAP animates width */ }

/* ---- Story header ---- */
.story-header {
  position: absolute;
  top: 22px;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 0;
  z-index: 30; /* above tap zones (z-20) */
}
.story-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.story-header .avatar {
  width: 36px; height: 36px;
  border: 2px solid rgba(255,255,255,0.8);
}
.story-header .story-user-info .s-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.story-header .story-user-info .s-time {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}
.story-header-right {
  display: flex;
  gap: 8px;
}
.story-close-btn,
.story-more-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0,0,0,0.25);
  border-radius: var(--r-full);
  backdrop-filter: blur(4px);
}
.story-close-btn svg, .story-more-btn svg {
  width: 20px; height: 20px;
  stroke: #fff;
}

/* ---- Story Media ---- */
.story-media-container {
  position: absolute;
  inset: 0;
}
.story-media-container img,
.story-media-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Gradient overlays ---- */
.story-overlay-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 180px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}
.story-overlay-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 200px;
  background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}

/* ---- Caption ---- */
.story-caption {
  position: absolute;
  bottom: 130px;
  left: 0; right: 0;
  padding: 0 var(--s-5);
  z-index: 10;
  text-align: center;
}
.story-caption p {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  line-height: 1.5;
}

/* ---- Story footer ---- */
.story-footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: var(--s-4) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom, 0px));
  z-index: 30; /* above tap zones */
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.story-reply-input {
  flex: 1;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: var(--r-full);
  padding: 10px 18px;
  font-size: 14px;
  color: #fff;
  backdrop-filter: blur(8px);
}
.story-reply-input::placeholder { color: rgba(255,255,255,0.6); }
.story-action-btn {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.story-action-btn:active { background: rgba(255,255,255,0.3); }
.story-action-btn svg { width: 20px; height: 20px; stroke: #fff; }

/* ---- Viewers bar (219 style) ---- */
.story-viewers-bar {
  position: absolute;
  bottom: 88px;
  left: 0; right: 0;
  padding: 0 var(--s-4);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.story-viewers-avatars {
  display: flex;
  align-items: center;
}
.story-viewers-avatars .avatar {
  width: 28px; height: 28px;
  border: 2px solid rgba(255,255,255,0.85);
  margin-right: -8px;
  flex-shrink: 0;
}
.story-viewers-avatars .avatar:last-child { margin-right: 0; }
.story-views-count {
  margin-left: 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

/* ---- Tap zones ---- */
.story-tap-prev,
.story-tap-next {
  position: absolute;
  top: 100px; bottom: 120px; /* leave room for header & footer */
  width: 40%;
  z-index: 20;
  cursor: pointer;
}
.story-tap-prev { left: 0; }
.story-tap-next { right: 0; }

/* ---- User list (horizontal) outside viewer ---- */
.stories-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0; right: 0;
  pointer-events: none;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  padding: 0 var(--s-3);
}
.story-nav-arrow {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(6px);
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  pointer-events: all;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.story-nav-arrow:hover { background: rgba(255,255,255,0.35); }
.story-nav-arrow svg { width: 18px; height: 18px; stroke: #fff; }
