/* Stories Container */
.stories-container {
	padding-left: 0px;
	width: 100%;
	max-width: 1500px;
	margin: 0px auto;
}

/* Stories Preview (horizontal scroll) */
.stories-preview {
	display: flex;
	gap: 12px;
	overflow-x: auto;
	padding: 10px 0px 20px 10px;
	scrollbar-width: none;
	-ms-overflow-style: none;
	flex-direction: row;
	flex-wrap: nowrap;
	align-content: center;
	justify-content: flex-start;
	align-items: center;
}

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

.story-avatar {
	flex-shrink: 0;
	cursor: pointer;
	text-align: center;
}

.story-avatar-ring {
	width: 96px;
	height: 96px;
	padding: 3px;
	background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s;
}

.story-avatar-ring:hover {
	transform: scale(1.05);
}

.story-avatar-ring.viewed {
	background: #c7c7c7;
}

.story-avatar-inner {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	border: 3px solid white;
	overflow: hidden;
}

.story-avatar-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.story-username {
	font-size: 14px;
	margin-top: 5px;
	color: #262626;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 96px;
}

/* Full Story Modal */
.story-modal {
	display: none;
	position: fixed;
	top: 0px;
	left: 0;
	width: 100%;
	height: 100vh;
	height: 100dvh;
	min-height: -webkit-fill-available;
	background: rgba(0, 0, 0, 0.95);
	z-index: 9999;
	align-items: center;
	justify-content: center;	
}

/* или с webkit-fill-available */
@supports (-webkit-touch-callout: none) {
  .story-modal {
	min-height: -webkit-fill-available !important;
  }
}

.story-modal.active {
	display: flex;
}

.story-viewer {
	position: relative;
	width: 100%;
	max-width: 500px;
	height: 100%;
	max-height: 90vh;
	background: #000;
	border-radius: 8px;
	overflow: hidden;
}

/* Fullscreen mode */
.story-modal.fullscreen {
	background: #000;
}

.story-modal.fullscreen .story-viewer {
	max-width: 100%;
	max-height: 100vh;
	border-radius: 0;
}

/* Progress Bars */
.story-progress-bars {
	position: absolute;
	top: 10px;
	left: 10px;
	right: 10px;
	display: flex;
	gap: 4px;
	z-index: 10;
}

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

.progress-bar-fill {
	height: 100%;
	background: white;
	width: 0%;
	transition: width 0.1s linear;
}

/* Header */
.story-header {
	position: absolute;
	top: 20px;
	left: 10px;
	right: 10px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	z-index: 10;
	margin-top: 15px;
}

.story-user-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.story-user-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 2px solid white;
	object-fit: cover;
}

.story-user-name {
	color: white;
	font-weight: 600;
	font-size: 14px;
}

.story-time {
	color: rgba(255, 255, 255, 0.7);
	font-size: 12px;
	margin-left: 5px;
}

.story-header-actions {
	display: flex;
	align-items: center;
	gap: 10px;
}

.fullscreen-btn {
	background: none;
	border: none;
	color: white;
	font-size: 20px;
	cursor: pointer;
	padding: 5px;
	line-height: 1;
}

.story-close {
	background: none;
	border: none;
	color: white;
	font-size: 28px;
	cursor: pointer;
	line-height: 1;
	padding: 5px;
}

/* Content */
.story-content {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.story-media {
	width: 100%;
	height: 100%;
	object-fit: contain;
}
video.story-media {
	object-fit: cover !important;
}

/* Call to Action Button */
.story-cta {
	position: absolute;
	bottom: 80px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 10;
	width: calc(100% - 40px);
	max-width: 400px;
	animation: ctaSlideUp 0.5s ease-out;
}

@keyframes ctaSlideUp {
	from {
		opacity: 0;
		transform: translateX(-50%) translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateX(-50%) translateY(0);
	}
}

.cta-button {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 16px 20px;
	background: var(--primary-color);
	border: none;
	border-radius: 22px;
	color: #fff;
	font-size: 15px;
	font-weight: normal;
	cursor: pointer;
	text-decoration: none;
	transition: all 0.2s ease;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.cta-button:hover {
	background: var(--primary-color);
	/* transform: translateY(-2px); */
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
	text-decoration: none;
	opacity: 0.9;
}

.cta-button:active {
	transform: translateY(0);
}

.cta-text {
	flex: 1;
	text-align: left;
}

.cta-icon {
	font-size: 18px;
	margin-left: 10px;
}

/* Swipe up indicator (опционально) */
.swipe-indicator {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.7);
	font-size: 12px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 5px;
	animation: bounce 2s infinite;
	z-index: 9;
}

@keyframes bounce {
	0%, 20%, 50%, 80%, 100% {
		transform: translateX(-50%) translateY(0);
	}
	40% {
		transform: translateX(-50%) translateY(-10px);
	}
	60% {
		transform: translateX(-50%) translateY(-5px);
	}
}

.swipe-icon {
	font-size: 20px;
}

/* Navigation Areas */
.story-nav-area {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 30%;
	cursor: pointer;
	z-index: 5;
}

.story-nav-prev {
	left: 0;
}

.story-nav-next {
	right: 0;
}

/* Navigation Buttons (mobile) */
.story-nav-buttons {
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	transform: translateY(-50%);
	display: flex;
	justify-content: space-between;
	padding: 0 10px;
	pointer-events: none;
	z-index: 9;
}

.nav-btn {
	pointer-events: all;
	background: rgba(0, 0, 0, 0.3);
	border: none;
	color: white;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	font-size: 20px;
	cursor: pointer;
	display: none;
}

@media (max-width: 768px) {
	.nav-btn {
		display: none;
	}
	.stories-preview {
		padding: 0px 0px 20px 10px;
	}
	.story-avatar-ring {
		width: 76px;
		height: 76px;
	}
	.story-username {
		font-size: 12px;
		max-width: 76px;
	}
}

/* Pause indicator */
.story-paused {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: white;
	font-size: 48px;
	z-index: 10;
	opacity: 0;
	transition: opacity 0.2s;
}

.story-viewer.paused .story-paused {
	opacity: 0.8;
}

@media (max-width: 768px) {
	.story-viewer {
		max-width: 100%;
		max-height: 100vh;
		border-radius: 0;
	}
}
/* ============================================================
   КВАДРАТНЫЕ STORIES (v2)
   Включается классом .stories-square на .stories-container.
   БЫСТРЫЙ ОТКАТ: убрать класс stories-square в index.php —
   вернётся исходный круглый вид (правила выше не тронуты).
   Полные копии исходников: css/stories_back.css, js/stories_back.js
   ============================================================ */

.stories-square {
	--stories-gap: 16px;
	--stories-per-view: 6;
	--stories-radius: 20px;
}

/* Рельса: выравнивание по слайдеру (.indexslides) + якорь для стрелок */
.stories-square .stories-rail {
	position: relative;
	padding: 0px;
}

.stories-square .stories-preview {
	gap: var(--stories-gap);
	padding: 10px 0px 20px 0px;
	align-items: flex-start;
	scroll-behavior: smooth;
}

.stories-square .story-avatar {
	position: relative;
	flex: 0 0 calc((100% - (var(--stories-per-view) - 1) * var(--stories-gap)) / var(--stories-per-view));
	width: calc((100% - (var(--stories-per-view) - 1) * var(--stories-gap)) / var(--stories-per-view));
	text-align: left;
}

/* Квадрат со скруглением как у слайдера, градиентная рамка сохранена */
.stories-square .story-avatar-ring {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	padding: 3px;
	border-radius: var(--stories-radius);
}

.stories-square .story-avatar-ring:hover {
	transform: none;
}

.stories-square .story-avatar-inner {
	border: none;
	border-radius: calc(var(--stories-radius) - 3px);
	background-color: #efefef;
	overflow: hidden;
}

.stories-square .story-avatar-image {
	display: block;
	transition: transform 0.35s ease;
}

.stories-square .story-avatar:hover .story-avatar-image {
	transform: scale(1.06);
}

/* Название — поверх картинки, с затемнением снизу */
.stories-square .story-username {
	position: absolute;
	left: 3px;
	right: 3px;
	bottom: 3px;
	margin: 0px;
	padding: 30px 12px 10px;
	max-width: none;
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.25;
	text-align: left;
	white-space: normal;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
	background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.42) 55%, rgba(0, 0, 0, 0) 100%);
	border-radius: 0 0 calc(var(--stories-radius) - 3px) calc(var(--stories-radius) - 3px);
	pointer-events: none;
}

/* Стрелки прокрутки — показываются только если есть куда листать */
.stories-square .stories-nav {
	position: absolute;
	top: 50%;
	margin-top: -5px; /* компенсация padding 10px сверху / 20px снизу у .stories-preview */
	transform: translateY(-50%);
	width: 44px;
	height: 44px;
	padding: 0px;
	border: none;
	border-radius: 50%;
	background: #fff;
	color: #262626;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	z-index: 5;
	display: none;
	align-items: center;
	justify-content: center;
	transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

.stories-square .stories-nav:hover {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.26);
}

.stories-square .stories-nav svg {
	display: block;
	width: 20px;
	height: 20px;
}

.stories-square .stories-nav-prev { left: 8px; }
.stories-square .stories-nav-next { right: 8px; }

.stories-square .stories-rail.can-scroll-prev .stories-nav-prev,
.stories-square .stories-rail.can-scroll-next .stories-nav-next {
	display: flex;
}

@media (max-width: 1380px) {
	.stories-square .stories-rail { padding: 0px 0px 0px 10px; }
}

@media (max-width: 959px) {
	.stories-square {
		--stories-per-view: 4.2;
		--stories-gap: 12px;
		--stories-radius: 16px;
	}
	.stories-square .stories-preview { padding: 0px 0px 20px 0px; }
	.stories-square .stories-nav { display: none !important; }
	.stories-square .story-username { font-size: 14px; }
}

@media (max-width: 767px) {
	.stories-square { --stories-per-view: 3.2; }
}

@media (max-width: 479px) {
	.stories-square { --stories-per-view: 2.3; }
	.stories-square .story-username { font-size: 13px; padding: 24px 10px 8px; }
}
