/* Markdown header sorter — Practical, legible, accessible */

:root {
	--bg-page: #f5f5f5;
	--bg-card: #ffffff;
	--bg-input: #fafafa;
	--text: #1a1a1a;
	--text-muted: #5c5c5c;
	--accent: #2563eb;
	--accent-hover: #1d4ed8;
	--accent-soft: rgba(37, 99, 235, 0.12);
	--border: #e5e5e5;
	--radius: 8px;
	--radius-sm: 6px;
	--shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
	--font-heading: 'Fraunces', Georgia, serif;
	--font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
	--font-mono: 'JetBrains Mono', ui-monospace, monospace;
	--focus-ring: 2px solid var(--accent);
	--focus-offset: 2px;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg-page: #1a1a1a;
		--bg-card: #262626;
		--bg-input: #1f1f1f;
		--text: #f5f5f5;
		--text-muted: #a3a3a3;
		--accent: #60a5fa;
		--accent-hover: #93c5fd;
		--accent-soft: rgba(96, 165, 250, 0.2);
		--border: #404040;
		--shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
		--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4);
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
}

body {
	margin: 0;
	min-height: 100vh;
	font-family: var(--font-body);
	font-size: 1rem;
	line-height: 1.6;
	color: var(--text);
	background: var(--bg-page);
}

/* Skip link for keyboard/screen reader */
.skip-link {
	position: absolute;
	top: -100%;
	left: 0.5rem;
	padding: 0.75rem 1rem;
	background: var(--bg-card);
	color: var(--accent);
	font-weight: 600;
	text-decoration: none;
	border: 2px solid var(--accent);
	border-radius: var(--radius-sm);
	z-index: 100;
}
.skip-link:focus {
	top: 0.5rem;
	outline: none;
	box-shadow: 0 0 0 4px var(--accent-soft);
}

/* Site header */
.site-header {
	padding: 2rem 1.5rem 1.5rem;
	text-align: center;
}

.site-header__inner {
	max-width: 42rem;
	margin: 0 auto;
}

.site-title {
	font-family: var(--font-heading);
	font-size: clamp(1.5rem, 4vw, 2rem);
	font-weight: 600;
	letter-spacing: -0.02em;
	margin: 0 0 0.25rem;
	color: var(--text);
}

.site-tagline {
	font-size: 1rem;
	color: var(--text-muted);
	margin: 0 0 0.5rem;
	line-height: 1.5;
}

.site-intro {
	font-size: 0.9375rem;
	color: var(--text-muted);
	max-width: 42rem;
	margin: 0 auto;
	line-height: 1.6;
}

.site-intro a {
	color: var(--accent);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.site-intro a:hover {
	text-decoration-thickness: 2px;
}

.site-intro a:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
	border-radius: 2px;
}

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

/* Main content */
.main {
	max-width: min(1600px, 94vw);
	margin: 0 auto;
	padding: 0 1.5rem 3rem;
}

/* Tool card */
.tool-card {
	background: var(--bg-card);
	border-radius: var(--radius);
	box-shadow: var(--shadow-card);
	border: 1px solid var(--border);
	padding: 1.5rem;
}

@media (min-width: 768px) {
	.tool-card {
		padding: 2rem;
	}
}

/* Tool bar */
.tool-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1.5rem;
}

.tool-bar__left {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
}

.tool-bar__examples {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem;
}

.tool-bar__examples-label {
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--text-muted);
}

.tool-bar__divider {
	width: 1px;
	height: 1.5rem;
	background: var(--border);
	margin: 0 0.25rem;
	flex-shrink: 0;
}

/* Buttons — min 44px touch target */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	min-width: 44px;
	padding: 0.5rem 1rem;
	font-family: var(--font-body);
	font-size: 0.875rem;
	font-weight: 500;
	border-radius: var(--radius-sm);
	border: 1px solid transparent;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.btn:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
}

.btn--primary {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}

.btn--primary:hover {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
}

.btn--primary:focus-visible {
	outline-color: var(--accent);
}

.btn--example,
.btn--secondary {
	background: var(--bg-input);
	color: var(--text);
	border-color: var(--border);
}

.btn--example:hover,
.btn--secondary:hover {
	background: var(--border);
	border-color: var(--border);
}

.btn--ghost {
	background: transparent;
	color: var(--text-muted);
	border-color: transparent;
}

.btn--ghost:hover {
	background: var(--accent-soft);
	color: var(--accent);
}

/* Editor panes */
.editor-panes {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	margin-bottom: 1rem;
}

@media (max-width: 767px) {
	.editor-panes {
		grid-template-columns: 1fr;
	}
}

.editor-pane {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.editor-pane__label {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--text);
}

.editor-pane textarea {
	width: 100%;
	min-height: 360px;
	padding: 1rem;
	font-family: var(--font-mono);
	font-size: 0.875rem;
	line-height: 1.6;
	color: var(--text);
	background: var(--bg-input);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	resize: vertical;
}

.editor-pane textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor-pane textarea:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
}

.editor-pane textarea::placeholder {
	color: var(--text-muted);
}

.editor-pane--output textarea {
	background: var(--bg-input);
}

/* Stats */
.tool-stats {
	font-size: 0.8125rem;
	color: var(--text-muted);
	text-align: right;
	margin-bottom: 1rem;
}

/* Level form */
.level-form {
	margin-bottom: 1rem;
}

.level-form__fieldset {
	border: none;
	margin: 0;
	padding: 0;
}

.level-form__legend {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--text);
	margin-bottom: 0.5rem;
}

.level-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
}

.radioButton {
	min-height: 44px;
	padding: 0.5rem 0.875rem;
	font-family: var(--font-body);
	font-size: 0.875rem;
	font-weight: 500;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--bg-input);
	color: var(--text-muted);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.radioButton:hover {
	background: var(--border);
	color: var(--text);
}

.radioButton.activeRadioButton {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

.radioButton:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
}

.radioButton.activeRadioButton:focus-visible {
	outline-color: #fff;
}

/* Requirements (collapsible) */
.requirements {
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg-input);
	overflow: hidden;
}

.requirements summary {
	display: block;
	font-size: 0.9375rem;
	font-weight: 600;
	padding: 0.75rem 1rem;
	cursor: pointer;
	list-style: none;
	color: var(--text);
}

.requirements summary::-webkit-details-marker {
	display: none;
}

.requirements summary::after {
	content: ' ▼';
	font-size: 0.75em;
	color: var(--text-muted);
}

.requirements[open] summary::after {
	content: ' ▲';
}

.requirements > *:not(summary) {
	padding: 0 1rem 1rem;
	margin: 0;
	font-size: 0.9375rem;
	line-height: 1.6;
	color: var(--text-muted);
}

.requirements pre {
	margin: 0.5rem 0;
	padding: 1rem;
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-family: var(--font-mono);
	font-size: 0.8125rem;
	line-height: 1.5;
	overflow-x: auto;
}

.requirements code {
	font-family: var(--font-mono);
	font-size: 0.9em;
}

.requirements__easter {
	margin-top: 0.5rem;
	cursor: pointer;
	color: var(--accent);
	text-decoration: underline;
}

/* Before & after */
.before-after {
	padding: 2rem 0;
	border-top: 1px solid var(--border);
}

.section-title {
	font-size: 1.25rem;
	font-weight: 600;
	margin: 0 0 0.5rem;
	color: var(--text);
}

.section-lead {
	font-size: 0.9375rem;
	line-height: 1.6;
	color: var(--text-muted);
	margin: 0 0 1rem;
	max-width: 42rem;
}

.before-after__grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	margin-bottom: 1rem;
}

@media (max-width: 767px) {
	.before-after__grid {
		grid-template-columns: 1fr;
	}
}

.before-after__block {
	background: var(--bg-input);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	overflow: hidden;
}

.before-after__label {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-muted);
	margin: 0;
	padding: 0.5rem 1rem;
	border-bottom: 1px solid var(--border);
}

.before-after__pre {
	margin: 0;
	padding: 1rem;
	font-family: var(--font-mono);
	font-size: 0.8125rem;
	line-height: 1.5;
	overflow-x: auto;
}

.before-after__pre code {
	background: none;
	padding: 0;
}

.before-after__cta {
	margin: 0;
}

.before-after__cta .btn {
	min-width: auto;
}

/* FAQ */
.faq {
	padding: 2rem 0;
	border-top: 1px solid var(--border);
}

.faq__list {
	display: flex;
	flex-direction: column;
	gap: 0;
}

.faq__item {
	border-bottom: 1px solid var(--border);
}

.faq__item:first-of-type {
	border-top: 1px solid var(--border);
}

.faq__q {
	font-size: 1rem;
	font-weight: 600;
	margin: 0;
	padding: 1rem 0 0.25rem;
	color: var(--text);
}

.faq__a {
	margin: 0;
	padding: 0 0 1rem;
}

.faq__a p {
	margin: 0;
	font-size: 0.9375rem;
	line-height: 1.6;
	color: var(--text-muted);
}

.faq__a a {
	color: var(--accent);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.faq__a a:hover {
	text-decoration-thickness: 2px;
}

.faq__a a:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
	border-radius: 2px;
}

.faq__a code {
	background: var(--bg-input);
	padding: 0.2em 0.4em;
	border-radius: 4px;
	font-size: 0.9em;
	border: 1px solid var(--border);
}

/* Footer */
.site-footer {
	padding: 1.5rem;
	border-top: 1px solid var(--border);
	margin-top: 2rem;
	text-align: center;
	font-size: 0.9375rem;
}

.site-footer__links,
.site-footer__projects {
	margin: 0.5rem 0;
}

.site-footer__projects {
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid var(--border);
}

.site-footer__label {
	color: var(--text-muted);
	font-size: 0.875rem;
	margin-right: 0.35rem;
}

.site-footer a {
	color: var(--text-muted);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.site-footer a:hover {
	color: var(--accent);
	text-decoration-thickness: 2px;
}

.site-footer a:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
	border-radius: 2px;
}

.site-footer__sep {
	color: var(--text-muted);
	margin: 0 0.5rem;
}

/* Easter egg — music play button bottom left */
.easter-egg-btn {
	position: fixed;
	bottom: 1rem;
	left: 1rem;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg-card);
	color: var(--text-muted);
	cursor: pointer;
	box-shadow: var(--shadow);
	transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.easter-egg-btn:hover {
	color: var(--accent);
	background: var(--bg-input);
	border-color: var(--accent);
}

.easter-egg-btn:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
}

.easter-egg-btn__icon {
	display: block;
}
