/* ===== Widget container ===== */
.topky-stories-widget {
	background: #ffffff;
	padding: 10px 0;
	overflow: hidden;
	height: 92px;
}

.topky-stories-widget * {
	box-sizing: border-box;
}

/* ===== Circles container ===== */
.stories-circles-container {
	display: flex;
	gap: 12px;
	padding: 0 12px;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.stories-circles-container::-webkit-scrollbar {
	display: none;
}

/* ===== Circle item ===== */
.circle-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0;
	cursor: pointer;
	flex-shrink: 0;
	-webkit-tap-highlight-color: transparent;
}

.circle-item:active .circle-border {
	transform: scale(0.95);
}

.circle-border {
	width: 65px;
	height: 65px;
	border-radius: 50%;
	padding: 3px;
	position: relative;
	transition: transform 200ms ease;
}

.circle-inner {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background: #fff;
	padding: 2px;
	overflow: hidden;
}

.circle-img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
	display: block;
}

.circle-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #EB1423;
	color: #fff;
	font-size: 11px;
	font-weight: bold;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #fff;
	line-height: 1;
}

.circle-label {
	font-size: 12px;
	font-weight: 600;
	color: #333;
	max-width: 80px;
	text-align: center;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ===== Story overlay ===== */
.story-overlay {
	position: fixed;
	inset: 0;
	background: #000;
	z-index: 2000001;
	opacity: 0;
	visibility: hidden;
	transition: opacity 300ms ease;
}

.story-overlay.active {
	opacity: 1;
	visibility: visible;
}

.story-content {
	width: 100%;
	height: 100%;
	position: relative;
	overflow: hidden;
}

.story-main-content {
	width: 100%;
	height: 100%;
	position: relative;
}

/* ===== Progress bar ===== */
.progress-container {
	display: flex;
	gap: 4px;
	padding: 8px 8px 0;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 30;
}

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

.progress-fill {
	height: 100%;
	background: #fff;
	width: 0;
	border-radius: 1px;
}

.progress-fill.completed {
	width: 100%;
}

.progress-fill.active {
	animation: progressFill 7s linear forwards;
}

.progress-fill.ad-active {
	animation: progressFill 10s linear forwards;
}

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

/* ===== Story header ===== */
.story-header {
	position: absolute;
	top: 14px;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 12px 0;
	z-index: 30;
}

.story-category {
	display: flex;
	align-items: center;
	gap: 8px;
}

.category-icon {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 1.5px solid #fff;
	object-fit: cover;
}

.category-name {
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
	text-transform: uppercase;
}

.story-close {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.5);
	border: none;
	color: #fff;
	font-size: 32px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	padding: 0;
	-webkit-tap-highlight-color: transparent;
}


/* ===== Story containers (dual-container pattern) ===== */
.story-container {
	position: absolute;
	inset: 0;
	will-change: transform, opacity;
}

.story-container.current {
	z-index: 1;
}

.story-container.next {
	z-index: 2;
	pointer-events: none;
}

.story-container.slide-in-next {
	animation: slideInFromRight 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.story-container.slide-in-prev {
	animation: slideInFromLeft 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.story-container.slide-out-next {
	animation: slideOutToLeft 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.story-container.slide-out-prev {
	animation: slideOutToRight 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInFromRight {
	from { transform: translateX(100%); }
	to { transform: translateX(0); }
}

@keyframes slideInFromLeft {
	from { transform: translateX(-100%); }
	to { transform: translateX(0); }
}

@keyframes slideOutToLeft {
	from { transform: translateX(0); }
	to { transform: translateX(-100%); }
}

@keyframes slideOutToRight {
	from { transform: translateX(0); }
	to { transform: translateX(100%); }
}

/* ===== Story slide ===== */
.story-slide {
	width: 100%;
	height: 100%;
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
}

.story-image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	animation: storyZoom 7s linear forwards;
}

@keyframes storyZoom {
	from { transform: scale(1.15); }
	to { transform: scale(1); }
}

.story-gradient {
	position: absolute;
	inset: 0;
	background: linear-gradient(
		to bottom,
		rgba(0, 0, 0, 0.6) 0%,
		transparent 50%,
		transparent 60%,
		rgba(0, 0, 0, 0.85) 85%
	);
	z-index: 1;
}

.story-text-area {
	position: relative;
	z-index: 2;
	padding: 0 16px 40px;
}

.story-title {
	display: block;
	font-size: 26px;
	font-weight: bold;
	color: #fff;
	text-decoration: none;
	line-height: 1.2;
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
	margin: 0 0 16px;
}

.story-cta {
	display: inline-block;
	background: #EB1423;
	color: #fff;
	text-decoration: none;
	padding: 10px 24px;
	border-radius: 25px;
	font-size: 13px;
	font-weight: bold;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* ===== Image error fallback ===== */
.story-image-error {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background: #1a1a1a;
	color: rgba(255, 255, 255, 0.6);
	font-size: 14px;
	gap: 16px;
	z-index: 1;
}

.story-image-error a {
	display: inline-block;
	background: #EB1423;
	color: #fff;
	text-decoration: none;
	padding: 10px 24px;
	border-radius: 25px;
	font-size: 13px;
	font-weight: bold;
	text-transform: uppercase;
}

/* ===== Ad overlay ===== */
.ad-overlay {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	background: #1a1a1a;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	z-index: 10;
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
}

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

.ad-label {
	color: rgba(255, 255, 255, 0.5);
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 2px;
}

.ad-slot-container {
	width: 300px;
	height: 250px;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* ===== Responsive: mobile < 768px ===== */
@media (max-width: 767px) {
	.story-content {
		border-radius: 0;
	}

	.story-text-area {
		text-align: left;
		padding: 0 14px 32px;
	}

	.story-title {
		font-size: 28px;
	}

	script[src$="story-widget.js"] + .box-special-event {
		margin-top: 0 !important;
	}
}

/* ===== Responsive: tablet 768px-1023px ===== */
@media (min-width: 768px) and (max-width: 1023px) {
	.story-content {
		max-width: 480px;
		max-height: 85vh;
		margin: auto;
		border-radius: 12px;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}
}

/* ===== Desktop: hide everything ===== */
@media (min-width: 1024px) {
	.topky-stories-widget {
		display: none !important;
	}

	.story-overlay {
		display: none !important;
	}
}
