/* ============================================================
   S.P.A.R.K. official theme — "Gunmetal Fire"
   Adapted from the behavior-compass Gunmetal instrument theme:
   dark-grey machined field, near-black frame, soft off-white text
   (deliberately NOT pure white — softer halation for astigmatism),
   glow off by default. Red swapped for FIRE ORANGE to match the
   SPARK black-and-fire logo. Dark is the brand default; light mode
   is a warm-paper gunmetal-light. Per-belt identity rides on the
   hero title color (--belt) with a soft glow.
   ============================================================ */

:root,
:root[data-theme="dark"] {
	color-scheme: dark;
	--bg: #1c2024;
	--bg-deep: #16191d;
	--frame: #0e1218; /* near-black machined frame */
	--surface: #262b30;
	--surface-2: #2f353c;
	--face: #15191f; /* recessed smoked-glass inset */
	--ink: #ece8e2; /* soft off-white body */
	--ink-strong: #f3efe9; /* titles */
	--muted: #9aa1a9;
	--line: rgba(200, 210, 222, 0.16);
	--line-2: rgba(200, 210, 222, 0.3);
	--fire: #ff6a1a; /* SPARK fire accent */
	--fire-bright: #ff8a3d;
	--fire-deep: #e8531a;
	--fire-soft: rgba(255, 106, 26, 0.14);
	--fire-line: rgba(255, 106, 26, 0.42);
	--belt: #94a3b8; /* overridden per page via inline --belt */
	--belt-title: var(--belt);
	--belt-glow: 0 0 24px color-mix(in srgb, var(--belt) 40%, transparent);
	--shadow: 0 14px 36px rgba(0, 0, 0, 0.4);
	--maxw: 720px;
}

:root[data-theme="light"] {
	color-scheme: light;
	--bg: #f3f1ea; /* warm paper, not pure white */
	--bg-deep: #eae7df;
	--frame: #d3cec1;
	--surface: #fbfaf5;
	--surface-2: #f1eee6;
	--face: #f6f4ee;
	--ink: #23282e; /* soft dark, not pure black */
	--ink-strong: #14171a;
	--muted: #5a616a;
	--line: rgba(28, 36, 46, 0.14);
	--line-2: rgba(28, 36, 46, 0.26);
	--fire: #d9531a; /* deepened for AA contrast on light */
	--fire-bright: #e8531a;
	--fire-deep: #bf4715;
	--fire-soft: rgba(217, 83, 26, 0.1);
	--fire-line: rgba(217, 83, 26, 0.34);
	/* pull light-belt hues toward ink so the title stays legible on paper */
	--belt-title: color-mix(in srgb, var(--belt) 72%, var(--ink-strong));
	--belt-glow: 0 0 18px color-mix(in srgb, var(--belt) 22%, transparent);
	--shadow: 0 12px 30px rgba(28, 32, 38, 0.12);
}

* {
	box-sizing: border-box;
}
html {
	scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family:
		"Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
		sans-serif;
	font-size: 19px;
	line-height: 1.75; /* generous leading helps astigmatism */
	letter-spacing: 0.003em;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	transition:
		background 0.25s ease,
		color 0.25s ease;
}
@media (prefers-reduced-motion: reduce) {
	body {
		transition: none;
	}
}

/* reading progress */
.progress {
	position: fixed;
	inset: 0 0 auto 0;
	height: 3px;
	z-index: 50;
	background: transparent;
}
.progress > i {
	display: block;
	height: 100%;
	width: 0;
	background: linear-gradient(
		90deg,
		var(--fire-deep),
		var(--fire),
		var(--fire-bright)
	);
	transition: width 0.12s linear;
}
@media (prefers-reduced-motion: reduce) {
	.progress > i {
		transition: none;
	}
}

/* top bar */
.topbar {
	position: sticky;
	top: 0;
	z-index: 40;
	background: color-mix(in srgb, var(--bg) 86%, transparent);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--line);
}
.topbar-in {
	max-width: var(--maxw);
	margin: 0 auto;
	padding: 12px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}
.brand {
	font-family: "Exo", sans-serif;
	font-weight: 800;
	letter-spacing: 0.16em;
	font-size: 14px;
	color: var(--ink-strong);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
.brand .ember {
	width: 9px;
	height: 9px;
	border-radius: 2px;
	background: linear-gradient(135deg, var(--fire-bright), var(--fire-deep));
	box-shadow: 0 0 10px var(--fire-line);
}
.brand span {
	color: var(--muted);
	font-weight: 600;
}
.bar-right {
	display: flex;
	align-items: center;
	gap: 6px;
}
.back {
	font-family: "Roboto Mono", monospace;
	font-size: 12.5px;
	font-weight: 500;
	color: var(--muted);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-radius: 8px;
}
.back:hover {
	background: var(--fire-soft);
	color: var(--fire);
}
.back:focus-visible {
	outline: 3px solid var(--fire-line);
	outline-offset: 2px;
}

/* theme toggle */
.theme-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 9px;
	cursor: pointer;
	background: var(--surface);
	border: 1px solid var(--line-2);
	color: var(--ink);
	transition:
		background 0.15s ease,
		border-color 0.15s ease;
}
.theme-toggle:hover {
	border-color: var(--fire-line);
	color: var(--fire);
}
.theme-toggle:focus-visible {
	outline: 3px solid var(--fire-line);
	outline-offset: 2px;
}
.theme-toggle svg {
	width: 17px;
	height: 17px;
}
.theme-toggle .i-sun {
	display: none;
}
.theme-toggle .i-moon {
	display: block;
}
:root[data-theme="light"] .theme-toggle .i-sun {
	display: block;
}
:root[data-theme="light"] .theme-toggle .i-moon {
	display: none;
}

.wrap {
	max-width: var(--maxw);
	margin: 0 auto;
	padding: 0 24px 120px;
}

/* hero */
header.hero {
	padding: 54px 0 26px;
	border-bottom: 1px solid var(--line);
}
.eyebrow {
	font-family: "Roboto Mono", monospace;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--belt-title);
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 16px;
}
.eyebrow .dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--belt);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--belt) 22%, transparent);
}
header.hero h1 {
	font-family: "Exo", sans-serif;
	font-weight: 800;
	font-size: clamp(33px, 6vw, 46px);
	line-height: 1.08;
	letter-spacing: -0.015em;
	margin: 0 0 16px;
	color: var(--belt-title);
	text-shadow: var(--belt-glow);
}
.lead {
	font-size: 21px;
	line-height: 1.55;
	color: var(--muted);
	margin: 0;
	max-width: 60ch;
}

/* article body */
article {
	padding: 14px 0 0;
}
.lesson-intro {
	font-size: 20px;
	color: var(--ink);
	margin: 30px 0 8px;
}
.lesson-intro p:first-child::first-letter {
	font-family: "Exo", sans-serif;
	font-weight: 800;
	font-size: 3.1em;
	line-height: 0.8;
	float: left;
	margin: 6px 12px 0 0;
	color: var(--fire);
	text-shadow: 0 0 18px var(--fire-line);
}
.lesson-section {
	margin: 34px 0;
}
.lesson-section h2 {
	font-family: "Exo", sans-serif;
	font-weight: 700;
	font-size: 25px;
	letter-spacing: -0.01em;
	margin: 0 0 12px;
	padding-left: 16px;
	border-left: 4px solid var(--fire);
	color: var(--ink-strong);
}
.lesson-section p {
	margin: 0 0 16px;
}
.lesson-section ul {
	margin: 0 0 16px;
	padding-left: 22px;
}
.lesson-section li {
	margin: 7px 0;
}
.lesson-section li::marker {
	color: var(--fire);
}
article strong {
	color: var(--fire);
	font-weight: 700;
}
:root[data-theme="light"] article strong {
	color: var(--fire-deep);
}
article em {
	color: var(--ink-strong);
}

/* takeaways panel */
.lesson-section.takeaways {
	background: var(--surface);
	border: 1px solid var(--line);
	border-left: 5px solid var(--fire);
	border-radius: 14px;
	padding: 22px 26px;
	margin-top: 40px;
	box-shadow: var(--shadow);
}
.lesson-section.takeaways h2 {
	border: 0;
	padding: 0;
	font-size: 16px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--fire);
}
.lesson-section.takeaways ul {
	padding-left: 20px;
	margin-bottom: 0;
}
.lesson-section.takeaways li {
	margin: 9px 0;
	font-weight: 500;
}

/* field drill callout */
.lesson-section.drill {
	background: var(--fire-soft);
	border: 1px solid var(--fire-line);
	border-radius: 14px;
	padding: 22px 26px;
	margin-top: 22px;
}
.lesson-section.drill h2 {
	border: 0;
	padding: 0;
	font-size: 16px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--fire);
	display: flex;
	align-items: center;
	gap: 9px;
}
.lesson-section.drill h2::before {
	content: "";
	width: 16px;
	height: 16px;
	border-radius: 4px;
	background: linear-gradient(135deg, var(--fire-bright), var(--fire-deep));
	box-shadow: 0 0 10px var(--fire-line);
	display: inline-block;
}
.lesson-section.drill p {
	margin: 0;
	font-weight: 500;
}

/* media slot */
.media {
	margin: 46px 0 0;
	padding-top: 36px;
	border-top: 1px solid var(--line);
}
.media-h {
	font-family: "Roboto Mono", monospace;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--muted);
	margin: 0 0 18px;
}
.media-grid {
	display: grid;
	gap: 16px;
}
.media-card {
	border: 1.5px dashed var(--fire-line);
	border-radius: 14px;
	background: var(--face);
	overflow: hidden;
}
.media-card .ph {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	gap: 8px;
	padding: 34px 20px;
	color: var(--muted);
}
.media-card .ph .glyph {
	width: 34px;
	height: 34px;
	color: var(--fire-line);
}
.media-card .ph b {
	font-family: "Exo", sans-serif;
	color: var(--ink);
	font-weight: 600;
	font-size: 15px;
}
.media-card .ph small {
	font-size: 13px;
}
.media-card .embed {
	position: relative;
	aspect-ratio: 16 / 9;
}
.media-card .embed iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}
.media-card img {
	display: block;
	width: 100%;
	height: auto;
}

footer {
	max-width: var(--maxw);
	margin: 0 auto;
	padding: 40px 24px 60px;
	border-top: 1px solid var(--line);
	color: var(--muted);
	font-size: 14.5px;
}
footer .f-brand {
	font-family: "Exo", sans-serif;
	font-weight: 700;
	letter-spacing: 0.1em;
	color: var(--fire);
}
footer a {
	color: var(--fire);
	text-decoration: none;
}
footer a:hover {
	text-decoration: underline;
}

/* ---- index page ---- */
.index-hero {
	padding: 64px 0 30px;
	border-bottom: 1px solid var(--line);
}
.index-hero .eyebrow {
	color: var(--muted);
}
.index-hero h1 {
	font-family: "Exo", sans-serif;
	font-weight: 800;
	font-size: clamp(36px, 7vw, 54px);
	line-height: 1.05;
	letter-spacing: -0.02em;
	margin: 0 0 16px;
	color: var(--ink-strong);
}
.index-hero h1 .fire {
	color: var(--fire);
	text-shadow: 0 0 26px var(--fire-line);
}
.index-hero .sub {
	font-size: 21px;
	color: var(--muted);
	margin: 0;
	max-width: 60ch;
}

section.belt {
	margin: 40px 0 0;
}
.belt-head {
	display: flex;
	align-items: center;
	gap: 13px;
	margin: 0 0 4px;
	flex-wrap: wrap;
}
.pill {
	font-family: "Exo", sans-serif;
	font-weight: 800;
	font-size: 13px;
	letter-spacing: 0.06em;
	color: #14171a;
	padding: 4px 13px;
	border-radius: 999px;
	text-transform: uppercase;
}
.belt h2 {
	font-family: "Exo", sans-serif;
	font-weight: 800;
	font-size: 26px;
	margin: 0;
	color: var(--ink-strong);
}
.belt .desc {
	color: var(--muted);
	margin: 6px 0 18px;
	font-size: 17px;
}
.badge {
	margin-left: auto;
	font-family: "Roboto Mono", monospace;
	font-size: 12px;
	font-weight: 600;
	color: var(--muted);
	border: 1px solid var(--line-2);
	padding: 3px 10px;
	border-radius: 999px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.badge.locked svg {
	width: 12px;
	height: 12px;
}

.topics {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
a.topic {
	display: block;
	text-decoration: none;
	color: inherit;
	background: var(--surface);
	border: 1px solid var(--line);
	border-left: 5px solid var(--belt, var(--fire));
	border-radius: 13px;
	padding: 16px 18px;
	transition:
		transform 0.15s ease,
		box-shadow 0.15s ease,
		border-color 0.15s ease;
}
a.topic:hover {
	transform: translateY(-2px);
	box-shadow: var(--shadow);
}
a.topic:focus-visible {
	outline: 3px solid var(--fire-line);
	outline-offset: 2px;
}
a.topic .n {
	font-family: "Roboto Mono", monospace;
	font-size: 12px;
	color: var(--muted);
	font-weight: 600;
}
a.topic .t {
	font-family: "Exo", sans-serif;
	font-weight: 700;
	font-size: 18px;
	margin: 3px 0 4px;
	color: var(--ink-strong);
}
a.topic .d {
	font-size: 14.5px;
	color: var(--muted);
	line-height: 1.5;
}
a.topic .go {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 10px;
	font-family: "Roboto Mono", monospace;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--fire);
}
.soon .topics {
	opacity: 0.5;
}
.soon a.topic {
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	a.topic {
		transition: none;
	}
}

/* compass / external-tool CTA (per-topic, when manifest sets tool_url) */
.tool-cta {
	margin: 26px 0 0;
}
.tool-cta-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	background: var(--surface);
	border: 1px solid var(--fire-line);
	border-radius: 14px;
	padding: 18px 22px;
	box-shadow: var(--shadow);
}
.tool-cta-eyebrow {
	font-family: "Roboto Mono", monospace;
	font-size: 12px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--fire);
	margin: 0 0 4px;
}
.tool-cta-title {
	font-family: "Exo", sans-serif;
	font-weight: 700;
	font-size: 18px;
	color: var(--ink-strong);
	margin: 0;
}
.tool-cta-btn {
	flex-shrink: 0;
	font-family: "Exo", sans-serif;
	font-weight: 700;
	font-size: 15px;
	text-decoration: none;
	color: #14171a;
	background: linear-gradient(135deg, var(--fire-bright), var(--fire-deep));
	padding: 11px 20px;
	border-radius: 10px;
	box-shadow: 0 0 18px var(--fire-line);
	transition:
		transform 0.15s ease,
		box-shadow 0.15s ease;
}
.tool-cta-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 0 26px var(--fire-line);
}
.tool-cta-btn:focus-visible {
	outline: 3px solid var(--fire-line);
	outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
	.tool-cta-btn {
		transition: none;
	}
}

/* responsive */
@media (max-width: 560px) {
	body {
		font-size: 18px;
	}
	header.hero,
	.index-hero {
		padding: 38px 0 22px;
	}
	.wrap {
		padding: 0 20px 90px;
	}
	.topbar-in {
		padding: 11px 18px;
	}
	.lesson-section.takeaways,
	.lesson-section.drill {
		padding: 18px 18px;
	}
	.topics {
		grid-template-columns: 1fr;
	}
}
