/* Play with Luby — lubyai.abrionsolutions.com/play
 *
 * Loaded only on the games page, after lubyai.css, and it inherits every
 * token from it (--ly-green, --ly-card, --ly-container and the rest). Nothing
 * here is used anywhere else on the site, which is why it is a separate file
 * rather than more weight on every other page.
 */

/* The browser's own [hidden] rule is a UA style, so any author rule that sets
   display beats it — and .ly-btn sets display:inline-flex. Without this, the
   "Play again" button is visible before the first round has even started. */
[hidden] { display: none !important; }

/* --- page shell ---------------------------------------------------------- */
.ly-play-hero {
	padding: 56px 0 32px;
	background:
		radial-gradient(900px 340px at 18% -12%, rgba(34, 197, 94, 0.16), transparent 62%),
		radial-gradient(720px 300px at 88% 6%, rgba(14, 165, 233, 0.14), transparent 60%);
}
.ly-play-hero h1 { margin: 10px 0 14px; font-size: clamp(32px, 6vw, 52px); line-height: 1.06; }
.ly-play-lede { max-width: 54ch; font-size: 17px; line-height: 1.65; color: var(--ly-body); }
.ly-play-jump { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* Copy and mascot side by side above 820px; the mascot drops below the copy
   on a phone, where a 150px robot beside a paragraph leaves room for neither. */
.ly-play-hero-inner { display: grid; gap: clamp(20px, 4vw, 40px); align-items: center; }
@media (min-width: 820px) {
	.ly-play-hero-inner { grid-template-columns: 1fr auto; }
}
.ly-play-hero-art { width: clamp(150px, 24vw, 230px); height: auto; justify-self: center; }

/* --- one game ------------------------------------------------------------- */
.ly-game {
	background: var(--ly-card);
	border: 1px solid var(--ly-border);
	border-radius: var(--ly-radius);
	padding: clamp(16px, 3vw, 28px);
}
.ly-game.is-broken { opacity: 0.6; }

.ly-game-head {
	display: flex; flex-wrap: wrap; gap: 16px;
	align-items: flex-start; justify-content: space-between;
	margin-bottom: 18px;
}
.ly-game-head h2 { margin: 0 0 6px; font-size: clamp(22px, 3.4vw, 28px); }
.ly-game-sub { margin: 0; max-width: 56ch; font-size: 14.5px; line-height: 1.6; color: var(--ly-muted); }

/* Scoreboard. A <dl> because each figure genuinely is a term and its value,
   and tabular numerals stop the width jumping as the score ticks up. */
.ly-score { display: flex; gap: 10px; margin: 0; flex: none; }
.ly-score > div {
	min-width: 70px; padding: 8px 12px; text-align: center;
	background: rgba(148, 163, 184, 0.08);
	border: 1px solid var(--ly-border);
	border-radius: 12px;
}
.ly-score dt {
	margin: 0; font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em;
	text-transform: uppercase; color: var(--ly-muted);
}
.ly-score dd {
	margin: 2px 0 0; font-family: var(--ly-head); font-size: 22px; font-weight: 700;
	color: var(--ly-text); font-variant-numeric: tabular-nums;
}

.ly-game-foot {
	display: flex; flex-wrap: wrap; gap: 12px;
	align-items: center; justify-content: space-between; margin-top: 16px;
}
.ly-game-keys { margin: 0; font-size: 13px; color: var(--ly-muted); }
.ly-game-keys strong { color: var(--ly-body); }
.ly-game-keys kbd {
	display: inline-block; padding: 1px 6px; margin: 0 1px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
	background: rgba(148, 163, 184, 0.14); border: 1px solid var(--ly-border-strong);
	border-radius: 5px; color: var(--ly-text);
}

/* The live region carries the running commentary for screen readers. It is
   not clipped to zero size, because a 1px box is what makes some readers skip
   it; it is simply off-screen and still rendered. */
.ly-live {
	position: absolute; width: 1px; height: 1px; margin: -1px;
	padding: 0; overflow: hidden; white-space: nowrap;
	clip: rect(0 0 0 0); clip-path: inset(50%); border: 0;
}

/* --- game 1: Reel Rush ----------------------------------------------------- */
.ly-stage-wrap { position: relative; border-radius: 14px; overflow: hidden; }
.ly-canvas {
	display: block; width: 100%; height: auto;
	background: var(--ly-navy);
	border: 1px solid var(--ly-border);
	border-radius: 14px;
	/* The pointer drag moves Luby; without this the browser would scroll the
	   page instead on a touchscreen. */
	touch-action: none;
	cursor: grab;
}
.ly-canvas:active { cursor: grabbing; }
.ly-canvas:focus-visible { outline: 3px solid var(--ly-green); outline-offset: 2px; }

.ly-overlay {
	position: absolute; inset: 0; display: grid; place-content: center;
	gap: 12px; padding: 24px; text-align: center;
	background: rgba(11, 18, 32, 0.82);
	backdrop-filter: blur(3px);
}
.ly-overlay[hidden] { display: none; }
.ly-overlay-title { margin: 0; font-family: var(--ly-head); font-size: clamp(26px, 5vw, 38px); font-weight: 700; color: var(--ly-text); }
.ly-overlay-text { margin: 0 auto; max-width: 42ch; font-size: 15px; line-height: 1.6; color: var(--ly-body); }
.ly-overlay .ly-btn { justify-self: center; }

/* --- game 2: Luby Says ------------------------------------------------------ */
.ly-pads {
	display: grid; gap: 12px;
	grid-template-columns: repeat(2, 1fr);
	margin-bottom: 18px;
}
@media (min-width: 720px) { .ly-pads { grid-template-columns: repeat(4, 1fr); } }

.ly-pad {
	position: relative; display: grid; gap: 6px; justify-items: center;
	padding: 22px 12px; border-radius: 14px; cursor: pointer;
	border: 2px solid var(--ly-border-strong);
	background: rgba(148, 163, 184, 0.07);
	color: var(--ly-body); font-family: inherit;
	transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.ly-pad:disabled { cursor: default; opacity: 0.72; }
.ly-pad:not(:disabled):hover { transform: translateY(-2px); background: rgba(148, 163, 184, 0.12); }
.ly-pad:focus-visible { outline: 3px solid var(--ly-sky); outline-offset: 2px; }
.ly-pad-icon { font-size: 26px; line-height: 1; }
.ly-pad-name { font-family: var(--ly-head); font-size: 14.5px; font-weight: 600; color: var(--ly-text); }
.ly-pad-key {
	position: absolute; top: 7px; right: 9px;
	font-size: 10.5px; font-weight: 700; color: var(--ly-muted);
}

/* Each pad has its own colour so the sequence is distinguishable without
   relying on position alone — and the lit state changes brightness as well as
   hue, so it still reads for a colour-blind player. */
.ly-pad-1 { --pad: #F59E0B; }
.ly-pad-2 { --pad: #A78BFA; }
.ly-pad-3 { --pad: #0EA5E9; }
.ly-pad-4 { --pad: #22C55E; }
.ly-pad.is-lit {
	background: var(--pad); border-color: var(--pad);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--pad) 28%, transparent);
	transform: translateY(-3px) scale(1.02);
}
.ly-pad.is-lit .ly-pad-name, .ly-pad.is-lit .ly-pad-key { color: #04121f; }
.ly-pad.is-wrong {
	background: #E06C75; border-color: #E06C75;
	animation: ly-shake 0.4s ease;
}
.ly-pad.is-wrong .ly-pad-name, .ly-pad.is-wrong .ly-pad-key { color: #140406; }

@keyframes ly-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-6px); }
	75% { transform: translateX(6px); }
}

.ly-says-bar {
	display: flex; flex-wrap: wrap; gap: 12px;
	align-items: center; justify-content: space-between;
}
.ly-says-status { margin: 0; font-size: 15px; color: var(--ly-body); min-height: 1.5em; }

/* --- game 3: Perfect Post ---------------------------------------------------- */
.ly-timing { display: grid; gap: 10px; }
.ly-timing-bar {
	position: relative; height: 56px; border-radius: 12px; overflow: hidden;
	background: linear-gradient(90deg, #0B1220, #16233c, #0B1220);
	border: 1px solid var(--ly-border-strong);
}
.ly-timing-zone {
	position: absolute; top: 0; bottom: 0;
	background: rgba(34, 197, 94, 0.26);
	border-left: 1px solid rgba(34, 197, 94, 0.55);
	border-right: 1px solid rgba(34, 197, 94, 0.55);
}
.ly-timing-bull {
	position: absolute; top: 0; bottom: 0;
	background: rgba(34, 197, 94, 0.5);
}
.ly-timing-marker {
	position: absolute; top: -3px; bottom: -3px; left: 0; width: 5px;
	margin-left: -2.5px; border-radius: 3px;
	background: #F8FAFC;
	box-shadow: 0 0 12px rgba(248, 250, 252, 0.8);
}
.ly-timing-marker.is-hit { background: #22C55E; box-shadow: 0 0 18px rgba(34, 197, 94, 0.95); }
.ly-timing-marker.is-miss { background: #E06C75; box-shadow: 0 0 18px rgba(224, 108, 117, 0.9); }

.ly-timing-scale {
	display: flex; justify-content: space-between;
	font-size: 11.5px; color: var(--ly-muted);
}
.ly-timing-status { margin: 4px 0 0; font-size: 15px; color: var(--ly-body); min-height: 1.5em; }
.ly-timing .ly-btn { justify-self: start; }

/* --- closing call to action ---------------------------------------------------- */
.ly-play-cta {
	display: flex; flex-wrap: wrap; gap: clamp(18px, 4vw, 40px); align-items: center;
}
.ly-play-cta-art { flex: none; width: clamp(110px, 18vw, 150px); height: auto; }
.ly-play-cta h2 { margin: 0 0 10px; }
.ly-play-cta p { max-width: 58ch; color: var(--ly-body); line-height: 1.65; }
.ly-play-cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }

/* --- reduced motion -------------------------------------------------------------
   Decoration stops; the games do not. The movement in all three IS the game,
   so suppressing it would leave nothing to play. What goes is the idle float,
   the hover lift and the shake — none of which carries any information. */
@media (prefers-reduced-motion: reduce) {
	.ly-play-cta-art { animation: none; }
	.ly-pad { transition: none; }
	.ly-pad:not(:disabled):hover { transform: none; }
	.ly-pad.is-lit { transform: none; }
	.ly-pad.is-wrong { animation: none; }
}

@media (max-width: 560px) {
	.ly-game-head { flex-direction: column; }
	.ly-score { width: 100%; }
	.ly-score > div { flex: 1; min-width: 0; }
	.ly-game-foot { flex-direction: column; align-items: flex-start; }
}
