/**
 * Christmas Snow front end: decorations, greeting bar, countdown and block.
 *
 * @package Christmas_Snow_Festive_Snowfall_Effect
 */

/* Scene ------------------------------------------------------------------- */

.cwg-snow-scene > div {
	position: fixed;
	left: 0;
	right: 0;
	z-index: var(--cwg-snow-z, 999999);
	pointer-events: none;
}

/* Lights garland ---------------------------------------------------------- */

/* Wire tile is 60px wide, lowest point at x=30, y=12. Bulb i sits at 30px + i * 60px. */
.cwg-snow-lights {
	top: var(--cwg-greeting-top, 0px);
	height: 40px;
	overflow: hidden;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='24' viewBox='0 0 60 24'%3E%3Cpath d='M0 3 Q30 21 60 3' fill='none' stroke='%231f2a24' stroke-width='2'/%3E%3C/svg%3E") repeat-x 0 0;
}

.cwg-snow-lights span {
	position: absolute;
	top: 13px;
	left: calc(25px + var(--i, 0) * 60px);
	width: 10px;
	height: 15px;
	color: #ef4444;
	background: currentColor;
	border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
	box-shadow: 0 2px 10px 2px currentColor;
	/* Animate opacity only. */
	animation: cwg-snow-twinkle 1.6s ease-in-out infinite;
	animation-delay: calc(var(--i, 0) * -0.37s);
}

.cwg-snow-lights span::before {
	position: absolute;
	top: -3px;
	left: 2px;
	width: 6px;
	height: 4px;
	content: "";
	background: #1f2a24;
	border-radius: 1px;
}

.cwg-snow-lights--multi span:nth-child(5n + 1) { color: #ef4444; }
.cwg-snow-lights--multi span:nth-child(5n + 2) { color: #facc15; }
.cwg-snow-lights--multi span:nth-child(5n + 3) { color: #22c55e; }
.cwg-snow-lights--multi span:nth-child(5n + 4) { color: #3b82f6; }
.cwg-snow-lights--multi span:nth-child(5n + 5) { color: #ec4899; }

.cwg-snow-lights--warm span { color: #fcd34d; }
.cwg-snow-lights--warm span:nth-child(even) { color: #fde68a; }

.cwg-snow-lights--cool span { color: #7dd3fc; }
.cwg-snow-lights--cool span:nth-child(3n + 2) { color: #e0f2fe; }
.cwg-snow-lights--cool span:nth-child(3n) { color: #ffffff; }

@keyframes cwg-snow-twinkle {
	0%,
	100% {
		opacity: 1;
	}

	50% {
		opacity: 0.4;
	}
}

/* Icicles ----------------------------------------------------------------- */

.cwg-snow-icicles {
	top: var(--cwg-greeting-top, 0px);
	height: 34px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='34' viewBox='0 0 40 34'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23ffffff' stop-opacity='.95'/%3E%3Cstop offset='1' stop-color='%23cfe8ff' stop-opacity='.5'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0 0h40v4H0z' fill='%23ffffff' fill-opacity='.95'/%3E%3Cpath d='M2 3 7 30 12 3zM15 3l3 15 3-15zM24 3l6 31 5-31z' fill='url(%23g)'/%3E%3C/svg%3E") repeat-x 0 0;
	filter: drop-shadow(0 1px 1px rgba(30, 64, 110, 0.18));
}

/* Frosted edges ----------------------------------------------------------- */

.cwg-snow-frost {
	top: 0;
	bottom: 0;
	background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0) 58%, rgba(214, 232, 255, 0.42) 100%);
	box-shadow: inset 0 0 90px 18px rgba(255, 255, 255, 0.5);
}

@media screen and (max-width: 600px) {
	.cwg-snow-frost {
		box-shadow: inset 0 0 46px 8px rgba(255, 255, 255, 0.5);
	}
}

/* Ground snow ------------------------------------------------------------- */

/* 200px tile with matching ends, repeats seamlessly. */
.cwg-snow-ground {
	bottom: var(--cwg-greeting-offset, 0px);
	height: 56px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='56' viewBox='0 0 200 56'%3E%3Cpath d='M0 30C30 18 60 14 100 26S170 42 200 30V56H0z' fill='%23ffffff'/%3E%3C/svg%3E") repeat-x 0 100%;
	filter: drop-shadow(0 -2px 5px rgba(30, 64, 110, 0.14));
}

/* Admin bar offset for the strips pinned to the top. */
body.admin-bar .cwg-snow-lights,
body.admin-bar .cwg-snow-icicles {
	top: calc(32px + var(--cwg-greeting-top, 0px));
}

@media screen and (max-width: 782px) {
	body.admin-bar .cwg-snow-lights,
	body.admin-bar .cwg-snow-icicles {
		top: calc(46px + var(--cwg-greeting-top, 0px));
	}
}

@media screen and (max-width: 600px) {
	.cwg-snow-ground {
		height: 34px;
		background-size: 120px 34px;
	}

	.cwg-snow-lights {
		height: 32px;
	}

	.cwg-snow-lights span {
		top: 11px;
		left: calc(26px + var(--i, 0) * 60px);
		width: 8px;
		height: 12px;
		box-shadow: 0 2px 8px 1px currentColor;
	}

	.cwg-snow-lights span::before {
		left: 1px;
	}
}

/* Greeting bar ------------------------------------------------------------ */

.cwg-snow-greeting {
	position: fixed;
	left: 0;
	right: 0;
	z-index: var(--cwg-snow-z, 1000000);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 10px 16px;
	box-sizing: border-box;
	margin: 0;
	padding: 12px 56px 12px 20px;
	color: var(--cwg-greeting-color, #ffffff);
	background: var(--cwg-greeting-bg, #14532d);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 15px;
	line-height: 1.4;
	text-align: center;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Respect the hidden attribute. */
.cwg-snow-greeting[hidden] {
	display: none !important;
}

.cwg-snow-greeting--bottom {
	bottom: 0;
	padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.16);
}

.cwg-snow-greeting--top {
	top: 0;
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.16);
}

body.admin-bar .cwg-snow-greeting--top {
	top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar .cwg-snow-greeting--top {
		top: 46px;
	}
}

.cwg-snow-greeting.is-leaving.cwg-snow-greeting--bottom {
	opacity: 0;
	transform: translateY(100%);
}

.cwg-snow-greeting.is-leaving.cwg-snow-greeting--top {
	opacity: 0;
	transform: translateY(-100%);
}

.cwg-snow-greeting .cwg-snow-greeting__text {
	margin: 0;
	padding: 0;
	color: inherit;
	font: inherit;
}

.cwg-snow-greeting .cwg-snow-greeting__btn {
	display: inline-block;
	padding: 6px 16px;
	color: var(--cwg-greeting-bg, #14532d);
	background: var(--cwg-greeting-color, #ffffff);
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	text-decoration: none;
}

.cwg-snow-greeting .cwg-snow-greeting__btn:hover {
	opacity: 0.9;
}

.cwg-snow-greeting .cwg-snow-greeting__close {
	position: absolute;
	top: 50%;
	right: 10px;
	width: 34px;
	height: 34px;
	min-height: 0;
	margin: 0;
	padding: 0;
	color: inherit;
	background: transparent;
	border: 0;
	border-radius: 50%;
	box-shadow: none;
	font-size: 24px;
	line-height: 34px;
	cursor: pointer;
	opacity: 0.8;
	transform: translateY(-50%);
}

.cwg-snow-greeting .cwg-snow-greeting__close:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.14);
}

.cwg-snow-greeting .cwg-snow-greeting__btn:focus-visible,
.cwg-snow-greeting .cwg-snow-greeting__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
	opacity: 1;
}

@media (pointer: coarse) {
	.cwg-snow-greeting .cwg-snow-greeting__btn {
		display: inline-flex;
		align-items: center;
		min-height: 44px;
		padding-top: 0;
		padding-bottom: 0;
	}

	.cwg-snow-greeting .cwg-snow-greeting__close {
		width: 44px;
		height: 44px;
		line-height: 44px;
	}
}

/* Phones: one row, close button in flow. */
@media screen and (max-width: 600px) {
	.cwg-snow-greeting {
		flex-wrap: nowrap;
		justify-content: flex-start;
		gap: 8px;
		padding: 6px 4px 6px 14px;
		font-size: 14px;
		line-height: 1.35;
		text-align: left;
	}

	.cwg-snow-greeting--bottom {
		padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
	}

	.cwg-snow-greeting .cwg-snow-greeting__text {
		flex: 1 1 auto;
		min-width: 0;
	}

	.cwg-snow-greeting .cwg-snow-greeting__btn {
		display: inline-flex;
		flex: 0 0 auto;
		align-items: center;
		justify-content: center;
		max-width: 42%;
		min-height: 44px;
		padding: 0 14px;
		font-size: 13px;
		line-height: 1.25;
		text-align: center;
	}

	.cwg-snow-greeting .cwg-snow-greeting__close {
		position: static;
		flex: 0 0 auto;
		width: 44px;
		height: 44px;
		line-height: 44px;
		transform: none;
	}
}

/* Countdown --------------------------------------------------------------- */

.cwg-snow-countdown {
	margin: 1.5em auto;
	text-align: center;
}

.cwg-snow-countdown__title {
	margin: 0 0 0.7em;
	font-size: 1.1em;
	font-weight: 600;
}

.cwg-snow-countdown__units {
	display: flex;
	justify-content: center;
	gap: clamp(6px, 2vw, 12px);
}

.cwg-snow-countdown__unit {
	box-sizing: border-box;
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	align-items: center;
	min-width: 0;
	max-width: 96px;
	padding: clamp(8px, 2.6vw, 12px) 4px;
	color: #ffffff;
	background: var(--cwg-countdown-a, #b91c1c);
	border-radius: 12px;
	box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.cwg-snow-countdown__unit:nth-child(even) {
	background: var(--cwg-countdown-b, #166534);
}

.cwg-snow-countdown__value {
	font-size: clamp(1.35em, 7vw, 2em);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	line-height: 1;
}

.cwg-snow-countdown__label {
	max-width: 100%;
	margin-top: 6px;
	font-size: clamp(0.65em, 2.8vw, 0.72em);
	letter-spacing: 0.04em;
	line-height: 1.2;
	text-align: center;
	overflow-wrap: anywhere;
	text-transform: uppercase;
	opacity: 0.9;
}

.cwg-snow-countdown__after {
	margin: 0;
	font-size: 1.6em;
	font-weight: 700;
}

/* Snow Container block ---------------------------------------------------- */

.cwg-snow-block {
	position: relative;
	overflow: hidden;
}

.cwg-snow-block__inner {
	position: relative;
	z-index: 1;
}

/* Editor only: make the container visible while it is empty. */
.cwg-snow-block.is-editor {
	outline: 1px dashed rgba(37, 99, 235, 0.45);
	outline-offset: -1px;
	background: linear-gradient(180deg, rgba(219, 234, 254, 0.5), rgba(219, 234, 254, 0));
}

.cwg-snow-block__badge {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 3;
	padding: 3px 9px;
	color: #ffffff;
	background: rgba(30, 64, 175, 0.9);
	border-radius: 999px;
	font: 600 11px/1.4 system-ui, -apple-system, sans-serif;
	pointer-events: none;
}

/* Motion and print -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.cwg-snow-lights span {
		animation: none;
	}

	.cwg-snow-greeting {
		transition: none;
	}
}

@media print {
	.cwg-snow-scene,
	.cwg-snow-greeting {
		display: none !important;
	}
}
