/*
 * Cocolino hero art — the koala video in the home hero.
 *
 * Loaded only where the class "cocolino-hero-art" appears (pattern
 * cocolino/hero-home). Markup (core/html block in the right column):
 *
 *   .cocolino-art                                   (size container)
 *     .cocolino-art-card                            (16:9 frame)
 *       video.cocolino-art__video[data-cocolino-video]
 *       .cocolino-art__controls
 *         button.cocolino-art__control.cocolino-art__play
 *         button.cocolino-art__control.cocolino-art__sound
 *     .cocolino-art__badges
 *       .badge-float.badge-1.float-2 > .ico   (🎈 Der ganze Spielraum nur für euch)
 *       .badge-float.badge-2.float-1 > .ico   (☕ Kaffee & Sirup inklusive)
 *
 * The video shows its poster until assets/js/site.js starts it. The script
 * adds .is-ready (the controls appear), .is-playing and .is-sound (the icons
 * follow). The badges float over the card's corners (design: .badge-float,
 * .float1-3), but only while the clip plays, so the pause button stops all
 * motion in the block and without JS nothing moves; in a column narrower
 * than 480px they sit still in a row under the card. Colours are tokens; the
 * icons are masks, so they take the button's text colour (in Windows
 * contrast themes the system's button text colour).
 */

/* ---------- stage ---------- */

.cocolino-art {
	position: relative;
	container-type: inline-size;
}

.cocolino-art-card {
	position: relative;
	overflow: hidden;
	isolation: isolate; /* Safari clips a playing video to the rounded corners only inside its own stacking context */
	aspect-ratio: 16 / 9;
	border: var(--wp--custom--border--width) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--xlarge);
	background: linear-gradient(160deg, var(--wp--preset--color--base-2) 0%, var(--wp--preset--color--tint) 100%);
	box-shadow: var(--wp--preset--shadow--raised);
}

.cocolino-art__video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ---------- controls: play/pause and sound ---------- */

/* The insets grow with the card's corner radius (rem), so a larger browser
   font size never lets the rounded corner clip a button or its focus ring. */
.cocolino-art__controls {
	position: absolute;
	right: max(12px, calc(var(--wp--custom--radius--xlarge) * 0.3));
	bottom: max(12px, calc(var(--wp--custom--radius--xlarge) * 0.3));
	z-index: 1;
	display: none;
	gap: 8px;
}

.cocolino-art.is-ready .cocolino-art__controls {
	display: flex;
}

.cocolino-art__control {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: var(--wp--custom--border--width) solid var(--wp--preset--color--border);
	border-radius: 50%;
	background: var(--wp--preset--color--base-2);
	box-shadow: var(--wp--preset--shadow--raised);
	color: var(--wp--preset--color--contrast);
	cursor: pointer;
}

.cocolino-art__control:hover {
	background: var(--wp--preset--color--tint);
}

/* Two-colour ring (WCAG technique C40): a contrast ring between the button's
   border and a base-2 halo, so it stands out on every frame of the video. */
.cocolino-art__control:focus-visible {
	outline: 3px solid var(--wp--preset--color--contrast);
	outline-offset: 0;
	box-shadow: 0 0 0 6px var(--wp--preset--color--base-2), var(--wp--preset--shadow--raised);
}

.cocolino-art__control::before {
	content: "";
	width: 20px;
	height: 20px;
	background: currentcolor;
	-webkit-mask: var(--cocolino-icon) center / contain no-repeat;
	mask: var(--cocolino-icon) center / contain no-repeat;
}

/* Icons: Material Icons (Apache 2.0) play_arrow, pause, volume_off, volume_up. */
.cocolino-art__play {
	--cocolino-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}

.cocolino-art.is-playing .cocolino-art__play {
	--cocolino-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E");
}

.cocolino-art__sound {
	--cocolino-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z'/%3E%3C/svg%3E");
}

.cocolino-art.is-sound .cocolino-art__sound {
	--cocolino-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/%3E%3C/svg%3E");
}

/* Windows contrast themes force background colours, which would paint the
   masked icons in the button's own colour; a system colour stays. */
@media (forced-colors: active) {
	.cocolino-art__control::before {
		forced-color-adjust: none;
		background: ButtonText;
	}
}

/* ---------- floating badges ---------- */

.cocolino-art__badges {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.cocolino-art .badge-float {
	position: absolute;
	z-index: 1;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	border: var(--wp--custom--border--width) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--medium);
	background: var(--wp--preset--color--base-2);
	box-shadow: var(--wp--preset--shadow--raised);
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
	font-weight: var(--wp--custom--typography--font-weight--label);
	line-height: 1.3;
	white-space: nowrap;
}

/* design: top 24px, right -6px */
.cocolino-art .badge-1 {
	top: 24px;
	right: -6px;
}

/* design: bottom 14px, left -10px */
.cocolino-art .badge-2 {
	bottom: 14px;
	left: -10px;
}

.cocolino-art .badge-float .ico {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	border-radius: var(--wp--custom--radius--small);
	background: var(--wp--preset--color--tint);
	font-size: 1.1rem;
	line-height: 1;
}

.cocolino-art .badge-2 .ico {
	background: var(--wp--preset--color--tint-2);
}

/* ---------- float animation ---------- */

.cocolino-art .float-1 {
	animation: cocolino-float 5.5s ease-in-out infinite;
}

.cocolino-art .float-2 {
	animation: cocolino-float 6.5s ease-in-out 0.6s infinite;
}

/* The badges move only while the clip plays (.is-playing comes from the script). */
.cocolino-art:not(.is-playing) .badge-float {
	animation-play-state: paused;
}

@keyframes cocolino-float {
	0%,
	100% {
		transform: translateY(0);
	}

	50% {
		transform: translateY(-14px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.cocolino-art .float-1,
	.cocolino-art .float-2 {
		animation: none;
	}
}

/* In a narrow column the badges would cover the koala: a row under the video; smaller controls. */
@container (max-width: 479px) {
	.cocolino-art__badges {
		position: static;
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: 10px;
		margin-top: 14px;
	}

	.cocolino-art .badge-float {
		position: static;
		gap: 8px;
		padding: 8px 12px;
		animation: none;
	}

	.cocolino-art .badge-float .ico {
		width: 28px;
		height: 28px;
	}

	.cocolino-art__controls {
		right: max(8px, calc(var(--wp--custom--radius--xlarge) * 0.3));
		bottom: max(8px, calc(var(--wp--custom--radius--xlarge) * 0.3));
		gap: 6px;
	}

	.cocolino-art__control {
		width: 40px;
		height: 40px;
	}

	.cocolino-art__control::before {
		width: 18px;
		height: 18px;
	}
}
