/* Zoom Room Buttons — public styles
 *
 * Built on The Porch palette, the design system this site already uses:
 *   Charcoal #2B2B2B page, Cream #FDF6E3 text, Plum #5A3447 panels,
 *   Gold #B08D57 panel borders, Deep Teal #2F5D62 for "active".
 *
 * The room IS the button and it is the biggest thing on the page. Two styles
 * share one set of status colours:
 *
 *   .zrb-btn--cutout  The artwork IS the button. Its transparent edge becomes
 *                     the outline. Open = full colour behind a lit outline
 *                     ("the lights are on"); closed = drained and dimmed
 *                     ("the lights are off").
 *   .zrb-btn (card)   A rectangle with a tile, kept for vector icons.
 *
 * Status is never carried by colour alone:
 *   1. a large OPEN / CLOSED text badge, with its own shape glyph,
 *   2. an outline that lights up or goes dark,
 *   3. dimming (cutout) or a border-style change (card).
 */

/* ------------------------------------------------------------ the palette */

.zrb-wrap {
	/* The Porch tokens, with the site's own values as fallbacks. */
	--zrb-cream: #fdf6e3;
	--zrb-charcoal: #2b2b2b;
	--zrb-lchar: #525151;
	--zrb-plum: #5a3447;
	--zrb-wine: #4a2c3a;
	--zrb-gold: #b08d57;
	--zrb-teal: #2f5d62;
	--zrb-parchment: #d6c4a0;

	/* Status pair. Each state is a dark ground that cream text stays readable on,
	   plus a vivid accent for the glyph and the hairline that ties the pill to
	   the page whatever colour the page happens to be.

	   Contrast, measured: cream on the open ground 6.15:1, cream on the closed
	   ground 11.32:1; the vivid dot on its ground 3.97:1, the vivid X on its
	   ground 3.44:1 — all above the 4.5:1 text / 3:1 non-text thresholds. */
	--zrb-go: #0b6b34; /* darker green the cream OPEN text sits on */
	--zrb-go-vivid: #00e676; /* the vivid dot */
	--zrb-stop: #6b1212; /* darker red the cream CLOSED text sits on */
	--zrb-stop-vivid: #ff3b30; /* the vivid X */

	--zrb-panel: var(--zrb-plum);
	--zrb-frame: var(--zrb-gold);
	--zrb-ink: var(--zrb-cream);
	--zrb-muted-ink: var(--zrb-parchment);

	/* This site's own fonts: body copy is Radio Canada, headings are Raleway.
	   Falling back to inherit keeps the plugin matching any other theme. */
	--zrb-font: var(--wp--preset--font-family--radio-canada, inherit);
	--zrb-font-heading: var(--wp--preset--font-family--raleway, inherit);

	--zrb-radius: 15px; /* The Porch panel radius. */
	--zrb-frame-w: 4px; /* The Porch panel border weight. */

	--zrb-cols: 1;
	--zrb-art-h: clamp(200px, 46vh, 460px);
	--zrb-line-w: clamp(8px, calc(var(--zrb-art-h) * 0.04), 14px);

	margin: 1.5em 0;
	color: var(--zrb-ink);
	font-family: var(--zrb-font);
}

/* Opt-in light scheme, for anyone running this off-site. */
.zrb-wrap.zrb-palette-light {
	--zrb-panel: #ffffff;
	--zrb-frame: #d0d5dd;
	--zrb-ink: #101828;
	--zrb-muted-ink: #475467;
	--zrb-go: #0b6b34;
	--zrb-stop: #6b1212;
}

.zrb-heading {
	margin: 0 0 0.6em;
	color: var(--zrb-ink);
	font-size: clamp(1.5rem, 1.5rem + ((1vw - 0.2rem) * 2.5), 3rem);
	line-height: 1.2;
}

.zrb-grid {
	display: grid;
	grid-template-columns: repeat(var(--zrb-cols), minmax(0, 1fr));
	gap: clamp(16px, 2.5vw, 30px);
	justify-items: center;
}

@media (max-width: 560px) {
	.zrb-grid {
		grid-template-columns: 1fr;
	}
}

/* One grid cell: just the button. */
.zrb-room {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	width: 100%;
	min-width: 0;
	container-type: inline-size;
	container-name: zrb-room;
}

/* A narrow column has no room for a tile, a name and a badge side by side. A
   room name is one unbreakable word, so without this it overflows its flex item
   and spills underneath the badge, which is painted later and hides it. */
@container zrb-room (max-width: 330px) {
	.zrb-btn:not(.zrb-btn--cutout) {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.zrb-btn:not(.zrb-btn--cutout) .zrb-btn__footer {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
		width: 100%;
	}

	.zrb-btn:not(.zrb-btn--cutout) .zrb-badge {
		margin-left: 0;
	}
}

/* ------------------------------------------------------------- the button */

.zrb-btn {
	/* --zrb-accent is set inline per room (its identity colour).
	   --zrb-status is what actually drives colour, and is overridden by the
	   state classes below. */
	--zrb-status: var(--zrb-teal);
	--zrb-line: var(--zrb-status);
	position: relative;
	display: flex;
	align-items: center;
	gap: 18px;
	width: 100%;
	max-width: 100%;
	padding: clamp(16px, 2.4vw, 26px);
	border: var(--zrb-frame-w) solid var(--zrb-frame);
	border-radius: var(--zrb-radius);
	background: var(--zrb-panel);
	color: var(--zrb-ink);
	text-align: left;
	cursor: pointer;
	overflow: hidden;
	transition: transform 0.12s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
	font: inherit;
	-webkit-tap-highlight-color: transparent;
}

.zrb-btn::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 6px;
	background: var(--zrb-line);
}

.zrb-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

/* The whole card is one button — icon, name and OPEN/CLOSED badge all join.
   Brightening the badge on hover makes it clear the badge is part of it too. */
.zrb-btn:hover .zrb-badge,
.zrb-btn:focus-visible .zrb-badge {
	filter: brightness(1.12);
}

.zrb-btn:focus-visible {
	outline: 3px solid var(--zrb-cream);
	outline-offset: 3px;
}

.zrb-btn:active {
	transform: translateY(0) scale(0.99);
}

.zrb-btn[disabled] {
	opacity: 0.7;
	cursor: progress;
}

.zrb-btn--unset {
	opacity: 0.8;
}

/* ------------------------------------------------------- status treatments */

/* OPEN — the lights are on: lit outline, full colour, Deep Teal badge. */
.zrb-btn.zrb-state-open {
	--zrb-status: var(--zrb-teal);
	--zrb-line: var(--zrb-teal-lite);
	border-color: var(--zrb-gold);
}

/* CLOSED — the lights are off: unlit outline, drained artwork, grey badge. */
.zrb-btn.zrb-state-closed {
	--zrb-status: var(--zrb-lchar);
	--zrb-line: #3a3a3a;
	border-style: dashed;
	border-color: var(--zrb-lchar);
}

.zrb-btn.zrb-state-closed .zrb-btn__label {
	color: var(--zrb-muted-ink);
}

/* OPENING SOON — gold, the Porch accent. */
.zrb-btn.zrb-state-soon {
	--zrb-status: var(--zrb-gold);
	--zrb-line: var(--zrb-gold);
	border-color: var(--zrb-gold);
}

/* UNKNOWN / CHECKING — neutral, dashed. */
.zrb-btn.zrb-state-unknown,
.zrb-btn.zrb-state-checking {
	--zrb-status: var(--zrb-wine);
	--zrb-line: var(--zrb-lchar);
	border-style: dashed;
	border-color: var(--zrb-lchar);
}

/* ---------------------------------------------------------------- the icon */

.zrb-btn__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--zrb-tile, 52px);
	height: var(--zrb-tile, 52px);
	flex: 0 0 var(--zrb-tile, 52px);
	border-radius: 12px;
	color: var(--zrb-line);
	background: rgba(0, 0, 0, 0.22);
}

.zrb-btn__icon svg {
	width: var(--zrb-icon, 28px);
	height: var(--zrb-icon, 28px);
	display: block;
}

/* Full-colour artwork keeps its own colours. The tile stays transparent so a
   status tint never washes over the illustration — status is still carried by
   the badge, the panel tint and the border. */
.zrb-btn__icon.zrb-btn__icon--image {
	background: transparent;
	padding: 0;
	overflow: hidden;
}

.zrb-btn__icon.zrb-btn__icon--image img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

/* Holds the name and the badge, so both styles can lay them out differently. */
.zrb-btn__footer {
	display: flex;
	align-items: center;
	gap: 16px;
	flex: 1 1 auto;
	min-width: 0;
}

.zrb-btn__text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
	overflow: hidden; /* never let a long name spill under the badge */
}

/* The room name uses the site's heading font, at heading weight and size, so it
   reads as a title rather than as button copy. */
.zrb-btn__label {
	cursor: inherit;
	color: var(--zrb-ink);
	font-family: var(--zrb-font-heading);
	font-weight: 800;
	font-size: clamp(1.4rem, 1.15rem + 1vw, 2.15rem);
	line-height: 1.15;
	overflow-wrap: anywhere;
}

.zrb-btn__sub {
	color: var(--zrb-muted-ink);
	font-size: 0.95rem;
}

/* --------------------------------------------------------------- the badge */

/* The badge is the primary cue, so it is deliberately large and heavy. The
   vivid hairline is what keeps the pill findable whatever colour the page is,
   now that the artwork itself no longer carries an outline. */
.zrb-badge {
	cursor: inherit;
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	padding: clamp(10px, 1.1vw, 15px) clamp(18px, 2vw, 28px);
	border: 3px solid transparent;
	border-radius: 999px;
	background: var(--zrb-status);
	color: var(--zrb-cream);
	font-family: var(--zrb-font);
	font-weight: 800;
	font-size: clamp(1.05rem, 0.9rem + 0.6vw, 1.55rem);
	letter-spacing: 0.05em;
	text-transform: uppercase;
	line-height: 1;
	white-space: nowrap;
	flex: 0 0 auto;
}

/* OPEN — a dark green ground so the cream word stays readable, ringed in a
   vivid green that matches the dot. */
.zrb-state-open .zrb-badge {
	background: var(--zrb-go);
	border-color: var(--zrb-go-vivid);
}

/* CLOSED — the same idea in red. */
.zrb-state-closed .zrb-badge {
	background: var(--zrb-stop);
	border-color: var(--zrb-stop-vivid);
}

.zrb-state-soon .zrb-badge {
	background: #7a5c2e;
	border-color: var(--zrb-gold);
}

.zrb-state-unknown .zrb-badge,
.zrb-state-checking .zrb-badge {
	background: var(--zrb-wine);
	border-color: #7a4e64;
}

.zrb-badge__glyph {
	width: 0.95em;
	height: 0.95em;
	flex: 0 0 0.95em;
	/* Masked rather than a background image, so the glyph can be given the vivid
	   accent colour and still sit on the badge's own dark ground. */
	background-color: currentColor;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-size: contain;
	mask-size: contain;
}

/* Shape carries the meaning too, not just colour:
   open = filled circle, closed = cross, soon = clock, unknown = dash. */
.zrb-state-open .zrb-badge__glyph {
	background-color: var(--zrb-go-vivid);
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Ccircle%20cx='8'%20cy='8'%20r='6'%20fill='%23000'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Ccircle%20cx='8'%20cy='8'%20r='6'%20fill='%23000'/%3E%3C/svg%3E");
}

.zrb-state-closed .zrb-badge__glyph {
	background-color: var(--zrb-stop-vivid);
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Cpath%20d='M4%204l8%208M12%204l-8%208'%20stroke='%23000'%20stroke-width='2.6'%20stroke-linecap='round'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Cpath%20d='M4%204l8%208M12%204l-8%208'%20stroke='%23000'%20stroke-width='2.6'%20stroke-linecap='round'/%3E%3C/svg%3E");
}

.zrb-state-soon .zrb-badge__glyph {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Ccircle%20cx='8'%20cy='8'%20r='6'%20fill='none'%20stroke='%23000'%20stroke-width='2'/%3E%3Cpath%20d='M8%205v3.5l2.5%201.5'%20fill='none'%20stroke='%23000'%20stroke-width='2'%20stroke-linecap='round'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Ccircle%20cx='8'%20cy='8'%20r='6'%20fill='none'%20stroke='%23000'%20stroke-width='2'/%3E%3Cpath%20d='M8%205v3.5l2.5%201.5'%20fill='none'%20stroke='%23000'%20stroke-width='2'%20stroke-linecap='round'/%3E%3C/svg%3E");
}

.zrb-state-unknown .zrb-badge__glyph,
.zrb-state-checking .zrb-badge__glyph {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Crect%20x='3'%20y='7'%20width='10'%20height='2.5'%20rx='1.25'%20fill='%23000'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Crect%20x='3'%20y='7'%20width='10'%20height='2.5'%20rx='1.25'%20fill='%23000'/%3E%3C/svg%3E");
}

/* A gentle attention ring on open rooms. */
.zrb-state-open .zrb-badge {
	animation: zrb-badge-pulse 2.6s ease-out infinite;
}

@keyframes zrb-badge-pulse {
	0% { box-shadow: 0 0 0 0 rgba(95, 163, 165, 0.5); }
	70% { box-shadow: 0 0 0 12px rgba(95, 163, 165, 0); }
	100% { box-shadow: 0 0 0 0 rgba(95, 163, 165, 0); }
}

/* --------------------------------------------------------------- spinner */

.zrb-btn__spinner {
	display: none;
	width: 18px;
	height: 18px;
	margin-left: 8px;
	flex: 0 0 18px;
	border: 2px solid rgba(253, 246, 227, 0.25);
	border-top-color: var(--zrb-line);
	border-radius: 50%;
	animation: zrb-spin 0.7s linear infinite;
}

.zrb-btn.is-loading .zrb-btn__spinner {
	display: block;
}

@keyframes zrb-spin {
	to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------- message */

.zrb-message {
	margin: 14px 0 0;
	font-size: 1rem;
	min-height: 1.2em;
	color: var(--zrb-muted-ink);
	text-align: center;
}

.zrb-message.is-error {
	color: #ffb4a8;
	font-weight: 700;
}

/* ------------------------------------------------- cutout (artwork) style */

/* The button is the illustration. It sits in a Porch panel — Plum ground, Gold
   frame, 15px radius — and the artwork is drawn big enough to be the thing you
   actually aim at. The room name and the OPEN / CLOSED badge sit below the
   outline, never inside it, so they are never clipped and never lose contrast. */

.zrb-btn.zrb-btn--cutout {
	flex-direction: column;
	align-items: center;
	gap: clamp(14px, 2vw, 26px);
	width: 100%;
	max-width: min(100%, 520px); /* kept close to the artwork so the panel hugs it */
	margin-inline: auto;
	padding: clamp(22px, 3vw, 40px) clamp(20px, 3vw, 36px) clamp(18px, 2.4vw, 30px);
	border: var(--zrb-frame-w) solid var(--zrb-frame);
	border-radius: var(--zrb-radius);
	background: var(--zrb-panel);
	box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
	overflow: visible;
	text-align: center;
}

.zrb-btn.zrb-btn--cutout::before {
	content: none;
}

.zrb-btn.zrb-btn--cutout:hover {
	transform: translateY(-3px);
	box-shadow: 0 16px 34px rgba(0, 0, 0, 0.5);
}

.zrb-btn.zrb-btn--cutout:focus-visible {
	outline: 3px solid var(--zrb-cream);
	outline-offset: 6px;
}

/* Frameless: the artwork and its outline float straight on the page, with no
   panel competing with them. This is the default look.

   The padding reserves exactly the width of the outline, which sits *outside*
   the artwork. Without it a full-width room would push its halo past the
   viewport edge and create a horizontal scrollbar. */
.zrb-btn.zrb-btn--cutout.zrb-btn--bare {
	max-width: min(100%, 600px);
	padding: calc(var(--zrb-line-w, 12px) + 2px);
	border: 0;
	background: transparent;
	box-shadow: none;
}

/* min() rather than a flat height: the artwork always grows to fill the panel,
   and only gives way to the viewport clamp on a short screen. */
.zrb-btn--cutout .zrb-btn__figure {
	position: relative;
	display: block;
	width: min(100%, var(--zrb-art-h, 300px));
	height: auto;
	aspect-ratio: 1 / 1;
	flex: 0 0 auto;
	margin: 0 auto;
}

.zrb-btn--cutout .zrb-btn__art {
	position: relative;
	z-index: 2;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	transition: transform 0.16s ease, filter 0.3s ease;
}

.zrb-btn--cutout .zrb-btn__footer {
	flex: 0 0 auto;
	flex-wrap: wrap;
	justify-content: center;
	gap: clamp(10px, 1.6vw, 18px);
}

.zrb-btn--cutout .zrb-badge {
	margin-left: 0;
}

.zrb-btn--cutout:hover .zrb-btn__art {
	transform: translateY(-4px);
}

/* --- the lights: on = full colour, off = drained to dark grey --- */

/* There is no outline any more. The artwork's own colour is the signal — vivid
   against dark grey — and the badge spells the state out. That also means the
   component no longer assumes a dark page: these rooms go on any background.

   The closed artwork is drained to a dark grey that is still solid enough to
   hold its silhouette. It deliberately keeps full opacity: fading it out would
   blend it into whatever is behind it and lose the shape. */
.zrb-btn--cutout.zrb-state-closed .zrb-btn__art {
	filter: grayscale(1) brightness(0.7) contrast(0.95);
}

.zrb-btn--cutout.zrb-state-soon .zrb-btn__art {
	filter: grayscale(0.55) brightness(0.92) opacity(0.9);
}

.zrb-btn--cutout.zrb-state-unknown .zrb-btn__art,
.zrb-btn--cutout.zrb-state-checking .zrb-btn__art {
	filter: grayscale(1) brightness(0.7) opacity(0.7);
}

/* ---------------------------------------------------- screen-reader only */

/* Announces a status change ("Courtyard is now Open") to assistive tech when a
   room opens or closes while someone is already on the page. Off-screen for
   sighted visitors, who see the badge flip instead. */
.zrb-live {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* ------------------------------------------------------ motion & contrast */

@media (prefers-reduced-motion: reduce) {
	.zrb-btn,
	.zrb-state-open .zrb-badge {
		animation: none !important;
		transition: none !important;
	}

	.zrb-btn:hover,
	.zrb-btn--cutout:hover .zrb-btn__art {
		transform: none;
	}
}

/* The strongest readable cue is a cream rim, so high-contrast mode keeps the
   status hues on the badge but rings it in cream and pushes the dimming
   further, so "off" is unmistakable even without colour. */
@media (prefers-contrast: more) {
	.zrb-btn {
		border-color: var(--zrb-cream);
	}

	.zrb-btn--cutout.zrb-state-closed .zrb-btn__art {
		filter: grayscale(1) brightness(0.55) contrast(0.95);
	}

	.zrb-badge {
		border: 3px solid var(--zrb-cream);
	}
}

/* Windows High Contrast / forced colours overrides our status colours but leaves
   the artwork alone, so vivid-against-grey still carries the state and the
   badge text still reads. A ring keeps the artwork's bounds findable. */
@media (forced-colors: active) {
	.zrb-btn--cutout .zrb-btn__figure {
		border: 3px solid CanvasText;
		border-radius: 12px;
	}

	.zrb-badge {
		border: 2px solid CanvasText;
	}
}
