/**
 * Carzy Announcement Bar - front end
 * minutes.agency
 */

/* DM Sans, served from the plugin folder so it never depends on a CDN. */
@font-face {
	font-family: "Carzy DM Sans";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url("../fonts/dm-sans-latin.woff2") format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
	font-family: "Carzy DM Sans";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url("../fonts/dm-sans-latin-ext.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

.carzy-ab {
	position: relative; /* never sticky */
	z-index: 20;
	width: 100%;
	/* Flat, no gradient. The theme colour is used as it is. */
	background-color: var(--carzy-ab-bg, #cca001);
	color: var(--carzy-ab-color, #050b20);
	font-family: "Carzy DM Sans", "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: var(--carzy-ab-size, 16px);
	line-height: 1.35;
	letter-spacing: var(--carzy-ab-spacing, 0.08em);
	text-transform: var(--carzy-ab-transform, uppercase);
	text-align: center;
	overflow: hidden;
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.16), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

/* A slow highlight passing over the bar. Enough to catch the eye on a page
   the visitor has already scrolled past once, not enough to nag. */
.carzy-ab.has-shine::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 45%;
	pointer-events: none;
	background: linear-gradient(
		100deg,
		rgba(255, 255, 255, 0) 0%,
		rgba(255, 255, 255, 0.26) 50%,
		rgba(255, 255, 255, 0) 100%
	);
	transform: translateX(-140%);
	/* Three passes on arrival, then it stops. A sweep that repeats for as long
	   as the page is open reads as nagging decoration rather than a moment. */
	animation: carzy-ab-shine 7s ease-in-out 2s 3;
	animation-fill-mode: forwards;
}

@keyframes carzy-ab-shine {
	0% {
		transform: translateX(-140%);
	}

	35%,
	100% {
		transform: translateX(330%);
	}
}

.carzy-ab *,
.carzy-ab {
	box-sizing: border-box;
}

/* Every message sits in the same grid cell, so they are stacked on top of one
   another and the bar keeps the height of the tallest one without jumping. */
.carzy-ab__inner {
	position: relative;
	display: grid;
	grid-template-columns: 1fr;
	padding: 0 20px;
	min-height: 54px;
}

.carzy-ab__item {
	grid-area: 1 / 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 54px;
	padding: 10px 0;
	opacity: 0;
	visibility: hidden;
	/* Out first: fade away immediately, then hide. */
	transition: opacity 0.35s ease 0s, visibility 0s linear 0.35s;
}

.carzy-ab__item.is-active {
	opacity: 1;
	visibility: visible;
	/* In second: wait for the old message to clear, then fade up. The two are
	   never on screen at the same time, so the texts cannot overlap. */
	transition: opacity 0.35s ease 0.35s, visibility 0s linear 0.35s;
}

.carzy-ab__text,
.carzy-ab__link {
	display: inline-block;
	color: inherit;
	font-weight: 700;
	margin: 0;
}

.carzy-ab__link {
	text-decoration: none;
	border-bottom: 1px solid currentColor;
	padding-bottom: 1px;
	transition: opacity 0.2s ease;
}

.carzy-ab__link:hover,
.carzy-ab__link:focus {
	color: inherit;
	opacity: 0.75;
	text-decoration: none;
}

.carzy-ab__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

@media (max-width: 782px) {
	.carzy-ab {
		font-size: calc(var(--carzy-ab-size, 16px) - 2px);
		letter-spacing: 0.05em;
	}

	.carzy-ab__inner {
		padding: 0 14px;
		min-height: 48px;
	}

	.carzy-ab__item {
		min-height: 48px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.carzy-ab__item,
	.carzy-ab__item.is-active {
		transition: none;
	}

	.carzy-ab.has-shine::after {
		animation: none;
		opacity: 0;
	}
}
