/*
 * Sunday mode.
 *
 * This is the one stylesheet the plugin puts on the front of the site, so it
 * has to look deliberate on a theme it has never met. Every colour is a theme
 * token with a fallback drawn from the default palette, and the layout is
 * flex with wrapping rather than anything that assumes a grid.
 */

/*
 * The dismiss button sets `hidden` on the bar, and `display: flex` below beats
 * the browser's own `[hidden] { display: none }` — which is a one-line rule in
 * the UA stylesheet and loses to any class selector. So the X set the
 * attribute, the bar stayed exactly where it was, and the button looked
 * broken. Anything that hides itself with `hidden` needs this alongside its
 * `display`.
 */
.cong-live-bar[hidden] {
	display: none;
}

.cong-live-bar {
	--cong-live-accent: var(--wp--preset--color--lime, #a3c11a);

	position: relative;
	z-index: 50;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1.25rem;
	padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
	padding-inline-end: 3rem;
	background: var(--wp--preset--color--ink, #04436a);
	color: #fff;
	font-size: 0.95rem;
	line-height: 1.3;
}

.cong-live-bar__now {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	margin: 0;
	font-weight: 700;
}

/*
 * The dot is the only thing on the page that says "this is happening now
 * rather than every week", so it is worth the animation — and worth switching
 * off for anyone who has asked for less of it.
 */
.cong-live-bar__dot,
.cong-live__dot {
	flex: none;
	inline-size: 0.6rem;
	block-size: 0.6rem;
	border-radius: 50%;
	background: #ff4d4f;
	box-shadow: 0 0 0 0 rgb(255 77 79 / 0.7);
	animation: cong-live-pulse 2s ease-out infinite;
}

@keyframes cong-live-pulse {
	70%  { box-shadow: 0 0 0 0.6rem rgb(255 77 79 / 0); }
	100% { box-shadow: 0 0 0 0 rgb(255 77 79 / 0); }
}

@media (prefers-reduced-motion: reduce) {
	.cong-live-bar__dot,
	.cong-live__dot {
		animation: none;
	}
}

.cong-live-bar__links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cong-live-bar__links > li {
	margin: 0;
}

.cong-live-bar__link {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

.cong-live-bar__link:hover,
.cong-live-bar__link:focus-visible {
	color: var(--cong-live-accent);
}

/*
 * The orders of worship read as one thing with a document behind each, rather
 * than as two more of the bar's errands. A leading icon is cheaper than a word
 * and survives the bar wrapping onto two lines on a phone.
 */
.cong-live-bar__link.is-order::before {
	content: "\2630";
	margin-inline-end: 0.35rem;
	opacity: 0.75;
	text-decoration: none;
}

.cong-live-bar__link.is-primary {
	padding: 0.35rem 0.9rem;
	border-radius: 999px;
	background: var(--cong-live-accent);
	color: var(--wp--preset--color--ink, #04436a);
	font-weight: 700;
	text-decoration: none;
}

.cong-live-bar__close {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-end: 0.75rem;
	transform: translateY(-50%);
	padding: 0.25rem 0.5rem;
	border: 0;
	background: none;
	color: inherit;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
	opacity: 0.75;
}

.cong-live-bar__close:hover {
	opacity: 1;
}

/* ---------- On a phone ---------------------------------------------------- */

/*
 * The bar is four links and a heading. On a desktop that is one tidy row; on a
 * phone it wraps to four lines, and with the utility strip and the header
 * underneath it, a quarter of the screen is gone before the page starts — on
 * the one morning when the thing people came for is a video.
 *
 * So on a narrow screen it becomes one line: the fact that something is
 * happening, and the button that takes you to it. The other three are in the
 * menu, on the page, and in the footer; the bar does not need to be the only
 * route to them.
 */
@media (max-width: 782px) {
	.cong-live-bar {
		flex-wrap: nowrap;
		align-items: center;
		gap: 0.6rem;
		padding: 0.45rem 2.5rem 0.45rem 0.9rem;
		font-size: 0.85rem;
	}

	.cong-live-bar__now {
		/* Shrinks before the button does, and loses its tail rather than
		   pushing the thing people are meant to tap off the screen. */
		min-width: 0;
		flex: 0 1 auto;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.cong-live-bar__links {
		flex: 0 0 auto;
		gap: 0;
	}

	/*
	 * Only the primary link survives. The rest are reachable from the menu and
	 * the page itself, and a row of four underlined links at this width is a
	 * row nobody can hit accurately anyway.
	 */
	.cong-live-bar__links > li {
		display: none;
	}

	.cong-live-bar__links > li:has( .is-primary ) {
		display: block;
	}

	.cong-live-bar__link.is-primary {
		padding: 0.3rem 0.8rem;
		white-space: nowrap;
	}

	.cong-live-bar__close {
		inset-inline-end: 0.4rem;
		padding: 0.25rem 0.4rem;
	}
}

/*
 * :has() is recent enough to be worth a fallback. Without it every link is
 * hidden, which would leave the bar announcing a service with no way to reach
 * it — so where it is unsupported the links simply all stay, and the bar wraps
 * as it did before.
 */
@supports not selector(li:has(a)) {
	@media (max-width: 782px) {
		.cong-live-bar__links > li {
			display: block;
		}

		.cong-live-bar {
			flex-wrap: wrap;
		}
	}
}

/* ---------- The stream block --------------------------------------------- */

.cong-live__heading {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	margin: 0 0 0.75rem;
	font-weight: 700;
}

.cong-live__frame {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--md, 14px);
	background: #000;
}

.cong-live__frame iframe {
	position: absolute;
	inset: 0;
	inline-size: 100%;
	block-size: 100%;
	border: 0;
}

.cong-live__aside {
	margin: 0.6rem 0 0;
	font-size: 0.9em;
}

/*
 * Off air. Not a greyed-out player: a panel that answers the question the
 * visitor actually has, which is "when is the next one".
 */
.cong-live__poster {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	padding: clamp(1.5rem, 5vw, 3rem);
	border-radius: var(--wp--custom--radius--md, 14px);
	background: var(--wp--preset--color--sky-soft, #eef6fb);
	text-align: center;
}

.cong-live__poster .cong-live__heading {
	justify-content: center;
	margin: 0;
	font-size: 1.15em;
}

.cong-live__times {
	margin: 0;
	padding: 0;
	list-style: none;
}

.cong-live__times > li {
	margin: 0;
}

.cong-live__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.75rem 1.25rem;
	margin: 0.25rem 0 0;
}

/*
 * Live, but the stream has not appeared yet. A sentence rather than a black
 * player: "this video is unavailable" reads as the church being broken.
 */
/*
 * Sized to its contents, not to the page.
 *
 * This was one sentence in a slab the full width of the band with up to three
 * rems of padding — the church was live and the page looked broken. It is now
 * a card: what is happening, when, and the button to go and watch it.
 */
.cong-live__pending {
	max-width: 32rem;
	margin: 0 auto;
	padding: 1.5rem;
	border-radius: var(--wp--custom--radius--md, 14px);
	background: rgb(255 255 255 / 0.08);
	text-align: center;
}

/*
 * Waiting for the stream: everything centres on the card.
 *
 * The heading used to sit hard against the left of a full-width band with the
 * card floating in the middle, reading as two unrelated things in a lot of
 * empty blue.
 */
.cong-live.is-pending {
	text-align: center;
}

.cong-live.is-pending .cong-live__heading {
	justify-content: center;
}

.cong-live__pending-lead {
	margin: 0;
	text-wrap: pretty;
}

.cong-live__pending .cong-live__times {
	margin: 1.25rem 0 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1.5rem;
	justify-content: center;
}

.cong-live__pending .cong-live__times > li {
	margin: 0;
}

.cong-live__pending-go {
	margin: 1.5rem 0 0;
}

.cong-live__when {
	margin: 0;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	font-size: 0.8em;
	color: var(--wp--preset--color--ink-muted, #55707f);
}
