/* QR Forge — self-contained, no dependencies. */

:root {
	--bg: #0f141b;
	--surface: #171f2a;
	--primary: #5b8def;
	--silver: #9aaac4;
	--text: #edf1f7;
	--muted: #a7b2c1;
	--border: #2a3441;
	--danger: #e07a6a;

	--font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	--font-display: "Space Grotesk", "Inter", -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
	margin: 0;
	background:
		radial-gradient(ellipse 90% 55% at 50% -10%, rgba(91, 141, 239, 0.2), transparent 70%),
		var(--bg);
	color: var(--text);
	font-family: var(--font);
	display: grid;
	place-items: start center;
	padding: clamp(1rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem) 3rem;
	overflow-x: hidden;
	color-scheme: dark;
}

.stage {
	width: 100%;
	max-width: 44rem;
}

.head { text-align: center; margin-bottom: clamp(1.5rem, 4vw, 2.5rem); }

h1 {
	font-family: var(--font-display);
	font-size: clamp(1.75rem, 1rem + 4vw, 3rem);
	font-weight: 700;
	letter-spacing: -0.03em;
	margin: 0 0 0.5rem;
}

.lede {
	color: var(--muted);
	margin: 0;
	font-size: clamp(0.9375rem, 0.85rem + 0.4vw, 1.0625rem);
}

/* ---- input panel ---- */

.panel {
	background: rgba(23, 31, 42, 0.7);
	border: 1px solid var(--border);
	border-radius: 16px;
	padding: clamp(1rem, 3vw, 1.5rem);
	margin-bottom: clamp(1.25rem, 3vw, 2rem);
}

.field { display: block; }

.field__label,
.control__label {
	display: block;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--muted);
	margin-bottom: 0.5rem;
}

.field__input {
	width: 100%;
	font-family: var(--font);
	font-size: 1rem;
	line-height: 1.5;
	color: var(--text);
	background: rgba(15, 20, 27, 0.8);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.75rem 0.875rem;
	resize: vertical;
	min-height: 3.5rem;
}

.field__input:focus { border-color: var(--primary); }

.controls { margin-top: 1.25rem; }

.segmented {
	display: inline-flex;
	gap: 2px;
	padding: 3px;
	background: rgba(15, 20, 27, 0.8);
	border: 1px solid var(--border);
	border-radius: 999px;
}

.seg {
	font-family: var(--font-display);
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--muted);
	background: transparent;
	border: 0;
	border-radius: 999px;
	padding: 0.5rem 1.1rem;
	cursor: pointer;
	min-width: 3rem;
}

.seg:hover { color: var(--text); }

.seg[aria-checked="true"] {
	background: var(--primary);
	color: #0b1017;
}

.control__hint {
	margin: 0.625rem 0 0;
	font-size: 0.8125rem;
	color: var(--muted);
	min-height: 1.2em;
}

/* ---- output ---- */

.output { text-align: center; }

.code {
	display: inline-block;
	/*
	   Always white, in both themes. A QR code needs genuine black-on-white
	   contrast to scan reliably off a screen — tinting it to match the page
	   would look nicer and work worse.
	*/
	background: #fff;
	padding: clamp(0.75rem, 2vw, 1rem);
	border-radius: 14px;
	line-height: 0;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.code[hidden] { display: none; }

#canvas {
	width: min(330px, 74vw);
	height: auto;
	/* Keep modules crisp when the canvas is scaled down by CSS. */
	image-rendering: pixelated;
}

.readout {
	margin: 1rem 0 0;
	font-size: 0.8125rem;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.error {
	margin: 1rem auto 0;
	max-width: 32rem;
	color: var(--danger);
	font-size: 0.9375rem;
}

.error[hidden] { display: none; }

.actions { margin-top: 1.5rem; }

.btn {
	font-family: var(--font-display);
	font-size: 1rem;
	font-weight: 600;
	color: #0b1017;
	background: var(--primary);
	border: 0;
	border-radius: 12px;
	padding: 0.85rem 1.75rem;
	cursor: pointer;
}

.btn:hover { background: #7da3f5; }

.btn:disabled {
	background: transparent;
	color: var(--muted);
	border: 1px dashed var(--border);
	cursor: not-allowed;
}

.foot {
	margin-top: clamp(2rem, 6vw, 3.5rem);
	text-align: center;
	color: var(--muted);
	font-size: 0.8125rem;
	opacity: 0.8;
}

.foot p { margin: 0; }

:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
	.btn, .seg { transition: background-color 150ms ease, color 150ms ease; }
}
