/**
 * The app shell.
 *
 * Every rule here hangs off `.gks-app`, a class only shell.js adds. Without
 * JavaScript none of this applies and the site is an ordinary set of pages
 * that scroll and reload the usual way.
 */

/*
 * The page itself never scrolls.
 *
 * That is the whole trick behind the address bar staying put: mobile Chrome
 * hides its bar when the DOCUMENT scrolls, which grows the viewport and shifts
 * everything on screen. Give the document nowhere to go and the bar stays,
 * the height stays, and the layout stops moving.
 *
 * The cost is pull-to-refresh, which stops working. On this site that is a
 * gain — pull-to-refresh is a real reload, and a real reload is the one thing
 * that stops the music.
 */
.gks-app,
.gks-app body {
	height: 100%;
	overflow: hidden;
	overscroll-behavior: none;
}

/*
 * The flex column is the theme's own wrapper, not body.
 *
 * A block theme puts everything inside .wp-site-blocks, so that is what has to
 * become the column — styling body instead leaves the wrapper as one tall
 * block and nothing lines up.
 */
.gks-app .gks-shell {
	display: flex;
	flex-direction: column;
	/* Falls back to 100% where dvh is not understood. */
	height: 100dvh;
	max-height: 100%;
}

.gks-app .gks-header {
	flex: none;
	z-index: 3;
}

/* The one thing that scrolls. */
.gks-scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-y: contain;
	/* Room for the player bar, plus the home indicator on a notched phone. */
	scroll-padding-bottom: 6rem;

	/*
	 * NO reserved scrollbar gutter, deliberately.
	 *
	 * `scrollbar-gutter: stable` holds the scrollbar's width open whether or
	 * not there is a scrollbar, and the header and the footer end at the edge
	 * of that held-open strip — so every page short enough not to scroll wore
	 * a band of bare page down its right-hand side.
	 *
	 * It was there to stop the page nudging sideways when a short page is
	 * swapped in for a long one, and that nudge is still real: about seven
	 * pixels, on the navigations where the scrollbar comes or goes. But the
	 * header is inside this box now, so it nudges WITH the page rather than
	 * against it — the whole window shifts together, which is what an ordinary
	 * page does and what nobody notices. A permanent empty strip is noticed.
	 */

	/*
	 * A column, so that a page too short to fill the window can still carry
	 * its footer to the bottom instead of leaving it stranded halfway up.
	 */
	display: flex;
	flex-direction: column;
}

/*
 * Full width each.
 *
 * A column flex container hands its children the horizontal axis, and an auto
 * side margin on one of them absorbs the slack instead of stretching — so the
 * song page, which centres itself that way, shrank to fit its own words and
 * sat in the middle of the window. A definite width leaves the auto margins
 * nothing to absorb until max-width actually bites, which is when centring is
 * wanted and not before.
 */
.gks-scroll > * {
	flex: none;
	width: 100%;
}

/* The page takes up the slack, and the footer rides down on it. */
.gks-scroll > #gks-content { flex: 1 0 auto; }

/*
 * A hairline of feedback while the next page is fetched.
 *
 * Deliberately not a spinner or a blanked screen: the page you are on stays
 * readable and usable, which on a slow connection is far better than an empty
 * box that promises something is coming.
 */
.gks-app.is-loading .gks-scroll { cursor: progress; }

.gks-app.is-loading::after {
	content: "";
	position: fixed;
	inset-block-start: 0;
	inset-inline: 0;
	height: 2px;
	background: var(--gks-accent);
	transform-origin: 0 50%;
	animation: gks-progress 1.4s ease-out forwards;
	z-index: 10;
}

@keyframes gks-progress {
	from { transform: scaleX(0); }
	to   { transform: scaleX(0.9); }
}

@media (prefers-reduced-motion: reduce) {
	.gks-app.is-loading::after { animation: none; transform: scaleX(0.4); }
}

/*
 * Installed to the home screen there is no address bar at all, which is the
 * real app feel. These keep content clear of the notch and the home indicator.
 */
@supports (padding: env(safe-area-inset-bottom)) {
	.gks-app .gks-scroll { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── The player bar ───────────────────────────────────────────────────────
 *
 * Two rows: the rail with its marks, and the controls under it. The rail needs
 * a row of its own because the marks need somewhere to be, and they are the
 * only place on the site where the shape of a recording can be seen.
 *
 * Three sizes hold the whole thing together, and nothing else is invented:
 *
 *   --gks-btn   one circle, every control, no exceptions for rank
 *   --gks-rail  the line
 *   --gks-pip   a mark in it, narrower than the line and never wider
 */

.gks-bar,
.gks-bar--still {
	--gks-btn: 32px;
	--gks-rail: 6px;
	--gks-pip: 4px;
}

/*
 * Pinned, always.
 *
 * WordPress prints this bar at the end of <body>, outside the wrapper the
 * shell turns into its column, so there is no flow for it to sit in and
 * nothing to flex it to the bottom. It holds itself there instead.
 *
 * Moved into a page it stops being pinned -- see .gks-bar.is-docked below.
 */
.gks-bar {
	position: fixed;
	inset-inline: 0;
	inset-block-end: 0;
	z-index: 4;
	background: var(--gks-surface);
	border-top: 1px solid var(--gks-rule);
	padding-bottom: env(safe-area-inset-bottom, 0);
}

.gks-bar[hidden] { display: none; }

/*
 * A handle, not a shape. The bar is moved in and out of the page, and this is
 * the spot it can always be put back into.
 */
.gks-bar-home { flex: none; }

/*
 * The two things that can stand in a song's player slot: the real player,
 * moved in, and the still one that waits there until it is.
 *
 * One shape between them, so that pressing play swaps the one for the other
 * and nothing on the page moves. The still one carries fewer controls, and
 * that costs no height at all -- the row is as tall as one circle whether it
 * holds two of them or eight.
 */
.gks-bar.is-docked,
.gks-bar--still {
	position: static;
	z-index: auto;
	margin-top: var(--wp--preset--spacing--40);
	background: var(--gks-surface);
	border: 1px solid var(--gks-rule);
	border-radius: 7px;
	padding-bottom: 0;
}

.gks-bar--still[hidden] { display: none; }

.gks-bar__inner {
	max-width: calc(var(--wp--style--global--wide-size) + var(--wp--preset--spacing--50) * 2);
	margin: 0 auto;
	/*
	 * Six and four, not nine and seven.
	 *
	 * The bar is 66px in the page: six above and below, a sixteen-pixel rail
	 * row, four between, and one 32px circle. Every pixel of that came out of
	 * the spacing rather than out of the controls, which are the part a thumb
	 * has to hit.
	 */
	padding: 6px var(--wp--preset--spacing--50);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.gks-bar.is-docked .gks-bar__inner,
.gks-bar--still .gks-bar__inner {
	max-width: none;
	padding-inline: 11px;
}

.gks-bar__row {
	display: flex;
	align-items: center;
	gap: 5px;
	min-width: 0;
}

.gks-bar__gap { flex: 1; min-width: 0; }

/* ── One control, and every control is it ──────────────────────────────────
 *
 * Same circle, same size, same weight. Nothing is coloured for being itself --
 * colour reports a state and nothing else, so the play button looks like its
 * neighbours until sound is actually coming out of it.
 */

.gks-b {
	flex: none;
	width: var(--gks-btn);
	height: var(--gks-btn);
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--gks-muted);
	font: inherit;
	font-family: var(--wp--preset--font-family--ibm-plex-sans);
	font-size: var(--wp--preset--font-size--label);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	display: inline-grid;
	place-items: center;
	cursor: pointer;
	position: relative;
}

.gks-b[hidden] { display: none; }
.gks-b:hover { color: var(--gks-accent); background: var(--gks-accent-soft); }
.gks-b.is-on { color: var(--gks-accent); background: var(--gks-accent-soft); }

.gks-b__ico { width: 16px; height: 16px; }

/* The number rides inside the circular arrow rather than beside it. */
.gks-b i {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-size: 0.44rem;
	font-style: normal;
	font-weight: 600;
	letter-spacing: -0.02em;
	color: inherit;
	pointer-events: none;
}

/* The one control carrying text. Same height and the same round ends; it grows
 * only as far as its digits need. */
.gks-b--speed {
	width: auto;
	min-width: var(--gks-btn);
	padding-inline: 7px;
	border-radius: 999px;
}

.gks-b__ico--pause { display: none; }
.gks-bar.is-playing .gks-b__ico--play { display: none; }
.gks-bar.is-playing .gks-b__ico--pause { display: block; }

/* One button, and it shows the place it would move to, not the place it is. */
.gks-b__ico--to-foot { display: none; }
.gks-b.is-docked .gks-b__ico--to-foot { display: block; }
.gks-b.is-docked .gks-b__ico--to-page { display: none; }

/* ── The rail ────────────────────────────────────────────────────────────── */

/* Sixteen: five clear pixels either side of the line, which is enough to
 * catch it without giving the row height away to empty space. */
.gks-rail {
	position: relative;
	height: 16px;
	display: flex;
	align-items: center;
	cursor: pointer;
	touch-action: none;
}

.gks-rail__bed,
.gks-rail__buffer,
.gks-rail__fill {
	position: absolute;
	left: 0;
	height: var(--gks-rail);
	border-radius: 999px;
}

.gks-rail__bed { inset-inline: 0; background: var(--gks-rule); }
.gks-rail__buffer { background: var(--gks-rule-soft); width: 0; }
.gks-rail__fill { background: var(--gks-accent); opacity: 0.85; width: 0; }

.gks-rail__marks { position: absolute; inset-inline: 0; height: var(--gks-rail); }

/*
 * A mark for every moment a block is sung.
 *
 * Narrower than the rail and well short of full strength: this sits directly
 * under the words somebody is trying to read, and a row of bright dots there
 * would be the loudest thing on the page for no good reason.
 */
.gks-rail__mark {
	position: absolute;
	top: 0;
	width: var(--gks-pip);
	height: var(--gks-pip);
	margin-top: calc((var(--gks-rail) - var(--gks-pip)) / 2);
	border-radius: 50%;
	background: var(--gks-stanza);
	opacity: 0.7;
	transform: translateX(-50%);
	pointer-events: none;
}

.gks-rail__mark.is-chorus { background: var(--gks-accent); }

/* Behind the playhead a teal mark on teal fill would vanish, so a mark already
 * passed is punched out of the fill rather than painted onto it. */
.gks-rail__mark.is-past { background: var(--gks-surface); opacity: 0.55; }

/* Where you are: the rail's own thickness, raised above nothing. */
.gks-rail__head {
	position: absolute;
	width: 3px;
	height: var(--gks-rail);
	border-radius: 999px;
	background: var(--gks-ink);
	transform: translateX(-50%);
	pointer-events: none;
}

.gks-rail:focus-visible {
	outline: 2px solid var(--gks-accent);
	outline-offset: 3px;
	border-radius: 4px;
}

/* ── What the bar says ───────────────────────────────────────────────────── */

.gks-bar__title {
	flex: 1;
	min-width: 0;
	color: var(--gks-ink);
	text-decoration: none;
	font-family: var(--wp--preset--font-family--ibm-plex-sans);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
	padding-inline: 4px;
	/* One line: the bar must not change height as songs change. */
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* In the page it sits under the song's own title and does not need to say it
 * again. At the foot it does, because there it may be a different song. */
.gks-bar.is-docked .gks-bar__title,
.gks-bar--still .gks-bar__title { display: none; }

/* And the steps go the other way: room for them in the page, not at the foot. */
.gks-bar:not(.is-docked) .gks-b--step { display: none; }

.gks-bar__time {
	flex: none;
	font-family: var(--wp--preset--font-family--ibm-plex-sans);
	color: var(--gks-faint);
	font-size: var(--wp--preset--font-size--label);
	font-variant-numeric: tabular-nums;
	padding-inline: 5px;
}

.gks-bar__where { color: var(--gks-accent); font-weight: 600; }
.gks-bar__where.is-stanza { color: var(--gks-stanza); }
.gks-bar__where:not(:empty)::before { content: "  "; white-space: pre; }

/* ── The slot on a song page ─────────────────────────────────────────────── */

/*
 * What the slot says when this song IS the one playing but the player has been
 * sent to the foot of the screen. Without it the slot would simply empty, and
 * an empty space reads as something having gone wrong.
 */
.gks-dock__now {
	margin: var(--wp--preset--spacing--40) 0 0;
	font-family: var(--wp--preset--font-family--ibm-plex-sans);
	font-size: var(--wp--preset--font-size--label);
	font-weight: 600;
	letter-spacing: 0.11em;
	text-transform: uppercase;
	color: var(--gks-accent);
}

.gks-dock__note {
	margin: 0.6rem 0 0;
	color: var(--gks-muted);
	font-size: var(--wp--preset--font-size--small);
}

/*
 * A thumb held at arm's length while singing needs more than a mouse does, and
 * the clock is the one thing that can go and still leave you knowing what is
 * happening.
 */
@media (max-width: 34rem) {
	.gks-bar,
	.gks-bar--still { --gks-btn: 36px; }

	.gks-bar__time { display: none; }

	/* Room enough that two 44px reaches do not overlap. */
	.gks-bar__row { gap: 8px; }

	/*
	 * The circle stays 36px and the REACH becomes 44. Growing the button
	 * itself would take the bar past the 66px it was just cut to, and the
	 * thing a thumb needs is the target, not the paint.
	 */
	.gks-b::after {
		content: "";
		position: absolute;
		top: 50%;
		left: 50%;
		width: var(--gks-tap);
		height: var(--gks-tap);
		transform: translate(-50%, -50%);
	}
}

/* ── The song page's play button ───────────────────────────────────── */

.gks-handoff {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: var(--wp--preset--spacing--40) 0;
}

.gks-handoff__play {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	/* 2.75rem tall: a real target for a thumb while standing and singing. */
	min-height: 2.75rem;
	padding: 0 1.1rem;
	border: 1px solid var(--gks-accent);
	border-radius: 999px;
	background: var(--gks-accent-soft);
	color: var(--gks-accent);
	font: inherit;
	cursor: pointer;
}

.gks-handoff__play:hover { background: var(--gks-accent); color: var(--gks-ground); }

.gks-handoff__ico { width: 1em; height: 1em; }
.gks-handoff__ico--pause { display: none; }
.gks-handoff.is-playing .gks-handoff__ico--play { display: none; }
.gks-handoff.is-playing .gks-handoff__ico--pause { display: inline-block; }

.gks-handoff.is-current .gks-handoff__play { background: var(--gks-accent); color: var(--gks-ground); }

.gks-handoff__meta { color: var(--gks-faint); font-size: var(--wp--preset--font-size--label); }
.gks-handoff__len { font-variant-numeric: tabular-nums; }
.gks-handoff__note { margin-inline-start: 0.5rem; }
.gks-handoff__get { color: var(--gks-faint); margin-inline-start: auto; }
.gks-handoff__get:hover { color: var(--gks-accent); }
