/**
 * Recall Notice Banner — banner styles.
 *
 * One semantic markup, four visual variants:
 *   .rnb--alert   high-urgency safety style (default)
 *   .rnb--modern  polished notification banner
 *   .rnb--theme   adapts to the active theme via CSS custom properties
 *   .rnb--minimal slim, understated bar
 *
 * Accent is driven by --rnb-accent (overridable via inline custom color).
 */

/* ---------- Accent tokens ---------- */
.rnb--accent-warning { --rnb-accent: #c8102e; --rnb-accent-ink: #ffffff; }
.rnb--accent-caution { --rnb-accent: #b45309; --rnb-accent-ink: #ffffff; }
.rnb--accent-info    { --rnb-accent: #1d4ed8; --rnb-accent-ink: #ffffff; }

/* ---------- Base (shared) ---------- */
.rnb {
	--rnb-accent-ink: #ffffff;
	--rnb-font-family: var(--html-font, Helvetica, Verdana, sans-serif);
	/* --rnb-ink: optional text colour override set via inline style. */
	box-sizing: border-box;
	width: 100%;
	font-family: var(--rnb-font-family) !important;
	font-size: 16px;
	line-height: 1.4 !important;
	color: var(--rnb-ink, inherit);
	/* Positioning context for .rnb__close (position: absolute). Declared here,
	   before .rnb--pos-sticky below, so the sticky/static variants can win the
	   cascade on equal specificity instead of being silently overridden by it. */
	position: relative;
}

.rnb *,
.rnb *::before,
.rnb *::after {
	box-sizing: border-box;
	font-family: inherit;
	line-height: inherit;
}


.rnb-stack--sticky {
	position: sticky;
	top: var(--rnb-stack-root-top, 0px);
	z-index: var(--rnb-stack-z-index, 99990);
}

.rnb-stack--static {
	position: static;
}

.rnb--pos-sticky,
.rnb--pos-static {
	position: relative;
}

/* Keep stacked banners fully separated so every notice remains visible. */
.rnb-stack .rnb + .rnb {
	margin-top: 0;
}

.rnb__link {
	display: flex;
	align-items: center;
	gap: 16px;
	max-width: 1200px;
	margin: 0 auto;
	padding: 14px 20px;
	text-decoration: none;
	color: inherit;
}

.rnb__icon {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.rnb__body {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.rnb__heading {
	font-weight: 700 !important;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	font-size: 0.82em;
}

.rnb__text {
	font-weight: 400 !important;
}

.rnb__date {
	font-size: 0.8em;
	font-weight: 400 !important;
	opacity: 0.85;
}

.rnb__cta {
	flex: 0 0 auto;
}

.rnb__button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 18px;
	border-radius: 6px;
	font-weight: 700 !important;
	white-space: nowrap;
	transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.rnb__close {
	position: absolute;
	top: 50%;
	right: 10px;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font: inherit !important;
	font-size: 22px;
	line-height: 1;
	background: transparent;
	border: 0;
	color: inherit;
	cursor: pointer;
	opacity: 0.8;
	border-radius: 4px;
}

.rnb__close:hover { opacity: 1; }

/* Focus visibility (keyboard a11y) */
.rnb__link:focus-visible,
.rnb__close:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: -3px;
}

/* Hover affordance on the CTA */
.rnb__link:hover .rnb__button {
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

/* ============================================================
 * Style 1 — ALERT (high-urgency safety style, default)
 * ============================================================ */
.rnb--alert {
	background: var(--rnb-accent);
	/* --rnb-ink set via inline style overrides the default accent ink. */
	color: var(--rnb-ink, var(--rnb-accent-ink));
	border-bottom: 4px solid rgba(0, 0, 0, 0.25);
}

.rnb--alert .rnb__icon { color: var(--rnb-ink, var(--rnb-accent-ink)); }

.rnb--alert .rnb__button {
	background: var(--rnb-btn-bg, #ffffff);
	color: var(--rnb-btn-ink, var(--rnb-accent));
}

.rnb--alert .rnb__close { color: var(--rnb-ink, var(--rnb-accent-ink)); }

/* ============================================================
 * Style 2 — MINIMAL (slim, understated bar)
 * ============================================================ */
.rnb--minimal {
	background: #1a1a1a;
	color: var(--rnb-ink, #f4f4f4);
	border-bottom: 2px solid var(--rnb-accent);
	font-size: 15px;
}

.rnb--minimal .rnb__link {
	padding: 10px 20px;
	gap: 10px;
}

.rnb--minimal .rnb__icon { color: var(--rnb-accent); }
.rnb--minimal .rnb__icon svg { width: 18px; height: 18px; }

.rnb--minimal .rnb__body {
	flex-direction: row;
	align-items: baseline;
	gap: 8px;
	flex-wrap: wrap;
}

.rnb--minimal .rnb__text {
	font-weight: 400 !important;
}

.rnb--minimal .rnb__heading {
	text-transform: none;
	font-size: 0.85em;
	letter-spacing: 0;
}

.rnb--minimal .rnb__date { display: none; }

/* CTA collapses to an inline arrow link */
.rnb--minimal .rnb__button {
	padding: 0;
	border-radius: 0;
	background: var(--rnb-btn-bg, transparent);
	color: var(--rnb-btn-ink, #ffffff);
	text-decoration: underline;
	text-underline-offset: 3px;
	box-shadow: none;
}

.rnb--minimal .rnb__link:hover .rnb__button {
	transform: none;
	box-shadow: none;
	color: var(--rnb-accent);
}

/* ============================================================
 * Style 3 — THEME (inherits the active theme look)
 * ============================================================ */
.rnb--theme {
	/* Read theme tokens with sensible fallbacks. */
	font-family: inherit;
	background: var(--rnb-bg, var(--wp--preset--color--background, #fbeae9));
	color: var(--rnb-ink, var(--rnb-fg, var(--wp--preset--color--foreground, #1a1a1a)));
	border-bottom: 4px solid var(--rnb-accent);
}

.rnb--theme .rnb__icon { color: var(--rnb-accent); }

.rnb--theme .rnb__heading { color: var(--rnb-accent); }

.rnb--theme .rnb__button {
	background: var(--rnb-btn-bg, var(--rnb-accent));
	color: var(--rnb-btn-ink, var(--rnb-accent-ink));
}

.rnb--theme .rnb__text {
	font-weight: 400 !important;
}

/* ============================================================
 * Style 4 — MODERN (polished notification banner, GOV.UK-inspired)
 * ============================================================ */
.rnb--modern {
	background: #ffffff;
	color: var(--rnb-ink, #1a1a1a);
	border-bottom: 1px solid #e5e7eb;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

/* Colored header strip + left accent rail */
.rnb--modern .rnb__link {
	position: relative;
	border-left: 6px solid var(--rnb-accent);
	padding-top: 16px;
	padding-bottom: 16px;
}

.rnb--modern .rnb__heading {
	color: var(--rnb-accent);
	font-size: 0.78em;
}

.rnb--modern .rnb__icon { color: var(--rnb-accent); }

.rnb--modern .rnb__text {
	font-size: 1.02em;
	font-weight: 400 !important;
}

.rnb--modern .rnb__button {
	background: var(--rnb-btn-bg, var(--rnb-accent));
	color: var(--rnb-btn-ink, var(--rnb-accent-ink));
	border-radius: 999px; /* pill */
	padding: 10px 22px;
}

/* ============================================================
 * Overflow banner — the single "+N more, view all" link shown
 * when live recalls exceed the configured maximum.
 * ============================================================ */
.rnb--overview {
	background: var(--rnb-accent);
	color: var(--rnb-accent-ink);
	border-bottom: 4px solid rgba(0, 0, 0, 0.25);
}

.rnb--overview .rnb__icon { color: var(--rnb-accent-ink); }

.rnb--overview .rnb__button {
	background: #ffffff;
	color: var(--rnb-accent);
}

/* ============================================================
 * Responsive — stack on small screens
 * ============================================================ */
@media (max-width: 720px) {
	.rnb__link {
		flex-wrap: wrap;
		gap: 10px 14px;
		padding: 12px 16px;
		padding-right: 44px; /* room for the close button */
	}

	.rnb__cta {
		flex-basis: 100%;
	}

	.rnb__button {
		display: flex;
		justify-content: center;
		width: 100%;
		min-height: 44px; /* touch target */
	}

	.rnb--minimal .rnb__cta { flex-basis: auto; }
	.rnb--minimal .rnb__button { width: auto; min-height: 0; display: inline-flex; }
}

/* ============================================================
 * Ticker (opt-in via .rnb--ticker; only animates when JS finds overflow)
 * ============================================================ */
.rnb--ticker .rnb__text {
	overflow: hidden;
}

/* Once JS confirms the text overflows, it adds .is-ticking and sets the duration. */
.rnb--ticker.is-ticking .rnb__text {
	white-space: nowrap;
}

.rnb--ticker.is-ticking .rnb__ticker-inner {
	display: inline-block;
	will-change: transform;
	animation: rnb-ticker var(--rnb-ticker-duration, 12s) linear infinite;
}

/* Endpoints are set in px by banner.js so the text re-enters from the right edge
 * the instant it leaves the left (no empty gap); the %-fallbacks keep it working
 * if the script never runs. */
@keyframes rnb-ticker {
	from { transform: translateX(var(--rnb-ticker-from, 100%)); }
	to   { transform: translateX(var(--rnb-ticker-to, -100%)); }
}

/* Endless (seamless) variant: JS duplicates the text into two identical halves,
 * so translating one half's width (-50%) makes the second half land exactly where
 * the first began — a gapless "TEXT - TEXT - …" loop. Overrides only the animation
 * name; duration/timing/iteration carry over from the base shorthand above. */
.rnb--ticker-endless.is-ticking .rnb__ticker-inner {
	animation-name: rnb-ticker-endless;
}

@keyframes rnb-ticker-endless {
	from { transform: translateX(0); }
	to   { transform: translateX(-50%); }
}

/* ============================================================
 * Motion / dismissal
 * ============================================================ */
.rnb.is-dismissed { display: none; }

/* ============================================================
 * [rnb_recall_list] shortcode — overview page listing every live recall.
 * ============================================================ */
.rnb-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.rnb-list__link {
	display: block;
	padding: 14px 18px;
	border: 1px solid #e5e7eb;
	border-left: 4px solid var(--rnb-accent, #c8102e);
	border-radius: 6px;
	text-decoration: none;
	color: inherit;
}

.rnb-list__link:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: -3px;
}

.rnb-list__heading {
	display: block;
	font-weight: 700;
	margin-bottom: 4px;
}

@media (prefers-reduced-motion: reduce) {
	.rnb__button,
	.rnb__link:hover .rnb__button {
		transition: none;
		transform: none;
	}

	/* Backstop: never scroll the ticker when reduced motion is requested. */
	.rnb--ticker.is-ticking .rnb__text {
		white-space: normal;
	}

	.rnb--ticker.is-ticking .rnb__ticker-inner {
		animation: none;
		transform: none;
	}
}
