/* ===============================
   FILA DE HISTORIAS (BUBBLES)
================================= */

.stories-row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  overflow-x: auto;
  scrollbar-width: none;        /* Firefox */
}
.stories-row::-webkit-scrollbar {
  display: none;                /* Chrome/Safari */
}

.story-item {
  flex: 0 0 auto;
  text-align: center;
  cursor: pointer;
}

.story-avatar-wrapper {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  padding: 2px;
  background: #eb0045; /* color sólido pedido */
  display: flex;
  align-items: center;
  justify-content: center;
}


.story-avatar {
  width: 75px;
  height: 75px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  border: 2px solid #fff;
}

.story-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center; /* 🔥 clave: recorta desde arriba */
  display: block;
}

.story-item-title {
  margin-top: 4px;
  font-size: 11px;
  color: #333;
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===============================
   MODAL
================================= */

.story-modal {
  position: fixed;
  inset: 0;
  display: none;              /* se muestra con .open */
  align-items: center;
  justify-content: center;
  z-index: 999999;            /* más alto que cualquier header/menu */
}

.story-modal.open {
  display: flex;
}

.story-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.story-modal-content {
  position: relative;
  z-index: 1;
  max-width: 420px;
  width: 100%;
  padding: 0 10px;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.story-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  z-index: 30; /* MÁS ALTO QUE EL BOTÓN DE AUDIO */
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}



/* Evitar scroll de la página cuando el modal está abierto */
body.no-scroll {
  overflow: hidden;
}

/* ===============================
   PLAYER
================================= */

.story-player {
  width: 100%;
  max-width: 420px;
  /* En vez de una altura fija, usamos relación 9:16 y limitamos con la ventana */
  aspect-ratio: 9 / 16;
  max-height: calc(100vh - 120px);
  position: relative;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}


.story-media {
  width: 100%;
  height: 100%;
}

.story-media img,
.story-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Áreas clicables izquierda/derecha (taps grandes) */
.tap {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  cursor: pointer;
  z-index: 4;
}
.tap.left { left: 0; }
.tap.right { right: 0; }

/* Barras de progreso */
.progress-container {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 6;
}

.progress-container div {
  background: rgba(255, 255, 255, 0.3);
  height: 3px;
  flex: 1;
  border-radius: 4px;
  overflow: hidden;
}

.progress-container div span {
  display: block;
  height: 100%;
  background: #fff;
  width: 0%;
}

/* Botones de control (prev, next, mute) */

.story-btn {
  position: absolute;
  z-index: 7;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-btn-prev {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.story-btn-next {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.story-btn-mute {
  position: absolute;
  right: 12px;
  top: 60px; /* antes estaba cerca de la X, ahora bajamos */
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 18px;
  cursor: pointer;
  z-index: 20; /* debajo de la X */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Por defecto (móvil): scroll horizontal de izquierda a derecha */
.stories-row {
  justify-content: flex-start;
}

.story-link-btn {
  display: block;
  margin-top: 12px;
  background: #eb0045;
  color: white;
  text-align: center;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  text-decoration: none;
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  font-weight: bold;
}


.story-link-btn:hover {
  background: #ffffff;
}


/* En pantallas grandes (PC) centramos y quitamos el scroll */
@media (min-width: 768px) {
  .stories-row {
    justify-content: center;
    overflow-x: visible;
  }
}

.story-title-bottom {
  position: absolute !important;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  text-align: center; /* 🔥 centra el texto de nuevo */
  background: rgba(34,34,34,0.90) !important; /* 🔥 color sólido con 80% opacidad */
  box-sizing: border-box;
  z-index: 10;
  pointer-events: none;
}



@media (max-width: 767px) {
  .story-modal-content {
    padding: 0;              /* usamos todo el ancho en móvil */
  }

  .story-player {
    max-width: 100%;
    border-radius: 0;        /* estilo “pantalla completa” en cel */
  }

  .story-title-bottom,
  .story-description {
    padding-left: 12px;
    padding-right: 12px;
  }
}

.story-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12;
}

.story-loading-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  animation: story-spin 0.8s linear infinite;
}

@keyframes story-spin {
  to { transform: rotate(360deg); }
}



