/* ================================================================
   Story Viewer — self-contained CSS
   All classes are prefixed .sv- to avoid collisions.
   ================================================================ */

/* ── Section wrapper ─────────────────────────────────────────── */
.sv-section {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
  padding: 18px 20px 14px;
  margin-bottom: 24px;
}

.sv-section-title {
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 14px;
}

/* ── Story rail (horizontal scroll) ─────────────────────────── */
.sv-rail {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  align-items: flex-start;
}

.sv-rail::-webkit-scrollbar {
  display: none;
}

/* ── Story circle ────────────────────────────────────────────── */
.sv-circle {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 74px;
  cursor: pointer;
  user-select: none;
}

.sv-circle:hover .sv-ring {
  transform: scale(1.06);
}

/* Gradient ring — unseen */
.sv-ring {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(
    135deg,
    #f09433 0%,
    #e6683c 25%,
    #dc2743 50%,
    #cc2366 75%,
    #bc1888 100%
  );
  transition: transform 0.2s ease;
}

/* Seen state — grey ring */
.sv-circle.sv-seen .sv-ring {
  background: #d1d5db;
}

.sv-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  overflow: hidden;
  background: #e5e7eb;
}

.sv-ring-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sv-circle-name {
  font-size: 11.5px;
  font-weight: 500;
  color: #374151;
  max-width: 74px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.3;
}

/* ── Add story button ────────────────────────────────────────── */
.sv-add-circle {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 74px;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}

.sv-add-ring {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #f3f4f6;
  border: 2px dashed #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  color: #00507a;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sv-add-circle:hover .sv-add-ring {
  background: #e9f5fb;
  border-color: #00507a;
}

.sv-add-label {
  font-size: 11.5px;
  font-weight: 500;
  color: #374151;
  text-align: center;
}

/* ── Viewer overlay ──────────────────────────────────────────── */
.sv-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sv-overlay.sv-open {
  visibility: visible;
  opacity: 1;
}

.sv-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
}

/* ── Viewer card ─────────────────────────────────────────────── */
.sv-viewer {
  position: relative;
  width: 100%;
  max-width: 400px;
  height: 90vh;
  max-height: 710px;
  border-radius: 14px;
  overflow: hidden;
  background: #0a0a0a;
  z-index: 1;
}

/* ── User navigation arrows (outside viewer card) ────────────── */
.sv-nav {
  position: relative;
  z-index: 2;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  backdrop-filter: blur(6px);
  margin: 0 10px;
}

.sv-nav:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

/* ── Progress bars ───────────────────────────────────────────── */
.sv-progress {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
  pointer-events: none;
}

.sv-bar {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.sv-bar-fill {
  height: 100%;
  background: #ffffff;
  width: 0%;
  border-radius: 2px;
}

/* ── Viewer header ───────────────────────────────────────────── */
.sv-head {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 6px;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.55) 0%,
    transparent 100%
  );
  z-index: 10;
}

.sv-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sv-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
}

.sv-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sv-name {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.sv-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.sv-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Icon buttons (close / delete) ──────────────────────────── */
.sv-btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  padding: 0;
  backdrop-filter: blur(4px);
}

.sv-btn-icon:hover {
  background: rgba(0, 0, 0, 0.72);
  transform: scale(1.08);
}

.sv-delete-btn:hover {
  background: rgba(200, 30, 30, 0.75);
}

/* ── Media area ──────────────────────────────────────────────── */
.sv-media-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
}

.sv-img,
.sv-vid {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Loading spinner ─────────────────────────────────────────── */
.sv-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  z-index: 5;
}

.sv-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: sv-spin 0.75s linear infinite;
}

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

/* ── Caption ─────────────────────────────────────────────────── */
.sv-caption {
  position: absolute;
  bottom: 20px;
  left: 14px;
  right: 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #ffffff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
  z-index: 6;
  pointer-events: none;
}

/* ── Tap zones (invisible prev / next triggers) ──────────────── */
.sv-tap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 38%;
  z-index: 8;
  cursor: pointer;
}

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

/* ── Story footer (reactions + comment) ─────────────────────── */
.sv-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px 18px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, transparent 100%);
  pointer-events: none;
}

.sv-reactions,
.sv-comment-row {
  pointer-events: all;
}

.sv-reactions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.sv-react-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
  backdrop-filter: blur(4px);
  padding: 0;
}

.sv-react-btn:hover {
  transform: scale(1.22);
  background: rgba(255, 255, 255, 0.28);
}

.sv-react-btn:active {
  transform: scale(0.88);
}

/* Floating emoji that rises on reaction click */
.sv-react-float {
  position: absolute;
  font-size: 2.2rem;
  line-height: 1;
  pointer-events: none;
  z-index: 20;
  animation: sv-float-up 1.1s ease-out forwards;
}

@keyframes sv-float-up {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  18% {
    transform: translateY(-14px) scale(1.3);
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) scale(0.9);
    opacity: 0;
  }
}

.sv-comment-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sv-comment-input {
  flex: 1;
  height: 40px;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  padding: 0 16px;
  outline: none;
  backdrop-filter: blur(6px);
}

.sv-comment-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
  -webkit-text-fill-color: rgba(255, 255, 255, 0.6);
}

.sv-comment-input:focus {
  border-color: #ffffff;
  background: rgba(0, 0, 0, 0.6);
  -webkit-text-fill-color: #ffffff;
}

.sv-comment-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  color: #111111;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.sv-comment-send:hover {
  transform: scale(1.1);
  background: #e5e7eb;
}

.sv-comment-send:active {
  transform: scale(0.92);
}

.sv-comment-send.sv-sent {
  background: #22c55e;
  color: #ffffff;
  transform: scale(1.12);
  transition: background 0.15s ease, transform 0.15s ease;
}

/* ── Conversation: story reference card ──────────────────────── */
.story-msg-ref {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  border-left: 3px solid rgba(0, 0, 0, 0.18);
  margin-bottom: 5px;
}

.li.me .story-msg-ref {
  border-left-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
}

.story-msg-thumb-wrap {
  flex-shrink: 0;
}

.story-msg-thumb {
  width: 40px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.story-msg-thumb--expired {
  width: 40px;
  height: 52px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
}

.story-msg-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

.story-reaction-display {
  display: block;
  font-size: 2rem;
  text-align: center;
  line-height: 1.2;
  margin: 2px 0 4px;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 560px) {
  .sv-viewer {
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
  }

  .sv-nav {
    display: none;
  }

  .sv-section {
    padding: 14px 14px 10px;
    border-radius: 12px;
  }
}

@media (max-width: 375px) {
  .sv-circle,
  .sv-ring,
  .sv-add-circle,
  .sv-add-ring {
    width: 64px;
    height: 64px;
  }

  .sv-ring {
    width: 64px;
    height: 64px;
  }
}
