/* LarkenxGames — topographic-light theme.
   Design language: a USGS quad sheet. Cream paper, dark ink, and the
   hypsometric elevation ramp (water → lowland → hills → peak) as the accent
   system. Faint contour lines drift in the page background. */

:root {
	--paper: #f7f5f0;
	--paper-raised: #fffdf8;
	--ink: #223333;
	--ink-soft: #54635f;
	--line: rgba(34, 51, 51, 0.14);
	--line-faint: rgba(34, 51, 51, 0.07);

	--water: #1b6ca8;
	--lowland: #4a9e5c;
	--hills: #c9a227;
	--peak: #ffffff;
	--rock: #79716a;
	--erode: #b0402f;

	--ramp: linear-gradient(90deg, var(--water), var(--lowland), var(--hills), var(--peak));

	--code-bg: rgba(34, 51, 51, 0.06);

	--font-prose: "Charter", "Bitstream Charter", "Source Serif 4", Georgia, serif;
	--font-ui: system-ui, "Segoe UI", sans-serif;
	--font-mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;

	--measure: 68ch;
	--radius: 10px;

	color-scheme: light;
}

/* Dark mode: a topo map at night. theme.js resolves system preference +
   localStorage into data-theme before first paint, so CSS only needs the
   attribute (no duplicated media-query block). */
html[data-theme="dark"] {
	--paper: #141b1a;
	--paper-raised: #1d2624;
	--ink: #e6e4dc;
	--ink-soft: #9fa9a4;
	--line: rgba(230, 228, 220, 0.16);
	--line-faint: rgba(230, 228, 220, 0.08);

	--water: #5ba8d4;
	--lowland: #62b274;
	--hills: #d6b449;
	--rock: #8d857d;
	--erode: #d4604c;

	--code-bg: rgba(230, 228, 220, 0.09);

	color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
	margin: 0;
	color: var(--ink);
	background-color: var(--paper);
	background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="640" height="640"><g fill="none" stroke="%23223333" stroke-opacity="0.045"><ellipse cx="180" cy="160" rx="150" ry="105" transform="rotate(-14 180 160)"/><ellipse cx="180" cy="160" rx="112" ry="76" transform="rotate(-11 180 160)"/><ellipse cx="180" cy="160" rx="74" ry="48" transform="rotate(-7 180 160)"/><ellipse cx="180" cy="160" rx="38" ry="23" transform="rotate(-3 180 160)"/><ellipse cx="500" cy="470" rx="170" ry="120" transform="rotate(21 500 470)"/><ellipse cx="500" cy="470" rx="128" ry="86" transform="rotate(17 500 470)"/><ellipse cx="500" cy="470" rx="86" ry="55" transform="rotate(12 500 470)"/><ellipse cx="500" cy="470" rx="44" ry="27" transform="rotate(6 500 470)"/></g></svg>');
	font-family: var(--font-prose);
	font-size: 18px;
	line-height: 1.65;
}

html[data-theme="dark"] body {
	background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="640" height="640"><g fill="none" stroke="%23e6e4dc" stroke-opacity="0.05"><ellipse cx="180" cy="160" rx="150" ry="105" transform="rotate(-14 180 160)"/><ellipse cx="180" cy="160" rx="112" ry="76" transform="rotate(-11 180 160)"/><ellipse cx="180" cy="160" rx="74" ry="48" transform="rotate(-7 180 160)"/><ellipse cx="180" cy="160" rx="38" ry="23" transform="rotate(-3 180 160)"/><ellipse cx="500" cy="470" rx="170" ry="120" transform="rotate(21 500 470)"/><ellipse cx="500" cy="470" rx="128" ry="86" transform="rotate(17 500 470)"/><ellipse cx="500" cy="470" rx="86" ry="55" transform="rotate(12 500 470)"/><ellipse cx="500" cy="470" rx="44" ry="27" transform="rotate(6 500 470)"/></g></svg>');
}


/* ---------- header / footer ---------- */

.site-header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.5rem 1.5rem;
	max-width: 1200px;
	margin: 0 auto;
	padding: 1.4rem 1.5rem 1rem;
}

.site-header .brand {
	font-family: var(--font-mono);
	font-size: 1.05rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	color: var(--ink);
	text-decoration: none;
}

.site-header .brand::after {
	content: "";
	display: block;
	height: 3px;
	margin-top: 4px;
	border-radius: 2px;
	background: var(--ramp);
}

.site-header nav {
	font-family: var(--font-ui);
	font-size: 0.92rem;
}

.site-header nav a {
	color: var(--ink-soft);
	text-decoration: none;
	margin-left: 1.2rem;
}

.site-header nav a:hover { color: var(--water); }

.theme-toggle {
	font-family: var(--font-mono);
	font-size: 0.95rem;
	line-height: 1;
	color: var(--ink-soft);
	background: none;
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 0.3rem 0.65rem;
	margin-left: 1.2rem;
	cursor: pointer;
	vertical-align: baseline;
}

.theme-toggle:hover { color: var(--water); border-color: var(--water); }

.site-footer {
	max-width: 1200px;
	margin: 4rem auto 0;
	padding: 1.5rem;
	border-top: 1px solid var(--line);
	font-family: var(--font-ui);
	font-size: 0.85rem;
	color: var(--ink-soft);
}

.site-footer a { color: var(--water); }

/* ---------- typography ---------- */

h1, h2, h3 {
	font-family: var(--font-ui);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); margin: 0.4em 0 0.3em; }

h2 {
	font-size: 1.45rem;
	margin: 2.2em 0 0.6em;
	padding-bottom: 0.35rem;
	position: relative;
}

/* Elevation-ramp underline on section headers. */
h2::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 4.5rem;
	height: 4px;
	border-radius: 2px;
	background: var(--ramp);
}

h3 { font-size: 1.12rem; margin: 1.8em 0 0.4em; }

p, ul, ol { max-width: var(--measure); }

a { color: var(--water); }

code {
	font-family: var(--font-mono);
	font-size: 0.86em;
	background: var(--code-bg);
	border-radius: 4px;
	padding: 0.08em 0.35em;
}

pre {
	max-width: var(--measure);
	overflow-x: auto;
	background: var(--paper-raised);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 0.9rem 1.1rem;
	line-height: 1.5;
}

pre code { background: none; padding: 0; }

.lede {
	font-size: 1.15rem;
	color: var(--ink-soft);
}

.aside {
	max-width: var(--measure);
	border-left: 3px solid var(--hills);
	background: var(--paper-raised);
	border-radius: 0 var(--radius) var(--radius) 0;
	padding: 0.7rem 1rem;
	font-size: 0.95rem;
	color: var(--ink-soft);
}

/* ---------- layout ---------- */

.page {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 1.5rem;
}

article.prose {
	max-width: 760px;
	margin: 0 auto;
	padding: 0 1.5rem 3rem;
}

/* Article + sticky demo, redblob-style: prose scrolls, demo stays in view. */
.article-with-demo {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 2rem;
	max-width: 1280px;
	margin: 0 auto;
	padding: 0 1.5rem 3rem;
}

@media (min-width: 1140px) {
	.article-with-demo {
		grid-template-columns: minmax(0, 1fr) minmax(440px, 46%);
		align-items: start;
	}
	.article-with-demo .demo-column {
		position: sticky;
		top: 1rem;
	}
}

/* ---------- demo embed ---------- */

godot-demo {
	display: block;
	aspect-ratio: 16 / 10;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--paper-raised);
	position: relative;
}

godot-demo iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

.demo-poster {
	position: absolute;
	inset: 0;
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.7rem;
	cursor: pointer;
	border: 0;
	color: var(--ink);
	font-family: var(--font-ui);
	background:
		radial-gradient(ellipse at 30% 25%, rgba(74, 158, 92, 0.18), transparent 55%),
		radial-gradient(ellipse at 72% 70%, rgba(201, 162, 39, 0.18), transparent 55%),
		var(--paper-raised);
}

.demo-poster:hover .demo-poster-button { transform: scale(1.05); }

.demo-poster-title {
	font-weight: 600;
	font-size: 1.05rem;
}

.demo-poster-button {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.95rem;
	font-weight: 600;
	color: #fff;
	background: var(--water);
	border-radius: 999px;
	padding: 0.55rem 1.3rem;
	transition: transform 0.15s ease;
}

.demo-poster-note {
	font-size: 0.8rem;
	color: var(--ink-soft);
}

/* ---------- lab controls ---------- */

lab-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0.8rem 0;
	font-family: var(--font-ui);
}

lab-controls button {
	font-family: var(--font-ui);
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--ink);
	background: var(--paper-raised);
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 0.42rem 1.1rem;
	cursor: pointer;
}

lab-controls button:hover { border-color: var(--water); color: var(--water); }

lab-controls button.primary {
	color: #fff;
	background: var(--water);
	border-color: var(--water);
}

lab-controls button.primary:hover { color: #fff; filter: brightness(1.1); }

lab-param {
	display: block;
	max-width: var(--measure);
	margin: 0.9rem 0;
	padding: 0.65rem 0.9rem;
	background: var(--paper-raised);
	border: 1px solid var(--line-faint);
	border-radius: var(--radius);
	font-family: var(--font-ui);
	font-size: 0.92rem;
}

lab-param .param-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 0.3rem;
}

lab-param .param-label { font-weight: 600; }

lab-param .param-value {
	font-family: var(--font-mono);
	font-size: 0.88em;
	color: var(--water);
}

lab-param input[type="range"] {
	width: 100%;
	accent-color: var(--water);
}

lab-param select,
lab-param input[type="checkbox"] {
	accent-color: var(--water);
	font-family: var(--font-ui);
	font-size: 0.92rem;
}

lab-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0.8rem 0;
	font-family: var(--font-mono);
	font-size: 0.82rem;
}

lab-stats .stat {
	background: var(--paper-raised);
	border: 1px solid var(--line-faint);
	border-radius: 6px;
	padding: 0.3rem 0.7rem;
}

lab-stats .stat b {
	color: var(--ink-soft);
	font-weight: 500;
	margin-right: 0.4rem;
}

/* ---------- gallery ---------- */

.hero {
	max-width: 1200px;
	margin: 2rem auto 0;
	padding: 0 1.5rem;
}

.hero p {
	font-size: 1.18rem;
	color: var(--ink-soft);
	max-width: 56ch;
}

.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
	gap: 1.4rem;
	max-width: 1200px;
	margin: 2.5rem auto;
	padding: 0 1.5rem;
}

.card {
	display: block;
	text-decoration: none;
	color: var(--ink);
	background: var(--paper-raised);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.card:hover {
	transform: translateY(-3px);
	box-shadow: 0 10px 28px rgba(34, 51, 51, 0.12);
}

.card-art {
	aspect-ratio: 16 / 9;
	display: block;
	width: 100%;
	object-fit: cover;
}

.card-body { padding: 0.9rem 1.1rem 1.1rem; }

.card-body h3 { margin: 0 0 0.3rem; }

.card-body p {
	margin: 0;
	font-family: var(--font-ui);
	font-size: 0.9rem;
	color: var(--ink-soft);
}

.card-tag {
	display: inline-block;
	font-family: var(--font-mono);
	font-size: 0.72rem;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--lowland);
	margin-bottom: 0.45rem;
}

.article-meta {
	font-family: var(--font-mono);
	font-size: 0.78rem;
	letter-spacing: 0.04em;
	color: var(--ink-soft);
	margin: -0.2rem 0 1.6rem;
}

/* ---------- misc ---------- */

figure {
	margin: 1.5rem 0;
	max-width: var(--measure);
}

figcaption {
	font-family: var(--font-ui);
	font-size: 0.85rem;
	color: var(--ink-soft);
	margin-top: 0.5rem;
}

::selection { background: rgba(201, 162, 39, 0.35); }

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

/* ---------- demo expand button ---------- */

.demo-expand-btn {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: none;
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s ease;
}

godot-demo:hover .demo-expand-btn,
godot-demo:focus-within .demo-expand-btn { opacity: 1; }

.demo-expand-btn:hover { background: rgba(0, 0, 0, 0.7); }

godot-demo:fullscreen {
	aspect-ratio: auto;
	width: 100vw;
	height: 100vh;
	border-radius: 0;
	border: none;
}

/* ---------- sandbox panel ---------- */

.sandbox-panel {
	margin: 0.6rem 0;
}

.sandbox-panel > summary {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	list-style: none;
	cursor: pointer;
	font-family: var(--font-ui);
	font-size: 0.88rem;
	font-weight: 600;
	color: var(--ink-soft);
	padding: 0.3rem 0;
	user-select: none;
}

.sandbox-panel > summary::before {
	content: "▾";
	display: inline-block;
	transition: transform 0.15s ease;
	font-size: 0.75em;
	color: var(--hills);
}

.sandbox-panel:not([open]) > summary::before {
	transform: rotate(-90deg);
}

.sandbox-panel > summary::-webkit-details-marker { display: none; }

lab-panel {
	display: block;
	margin-top: 0.3rem;
}

.panel-group {
	margin-bottom: 0.4rem;
	border: 1px solid var(--line-faint);
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--paper-raised);
}

.panel-group-header {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	list-style: none;
	cursor: pointer;
	padding: 0.38rem 0.75rem;
	font-family: var(--font-ui);
	font-size: 0.76rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ink-soft);
	background: var(--paper-raised);
	border-bottom: 1px solid var(--line-faint);
	user-select: none;
}

.panel-group:not([open]) .panel-group-header { border-bottom: none; }

.panel-group-header::before {
	content: "▾";
	display: inline-block;
	transition: transform 0.15s ease;
	font-size: 0.75em;
	color: var(--hills);
}

.panel-group:not([open]) .panel-group-header::before { transform: rotate(-90deg); }

.panel-group-header::-webkit-details-marker { display: none; }

.panel-group-body {
	padding: 0.35rem 0.6rem 0.45rem;
}

.panel-row {
	margin-bottom: 0.35rem;
}

.panel-row:last-child { margin-bottom: 0; }

.panel-row-top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem;
	margin-bottom: 0.1rem;
}

.panel-label {
	font-family: var(--font-ui);
	font-size: 0.84rem;
	font-weight: 500;
	color: var(--ink);
}

.panel-value {
	font-family: var(--font-mono);
	font-size: 0.78rem;
	color: var(--water);
	min-width: 5ch;
	text-align: right;
}

.panel-row input[type="range"] {
	display: block;
	width: 100%;
	accent-color: var(--water);
	margin: 0;
}

.panel-row input[type="checkbox"] {
	accent-color: var(--water);
}

.panel-row select {
	font-family: var(--font-ui);
	font-size: 0.82rem;
	accent-color: var(--water);
	max-width: 100%;
}

/* ---------- article diagrams ---------- */

figure.article-diagram {
	display: block;
	max-width: var(--measure);
	margin: 1.4rem 0;
	border: 1px solid var(--line-faint);
	border-radius: var(--radius);
	background: var(--paper-raised);
	overflow: hidden;
}

figure.article-diagram > svg {
	display: block;
	width: 100%;
	padding: 0.5rem 0.5rem 0.3rem;
}

figure.article-diagram figcaption {
	padding: 0.5rem 0.9rem 0.6rem;
	border-top: 1px solid var(--line-faint);
	font-family: var(--font-ui);
	font-size: 0.85rem;
	color: var(--ink-soft);
	margin: 0;
}

/* SVG element classes — use CSS custom props so dark mode is free */
.diag-tf   { fill: color-mix(in srgb, var(--lowland) 22%, transparent); }
.diag-ts   { stroke: var(--lowland); stroke-width: 2; fill: none; }
.diag-path { stroke: var(--ink-soft); stroke-width: 1.5; fill: none;
             stroke-dasharray: 4 3; opacity: 0.55; }
.diag-drop { fill: var(--water); }
.diag-sed  { fill: var(--hills); opacity: 0.88; }
.diag-cap  { fill: color-mix(in srgb, var(--lowland) 25%, transparent);
             stroke: var(--lowland); stroke-width: 1.5; stroke-dasharray: 3 2; }
.diag-erode-fill { fill: var(--erode); opacity: 0.72; }
.diag-depo { fill: var(--hills); opacity: 0.58; }
.diag-vel  { stroke: var(--ink-soft); stroke-width: 1.5; }
.diag-arrowhead { fill: var(--ink-soft); }
.diag-divider   { stroke: var(--line); stroke-width: 1; }
.diag-label { font-size: 10.5px; fill: var(--ink); font-weight: 600; }
.diag-note2 { font-size: 9.5px; fill: var(--ink-soft); }
