/* Widget gallery — matches root style.css tokens. */

html,
body.gallery-body {
	overflow: auto;
	height: auto;
	min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.gallery-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--space-md) var(--space-lg);
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	position: sticky;
	top: 0;
	z-index: 10;
}

.gallery-header h1 {
	margin: 0;
	font-size: var(--text-lg);
	font-weight: 600;
}

.gallery-header h1 a {
	color: inherit;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: var(--space-xs);
}

.gallery-header .features-nav {
	display: flex;
	gap: var(--space-md);
	align-items: center;
	font-size: var(--text-sm);
}

.gallery-header .features-nav a {
	color: rgba(229, 229, 229, 0.65);
	text-decoration: none;
	padding: var(--space-xs) var(--space-sm);
	border-radius: var(--radius-md);
	transition:
		color 0.15s,
		background 0.15s;
}

.gallery-header .features-nav a:hover,
.gallery-header .features-nav a.active {
	color: #fff;
	background: rgba(255, 255, 255, 0.06);
}

/* ── Main layout ─────────────────────────────────────────────────────────────── */

.gallery-main {
	max-width: 1400px;
	margin: 0 auto;
	padding: var(--space-2xl) var(--space-lg);
	display: flex;
	flex-direction: column;
	gap: var(--space-2xl);
}

/* ── Hero ────────────────────────────────────────────────────────────────────── */

.gallery-hero {
	text-align: center;
	display: flex;
	flex-direction: column;
	gap: var(--space-md);
	align-items: center;
}

.gallery-hero .eyebrow {
	margin: 0;
	font-size: var(--text-sm);
	letter-spacing: 4px;
	text-transform: uppercase;
	color: var(--accent);
	font-weight: 600;
}

.gallery-hero h2 {
	margin: 0;
	font-family: var(--font-display);
	font-size: var(--text-2xl);
	font-weight: 300;
	letter-spacing: -1px;
	line-height: 1.1;
}

.gallery-hero .lede {
	max-width: 60ch;
	margin: 0;
	font-size: var(--text-lg);
	color: rgba(229, 229, 229, 0.7);
	line-height: var(--leading-normal);
}

.hero-badges {
	display: flex;
	gap: var(--space-sm);
	flex-wrap: wrap;
	justify-content: center;
	margin-top: var(--space-xs);
}

.hero-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.3rem 0.75rem;
	border-radius: 999px;
	font-size: var(--text-sm);
	font-weight: 500;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.1);
	color: rgba(229, 229, 229, 0.8);
}

.hero-badge-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 8px var(--accent);
}

.cta-row {
	display: flex;
	gap: var(--space-sm);
	flex-wrap: wrap;
	justify-content: center;
	margin-top: var(--space-sm);
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */

.btn {
	display: inline-flex;
	align-items: center;
	gap: var(--space-xs);
	padding: var(--space-sm) var(--space-lg);
	border-radius: 999px;
	font-family: var(--font-body);
	font-size: var(--text-base);
	font-weight: 500;
	text-decoration: none;
	border: 1px solid transparent;
	cursor: pointer;
	transition:
		transform 0.15s,
		background 0.15s,
		border-color 0.15s;
}

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

.btn-primary {
	background: var(--accent);
	color: #fff;
}

.btn-primary:hover {
	transform: translateY(-1px);
	background: #7c3aed;
}

.btn-ghost {
	background: transparent;
	color: rgba(229, 229, 229, 0.85);
	border-color: rgba(255, 255, 255, 0.18);
}

.btn-ghost:hover {
	background: rgba(255, 255, 255, 0.06);
}

/* ── Filter bar ──────────────────────────────────────────────────────────────── */

.filter-bar {
	display: flex;
	gap: var(--space-sm);
	flex-wrap: wrap;
	align-items: center;
}

.filter-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.45rem 1rem;
	border-radius: 999px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	background: rgba(255, 255, 255, 0.04);
	color: rgba(229, 229, 229, 0.7);
	font-family: var(--font-body);
	font-size: var(--text-sm);
	font-weight: 500;
	cursor: pointer;
	transition:
		background 0.15s,
		border-color 0.15s,
		color 0.15s;
	white-space: nowrap;
}

.filter-btn::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--type-color, transparent);
	display: none;
}

.filter-btn[data-type]::before {
	display: block;
}

.filter-btn:hover {
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	border-color: rgba(255, 255, 255, 0.2);
}

.filter-btn[data-active='true'] {
	background: rgba(255, 255, 255, 0.1);
	border-color: var(--type-color, rgba(255, 255, 255, 0.4));
	color: #fff;
}

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

/* ── Gallery grid ────────────────────────────────────────────────────────────── */

.gallery-grid {
	display: flex;
	flex-direction: column;
	gap: var(--space-2xl);
}

.gallery-grid .loading {
	color: rgba(229, 229, 229, 0.55);
	text-align: center;
}

/* ── Skeleton shimmer ────────────────────────────────────────────────────────── */

@keyframes shimmer {
	0% {
		background-position: -600px 0;
	}
	100% {
		background-position: 600px 0;
	}
}

.skel-block,
.skel-line {
	border-radius: var(--radius-md);
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.04) 75%);
	background-size: 600px 100%;
	animation: shimmer 1.6s infinite linear;
}

.skel-row {
	display: flex;
	gap: var(--space-xs);
	margin-top: var(--space-sm);
}

.showcase-skeleton .showcase-frame {
	min-height: 400px;
}

/* ── Showcase card ───────────────────────────────────────────────────────────── */

.showcase {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(280px, 400px);
	gap: var(--space-xl);
	align-items: start;
	padding: var(--space-xl);
	background: rgba(255, 255, 255, 0.025);
	border: 1px solid rgba(255, 255, 255, 0.06);
	border-radius: var(--radius-lg);
	/* scroll-in: start invisible */
	opacity: 0;
	transform: translateY(28px);
	transition:
		opacity 0.45s ease,
		transform 0.45s ease,
		border-color 0.2s;
}

.showcase.sc-visible {
	opacity: 1;
	transform: none;
}

/* Skeleton cards skip the animation */
.showcase-skeleton {
	opacity: 1 !important;
	transform: none !important;
	transition: none !important;
}

.showcase:hover {
	border-color: rgba(255, 255, 255, 0.1);
}

/* Alternate: even cards flip frame to right */
.showcase:not(.showcase-skeleton):nth-child(even) {
	direction: ltr; /* reset if parent has rtl */
}

.showcase:not(.showcase-skeleton):nth-child(even) .showcase-frame {
	order: 2;
}

.showcase:not(.showcase-skeleton):nth-child(even) .showcase-meta {
	order: 1;
}

@media (max-width: 900px) {
	.showcase {
		grid-template-columns: 1fr;
	}

	.showcase:not(.showcase-skeleton):nth-child(even) .showcase-frame,
	.showcase:not(.showcase-skeleton):nth-child(even) .showcase-meta {
		order: unset;
	}
}

/* ── Showcase frame ──────────────────────────────────────────────────────────── */

.showcase-frame {
	position: relative;
	border-radius: var(--radius-md);
	overflow: hidden;
	background: #050505;
	aspect-ratio: 1 / 1;
	min-height: 420px;
}

.showcase-frame iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* ── Click-to-load placeholder ───────────────────────────────────────────────── */

.frame-placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background:
		radial-gradient(ellipse at 30% 40%, color-mix(in srgb, var(--type-color, #8b5cf6) 12%, transparent) 0%, transparent 70%),
		radial-gradient(ellipse at 75% 70%, color-mix(in srgb, var(--type-color, #8b5cf6) 6%, transparent) 0%, transparent 60%),
		#050505;
	transition: opacity 0.3s ease;
}

.frame-placeholder--loading {
	opacity: 0.4;
	pointer-events: none;
}

.frame-ph-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	text-align: center;
}

.play-btn {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.15);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition:
		background 0.15s,
		transform 0.15s,
		border-color 0.15s;
}

.play-btn:hover,
.play-btn:focus-visible {
	background: color-mix(in srgb, var(--type-color, #8b5cf6) 30%, rgba(255, 255, 255, 0.12));
	border-color: var(--type-color, rgba(255, 255, 255, 0.4));
	transform: scale(1.08);
	outline: none;
}

.frame-ph-label {
	font-family: var(--font-display);
	font-size: var(--text-base);
	font-weight: 500;
	color: rgba(229, 229, 229, 0.75);
}

.frame-ph-dim {
	font-family: var(--font-mono);
	font-size: var(--text-xs);
	color: rgba(229, 229, 229, 0.35);
	letter-spacing: 0.05em;
}

/* ── Showcase meta ───────────────────────────────────────────────────────────── */

.showcase-meta {
	display: flex;
	flex-direction: column;
	gap: var(--space-md);
}

.type-tag {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-size: var(--text-xs);
	letter-spacing: 2.5px;
	text-transform: uppercase;
	color: var(--type-color, var(--accent));
	font-weight: 600;
	width: fit-content;
}

.type-tag::before {
	content: '';
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--type-color, var(--accent));
	box-shadow: 0 0 6px var(--type-color, var(--accent));
}

.showcase-meta h3 {
	margin: 0;
	font-family: var(--font-display);
	font-size: var(--text-xl);
	font-weight: 400;
	letter-spacing: -0.5px;
	line-height: 1.2;
}

.showcase-meta > p {
	margin: 0;
	color: rgba(229, 229, 229, 0.7);
	line-height: var(--leading-normal);
}

/* Feature list inside card */
.widget-features {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.widget-features li {
	font-size: var(--text-sm);
	color: rgba(229, 229, 229, 0.6);
	padding-left: 1.1rem;
	position: relative;
}

.widget-features li::before {
	content: '›';
	position: absolute;
	left: 0;
	color: var(--accent);
}

/* ── Snippet ─────────────────────────────────────────────────────────────────── */

.snippet {
	position: relative;
	background: #0a0a0a;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: var(--radius-md);
	padding: var(--space-sm);
	font-family: var(--font-mono);
	font-size: var(--text-sm);
	color: rgba(229, 229, 229, 0.85);
	white-space: pre-wrap;
	word-break: break-all;
	overflow-x: auto;
	line-height: 1.6;
}

.snippet code {
	display: block;
}

/* ── Snippet action row ───────────────────────────────────────────────────────── */

.snippet-row {
	display: flex;
	gap: var(--space-xs);
	flex-wrap: wrap;
}

.snippet-row button,
.snippet-row a {
	flex: 1 1 auto;
	min-width: 110px;
	padding: var(--space-xs) var(--space-sm);
	font-size: var(--text-sm);
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.1);
	color: #e5e5e5;
	border-radius: var(--radius-md);
	cursor: pointer;
	text-align: center;
	text-decoration: none;
	font-family: var(--font-body);
	transition:
		background 0.15s,
		border-color 0.15s;
}

.snippet-row button:hover,
.snippet-row a:hover {
	background: rgba(255, 255, 255, 0.1);
	border-color: rgba(255, 255, 255, 0.2);
}

.snippet-row button:focus-visible,
.snippet-row a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.snippet-row .copied {
	background: var(--accent-soft);
	border-color: var(--accent);
	color: #c4b5fd;
}

/* ── Error state ─────────────────────────────────────────────────────────────── */

.error-state {
	display: flex;
	align-items: flex-start;
	gap: var(--space-sm);
	padding: var(--space-md) var(--space-lg);
	background: rgba(255, 80, 80, 0.06);
	border: 1px solid rgba(255, 80, 80, 0.2);
	border-radius: var(--radius-md);
	color: rgba(255, 200, 200, 0.9);
	font-size: var(--text-sm);
	line-height: var(--leading-normal);
}

.error-state code {
	font-family: var(--font-mono);
	font-size: var(--text-xs);
	color: rgba(255, 180, 180, 0.8);
}

/* ── Bottom CTA ──────────────────────────────────────────────────────────────── */

.gallery-cta {
	text-align: center;
	padding: var(--space-2xl) var(--space-lg);
	background: rgba(139, 92, 246, 0.06);
	border: 1px solid rgba(139, 92, 246, 0.15);
	border-radius: var(--radius-lg);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-md);
}

.gallery-cta h3 {
	margin: 0;
	font-family: var(--font-display);
	font-size: var(--text-xl);
	font-weight: 400;
}

.gallery-cta p {
	margin: 0;
	color: rgba(229, 229, 229, 0.7);
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */

.gallery-footer {
	position: static;
	padding: var(--space-lg);
	text-align: center;
	color: rgba(229, 229, 229, 0.5);
	font-size: var(--text-sm);
	border-top: 1px solid rgba(255, 255, 255, 0.06);
	pointer-events: auto;
}

.gallery-footer a {
	color: rgba(229, 229, 229, 0.7);
	text-decoration: none;
	margin: 0 var(--space-xs);
}

.gallery-footer a:hover {
	color: #fff;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
	.gallery-header {
		flex-wrap: wrap;
		gap: var(--space-sm);
	}

	.gallery-header .features-nav {
		gap: var(--space-sm);
		font-size: var(--text-xs);
	}

	.gallery-hero h2 {
		font-size: var(--text-xl);
	}

	.filter-bar {
		gap: var(--space-xs);
	}

	.filter-btn {
		font-size: var(--text-xs);
		padding: 0.35rem 0.75rem;
	}

	.showcase-frame {
		min-height: 300px;
	}
}

/* ── Reduced motion ──────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
	.btn,
	.snippet-row button,
	.snippet-row a,
	.filter-btn,
	.play-btn,
	.showcase {
		transition: none;
		animation: none;
	}

	.btn-primary:hover {
		transform: none;
	}

	.showcase {
		opacity: 1;
		transform: none;
	}

	.skel-block,
	.skel-line {
		animation: none;
	}
}
