:root {
	--radius-sm: 8px;
	--radius-md: 12px;
	--radius-lg: 18px;

	--ease-out: cubic-bezier(.22, 1, .36, 1);

	/* Theme tokens (defaults overridden per [data-theme]) */
	--bg: #0b0b0f;
	--bg-elev: #121219;
	--text: #e9e9ef;
	--muted: #a7a7b4;
	--brand: #e50914;
	--brand-soft: rgb(from var(--brand) r g b / 14%);
	--card: #161620;
	--accent: #3b82f6;
	--accent-contrast: white;
	--muted-border: rgb(from var(--text) r g b / 10%);

	--grid-gap: 16px;
	--scroll-fade: 32px;
	--container: clamp(320px, 94vw, 1200px);
	--theme: dark;
}

/* Theme: dark */
[data-theme="dark"] {
	--bg: #0b0b0f;
	--bg-elev: #121219;
	--text: #e9e9ef;
	--muted: #9a9aac;
	--brand: #e50914;
	--card: #161620;
	--accent: #3b82f6;
	--accent-contrast: #ffffff;
	color-scheme: dark;
}

/* Theme: light */
[data-theme="light"] {
	--bg: #f8f8fb;
	--bg-elev: #ffffff;
	--text: #17171c;
	--muted: #565666;
	--brand: #e50914;
	--card: #ffffff;
	--accent: #1d4ed8;
	--accent-contrast: #ffffff;
	color-scheme: light;
}

/* Theme: sepia/cinema */
[data-theme="sepia"] {
	--bg: #14110f;
	--bg-elev: #1b1715;
	--text: #f1e7db;
	--muted: #c0b4a6;
	--brand: #d97706;
	/* ambre */
	--card: #211c19;
	--accent: #ea580c;
	--accent-contrast: #fff7ed;
	color-scheme: dark;
}

* {
	box-sizing: border-box;
	transition:
		color 500ms var(--ease-out),
		background-color 500ms var(--ease-out),
		border-color 500ms var(--ease-out);
}

html,
body {
	min-height: 100%;
}

body {
	margin: 0;
	font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
	color: var(--text);
}

*::-webkit-scrollbar {
	width: .1rem;
	height: .1rem;
}

*::-webkit-scrollbar-thumb {
	background: var(--muted-border);
	border-radius: 4px
}

main {
	margin: auto;
	width: 90%;
}

img,
svg {
	display: block;
	max-width: 100%;
	max-height: 100%;
}

.section {
	padding: 24px 0;
	scroll-margin-top: 72px;
}

header {
	position: sticky;
	top: 0;
	inset-inline: 0;
	z-index: 50;
	background: var(--bg-elev);
	border-bottom: 1px solid var(--muted-border);

	>div {
		display: flex;
		align-items: center;
		gap: 2rem;
		justify-content: space-between;
		padding: 6px 12px;
		max-width: var(--container);
		margin-inline: auto;
	}


	.primary-nav {
		position: relative;
		display: none;
		align-items: center;
		gap: 8px;

		.nav-tab {
			position: relative;
			background: none;
			border: 0;
			color: var(--muted);
			padding: 8px 10px;
			border-radius: 10px;
			font-weight: 600;
			text-decoration: none;
			display: inline-flex;
		}

		.nav-tab.is-active,
		.nav-tab:hover {
			border-bottom: 1px solid var(--accent);
			color: var(--text);
		}
	}

	.theme-switcher {
		display: flex;
		gap: 6px;
		background: rgb(from var(--card) r g b / 70%);
		padding: 4px;
		border-radius: 999px;
		border: 1px solid var(--muted-border);

		.chip {
			background: transparent;
			border: 0;
			color: var(--text);
			padding: 6px 10px;
			border-radius: 100%;
			font-weight: 600;
			cursor: pointer;
		}

		.chip.is-active,
		.chip:hover {
			background: rgb(from var(--accent) r g b / 18%);
			color: rgb(from var(--text) r g b / 80%);
		}
	}

	.breadcrumb {
		font-size: 0.75rem;
		border-top: 1px solid var(--muted-border);

		ol {
			list-style: none;
			margin: 0;
			padding: 6px 12px;
			display: flex;
			gap: 8px;
			max-width: var(--container);
			margin-inline: auto;
		}

		a {
			color: var(--muted);
			text-decoration: none;
		}

		a:hover {
			color: var(--text);
		}

		/* separator seulement a partir du deuxième élément */
		li+li::before {
			content: "/";
			opacity: .5;
			margin: 0 6px;
		}
	}
}

.hero {
	position: relative;
	display: none;
	margin-top: 1rem;
	min-height: 30vh;
	place-items: end start;
	aspect-ratio: 1.85/1;
	overflow: hidden;
	border-radius: var(--radius-lg);
	padding: 0;

	/* video background layer */
	.hero-video {
		position: absolute;
		inset: 0;
		z-index: 0;
		overflow: hidden;
		pointer-events: none;

		iframe,
		video {
			/* Let the wrapper control sizing; ensure iframe fills it */
			position: absolute;
			inset: 0;
			width: 100%;
			height: 100%;
			object-fit: cover;
			filter: saturate(105%) contrast(105%);
		}

		.yt-bg-wrapper {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			width: 135%;
			height: 135%;
		}
	}

	/* bordure en overlay, sinon c'est caché par l'image */
	&::after {
		content: "";
		position: absolute;
		inset: 0;
		border-radius: inherit;
		border: 4px solid #e9e9ef0a;
		z-index: 1;
		pointer-events: none;
	}

	h1 {
		font-size: clamp(0.75rem, 5vw, 1.5rem);
		color: #e9e9ef;
		margin: 0 0 8px;
		letter-spacing: -0.02em;
	}

	p {
		color: #a7a7b4;
		font-size: 1rem;
	}

	.hero-content {
		z-index: 2;
		width: 100%;
		padding: 0 1rem 1rem;
		backdrop-filter: blur(2px);
		border-radius: calc(var(--radius-lg) - 4px);
		background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.5) 20%, rgba(0, 0, 0, 0.9));

		article {
			place-content: end;
		}

		.badge {
			display: inline-flex;
			align-items: center;
			gap: 6px;
			font-size: .85rem;
			padding: 4px 8px;
			border-radius: 999px;
			background: rgb(from var(--bg-elev) r g b / 65%);
			border: 1px solid var(--muted-border);
		}

		.badge.rating {
			background: rgb(from var(--accent) r g b / 24%);
			border-color: rgb(from var(--accent) r g b / 36%);
		}

		.hero-meta {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			gap: 8px;
			margin: 8px 0 6px;

			.meta {
				color: #e9e9ef;
				font-size: .95rem;
			}

			.dot {
				opacity: .6;
				color: #a7a7b4;
			}

			.genres {
				display: inline-flex;
				gap: 6px;
			}
		}

		.badge {
			background-color: #0b0b0fFA;
			color: #e9e9ef;
		}


		.hero-overview {
			max-width: min(70ch, 90%);
			margin: 8px 0 12px;
			line-height: 1.25;
		}

		.hero-actions {
			display: flex;
			gap: 10px;
		}

		.button {
			appearance: none;
			border: 1px solid var(--muted-border);
			background: rgb(from var(--card) r g b / 70%);
			color: var(--text);
			text-decoration: none;
			cursor: pointer;
			padding: 10px 14px;
			border-radius: 10px;
			font-weight: 600;
			display: inline-flex;
			align-items: center;
			gap: 8px;

			&:hover {
				border-color: var(--accent);
			}

			&:focus {
				outline: 2px solid var(--accent);
				outline-offset: 2px;
			}

			&.is-disabled {
				opacity: .6;
				pointer-events: none;
			}

			&.primary {
				background: var(--accent);
				border-color: transparent;
				color: var(--accent-contrast);

				&:hover {
					background: rgb(from var(--accent) r g b / 70%);
				}
			}
		}

	}
}

.section-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 0.5rem 0;

	h2 {
		margin: 0;
		letter-spacing: -0.01em;
	}
}

.media-row {
	display: flex;
	gap: var(--grid-gap);
	padding: 1rem 2rem 1rem 2rem;
	margin-left: -1rem;
	scroll-padding-left: 2rem;
	scroll-padding-right: 2rem;
	overflow-x: auto;
	overscroll-behavior-inline: contain;
	scroll-snap-type: inline mandatory;
	position: relative;

	mask-image: linear-gradient(
		to right,
		transparent 0,
		rgba(0, 0, 0, 1) var(--scroll-fade),
		rgba(0, 0, 0, 1) calc(100% - var(--scroll-fade)),
		transparent 100%
	);
}


.media-card:hover,
.media-card:focus {
	transform: translateY(-0.5rem);
	box-shadow: 0 0.5rem 12px rgba(0, 0, 0, .25);
	outline: none;
}

.media-card {
	scroll-snap-align: start;
	background: var(--card);
	border: 1px solid var(--muted-border);
	border-radius: var(--radius-lg);
	position: relative;

	.card-link { display: block; color: inherit; text-decoration: none; }

	.poster {
		min-width: 150px;
		width: 200px;
		height: 100%;
		aspect-ratio: 2/3;
		border-radius: var(--radius-lg);
		background: var(--muted-border);
		overflow: hidden;
	}

	.info {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		color: white;
		border-radius: 0 0 var(--radius-lg) var(--radius-lg);
		background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.9), black);
		padding: 0.5rem 1rem;
	}

	.wide {

		.poster {
			aspect-ratio: 16/9;
		}
	}

	.title {
		margin: 0 0 4px;
		font-size: 0.5rem;
		font-weight: 700;
		letter-spacing: .2px;
	}

	.shimmer {
		position: relative;
		overflow: hidden;
	}

	.shimmer::after {
		content: "";
		width: 200%;
		height: 200%;
		position: absolute;
		inset: 0;
		background: linear-gradient(45deg, transparent 20%, var(--muted-border) 40%, transparent 60%);
		transform: translate(-50%, -100%);
		animation: shimmer 1.6s infinite;
	}
}

@keyframes shimmer {
	to {
		transform: translateY(100%);
	}
}

footer {
	background: var(--bg-elev);
	border-top: 1px solid var(--muted-border);
	padding: 16px 0 24px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: center;
	justify-content: space-between;

	.footer-nav {
		display: flex;
		gap: 12px;

		a {
			color: var(--muted);
			text-decoration: none;
		}

		a:hover {
			color: var(--text);
		}
	}
}

@media (min-width: 768px) {
	header .primary-nav {
		display: flex;
	}

	.hero {
		display: grid;
		min-height: 50vh;

		h1 {
			font-size: clamp(2rem, 5vw, 4rem);
		}
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		animation: none !important;
		transition: none !important;
	}
}