/**
 * Story Lens front end.
 *
 * Colours are pulled from the host theme first. Kadence exposes its palette as
 * --global-palette1..9, so a site using Kadence gets the viewer in its own brand
 * colours with no configuration. Every variable has a neutral fallback for
 * themes that expose nothing.
 *
 * The player is deliberately the only loud element on the page. Everything
 * around it stays quiet so it does not fight the theme it is embedded in.
 */

.slens {
	--slens-ink: var(--global-palette4, #1f2933);
	--slens-muted: var(--global-palette5, #6b7684);
	--slens-line: var(--global-palette7, #e3e6ea);
	--slens-surface: var(--global-palette9, #ffffff);
	--slens-accent: var(--global-palette1, #3d5afe);
	--slens-accent-ink: var(--global-palette9, #ffffff);
	--slens-radius: 10px;

	color: var(--slens-ink);
	container-type: inline-size;
	max-width: 720px;
	margin-inline: auto;
}

.slens *,
.slens *::before,
.slens *::after {
	box-sizing: border-box;
}

/* ---------- Search ---------- */

.slens-search__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.slens-search__row {
	display: flex;
	align-items: stretch;
	gap: 8px;
	border: 1px solid var(--slens-line);
	border-radius: var(--slens-radius);
	background: var(--slens-surface);
	padding: 4px 4px 4px 14px;
	transition: border-color 120ms ease;
}

.slens-search__row:focus-within {
	border-color: var(--slens-accent);
}

.slens-search__at {
	align-self: center;
	color: var(--slens-muted);
	font-size: 1rem;
	line-height: 1;
}

.slens-search__input {
	flex: 1;
	border: 0;
	background: none;
	padding: 12px 0;
	font: inherit;
	font-size: 1rem;
	color: inherit;
	min-width: 0;
}

.slens-search__input:focus {
	outline: none;
}

.slens-search__go {
	border: 0;
	border-radius: calc(var(--slens-radius) - 3px);
	background: var(--slens-accent);
	color: var(--slens-accent-ink);
	font: inherit;
	font-weight: 600;
	padding: 0 22px;
	cursor: pointer;
}

.slens-search__go:disabled {
	opacity: 0.55;
	cursor: progress;
}

/* ---------- Status ---------- */

.slens-status {
	margin-top: 12px;
	font-size: 0.9375rem;
	color: var(--slens-muted);
	min-height: 1.4em;
}

.slens-status--error {
	color: #b3261e;
}

.slens-status__dots::after {
	content: "";
	animation: slens-dots 1.2s steps(4, end) infinite;
}

@keyframes slens-dots {
	0% { content: ""; }
	25% { content: "."; }
	50% { content: ".."; }
	75% { content: "..."; }
}

/* ---------- Profile ---------- */

.slens-profile {
	display: flex;
	gap: 16px;
	align-items: flex-start;
	margin-top: 20px;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--slens-line);
}

.slens-profile__avatar {
	width: 76px;
	height: 76px;
	border-radius: 50%;
	object-fit: cover;
	flex: 0 0 auto;
	background: var(--slens-line);
}

.slens-profile__name {
	font-size: 1.125rem;
	font-weight: 650;
	margin: 0;
	display: flex;
	align-items: center;
	gap: 6px;
}

.slens-profile__handle {
	color: var(--slens-muted);
	font-size: 0.9375rem;
	margin: 2px 0 8px;
}

.slens-profile__check {
	color: var(--slens-accent);
	flex: 0 0 auto;
}

.slens-profile__stats {
	display: flex;
	gap: 18px;
	margin: 0 0 8px;
	padding: 0;
	list-style: none;
	font-size: 0.875rem;
	color: var(--slens-muted);
	flex-wrap: wrap;
}

.slens-profile__stats b {
	color: var(--slens-ink);
	font-weight: 600;
}

.slens-profile__bio {
	margin: 0;
	font-size: 0.9375rem;
	line-height: 1.55;
	white-space: pre-line;
	max-width: 60ch;
}

/* ---------- Tabs ---------- */

.slens-tabs {
	display: flex;
	gap: 4px;
	margin: 16px 0 20px;
	border-bottom: 1px solid var(--slens-line);
}

.slens-tab {
	border: 0;
	background: none;
	font: inherit;
	font-size: 0.9375rem;
	color: var(--slens-muted);
	padding: 10px 14px;
	cursor: pointer;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
}

.slens-tab[aria-selected="true"] {
	color: var(--slens-ink);
	border-bottom-color: var(--slens-accent);
	font-weight: 600;
}

.slens-tab:focus-visible {
	outline: 2px solid var(--slens-accent);
	outline-offset: -2px;
}

/* ---------- Grid ---------- */

.slens-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.slens-grid--stories {
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.slens-card {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 9 / 16;
	border: 0;
	padding: 0;
	border-radius: 8px;
	overflow: hidden;
	background: var(--slens-line);
	cursor: pointer;
}

.slens-grid--posts .slens-card {
	aspect-ratio: 1;
}

.slens-card img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.slens-card:focus-visible {
	outline: 3px solid var(--slens-accent);
	outline-offset: 2px;
}

.slens-card__badge {
	position: absolute;
	top: 6px;
	right: 6px;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	border-radius: 4px;
	padding: 2px 5px;
	font-size: 0.6875rem;
	line-height: 1.4;
}

.slens-card__title {
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	padding: 18px 8px 7px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
	color: #fff;
	font-size: 0.8125rem;
	text-align: start;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.slens-empty {
	color: var(--slens-muted);
	font-size: 0.9375rem;
	padding: 28px 0;
	margin: 0;
	max-width: 48ch;
}

/* ---------- Player ---------- */

.slens-player {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: #08090b;
	display: grid;
	grid-template-rows: auto 1fr auto;
	align-items: center;
	justify-items: center;
}

.slens-player[hidden] {
	display: none;
}

.slens-player__bars {
	grid-row: 1;
	display: flex;
	gap: 3px;
	width: min(440px, 92vw);
	padding: 14px 0 0;
	align-self: start;
}

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

.slens-bar__fill {
	display: block;
	height: 100%;
	width: 0;
	background: #fff;
}

.slens-bar--done .slens-bar__fill {
	width: 100%;
}

.slens-player__stage {
	grid-row: 2;
	width: min(440px, 100vw);
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px 0;
}

.slens-player__stage img,
.slens-player__stage video {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 8px;
	background: #000;
}

.slens-player__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	width: 40px;
	height: 40px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
}

.slens-player__nav {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 32%;
	border: 0;
	background: none;
	cursor: pointer;
	opacity: 0;
}

.slens-player__nav--prev { left: 0; }
.slens-player__nav--next { right: 0; }

.slens-player__nav:focus-visible {
	opacity: 1;
	background: rgba(255, 255, 255, 0.08);
	outline: 2px solid #fff;
	outline-offset: -6px;
}

.slens-player__meta {
	grid-row: 3;
	width: min(440px, 92vw);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 0 20px;
	color: rgba(255, 255, 255, 0.72);
	font-size: 0.8125rem;
	z-index: 2;
}

.slens-save {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border: 1px solid rgba(255, 255, 255, 0.28);
	border-radius: 999px;
	background: none;
	color: #fff;
	font: inherit;
	font-size: 0.8125rem;
	padding: 7px 16px;
	text-decoration: none;
	cursor: pointer;
}

.slens-save:hover,
.slens-save:focus-visible {
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
}

/* ---------- Narrow screens ---------- */

@container (max-width: 420px) {
	.slens-profile {
		gap: 12px;
	}

	.slens-profile__avatar {
		width: 60px;
		height: 60px;
	}

	.slens-search__go {
		padding: 0 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.slens-status__dots::after {
		animation: none;
		content: "…";
	}

	.slens-bar__fill {
		transition: none !important;
	}
}
