/* Four Corners — engine styles (games build spec §C "Four Corners").
 *
 * 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. No `[data-rt-theme]` selector appears in this file on purpose.
 *
 * Times stack: black on white, 1px rules, no radii, no shadows, no fills.
 * Selected tiles invert (the site's button idiom); a solved group becomes a
 * full-width ruled bar with its label in 11px letterspaced caps; a group
 * revealed on a loss gets DASHED rules, lighter words and a "Revealed" tag;
 * a disabled button drops its fill for a dashed muted outline. Every state
 * therefore differs in shape or words, never by colour alone.
 *
 * The stage is content-sized: the page opens at the top with the puzzle
 * live (no Play step, no 100svh stage).
 */

.rtg--corners .rtg-stage {
	padding: .5rem 0;
}

.rtc-corners {
	display: flex;
	flex-direction: column;
	gap: .6rem;
}

@media (min-width: 641px) {
	.rtc-corners {
		max-width: 34em;
		margin: 0 auto;
	}
}
/* Owner, 2026-09-21 "rethink": more room once the column widened past the
   760px prose measure — the tile grid (and its cqi-sized words) scales up
   with it via the existing fitTiles() formula below. */
@media (min-width: 1024px) {
	.rtc-corners {
		max-width: 40em;
	}
}

/* -- groups: full-width ruled bars, difficulty order ----------------------- */

.rtc-bars {
	display: flex;
	flex-direction: column;
	gap: .4rem;
}
.rtc-bars:empty {
	display: none;
}

.rtc-bar {
	border-bottom: 1px solid var(--wp--preset--color--contrast);
	padding: .4rem .1rem;
}
.rtc-bar:first-child {
	border-top: 1px solid var(--wp--preset--color--contrast);
}
.rtc-bar-label {
	margin: 0 0 .2rem;
	display: flex;
	justify-content: space-between;
	gap: .5rem;
}
.rtc-bar-tag {
	flex: 0 0 auto;
}
.rtc-bar-words {
	margin: 0;
	font-weight: 600;
	font-size: 1.0625rem;
}

/* Revealed on a loss: dashed rules, regular-weight muted words, and the
 * "Revealed" tag in words (corners.js). */
.rtc-bar.is-revealed {
	border-bottom: 1px dashed var(--wp--preset--color--muted);
}
.rtc-bar.is-revealed:first-child {
	border-top: 1px dashed var(--wp--preset--color--muted);
}
.rtc-bar.is-revealed .rtc-bar-words {
	font-weight: 400;
	color: var(--wp--preset--color--muted);
}
.rtc-bar.is-revealed .rtc-bar-tag {
	text-decoration: underline dashed;
	text-underline-offset: .2em;
}

/* -- mistakes ------------------------------------------------------------- */

.rtc-head {
	display: flex;
	justify-content: flex-end;
}
.rtc-mistakes {
	margin: 0;
	color: var(--wp--preset--color--muted);
}
.rtc-dot {
	color: var(--wp--preset--color--contrast);
	letter-spacing: .1em;
}
.rtc-dot.is-used {
	color: var(--wp--preset--color--muted);
}
.rtc-corners.is-finished .rtc-head {
	justify-content: flex-start;
}
.rtc-corners.is-finished .rtc-mistakes {
	color: var(--wp--preset--color--contrast);
}

/* -- tile grid ------------------------------------------------------------ */

.rtc-grid {
	flex: 0 0 auto;
	min-height: 0;
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: .5rem;
	align-content: center;
}
.rtc-grid[hidden] {
	display: none;
}

.rtc-tile {
	font: inherit;
	font-weight: 700;
	font-size: .8rem;
	line-height: 1.15;
	letter-spacing: .01em;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	border: 1px solid var(--wp--preset--color--contrast);
	border-radius: 0;
	padding: .35rem .25rem;
	min-height: 64px;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	cursor: pointer;
	container-type: inline-size;
	touch-action: manipulation;
	/* the WebKit tap flash tinted a just-tapped tile (teal in Terminal),
	 * muddying the inverted state */
	-webkit-tap-highlight-color: transparent;
}
/* A word wraps only at its spaces, never mid-word: the text shrinks until
 * the tile's longest single word fits the tile (--rtc-len is set per tile by
 * corners.js; ~0.68em per bold Times capital, 0.8rem at most — PADDLEFISH
 * sets at ~10px in a 390px phone's tile). A word of unusually wide letters
 * is caught by corners.js's fitTiles(), which raises its --rtc-len. */
.rtc-tile-t {
	display: block;
	width: 100%;
	font-size: min(.9rem, calc(100cqi / (var(--rtc-len, 8) * .68)));
	overflow-wrap: normal;
	word-break: normal;
	hyphens: none;
}
/* 10+ letter words (CHAMBOURCIN, PADDLEFISH): tighter tracking and side
 * padding keep them at a legible size (≥ 9px) on a 390px phone. */
.rtc-tile[data-long] {
	padding-inline: 2px;
	letter-spacing: -.03em;
}
.rtc-tile:focus-visible {
	background: var(--wp--preset--color--light);
}
@media (hover: hover) {
	.rtc-tile:hover {
		background: var(--wp--preset--color--light);
	}
}
/* Selected: inverted (the site idiom); aria-pressed carries it for AT. */
.rtc-tile.is-selected,
.rtc-tile.is-selected:focus-visible,
.rtc-grid .rtc-tile.is-selected:hover {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* -- feedback line ---------------------------------------------------------
 * Visible AND duplicated to the shared aria-live region (api.announce). */

.rtc-msg {
	min-height: 1.3em;
	margin: 0;
	font-weight: 600;
	text-align: center;
}
.rtc-corners.is-finished .rtc-msg {
	text-align: left;
	font-weight: 400;
}

/* -- controls: Shuffle · Deselect all · Submit ----------------------------- */

.rtc-controls {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
}
.rtc-controls[hidden] {
	display: none;
}

.rtc-btn {
	flex: 1 1 auto;
	font-size: 15px;
	letter-spacing: .04em;
	text-transform: uppercase;
	font-weight: 600;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	border: 1px solid var(--wp--preset--color--contrast);
	border-radius: 0;
	padding: .6rem .75rem;
	min-height: 44px;
	min-width: 44px;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
.rtc-btn:hover:not(:disabled),
.rtc-btn:focus-visible {
	background: var(--wp--preset--color--light);
}
.rtc-btn-primary {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}
.rtc-btn-primary:hover:not(:disabled),
.rtc-btn-primary:focus-visible {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}
/* Disabled: no fill, muted dashed outline — reads as unavailable by shape,
 * not only by a dimmer colour (Terminal's green-on-black included). */
.rtc-btn:disabled,
.rtc-btn-primary:disabled {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--muted);
	border: 1px dashed var(--wp--preset--color--muted);
	cursor: default;
}

@media (prefers-reduced-motion: reduce) {
	.rtc-tile,
	.rtc-btn {
		transition: none;
	}
}

/* The page template's `.wp-block-post-content p { margin-bottom: 1.4em }`
 * outranks this sheet's single-class rules. Restate each paragraph's own
 * bottom margin at a specificity that wins. */
.rtg p.rtc-bar-words,
.rtg p.rtc-mistakes,
.rtg p.rtc-msg {
	margin-bottom: 0;
}
.rtg p.rtc-bar-label {
	margin-bottom: .2rem;
}
