/* jbk9 Актуально2 — vertical stories (based on topstories / artkelo) */

.jbk9-stories {
  position: relative;
  margin: 0 0 calc(var(--section-gap, 72px) * 0.8);
  box-sizing: border-box;
}
.jbk9-stories *,
.jbk9-stories *::before,
.jbk9-stories *::after { box-sizing: border-box; }
.jbk9-stories img { border-style: none; max-width: 100%; }

.jbk9-stories .jbk9-stories__title {
  margin: 0 0 16px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 600;
  color: #1a1a1a;
  font-family: var(--font-primary, "Golos Text", system-ui, sans-serif);
}
/* крупный заголовок только на главной */
body.home2-page.id-1 .jbk9-stories .jbk9-stories__title,
body.home2-page.base-template.id-1 .jbk9-stories .jbk9-stories__title,
body.id-1 .jbk9-stories .jbk9-stories__title.section-title {
  margin: 0 0 24px;
  font-size: 48px;
  line-height: 1.15;
}

.jbk9-stories .stories-inner {
  display: flex;
  flex-wrap: nowrap;
  margin: 0;
  padding: 0 4px 4px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  gap: 0;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  user-select: none;
}
.jbk9-stories .stories-inner.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}
.jbk9-stories .stories-inner.is-dragging .stories-item {
  pointer-events: none;
}
.jbk9-stories .stories-inner::-webkit-scrollbar { display: none; }

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

.jbk9-stories .stories-item .img {
  /* ~5 в ряд в .container 1140px: 5×(192+12)=1020 */
  width: 192px;
  height: 341px; /* ~9:16 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: 2px solid #9D855F;
  border-radius: 20px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  background: #f3efe6;
}

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

.jbk9-stories .stories-item:hover .img img { transform: scale(1.08); }
.jbk9-stories .stories-item:hover .img {
  box-shadow: 0 8px 20px rgba(122, 104, 69, 0.28);
}

.jbk9-stories .stories-item h6 {
  margin-top: 10px;
  max-width: 192px;
  font-family: var(--font-primary, "Golos Text", system-ui, sans-serif);
  font-size: 14px;
  font-weight: 500;
  color: #333;
  text-align: center;
  line-height: 1.25;
  /* 4 строки: 14px × 1.25 × 4 ≈ 70px */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  max-height: 70px;
}

/* Overlay */
.stories-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 10060;
  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: 390px;
  width: min(100%, 390px);
  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); }

.stories-media-wrap { position: relative; width: 100%; }

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

.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;
}
.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: jbk9StoryProgress linear forwards;
}
.stories-overlay .stories-progress-bar .fill.done { width: 100%; }

.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;
}
.stories-info-more:hover { color: #fff; }

.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; }
.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);
}

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

@media only screen and (max-width: 767px) {
  .jbk9-stories .jbk9-stories__title { font-size: 22px; }
  .jbk9-stories .stories-item { padding: 0 5px; }
  .jbk9-stories .stories-item .img {
    width: 148px;
    height: 263px;
    padding: 2px;
    border-radius: 18px;
  }
  .jbk9-stories .stories-item .img img { border-radius: 14px; }
  .jbk9-stories .stories-item h6 {
    max-width: 148px;
    font-size: 14px;
  }
  /* просмотр сторис — не во весь экран, боковые отступы */
  .stories-overlay {
    padding: 16px 24px;
    align-items: center;
    box-sizing: border-box;
  }
  .stories-overlay .stories-viewer {
    max-width: calc(100vw - 48px);
    width: 100%;
    max-height: calc(100vh - 32px);
  }
  .stories-overlay video,
  .stories-overlay .stories-photo {
    border-radius: 12px;
    max-height: calc(100vh - 80px);
    width: 100%;
    aspect-ratio: 9 / 16;
    object-fit: contain;
    background: #000;
  }
  .stories-info { border-radius: 0 0 12px 12px; }
  .stories-overlay .stories-nav-prev,
  .stories-overlay .stories-nav-next {
    width: 40%;
  }
  .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; }
}


/* match home .section-title responsive — only homepage */
@media (max-width: 1199px) {
  body.id-1 .jbk9-stories .jbk9-stories__title.section-title {
    font-size: 40px;
  }
}
@media (max-width: 767px) {
  body.id-1 .jbk9-stories .jbk9-stories__title.section-title {
    font-size: 32px;
  }
}