/**
 * Maati Stories — Frontend styles.
 * All selectors are namespaced under .maati- to avoid theme conflicts.
 */

.maati-stories-bar {
	--maati-thumb-size: 64px;
	--maati-accent: #6c2bd9;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	overflow: hidden;
}

.maati-stories-track {
	display: flex !important;
	gap: 16px !important;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 8px 4px 14px;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	list-style: none;
	margin: 0;
}

.maati-stories-track::-webkit-scrollbar {
	height: 6px;
}
.maati-stories-track::-webkit-scrollbar-thumb {
	background: rgba(0,0,0,.15);
	border-radius: 6px;
}

.maati-story-item {
	all: unset;
	box-sizing: border-box;
	display: flex !important;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	flex: 0 0 auto !important;
	width: calc(var(--maati-thumb-size) + 12px) !important;
	max-width: none !important;
	cursor: pointer;
	text-align: center;
}

.maati-story-item:focus-visible .maati-story-ring {
	outline: 2px solid var(--maati-accent);
	outline-offset: 3px;
}

.maati-story-ring {
	position: relative;
	width: var(--maati-thumb-size) !important;
	height: var(--maati-thumb-size) !important;
	border-radius: 50%;
	padding: 3px;
	background: linear-gradient(45deg, #f9ce34, #ee2a7b, #6228d7);
	transition: opacity .2s ease, filter .2s ease;
	flex-shrink: 0;
}

.maati-story-item.maati-seen .maati-story-ring {
	background: #d0d0d5;
}

.maati-stories-bar.maati-style-rounded .maati-story-ring,
.maati-stories-bar.maati-style-rounded .maati-story-thumb {
	border-radius: 18%;
}

.maati-stories-bar.maati-style-card .maati-story-item {
	width: var(--maati-thumb-size) !important;
	position: relative;
	gap: 0;
}

.maati-stories-bar.maati-style-card .maati-story-ring {
	width: 100% !important;
	aspect-ratio: 9 / 16;
	height: auto !important;
	border-radius: 12px;
	padding: 0;
	background: #222;
	overflow: hidden;
	position: relative;
}

.maati-stories-bar.maati-style-card .maati-story-thumb {
	border-radius: 12px;
	width: 100%;
	height: 100%;
	border: none;
	position: relative;
}

/* Darkening gradient so the overlaid title stays readable on any photo. */
.maati-stories-bar.maati-style-card .maati-story-thumb::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(0,0,0,.75) 0%, rgba(0,0,0,.15) 45%, rgba(0,0,0,0) 70%);
	border-radius: 12px;
}

.maati-stories-bar.maati-style-card .maati-story-badge {
	top: 8px;
	right: 8px;
	bottom: auto;
	z-index: 2;
}

.maati-stories-bar.maati-style-card .maati-story-title {
	position: absolute;
	left: 8px;
	right: 8px;
	bottom: 8px;
	z-index: 2;
	max-width: none;
	white-space: normal;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	color: #fff;
	font-weight: 700;
	text-align: left;
	text-shadow: 0 1px 4px rgba(0,0,0,.7);
}

.maati-story-thumb {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background-color: #eee;
	background-size: cover;
	background-position: center;
	border: 3px solid #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.maati-story-thumb-fallback {
	font-weight: 700;
	font-size: calc(var(--maati-thumb-size) * 0.35);
	color: #888;
	text-transform: uppercase;
}

.maati-story-badge {
	position: absolute;
	bottom: -4px;
	right: -4px;
	background: var(--maati-accent);
	color: #fff;
	font-size: 9px;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 8px;
	white-space: nowrap;
	box-shadow: 0 0 0 2px #fff;
}
.maati-story-badge.maati-badge-new {
	background: #e0245e;
}

.maati-story-title {
	font-size: 12px;
	line-height: 1.3;
	max-width: calc(var(--maati-thumb-size) + 16px);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: inherit;
}

/* ------------------------------------------------------------------ */
/* Viewer                                                              */
/* ------------------------------------------------------------------ */

.maati-stories-viewer {
	--maati-viewer-max-width: 420px;
	--maati-accent: #6c2bd9;
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
}
.maati-stories-viewer[hidden] {
	display: none;
}

body.maati-stories-open {
	overflow: hidden;
}

.maati-viewer-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.92);
}

.maati-viewer-frame {
	position: relative;
	width: 100%;
	max-width: var(--maati-viewer-max-width);
	height: 100%;
	max-height: 100vh;
	max-height: 100dvh;
	background: #000;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	padding-top: env(safe-area-inset-top);
	padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 620px) {
	.maati-viewer-frame {
		height: min(90vh, 780px);
		border-radius: 14px;
		box-shadow: 0 20px 60px rgba(0,0,0,.5);
	}
}

.maati-viewer-progress {
	display: flex;
	gap: 4px;
	padding: 10px 10px 0;
	position: relative;
	z-index: 3;
}

.maati-progress-seg {
	flex: 1;
	height: 3px;
	background: rgba(255,255,255,.35);
	border-radius: 3px;
	overflow: hidden;
}
.maati-progress-fill {
	height: 100%;
	width: 0%;
	background: #fff;
}

.maati-viewer-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 12px;
	position: relative;
	z-index: 3;
	color: #fff;
}

.maati-viewer-identity {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.maati-viewer-cover {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background-size: cover;
	background-position: center;
	background-color: #444;
	flex: 0 0 auto;
}

.maati-viewer-title {
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.maati-viewer-badge {
	font-size: 10px;
	background: rgba(255,255,255,.2);
	padding: 2px 8px;
	border-radius: 8px;
	flex: 0 0 auto;
}

.maati-viewer-controls {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 0 0 auto;
}

.maati-viewer-controls button {
	all: unset;
	cursor: pointer;
	color: #fff;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	border-radius: 50%;
}
.maati-viewer-controls button:focus-visible {
	outline: 2px solid #fff;
}
.maati-viewer-controls button:hover {
	background: rgba(255,255,255,.12);
}

.maati-viewer-stage {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #000;
	overflow: hidden;
}

.maati-slide {
	position: relative;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.maati-slide-media {
	max-width: 100%;
	max-height: 100%;
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #000;
}

.maati-slide-image .maati-slide-media,
.maati-slide-video .maati-slide-media {
	object-fit: cover;
}

.maati-slide-overlay {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
	background: linear-gradient(to top, rgba(0,0,0,.75), rgba(0,0,0,0));
	color: #fff;
}
.maati-slide-overlay h3 {
	margin: 0 0 6px;
	font-size: 18px;
}
.maati-slide-overlay p {
	margin: 0;
	font-size: 13px;
	opacity: .9;
}
.maati-align-center { text-align: center; }
.maati-align-right  { text-align: right; }

.maati-slide-text {
	flex-direction: column;
	padding: 40px 28px;
	box-sizing: border-box;
}
.maati-text-slide-content h3 {
	margin: 0 0 12px;
}
.maati-text-slide-content p {
	margin: 0;
	opacity: .92;
}
.maati-slide-text.maati-font-small h3 { font-size: 20px; }
.maati-slide-text.maati-font-medium h3 { font-size: 28px; }
.maati-slide-text.maati-font-large h3 { font-size: 36px; }
.maati-slide-text.maati-font-xlarge h3 { font-size: 46px; }
.maati-slide-text.maati-font-small p { font-size: 14px; }
.maati-slide-text.maati-font-medium p { font-size: 16px; }
.maati-slide-text.maati-font-large p { font-size: 19px; }
.maati-slide-text.maati-font-xlarge p { font-size: 22px; }

.maati-slide-offer {
	flex-direction: column;
	background: #111;
}
.maati-offer-panel {
	padding: 20px 24px calc(20px + env(safe-area-inset-bottom));
	color: #fff;
	width: 100%;
	box-sizing: border-box;
	background: linear-gradient(to top, rgba(0,0,0,.85), rgba(0,0,0,.1));
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
}
.maati-offer-discount {
	display: inline-block;
	background: #e0245e;
	color: #fff;
	font-weight: 700;
	font-size: 12px;
	padding: 3px 10px;
	border-radius: 4px;
	margin-bottom: 8px;
}
.maati-offer-panel h3 {
	margin: 0 0 8px;
	font-size: 22px;
}
.maati-offer-prices {
	display: flex;
	gap: 10px;
	align-items: baseline;
	margin-bottom: 6px;
}
.maati-offer-prices s {
	opacity: .6;
}
.maati-offer-prices strong {
	font-size: 20px;
	color: #4ade80;
}
.maati-offer-panel p {
	margin: 0;
	font-size: 13px;
	opacity: .9;
}

.maati-media-error {
	background: #1a1a1a;
}
.maati-media-error-msg {
	color: #999;
	font-size: 40px;
}

.maati-viewer-nav {
	all: unset;
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	display: none;
	align-items: center;
	justify-content: center;
	color: #fff;
	background: rgba(0,0,0,.25);
	border-radius: 50%;
	cursor: pointer;
	font-size: 22px;
	z-index: 3;
}
.maati-nav-prev { left: 10px; }
.maati-nav-next { right: 10px; }

@media (hover: hover) and (pointer: fine) {
	.maati-viewer-nav {
		display: flex;
	}
}
.maati-viewer-nav:focus-visible {
	outline: 2px solid #fff;
}

.maati-viewer-cta-slot {
	position: relative;
	z-index: 4;
	padding: 0 16px calc(16px + env(safe-area-inset-bottom));
	margin-top: -1px;
}

.maati-cta-button {
	display: block;
	width: 100%;
	box-sizing: border-box;
	text-align: center;
	background: var(--maati-accent);
	color: #fff;
	text-decoration: none;
	font-weight: 700;
	font-size: 15px;
	padding: 13px 16px;
	border-radius: 10px;
	transition: transform .15s ease, opacity .15s ease;
}
.maati-cta-button:hover {
	opacity: .92;
}
.maati-cta-button:active {
	transform: scale(.98);
}
.maati-cta-button:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* RTL                                                                  */
/* ------------------------------------------------------------------ */
html[dir="rtl"] .maati-story-badge {
	right: auto;
	left: -4px;
}
html[dir="rtl"] .maati-nav-prev {
	left: auto;
	right: 10px;
}
html[dir="rtl"] .maati-nav-next {
	right: auto;
	left: 10px;
}
html[dir="rtl"] .maati-align-right {
	text-align: left;
}

/* ------------------------------------------------------------------ */
/* Reduced motion                                                      */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
	.maati-stories-track {
		scroll-behavior: auto;
	}
	.maati-story-ring,
	.maati-cta-button {
		transition: none;
	}
}

/* ------------------------------------------------------------------ */
/* Small screens                                                       */
/* ------------------------------------------------------------------ */
@media (max-width: 480px) {
	.maati-viewer-title {
		max-width: 160px;
	}
}
