/* === TopStories — extracted from artkelo.ru === */

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
img { border-style: none; max-width: 100%; }

/* Stories row */
.stories {
  position: relative;
  margin: 40px 0 0 0;
}

.stories-inner {
  display: flex;
  flex-wrap: nowrap;
  margin: 0;
  padding: 0 16px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.stories-inner::-webkit-scrollbar { display: none; }

.stories h3 {
  text-align: left;
  font-size: 110%;
  margin-bottom: 5px;
  margin-left: 40px;
}

.stories-item:first-child { margin-left: auto; }
.stories-item:last-child { margin-right: auto; }

.stories-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 15px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.stories-item .img {
  width: 148px;
  height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 1px solid rgb(142, 113, 95);
  box-sizing: border-box;
  border-radius: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.stories-item .img {
  overflow: hidden;
}

.stories-item .img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 100%;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.3s ease;
}

.stories-item:hover .img img {
  transform: scale(1.15);
}

/* Shape: squircle (rounded square) */
.stories-item[data-shape="squircle"] .img {
  border-radius: 12%;
}

.stories-item[data-shape="squircle"] .img img {
  border-radius: 8%;
}

/* Watched state */
.stories-item.is-watched {
  opacity: 0.4;
}

.stories-item h6 {
  margin-top: 8px;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 148px;
  max-height: 77px;
  font-family: "Open Sans", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  text-align: center;
  line-height: 140%;
}

/* Stories overlay (video viewer) */
.stories-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.stories-overlay.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.stories-overlay .stories-viewer {
  position: relative;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stories-overlay .stories-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10;
}

.stories-overlay .stories-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.stories-overlay .stories-close::before,
.stories-overlay .stories-close::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

.stories-overlay .stories-close::before { transform: rotate(45deg); }
.stories-overlay .stories-close::after { transform: rotate(-45deg); }

/* Media wrapper for slide animation */
.stories-media-wrap {
  position: relative;
  width: 100%;
}

.stories-overlay video {
  width: 100%;
  max-height: 85vh;
  border-radius: 16px;
  object-fit: contain;
  background: #000;
  cursor: pointer;
}

.stories-overlay .stories-photo {
  width: 100%;
  max-height: 85vh;
  border-radius: 16px;
  object-fit: contain;
  background: #000;
}

/* Mute button */
.stories-mute {
  position: absolute;
  top: 28px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.stories-mute:hover {
  background: rgba(0, 0, 0, 0.6);
}

.stories-mute::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.stories-mute[data-muted="1"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cline x1='23' y1='9' x2='17' y2='15'/%3E%3Cline x1='17' y1='9' x2='23' y2='15'/%3E%3C/svg%3E");
}

.stories-mute[data-muted="0"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cpath d='M19.07 4.93a10 10 0 0 1 0 14.14'/%3E%3Cpath d='M15.54 8.46a5 5 0 0 1 0 7.07'/%3E%3C/svg%3E");
}

.stories-overlay .stories-progress {
  display: flex;
  gap: 4px;
  width: 100%;
  padding: 8px 8px 0;
  position: absolute;
  top: 8px;
  left: 0;
  z-index: 5;
}

.stories-overlay .stories-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.stories-overlay .stories-progress-bar::before {
  content: "";
  position: absolute;
  inset: -8px 0;
}

.stories-overlay .stories-progress-bar .fill {
  height: 100%;
  background: #fff;
  width: 0;
  border-radius: 2px;
}

.stories-overlay .stories-progress-bar .fill.active {
  animation: storyProgress linear forwards;
}

.stories-overlay .stories-progress-bar .fill.done {
  width: 100%;
}

/* Info block (title + description) */
.stories-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 60px 16px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.35) 60%, transparent 100%);
  border-radius: 0 0 16px 16px;
  z-index: 6;
  color: #fff;
}

.stories-info-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
}

.stories-info-desc {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.85);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stories-info-desc.expanded {
  -webkit-line-clamp: unset;
  overflow: visible;
}

.stories-info-more {
  display: none;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  margin-top: 4px;
  transition: color 0.2s;
}

.stories-info-more:hover {
  color: #fff;
}

/* Navigation arrows */
.stories-overlay .stories-nav-prev,
.stories-overlay .stories-nav-next {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 4;
  cursor: pointer;
  background: none;
  border: none;
  display: flex;
  align-items: center;
}

.stories-overlay .stories-nav-prev { left: -17%; justify-content: flex-start; padding-left: 8px; }
.stories-overlay .stories-nav-next { right: -17%; justify-content: flex-end; padding-right: 8px; }

/* Arrow icons */
.stories-overlay .stories-nav-prev::after,
.stories-overlay .stories-nav-next::after {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  border-right: 2px solid rgba(255, 255, 255, 0.35);
  border-bottom: 2px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  transition: border-color 0.2s, transform 0.2s;
}

.stories-overlay .stories-nav-prev::after {
  transform: rotate(135deg);
  margin-left: 12px;
}

.stories-overlay .stories-nav-next::after {
  transform: rotate(-45deg);
  margin-right: 12px;
}

.stories-overlay .stories-nav-prev:hover::after,
.stories-overlay .stories-nav-next:hover::after {
  border-color: rgba(255, 255, 255, 0.7);
}

.stories-overlay .stories-nav-prev:hover::after {
  transform: rotate(135deg) translate(7px, 7px);
}

.stories-overlay .stories-nav-next:hover::after {
  transform: rotate(-45deg) translate(7px, 7px);
}

@keyframes storyProgress {
  from { width: 0; }
  to { width: 100%; }
}

/* Responsive */
@media only screen and (max-width: 767px) {
  .stories-inner {
    padding: 0 16px;
  }

  .stories-item {
    padding: 0 4px;
  }

  .stories-item .img {
    width: 100px;
    height: 100px;
    padding: 3px;
  }

  .stories-item h6 {
    max-width: 100px;
    max-height: 50px;
    margin-top: 6px;
    font-size: 11px;
  }

  .stories-overlay .stories-viewer {
    max-width: 100vw;
  }

  .stories-overlay video,
  .stories-overlay .stories-photo {
    border-radius: 0;
    max-height: 100vh;
  }

  .stories-info {
    border-radius: 0;
  }

  .stories-overlay .stories-nav-prev,
  .stories-overlay .stories-nav-next {
    width: 40%;
    left: 0;
    right: 0;
  }

  .stories-overlay .stories-nav-prev { left: 0; }
  .stories-overlay .stories-nav-next { right: 0; }

  .stories-overlay .stories-nav-prev::after,
  .stories-overlay .stories-nav-next::after {
    display: none;
  }

  .stories-mute {
    top: 30px;
    right: 8px;
  }
}

@media only screen and (max-width: 480px) {
  .stories {
    margin: 16px 0 30px;
  }
}
