/* Taheriniya Stories — Instagram-style circles */

.taheriniya-stories {
	--taheriniya-circle-size: 74px;
	--taheriniya-card-width: var(--taheriniya-circle-size);
	--taheriniya-ring-width: 2.5px;
	--taheriniya-ring-gap: 3px;
	--taheriniya-gap: 14px;
	--taheriniya-ring-bg: linear-gradient(45deg, #f9ce34 0%, #ee2a7b 50%, #6228d7 100%);
	--taheriniya-ring-seen: #dbdbdb;
	--taheriniya-progress-color: #ffffff;
	--taheriniya-viewer-bg: #1a1a1a;

	width: 100%;
	overflow: hidden;
	background: transparent;
}

.taheriniya-stories__track {
	display: flex;
	gap: var(--taheriniya-gap);
	overflow-x: auto;
	padding: 8px 12px 10px;
	scroll-snap-type: x proximity;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.taheriniya-stories__track::-webkit-scrollbar {
	display: none;
}

.taheriniya-stories__item {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: var(--taheriniya-card-width);
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	scroll-snap-align: start;
	font-family: "Vazirmatn", Tahoma, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: inherit;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
}

.taheriniya-stories__ring {
	position: relative;
	display: block;
	width: var(--taheriniya-card-width);
	height: var(--taheriniya-card-width);
	padding: var(--taheriniya-ring-width);
	border-radius: 50%;
	background: var(--taheriniya-ring-bg);
	box-sizing: border-box;
	transition: transform 0.2s ease, filter 0.2s ease;
}

.taheriniya-stories__item:hover .taheriniya-stories__ring,
.taheriniya-stories__item:focus-visible .taheriniya-stories__ring {
	transform: scale(1.04);
}

.taheriniya-stories__item:focus-visible {
	outline: none;
}

.taheriniya-stories__item:focus-visible .taheriniya-stories__ring {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.taheriniya-stories__item:active .taheriniya-stories__ring {
	transform: scale(0.97);
}

.taheriniya-stories__item.is-seen .taheriniya-stories__ring {
	background: var(--taheriniya-ring-seen) !important;
}

.taheriniya-stories__avatar {
	display: block;
	width: 100%;
	height: 100%;
	padding: var(--taheriniya-ring-gap);
	border-radius: 50%;
	overflow: hidden;
	background: #fff;
	box-sizing: border-box;
}

.taheriniya-stories__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: 50%;
}

.taheriniya-stories__placeholder {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background: linear-gradient(160deg, #833ab4, #fd1d1d, #fcb045);
}

.taheriniya-stories__title {
	display: block;
	width: 100%;
	margin-top: 6px;
	font-size: 12px;
	line-height: 1.3;
	font-weight: 400;
	color: inherit;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.taheriniya-stories__item:not(.is-seen) .taheriniya-stories__ring {
	animation: taheriniya-ring-glow 3.2s ease-in-out infinite;
}

@keyframes taheriniya-ring-glow {
	0%,
	100% {
		filter: saturate(1);
	}
	50% {
		filter: saturate(1.18) brightness(1.04);
	}
}

@media (prefers-reduced-motion: reduce) {
	.taheriniya-stories__item:not(.is-seen) .taheriniya-stories__ring,
	.taheriniya-stories__ring,
	.taheriniya-stories__avatar img,
	.taheriniya-viewer__media-enter--next,
	.taheriniya-viewer__media-enter--prev {
		animation: none;
		transition: none;
	}
}

@media (max-width: 640px) {
	.taheriniya-stories {
		--taheriniya-card-width: min(var(--taheriniya-circle-size), 66px);
		--taheriniya-gap: 12px;
	}

	.taheriniya-stories__title {
		font-size: 11px;
		margin-top: 5px;
	}
}

.taheriniya-stories-empty {
	padding: 12px;
	background: #fff3cd;
	border: 1px solid #ffecb5;
	border-radius: 8px;
}

/* ── Viewer (Instagram modal) ── */

.taheriniya-viewer {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.taheriniya-viewer[hidden] {
	display: none !important;
}

.taheriniya-viewer__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(8, 8, 10, 0.88);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
}

.taheriniya-viewer__frame {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 0;
}

.taheriniya-viewer__container {
	position: relative;
	width: 100%;
	max-width: 420px;
	aspect-ratio: 9 / 16;
	max-height: 100dvh;
	background: var(--taheriniya-viewer-bg, #000);
	overflow: hidden;
	border-radius: 18px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
}

@media (max-width: 768px) {
	.taheriniya-viewer__container {
		max-width: 100%;
		height: 100dvh;
		max-height: 100dvh;
		aspect-ratio: unset;
		border-radius: 0;
	}

	.taheriniya-viewer__slide-nav {
		width: 38px;
		height: 38px;
	}

	.taheriniya-viewer__slide-nav--prev {
		left: max(8px, env(safe-area-inset-left));
	}

	.taheriniya-viewer__slide-nav--next {
		right: max(8px, env(safe-area-inset-right));
	}
}

/* Progress bars */
.taheriniya-viewer__progress {
	position: absolute;
	top: 8px;
	left: 8px;
	right: 8px;
	z-index: 10;
	display: flex;
	gap: 4px;
}

.taheriniya-viewer__bar {
	flex: 1;
	height: 2px;
	background: rgba(255, 255, 255, 0.35);
	border-radius: 2px;
	overflow: hidden;
}

.taheriniya-viewer__bar span {
	display: block;
	height: 100%;
	width: 0;
	background: var(--taheriniya-progress-color);
	border-radius: inherit;
}

.taheriniya-viewer__bar.is-done span {
	width: 100%;
}

/* Header */
.taheriniya-viewer__header {
	position: absolute;
	top: 18px;
	left: 0;
	right: 0;
	z-index: 15;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 12px;
	pointer-events: none;
}

.taheriniya-viewer__user {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	pointer-events: auto;
}

.taheriniya-viewer__avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	border: 1px solid rgba(255, 255, 255, 0.4);
}

.taheriniya-viewer__user-info {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
	color: #fff;
	font-size: 13px;
	line-height: 1;
	font-weight: 600;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.taheriniya-viewer__name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.taheriniya-viewer__time {
	font-weight: 400;
	opacity: 0.85;
	font-size: 12px;
	flex-shrink: 0;
}

.taheriniya-viewer__time::before {
	content: "·";
	margin-left: 4px;
	margin-right: 4px;
}

.taheriniya-viewer__actions {
	pointer-events: auto;
	position: relative;
	z-index: 20;
}

.taheriniya-viewer__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	background: rgba(0, 0, 0, 0.55);
	border: 1.5px solid rgba(255, 255, 255, 0.45);
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
	transition: background 0.15s ease, transform 0.15s ease;
}

.taheriniya-viewer__close svg {
	width: 18px;
	height: 18px;
	stroke-width: 2.5;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.taheriniya-viewer__close:hover {
	background: rgba(0, 0, 0, 0.75);
	transform: scale(1.05);
}

.taheriniya-viewer__close:active {
	transform: scale(0.97);
}

/* Backdrop close — visible on desktop outside story frame */
.taheriniya-viewer__backdrop-close {
	position: absolute;
	top: 20px;
	right: 20px;
	z-index: 5;
	display: none;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 16px;
	background: rgba(255, 255, 255, 0.15);
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: 999px;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	cursor: pointer;
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	transition: background 0.15s ease;
}

.taheriniya-viewer__backdrop-close:hover {
	background: rgba(255, 255, 255, 0.25);
}

.taheriniya-viewer__backdrop-close svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

@media (min-width: 769px) {
	.taheriniya-viewer__backdrop-close {
		display: flex;
	}
}

/* Media stage */
.taheriniya-viewer__stage {
	position: absolute;
	inset: 0;
	background: #000;
	overflow: hidden;
}

.taheriniya-viewer__media {
	width: 100%;
	height: 100%;
	will-change: transform, opacity;
}

.taheriniya-viewer__media img,
.taheriniya-viewer__media video {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	background: #000;
}

.taheriniya-viewer__media-enter--next,
.taheriniya-viewer__media-enter--prev {
	animation-duration: 0.28s;
	animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
	animation-fill-mode: both;
}

.taheriniya-viewer__media-enter--next {
	animation-name: taheriniya-media-in-next;
}

.taheriniya-viewer__media-enter--prev {
	animation-name: taheriniya-media-in-prev;
}

@keyframes taheriniya-media-in-next {
	from {
		transform: translateX(18%);
		opacity: 0.35;
	}
	to {
		transform: none;
		opacity: 1;
	}
}

@keyframes taheriniya-media-in-prev {
	from {
		transform: translateX(-18%);
		opacity: 0.35;
	}
	to {
		transform: none;
		opacity: 1;
	}
}

.taheriniya-viewer__tap {
	position: absolute;
	top: 56px;
	bottom: 0;
	z-index: 5;
	width: 35%;
}

.taheriniya-viewer__tap--prev {
	left: 0;
}

.taheriniya-viewer__tap--next {
	right: 0;
}

.taheriniya-viewer__slide-nav {
	position: absolute;
	top: 50%;
	z-index: 12;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.42);
	color: #fff;
	cursor: pointer;
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
	transform: translateY(-50%);
	transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.taheriniya-viewer__slide-nav svg {
	width: 22px;
	height: 22px;
	stroke-width: 2.4;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.taheriniya-viewer__slide-nav--prev {
	left: 10px;
}

.taheriniya-viewer__slide-nav--next {
	right: 10px;
}

.taheriniya-viewer__slide-nav:hover {
	background: rgba(255, 255, 255, 0.22);
	transform: translateY(-50%) scale(1.08);
}

.taheriniya-viewer__slide-nav:active {
	transform: translateY(-50%) scale(0.96);
}

.taheriniya-viewer__slide-nav:disabled {
	opacity: 0.22;
	cursor: default;
	pointer-events: none;
}

.taheriniya-viewer__slide-nav:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Footer / caption */
.taheriniya-viewer__footer {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 8;
	padding: 40px 16px 24px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
	pointer-events: none;
}

.taheriniya-viewer__caption {
	color: #fff;
	font-size: 14px;
	line-height: 1.45;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
	margin-bottom: 8px;
	word-break: break-word;
}

.taheriniya-viewer__caption:empty {
	display: none;
}

.taheriniya-viewer__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: #fff;
	text-decoration: none;
	font-size: 14px;
	font-weight: 600;
	pointer-events: auto;
	text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.taheriniya-viewer__link:hover,
.taheriniya-viewer__link:focus {
	color: #fff;
	opacity: 0.9;
}

/* User navigation arrows (desktop — like Instagram web) */
.taheriniya-viewer__user-nav {
	position: relative;
	z-index: 2;
	display: none;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	border: 1px solid rgba(255, 255, 255, 0.28);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	margin: 0 16px;
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
	transition: background 0.15s ease, transform 0.15s ease;
}

.taheriniya-viewer__user-nav:hover {
	background: rgba(255, 255, 255, 0.28);
	transform: scale(1.06);
}

.taheriniya-viewer__user-nav:disabled {
	opacity: 0.25;
	cursor: default;
	pointer-events: none;
	transform: none;
}

@media (min-width: 769px) {
	.taheriniya-viewer__user-nav {
		display: flex;
	}
}

/* Pause state */
.taheriniya-viewer.is-paused .taheriniya-viewer__bar span {
	transition: none;
}

html.taheriniya-viewer-open {
	overflow: hidden;
}

html.taheriniya-viewer-open body {
	overflow: hidden;
}
