/**
 * The lobby touchscreen.
 *
 * A screen nobody is holding: no site header, no footer, no scrollbar to
 * discover. It fills whatever it is mounted on — usually a portrait panel —
 * and the type is sized against the viewport so the same page is legible
 * from across a foyer and from arm's length at the glass.
 */
.cong-kiosk {
	display: flex;
	flex-direction: column;
	/* A fixed height, not a minimum: a wall panel has the height it has, and
	   anything that will not fit has to be dealt with inside, not by making
	   the page taller than the glass. */
	block-size: 100vh;
	block-size: 100dvh;
	/*
	 * Clipped, not just hidden. A hidden overflow can still be scrolled by
	 * script — and the campus map's search box takes focus when it loads,
	 * which scrolled the screen until the pictures were off the top of the
	 * glass. `clip` cannot be scrolled at all; `hidden` stays for a browser
	 * that does not know it.
	 *
	 * The plain `vh` line before `dvh` is for the same kind of browser: a
	 * signage player's older Chrome ignored `100dvh`, the panel had no height,
	 * the day's list grew to its full length and the page ran off the bottom.
	 */
	overflow: hidden;
	overflow: clip;
	background: var(--wp--preset--color--base, #fff);
}

/*
 * Two rules, not one list: the lobby's BrightSign players run Chrome 87, which
 * has no `:has()`, and one selector it cannot read throws out the whole list.
 */
html:has(.cong-kiosk) {
	overflow: hidden;
	overflow: clip;
	block-size: 100%;
}

body.page-template-page-kiosk {
	/* WordPress clears this margin with `:where(body)`, also unknown to Chrome 87. */
	margin: 0;
	overflow: hidden;
	overflow: clip;
	block-size: 100%;
}

/*
 * The content wrapper has to be part of the flex column.
 *
 * The template puts `post-content` between the panel and its three sections,
 * so every `flex` below was talking to an ordinary flow container and did
 * nothing at all: the panel grew to whatever its contents wanted — 1,586px
 * on a 1,080px screen — and the bottom third of the campus map was simply
 * off the wall.
 */
.cong-kiosk > .wp-block-post-content {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-block-size: 0;
	padding: 0;
	margin: 0;
}

.cong-kiosk > .wp-block-post-content > * {
	margin-block: 0;
}

/* The site chrome is for the website, not for a wall panel. */
.page-kiosk .cong-header,
.page-kiosk .cong-utility,
.page-kiosk .wp-block-template-part,
.page-kiosk footer {
	display: none;
}

/*
 * The pictures take a share of the height, set on the lobby settings screen.
 * They used to be sized by their own `short` minimum, which on a 1080px panel
 * left a 346px band — so a 1920 × 1080 notice shown whole came out 615px
 * wide, marooned in the middle of a very wide letterbox.
 */
.cong-kiosk__slides {
	/*
	 * Full width, and exactly as tall as a 16:9 notice at that width — the
	 * dots sit on the picture, not under it. A fixed share of the height was
	 * 960px on a 1920px portrait panel for a 607px picture: two navy bands,
	 * and the day's events cut off below. The share set on the settings
	 * screen is now only the most the pictures may take, which is what keeps
	 * them from filling a landscape screen.
	 */
	flex: 0 0 min(calc(100vw * 9 / 16), calc(var(--cong-slides-share, 50) * 1vh));
	min-block-size: 0;
}

/*
 * Behind @supports, because the usual "plain line first" fallback cannot work
 * here. A declaration holding var() is accepted whatever else is in it, so
 * Chrome 87 kept the `dvh` line, found it meaningless once the variable was
 * filled in, and fell back to `flex: 0 1 auto`. Plain slides have no height of
 * their own, so the pictures measured zero and vanished without a trace.
 */
@supports (block-size: 1dvh) {
	.cong-kiosk__slides {
		flex: 0 0 min(calc(100vw * 9 / 16), calc(var(--cong-slides-share, 50) * 1dvh));
	}
}

/*
 * The slides fill the panel the flex row gave them.
 *
 * Everywhere else a slide is as tall as its own words, and min-block-size
 * keeps it from collapsing. On the kiosk the panel decides the height and
 * that minimum is dropped — but a *plain* slide has no words at all, so with
 * nothing to hold it open the track measured zero and four perfectly good
 * 1920×1080 notices were drawn into a strip of nothing.
 */
.cong-kiosk__slides .cong-slideshow__track,
.cong-kiosk__slides .cong-slide {
	min-block-size: 0;
	block-size: 100%;
}

/*
 * Still, and whole. The slow push the home page's slideshow gives a
 * photograph scales it past its edges, which crops a poster — and these are
 * notices designed to the pixel, where the cropped edge is the date or the
 * web address. No drift here, and every picture shown entire.
 */
.cong-kiosk__slides .cong-slide__img,
.cong-kiosk__slides[data-cong-ready] .cong-slide__img,
.cong-kiosk__slides[data-cong-ready] .cong-slide.is-current .cong-slide__img {
	transform: none;
	animation: none;
	object-fit: contain;
}

/* The Sunday note, a band between the pictures and the day: read across a foyer. */
.cong-kiosk__note {
	flex: 0 0 auto;
	padding: clamp(0.75rem, 1.5vmin, 1.5rem) clamp(1rem, 3vmin, 3rem);
	border-inline-start: 6px solid var(--wp--preset--color--lime);
	background: var(--wp--preset--color--sky-soft);
}

.cong-kiosk__note-when {
	margin: 0 0 0.25rem;
	color: var(--wp--preset--color--leaf);
	font-size: clamp(0.9rem, 1.8vmin, 1.4rem);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.cong-kiosk__note .cong-sunday-note {
	margin: 0;
	font-size: clamp(1.1rem, 2.4vmin, 2rem);
}

.cong-kiosk__note .cong-sunday-note__title {
	font-size: 1.25em;
}

.cong-kiosk__body {
	flex: 1 1 auto;
	display: grid;
	/*
	 * An explicit row, not an automatic one.
	 *
	 * A grid row sizes itself to its tallest item, and the campus map frame
	 * has a height of its own — so the row became 827px inside a 602px panel
	 * and the bottom of both columns was clipped away. minmax(0, 1fr) makes
	 * the row exactly as tall as the space there is, and the two columns
	 * then have something definite to fill.
	 */
	grid-template-rows: minmax(0, 1fr);
	/*
	 * Edge to edge. Cards with gutters round them suit a page somebody
	 * scrolls; on a screen on a wall they only spend glass on margins. The
	 * list and the map meet at a single line.
	 */
	gap: 0;
	padding: 0;
	min-block-size: 0;
}

.cong-kiosk .cong-kiosk__body .cong-day {
	border-radius: 0;
	background: var(--wp--preset--color--base, #fff);
}

.cong-kiosk .cong-kiosk__body .cong-campus {
	border-radius: 0;
	box-shadow: none;
}

@media (orientation: landscape) {
	.cong-kiosk__body > .cong-kiosk__map { border-inline-start: 1px solid #dde3ea; }
}

@media (orientation: portrait) {
	.cong-kiosk__body > .cong-kiosk__map { border-block-start: 1px solid #dde3ea; }
}

/* The map growing to take the screen, and settling back: a fade, since a
   grid cannot be animated on the players' Chrome 87. */
.cong-kiosk__body.is-growing > .cong-kiosk__map { animation: cong-kiosk-grow 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.cong-kiosk__body.is-settling > .cong-kiosk__map { opacity: 0; transform: scale(0.985); transition: opacity 0.3s ease, transform 0.3s ease; }
.cong-kiosk__body:not(.is-showing-map) > .cong-kiosk__map { animation: cong-kiosk-fade 0.4s ease both; }

@keyframes cong-kiosk-grow {
	0% { opacity: 0.35; transform: scale(0.97); }
	100% { opacity: 1; transform: scale(1); }
}

@keyframes cong-kiosk-fade {
	0% { opacity: 0; }
	100% { opacity: 1; }
}

/*
 * Portrait panels are the common mounting, and there the map belongs under
 * the list. Given a landscape screen, the two sit side by side instead.
 */
@media (orientation: landscape) {
	.cong-kiosk__body { grid-template-columns: 1fr 1fr; }
}

/* Portrait stacks the two, so they share the height rather than each
   claiming all of it. */
@media (orientation: portrait) {
	.cong-kiosk__body { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
}

/* A few dots say where you are; twenty-six ran off the edge of a narrow
   panel and, wrapped, sat in two rows across the notice. Past ten they tell
   nobody anything, and on this screen the pictures move by themselves. */
.cong-kiosk__slides .cong-slideshow__dots:has(> :nth-child(11)) {
	display: none;
}

.cong-kiosk__slides.has-many-slides .cong-slideshow__dots {
	display: none;
}

.cong-kiosk__map { min-block-size: 0; }

/*
 * The map is the frame, not a wrapper around one.
 *
 * `.cong-kiosk__map .cong-frame` is a descendant selector, and the embed
 * block puts both classes on the same element — so it matched nothing, the
 * frame kept its own 799px height, and it hung 240px off the bottom of the
 * panel.
 */
.cong-kiosk__map.cong-frame,
.cong-kiosk__map .cong-frame,
.cong-kiosk__map.cong-campus {
	block-size: 100%;
	min-block-size: 0;
}

/*
 * A busy Sunday has more events than the panel is tall. The list scrolls
 * inside its own half rather than pushing the map off the screen — there is
 * a finger in front of this one, so scrolling is a reasonable thing to ask.
 */
.cong-kiosk__body > * {
	min-block-size: 0;
	/* The global block gap lands between grid items too, and 28px of it was
	   enough to push the map past the bottom edge. */
	margin-block: 0;
}

.cong-kiosk .cong-day {
	display: flex;
	flex-direction: column;
	min-block-size: 0;
	overflow: hidden;
}

.cong-kiosk .cong-day__list {
	flex: 1 1 auto;
	min-block-size: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* ---------- Directions from the list ------------------------------------- */

/*
 * A room name that is also the way there.
 *
 * Underlined rather than buttoned: it sits inside a line of small grey
 * metadata, and a button there would outweigh the event's own name above it.
 * The dot is the only ornament, and it is what makes the line scan as
 * tappable on a screen nobody reads instructions for.
 */


/*
 * While a room is showing, the map takes the screen: somebody who just asked
 * where a room is wants the answer large. The list is still there, behind a
 * tap.
 */
.cong-kiosk__body.is-showing-map {
	grid-template-columns: minmax(0, 1fr);
}

.cong-kiosk__body.is-showing-map > :not(.cong-kiosk__map):not(.cong-kiosk__back) {
	display: none;
}

.cong-kiosk__back {
	display: none;
}

.cong-kiosk__body.is-showing-map .cong-kiosk__back {
	display: block;
	position: absolute;
	/* Bottom left: the campus map keeps its zoom buttons bottom right and
	   the room's name top left. */
	inset-block-end: var(--wp--preset--spacing--30);
	inset-inline-start: var(--wp--preset--spacing--30);
	z-index: 2;
	padding: 0.6em 1.2em;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--ink);
	box-shadow: 0 2px 12px rgb(11 42 66 / 0.35);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.cong-kiosk__body {
	position: relative;
}

/* Scan to follow along: the service now, in the corner. */
.cong-kiosk__scan {
	position: fixed;
	right: clamp(16px, 2vw, 40px);
	bottom: clamp(16px, 2vw, 40px);
	z-index: 50;
	display: flex;
	gap: 16px;
	padding: 16px 16px 14px;
	border-radius: 18px;
	background: #fff;
	color: var(--wp--preset--color--ink);
	box-shadow: 0 12px 40px rgb(0 0 0 / .28);
	text-align: center;
}

.cong-kiosk__scan[hidden], .cong-kiosk__scan-item[hidden] { display: none; }
.cong-kiosk__scan-item { width: clamp(180px, 13vw, 250px); }
.cong-kiosk__scan-code svg { display: block; width: 100%; height: auto; }
.cong-kiosk__scan-say { margin: 10px 0 2px; font-family: var(--wp--preset--font-family--display); font-size: clamp(1.05rem, 1.3vw, 1.4rem); font-weight: 700; line-height: 1.15; }
.cong-kiosk__scan-what { margin: 0; font-size: clamp(.8rem, .95vw, 1rem); color: var(--wp--preset--color--ink-muted); }

/* The worship-guide code steps aside while the map is big: the map's own
   code to take a room away sits in that corner. */
html.cong-map-big .cong-kiosk__scan { opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }

/* ---------- One grid for the whole screen ------------------------------ *
 *
 * The pictures keep their 16:9 — a slide is made at that shape, and a band
 * across the top cropped every one of them — and the rest of the glass is
 * shared out around them. Landscape: pictures and today's list on the left,
 * the map the full height on the right. Portrait: pictures across the top,
 * then the list, then the map.
 *
 * The body group steps out of the way (display: contents) so the list and
 * the map are laid out beside the pictures rather than below them.
 * ------------------------------------------------------------------------ */

.cong-kiosk > .wp-block-post-content {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	grid-template-rows: auto auto minmax(0, 1fr);
	grid-template-areas:
		"slides map"
		"note   map"
		"list   map";
}

.cong-kiosk > .wp-block-post-content > .cong-kiosk__slides {
	grid-area: slides;
	block-size: calc(50vw * 9 / 16);
	min-block-size: 0;
}

.cong-kiosk > .wp-block-post-content > .cong-kiosk__note { grid-area: note; }
.cong-kiosk > .wp-block-post-content > .cong-kiosk__body { display: contents; }
.cong-kiosk__body > .cong-day { grid-area: list; min-block-size: 0; }
.cong-kiosk__body > .cong-kiosk__map { grid-area: map; min-block-size: 0; }

@media (orientation: portrait) {
	.cong-kiosk > .wp-block-post-content {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: auto auto minmax(0, 1fr) minmax(0, 1.25fr);
		grid-template-areas: "slides" "note" "list" "map";
	}

	.cong-kiosk > .wp-block-post-content > .cong-kiosk__slides { block-size: calc(100vw * 9 / 16); }
}

/* Somebody touched the map, picked a room, or pressed expand: the map takes
   the whole screen, pictures and all, until it settles back. */
.cong-kiosk__body.is-showing-map > .cong-kiosk__map {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 40;
	border: 0;
}

.cong-kiosk__body.is-showing-map .cong-kiosk__back { position: fixed; z-index: 41; }

/* With the map's code showing, "Back to the list" moves up out of its way:
   a button over the corner of a code can stop a phone reading it. */
html.cong-map-code .cong-kiosk__body.is-showing-map .cong-kiosk__back { bottom: 240px; }
