/*
 * Runtime chrome for the game — the HUD, gear/hint icons, start/solved/settings/instructions cards,
 * buttons and the wordmark. Loaded by play.html (like theme.css); the DOM these style is created by
 * src/runtime/mount.ts.
 *
 * The per-palette colours are NOT here: mount.ts sets `--shp-*` custom properties on the container at
 * runtime (see applyPopupTheme) so the cards follow the active board palette. Every var() below keeps a
 * literal fallback, so the chrome still renders if those runtime vars (or the theme.css font tokens)
 * are ever absent.
 */

/* ── HUD (level · moves/par · timer), pinned across the top ───────────────── */
.shp-hud {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 8;
	display: flex;
	gap: 16px;
	justify-content: center;
	padding: calc(10px + env(safe-area-inset-top, 0px))
		calc(10px + env(safe-area-inset-right, 0px)) 10px
		calc(10px + env(safe-area-inset-left, 0px));
	font: 13px/1.4 var(--font-mono, ui-monospace, Menlo, monospace);
	color: #dfe7f5;
	pointer-events: none;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.shp-stat {
	opacity: 0.92;
}

/* ── Corner icons (gear top-left, hint top-right) ─────────────────────────── */
/* They hug the top edge (they used to be pushed down to clear a fullscreen header that no longer
   exists); safe-area keeps them clear of a notch, and the standalone clamp at the bottom guards the PWA. */
.shp-gear {
	position: fixed;
	top: calc(12px + env(safe-area-inset-top, 0px));
	left: calc(12px + env(safe-area-inset-left, 0px));
	z-index: 8;
}
.shp-hint {
	position: fixed;
	top: calc(12px + env(safe-area-inset-top, 0px));
	right: calc(12px + env(safe-area-inset-right, 0px));
	z-index: 8;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.shp-btn {
	min-width: 48px;
	min-height: 48px;
	padding: 0 16px;
	border-radius: 14px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	letter-spacing: 0.2px;
	font: 600 15px/1 var(--font-display, system-ui, sans-serif);
	color: #eef2fb;
	background: rgba(40, 48, 66, 0.82);
	border: 1px solid rgba(130, 150, 200, 0.28);
	backdrop-filter: blur(6px);
	transition:
		background 0.18s,
		box-shadow 0.16s,
		transform 0.12s,
		filter 0.16s;
}
.shp-btn:hover {
	background: rgba(56, 66, 90, 0.92);
}
.shp-btn:active {
	transform: translateY(1px);
}
.shp-btn svg {
	display: block;
}
.shp-icon {
	padding: 0;
}

/* Primary CTA: borrows the landing's form — top-lit gradient, inset highlight, a coloured glow — but
   its colour still comes from the active palette (--shp-accent), so cards keep their per-palette look. */
.shp-primary {
	min-width: 150px;
	min-height: 52px;
	padding: 0 24px;
	font-weight: 600;
	letter-spacing: 0.3px;
	color: var(--shp-accent-fg, #fff);
	border-color: transparent;
	background: linear-gradient(
		180deg,
		color-mix(in srgb, var(--shp-accent, #5a82d2), #fff 16%),
		var(--shp-accent, #5a82d2)
	);
	box-shadow:
		0 12px 30px -10px
			color-mix(in srgb, var(--shp-accent, #5a82d2) 55%, transparent),
		inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.shp-primary:hover {
	filter: brightness(1.05);
	transform: translateY(-1px);
	background: linear-gradient(
		180deg,
		color-mix(in srgb, var(--shp-accent, #5a82d2), #fff 16%),
		var(--shp-accent, #5a82d2)
	);
	box-shadow:
		0 16px 38px -10px
			color-mix(in srgb, var(--shp-accent, #5a82d2) 70%, transparent),
		inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.shp-primary:active {
	transform: translateY(1px);
	filter: brightness(0.98);
}

/* Secondary CTA under Play: shown only when there's saved progress to resume. */
.shp-continue {
	display: block;
	min-width: 150px;
	margin: 12px auto 0;
}

/* Low-emphasis link (e.g. "How to play"): a bare text button, no fill/border. */
.shp-subtle {
	display: block;
	min-height: 40px;
	min-width: 0;
	margin: 14px auto 0;
	padding: 0;
	background: none;
	border: none;
	backdrop-filter: none;
	font-weight: 500;
	opacity: 0.7;
	color: var(--shp-card-fg, #eaf0fb);
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
}
.shp-subtle:hover {
	background: none;
	opacity: 1;
}
.shp-subtle:active {
	transform: none;
}

/* ── Settings form ────────────────────────────────────────────────────────── */
.shp-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin: 6px 0 20px;
	text-align: left;
}
.shp-field {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	font: 14px/1.4 var(--font-body, system-ui, sans-serif);
	cursor: pointer;
}
.shp-field-label {
	opacity: 0.9;
}
.shp-select {
	min-width: 150px;
	padding: 8px 10px;
	border-radius: 10px;
	color: inherit;
	background: rgba(0, 0, 0, 0.28);
	border: 1px solid var(--shp-card-border, rgba(130, 150, 200, 0.3));
	font: 14px/1 var(--font-body, system-ui, sans-serif);
}
.shp-check {
	width: 20px;
	height: 20px;
	accent-color: var(--shp-accent, #5a82d2);
	cursor: pointer;
}

/* ── Overlay + card (start / solved / settings / instructions) ────────────── */
/* The overlay's own padding guarantees a gutter so the card never kisses the screen edges. */
.shp-overlay {
	position: fixed;
	inset: 0;
	z-index: 9;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: var(--shp-overlay-bg, rgba(8, 11, 18, 0.6));
	backdrop-filter: blur(var(--shp-overlay-blur, 3px));
	-webkit-backdrop-filter: blur(var(--shp-overlay-blur, 3px));
}
.shp-card {
	width: min(360px, 100%);
	text-align: center;
	padding: 30px 28px;
	border-radius: var(--shp-card-radius, 18px);
	background: var(--shp-card-bg, rgba(24, 29, 40, 0.96));
	border: 1px solid var(--shp-card-border, rgba(130, 150, 200, 0.22));
	color: var(--shp-card-fg, #eaf0fb);
	box-shadow: var(--shp-card-shadow, 0 20px 60px rgba(0, 0, 0, 0.45));
}
.shp-title {
	margin: 0 0 10px;
	font: 600 28px/1.1 var(--font-display, system-ui, sans-serif);
	letter-spacing: 0.2px;
}
.shp-sub {
	margin: 0 0 18px;
	font: 14px/1.5 var(--font-body, system-ui, sans-serif);
	opacity: 0.82;
}
.shp-best {
	margin: 0 0 16px;
	font: 13px/1.45 var(--font-body, system-ui, sans-serif);
	opacity: 0.72;
}
.shp-stars {
	display: flex;
	justify-content: center;
	gap: 6px;
	color: var(--shp-star, #ffd873);
	margin-bottom: 10px;
}

/* ── Wordmark: faint bottom watermark so screenshots stay attributable ────── */
.shp-wordmark {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	z-index: 7;
	pointer-events: none;
	bottom: calc(6px + env(safe-area-inset-bottom, 0px));
	font: 600 12px/1 var(--font-display, system-ui, sans-serif);
	letter-spacing: 1.5px;
	color: #dfe7f5;
	opacity: 0.36;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

/* ── Installed PWA ────────────────────────────────────────────────────────── */
/* The OS status bar overlays the content, but env(safe-area-inset-top) can report 0 (non-notched iOS,
   black-translucent), which would hide the top-anchored HUD/icons under the clock. Enforce a minimum
   top clearance so they stay readable + reachable. */
@media (display-mode: standalone), (display-mode: fullscreen) {
	.shp-gear,
	.shp-hint {
		top: max(env(safe-area-inset-top, 0px), 28px);
	}
	.shp-hud {
		padding-top: calc(6px + max(env(safe-area-inset-top, 0px), 28px));
	}
}
