/* Comics & Games — shared shell chrome for the four new games (Mini, Weekly
 * Quiz, Four Corners, Letterpress). Enqueued once per page by
 * RTG_Shell::render(); each game's own sheet (mini.css, quiz.css, …) is
 * loaded AFTER this one as a dependency, so it may override anything here.
 *
 * TOKENS ONLY. Every colour is var(--wp--preset--color--*) so Terminal's
 * token re-declaration and Rainbow's inheritance both work with zero edits
 * here (see modules/themes/assets/terminal.css, rainbow.css). No
 * `[data-rt-theme]` selector appears in this file on purpose.
 *
 * Times stack: black on white, 1px rules, no radii, no shadows, no fills.
 * The active/selected state INVERTS — the site's button idiom — and labels
 * are 11px letterspaced caps.
 */

.rtg {
	/* Type scale (owner, 2026-09-21 "rethink"): small-caps labels 13px, up to
	   14px on tablet/desktop; everything else that reads as UI chrome (button
	   labels, meta, timers) gets its own larger size below — --rtg-label is
	   for `.lab` only. */
	--rtg-label: 13px;
	color: var(--wp--preset--color--contrast);
	max-width: 100%;
}
@media (min-width: 768px) {
	.rtg { --rtg-label: 14px; }
}

.rtg .lab {
	font-size: var(--rtg-label);
	letter-spacing: .08em;
	text-transform: uppercase;
	font-weight: 600;
}

/* -- header: title · week · timer · Help -------------------------------- */

.rtg-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: .5rem 1rem;
	border-bottom: 1px solid var(--wp--preset--color--contrast);
	padding-bottom: .5rem;
	margin: 0 0 .75rem;
}

.rtg-title {
	/* Owner, 2026-09-21: this is now the ONE visible title on the page (the
	   real WP post title is hidden below, screen-reader/SEO only, so the
	   games never show a small kicker flag AND this bold heading together).
	   Bold masthead scale, matching The Crossing: 32px on a phone up to 48px
	   on desktop. */
	margin: 0 0 .2rem;
	font-family: var(--wp--preset--font-family--serif, serif);
	font-size: clamp(2rem, 1.5rem + 3vw, 3rem);
	font-weight: 700;
	line-height: 1.05;
}

.rtg-meta,
.rtg p.rtg-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .35rem 1rem;
	margin: 0;
	font-size: 15px;
}
@media (min-width: 768px) {
	.rtg-meta, .rtg p.rtg-meta { font-size: 16px; }
}

.rtg-week,
.rtg-cadence,
.rtg-timer {
	color: var(--wp--preset--color--muted);
}

.rtg-help-btn {
	font-size: 15px;
	letter-spacing: .04em;
	text-transform: uppercase;
	font-weight: 600;
	background: none;
	border: 1px solid var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--contrast);
	padding: .3rem .6rem;
	cursor: pointer;
	border-radius: 0;
	min-height: 44px;
	min-width: 44px;
}
@media (min-width: 768px) {
	.rtg-help-btn { font-size: 16px; }
}
.rtg-help-btn:hover,
.rtg-help-btn:focus-visible {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* -- "from the case" ------------------------------------------------------ */

.rt-game-case[hidden] {
	display: none;
}
.rt-game-case,
.rtg p.rt-game-case {
	margin: 0 0 .75rem;
	font-size: 13px;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--wp--preset--color--muted);
}
@media (min-width: 768px) {
	.rt-game-case, .rtg p.rt-game-case { font-size: 14px; }
}

/* -- how to play: always visible, server-rendered, above the puzzle ------
   Owner, 2026-09-21 ("rethink"): 17-18px on a phone, 19-20px from tablet up,
   at every width — this is the instructions text the owner first flagged as
   too small. */

.rtg-howto {
	margin: 0 0 .75rem;
	font-size: 18px;
	line-height: 1.5;
	max-width: 46em;
}
.rtg .rtg-howto p {
	margin: 0 0 .35rem;
}
.rtg-noscript,
.rtg p.rtg-noscript,
.rtg p.rtg-status {
	margin: 0 0 1rem;
	font-style: italic;
	font-size: 15px;
}
.rtg-status[hidden] {
	display: none;
}

@media (min-width: 768px) {
	.rtg-howto {
		font-size: 20px;
		line-height: 1.5;
	}
}

/* -- the stage --------------------------------------------------------------
 * The puzzle is live on load (no Play gate, no scrollIntoView): the page
 * opens at the top and the stage sits directly under the how-to lines. */

.rtg-stage[hidden] {
	display: none;
}
.rtg-stage {
	position: relative;
}

@media (max-width: 640px) {
	.rtg-stage {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
	}
}

/* -- no layout shift on load ------------------------------------------------
 * The stage is server-rendered empty and filled by the engine on
 * DOMContentLoaded. Until then it reserves roughly its first-screen height
 * (measured 2026-09-21 at 360–1280px, each value at or just under the real
 * one), so nothing below it jumps (Lighthouse CLS was 0.33 on /games/mini/).
 * `:empty` only, so a shorter finished view never leaves a gap. */
.rtg--mini .rtg-stage:empty { min-height: 490px; }
.rtg--quiz .rtg-stage:empty { min-height: 390px; }
.rtg--corners .rtg-stage:empty { min-height: 400px; }
.rtg--letterpress .rtg-stage:empty { min-height: 360px; }
@media (max-width: 640px) {
	.rtg--mini .rtg-stage:empty { min-height: calc(100vw + 226px); }
	.rtg--quiz .rtg-stage:empty { min-height: 415px; }
}

/* -- a game that IS the page: keep the puzzle on the first phone screen ------
 * Owner, 2026-09-21 (title unification): flipped from the old rule here.
 * The page's own WP post title (the small-caps "flag") is now the element
 * hidden for readers — screen-reader/SEO only, see games.css — and this
 * shell's .rtg-title above is the one bold heading a reader actually sees,
 * so the page never shows two titles in two styles at once. On phones the
 * page's top padding still shrinks a little so the puzzle starts higher
 * (the page loads at the top with the puzzle live; there is no
 * Play/scrollIntoView step). */
@media (max-width: 640px) {
	body:has(.wp-block-post-content > .rtg:first-child) #rt-main {
		padding-top: var(--wp--preset--spacing--30, 1rem) !important;
	}
	.wp-block-post-title:has(+ .wp-block-post-content > .rtg:first-child) {
		margin-bottom: .5rem;
	}
	.wp-block-post-title + .wp-block-post-content:has(> .rtg:first-child) {
		margin-block-start: .5rem;
	}
	.rtg-head {
		margin-bottom: .5rem;
		padding-bottom: .35rem;
	}
}

/* -- the site's floating companion launcher ---------------------------------
 * .rt-oak-launch (modules/companion-oak) is fixed to the bottom-right of the
 * viewport. The puzzle now scrolls with the page (no Play step), so on a
 * phone some control — a key, Submit, Enter, I'm done — always passes under
 * it. While a puzzle is live on a phone the launcher steps aside; it returns
 * with the result card and on every other page. */
@media (max-width: 640px) {
	body:has(.rtg .rtg-stage:not([hidden]):not([data-rtg-finished])) .rt-oak-launch {
		display: none;
	}
}

/* -- done card --------------------------------------------------------------- */

.rtg-done[hidden] {
	display: none;
}
.rtg-done {
	border-top: 1px solid var(--wp--preset--color--contrast);
	padding-top: 1rem;
	margin-top: 1rem;
}
.rtg-done-result,
.rtg p.rtg-done-result {
	font-family: var(--wp--preset--font-family--serif, serif);
	font-size: 1.25rem;
	margin: 0 0 .75rem;
}
.rtg-share {
	font-size: 15px;
	letter-spacing: .04em;
	text-transform: uppercase;
	font-weight: 600;
	background: none;
	border: 1px solid var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--contrast);
	padding: .5rem 1rem;
	min-height: 44px;
	cursor: pointer;
	border-radius: 0;
}
.rtg-share:hover,
.rtg-share:focus-visible {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* -- archive: "Past weeks" ----------------------------------------------------- */

.rtg-arch {
	margin-top: 1.5rem;
	border-top: 1px solid var(--wp--preset--color--border, #bbb);
	padding-top: .75rem;
}
.rtg-arch summary {
	cursor: pointer;
}
.rtg-arch-list {
	list-style: none;
	margin: .75rem 0 0;
	padding: 0;
}
.rtg-arch-list li {
	border-bottom: 1px solid var(--wp--preset--color--border, #bbb);
	padding: .4rem 0;
}
.rtg-arch-list a {
	color: var(--wp--preset--color--clay-dark);
	text-decoration: underline;
}
.rtg-arch-list [aria-current] {
	font-weight: 700;
}

/* -- help dialog --------------------------------------------------------------- */

.rtg-help {
	border: 1px solid var(--wp--preset--color--contrast);
	border-radius: 0;
	padding: 1.25rem;
	max-width: 32em;
	width: min(90vw, 32em);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}
.rtg-help::backdrop {
	background: rgba(0, 0, 0, .4);
}
.rtg-help form {
	margin-top: 1rem;
	text-align: right;
}
.rtg-help button[type="submit"] {
	font-size: 15px;
	letter-spacing: .04em;
	text-transform: uppercase;
	font-weight: 600;
	background: none;
	border: 1px solid var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--contrast);
	padding: .5rem 1rem;
	min-height: 44px;
	cursor: pointer;
	border-radius: 0;
}

/* -- live region: visually hidden, still announced ----------------------------- */

.rtg-live {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* -- focus ring, all games ------------------------------------------------------ */

.rtg :focus-visible {
	outline: 2px solid var(--wp--preset--color--clay-dark);
	outline-offset: 2px;
}

/* -- reduced motion --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.rtg * {
		transition: none !important;
		animation: none !important;
	}
}
