/* Documentary Player */

video-player {
	display: contents;
}

.dp-player {
	position: relative;
	width: 100%;
	aspect-ratio: var(--dp-aspect, 16 / 9);
	background: #000;
	border-radius: var(--dp-radius, 12px);
	overflow: hidden;
}

/* Inside the theme's .ds-player box (which already has the aspect ratio). */
.ds-player > .dp-player {
	position: absolute;
	inset: 0;
	aspect-ratio: auto;
	height: 100%;
	border-radius: inherit;
}

.dp-player .dp-skin {
	display: block;
	width: 100%;
	height: 100%;
}

.dp-player .dp-skin youtube-video,
.dp-player .dp-skin vimeo-video,
.dp-player .dp-skin hls-video,
.dp-player .dp-skin video {
	position: static;
	width: 100%;
	height: 100%;
}

/* "Load after click" cover */
.dp-cover {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	width: 100%;
	padding: 0;
	border: 0;
	background: #000;
	color: #fff;
	cursor: pointer;
	font: inherit;
}

.dp-cover__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0.85;
	transition: opacity 0.3s, transform 0.6s;
}

.dp-cover:hover .dp-cover__img,
.dp-cover:focus-visible .dp-cover__img {
	opacity: 1;
	transform: scale(1.02);
}

.dp-cover__play {
	position: relative;
	display: grid;
	place-items: center;
	width: 76px;
	height: 76px;
	padding-left: 4px;
	border-radius: 50%;
	background: var(--dp-accent, #ff4757);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	transition: transform 0.2s;
}

.dp-cover:hover .dp-cover__play {
	transform: scale(1.08);
}

.dp-cover__note {
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: 12px;
	padding: 6px 10px;
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.65);
	font-size: 0.78rem;
	line-height: 1.35;
	text-align: center;
}

.dp-cover:focus-visible {
	outline: 3px solid var(--dp-accent, #ff4757);
	outline-offset: -3px;
}

.dp-loading .dp-cover__play {
	animation: dp-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes dp-pulse {
	to {
		transform: scale(0.88);
		opacity: 0.7;
	}
}

.dp-failed::after {
	content: "The player could not be loaded.";
	position: absolute;
	inset: auto 0 0;
	padding: 8px;
	background: rgba(0, 0, 0, 0.8);
	color: #fff;
	font-size: 0.85rem;
	text-align: center;
}

.dp-embed {
	margin: 1.5em 0;
}

/* End screen ----------------------------------------------------------- */

.dp-player {
	container-type: inline-size;
	container-name: dp;
}

.dp-end {
	position: absolute;
	inset: 0;
	z-index: 20;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: clamp(8px, 2.5cqw, 20px);
	padding: clamp(12px, 4cqw, 40px);
	background:
		radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--dp-accent, #ff4757) 18%, transparent), transparent 60%),
		#0c0c11;
	color: #fff;
	font-family: var(--media-font-family, inherit);
	animation: dp-end-in 0.35s ease;
}

.dp-end[hidden] {
	display: none;
}

/*
 * The player behind the suggestions is hidden completely: cross-origin iframes (YouTube, Vimeo)
 * are composited separately and their own overlays would shine through a translucent layer.
 * The skin is also set inert in JS, so its controls cannot be reached with the keyboard.
 */
.dp-end-open .dp-skin {
	visibility: hidden !important;
}

@keyframes dp-end-in {
	from {
		opacity: 0;
	}
}

.dp-end__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.dp-end__title {
	margin: 0;
	font-size: clamp(0.95rem, 2.6cqw, 1.35rem);
	font-weight: 700;
}

.dp-end__close {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
}

.dp-end__close:hover {
	background: rgba(255, 255, 255, 0.24);
}

.dp-end__error {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 16px;
	padding: 10px 14px;
	border-left: 3px solid var(--dp-accent, #ff4757);
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.06);
}

.dp-end__error[hidden] {
	display: none;
}

.dp-end__error-text {
	flex: 1 1 260px;
	margin: 0;
	font-size: clamp(0.85rem, 2.2cqw, 1rem);
	font-weight: 600;
}

.dp-end__watch {
	text-decoration: none;
	white-space: nowrap;
}

.dp-end__close[hidden] {
	display: none;
}

.dp-end__cards {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(10px, 2.5cqw, 24px);
}

.dp-end__card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
	padding: 6px;
	border-radius: calc(var(--dp-radius, 12px) - 2px);
	color: #fff;
	text-decoration: none;
	transition: background 0.2s;
}

.dp-end__card:hover,
.dp-end__card:focus-visible {
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
	outline: none;
}

.dp-end__card:focus-visible {
	box-shadow: 0 0 0 3px var(--dp-accent, #ff4757);
}

.dp-end__thumb {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: 8px;
	background: #1d1d26;
}

.dp-end__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s;
}

.dp-end__card:hover .dp-end__thumb img {
	transform: scale(1.04);
}

.dp-end__duration {
	position: absolute;
	right: 6px;
	bottom: 6px;
	padding: 1px 6px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.8);
	font-size: 0.75rem;
	font-weight: 600;
}

/* Countdown bar on the first card */
.dp-end__bar {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 4px;
	width: 0;
	background: var(--dp-accent, #ff4757);
}

.dp-end-counting .dp-end__bar {
	animation: dp-countdown var(--dp-countdown, 10s) linear forwards;
}

@keyframes dp-countdown {
	to {
		width: 100%;
	}
}

.dp-end__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.dp-end__label {
	color: var(--dp-accent, #ff4757);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.dp-end__name {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: clamp(0.82rem, 2.1cqw, 1rem);
	font-weight: 600;
	line-height: 1.3;
}

.dp-end__meta {
	color: #b5b5c2;
	font-size: 0.78rem;
}

.dp-end__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.dp-end__status {
	margin: 0;
	color: #d5d5de;
	font-size: 0.85rem;
}

.dp-end__actions {
	display: flex;
	gap: 8px;
	margin-left: auto;
}

.dp-end__btn {
	padding: 7px 14px;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font: inherit;
	font-size: 0.85rem;
	font-weight: 600;
	cursor: pointer;
}

.dp-end__btn:hover {
	background: rgba(255, 255, 255, 0.26);
}

.dp-end__btn[hidden] {
	display: none;
}

/* Small players (phones): compact cards, no category line */
@container dp (max-width: 520px) {
	.dp-end {
		gap: 6px;
		padding: 10px 10px 8px;
		justify-content: space-between;
	}

	.dp-end__card {
		flex-direction: row;
		align-items: center;
		gap: 10px;
		padding: 2px;
	}

	.dp-end__thumb {
		flex: 0 0 34%;
	}

	.dp-end__name {
		font-size: 0.8rem;
	}

	.dp-end__label {
		font-size: 0.66rem;
	}

	.dp-end__status {
		display: none;
	}

	.dp-end__btn {
		padding: 5px 12px;
		font-size: 0.78rem;
	}

	.dp-end__cards {
		grid-template-columns: minmax(0, 1fr);
		gap: 6px;
	}

	.dp-end__meta,
	.dp-end__title {
		display: none;
	}

	.dp-end__head {
		position: absolute;
		top: 6px;
		right: 6px;
	}
}

/* Pause screen (YouTube) ------------------------------------------------ */

/* YouTube's own "More videos" bar lives in its iframe: hide the iframe while paused. */
.dp-paused .dp-skin youtube-video {
	visibility: hidden;
}

.dp-pause {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 64px; /* Set from the real control bar position in JS. */
	z-index: 15;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: clamp(10px, 3cqw, 28px) clamp(10px, 3cqw, 28px) 4px;
	background:
		linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.55) 45%, rgba(0, 0, 0, 0.35) 100%),
		var(--dp-poster, none) center / cover no-repeat,
		#000;
	color: #fff;
	font-family: var(--media-font-family, inherit);
	overflow: hidden; /* Never spill over the player controls below. */
	animation: dp-end-in 0.25s ease;
}

.dp-pause[hidden] {
	display: none;
}

.dp-pause__resume {
	display: grid;
	place-items: center;
	flex: none;
	width: clamp(54px, 10cqw, 76px);
	height: clamp(54px, 10cqw, 76px);
	margin: auto 0;
	padding-left: 4px;
	border: 0;
	border-radius: 50%;
	background: var(--dp-accent, #ff4757);
	color: #fff;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	cursor: pointer;
	transition: transform 0.2s;
}

.dp-pause__resume:hover {
	transform: scale(1.06);
}

.dp-pause__resume:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

.dp-pause__shelf {
	width: 100%;
}

.dp-pause__title {
	margin: 0 0 8px;
	font-size: clamp(0.8rem, 1.8cqw, 0.95rem);
	font-weight: 700;
}

.dp-pause__cards {
	display: grid;
	grid-template-columns: repeat(var(--dp-pause-cols, 3), minmax(0, 1fr));
	gap: clamp(8px, 1.8cqw, 16px);
}

.dp-pause__card {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
	color: #fff;
	text-decoration: none;
}

.dp-pause__card:hover,
.dp-pause__card:focus-visible {
	color: #fff;
	outline: none;
}

.dp-pause__card:focus-visible .dp-pause__thumb {
	box-shadow: 0 0 0 3px var(--dp-accent, #ff4757);
}

.dp-pause__thumb {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: 6px;
	background: #1d1d26;
}

.dp-pause__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s;
}

.dp-pause__card:hover .dp-pause__thumb img {
	transform: scale(1.05);
}

.dp-pause__name {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: clamp(0.72rem, 1.6cqw, 0.88rem);
	font-weight: 600;
	line-height: 1.3;
}

/* Small players (phones): two compact thumbnails, no titles. */
@container dp (max-width: 520px) {
	.dp-pause {
		padding: 8px 8px 2px;
		gap: 6px;
	}

	.dp-pause__cards {
		grid-template-columns: repeat(2, minmax(0, 132px));
		justify-content: center;
	}

	.dp-pause__card:nth-child(n + 3) {
		display: none;
	}

	.dp-pause__name,
	.dp-pause__title {
		display: none;
	}

	.dp-pause__resume {
		width: 48px;
		height: 48px;
		margin: auto 0;
	}
}

@container dp (max-height: 260px) {
	.dp-pause__name {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dp-end,
	.dp-pause {
		animation: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dp-cover__img,
	.dp-cover__play {
		transition: none;
	}

	.dp-loading .dp-cover__play {
		animation: none;
	}
}
