/* Boxscape site styles.
 *
 * Colours are lifted from scripts/design/palette.gd rather than invented, so
 * the site and the game cannot drift apart -- when the game's palette moves,
 * this file is the one place to follow it. Type is the game's own pairing:
 * Baloo 2 for anything carved into a sign, Nunito Sans for anything read.
 *
 * Deliberately single-theme. Boxscape is a dark forest at dawn; a light mode
 * would be a different game. Every colour is painted explicitly so the page
 * holds on any host background rather than borrowing one.
 */

@font-face {
	font-family: "Baloo 2";
	src: url("../fonts/Baloo2-ExtraBold.ttf") format("truetype");
	font-weight: 800;
	font-display: swap;
}
@font-face {
	font-family: "Nunito Sans";
	src: url("../fonts/NunitoSans-Regular.ttf") format("truetype");
	font-weight: 400;
	font-display: swap;
}
@font-face {
	font-family: "Nunito Sans";
	src: url("../fonts/NunitoSans-Bold.ttf") format("truetype");
	font-weight: 700;
	font-display: swap;
}

:root {
	/* Palette.BACKDROP, PLAQUE_BG, FOREST_*, GOLD_*, IVORY, MOSS, WOOD_* */
	--ground: #0a1410;
	--ground-lift: #10201a;
	--panel: #16281e;
	--panel-edge: rgba(155, 203, 155, 0.14);
	--forest-mid: #2e6b45;
	--ink: #f7f4e9;
	--ink-dim: #9bcb9b;
	--ink-faint: rgba(247, 244, 233, 0.58);
	--gold: #f2c16b;
	--gold-deep: #e8a24c;
	--wood: #8a5e34;
	--wood-dark: #6b4423;
	--escape: #c0544a;

	--step--1: 0.875rem;
	--step-0: 1.0625rem;
	--step-1: 1.3125rem;
	--step-2: 1.75rem;
	--step-3: 2.5rem;
	--step-4: clamp(2.75rem, 7.5vw, 4.75rem);

	--shell: 1120px;
	--prose: 64ch;
	--gap: clamp(1rem, 2.5vw, 1.75rem);
	--section-gap: clamp(4rem, 10vw, 7.5rem);
	--radius: 14px;
}

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

html {
	scroll-behavior: smooth;
}

body {
	margin: 0;
	/* Explicit, not inherited: the host paints its own ground behind us. */
	background-color: var(--ground);
	background-image:
		radial-gradient(120% 70% at 50% 0%, rgba(46, 107, 69, 0.30), transparent 62%),
		radial-gradient(80% 50% at 12% 92%, rgba(31, 77, 59, 0.24), transparent 70%);
	/* Deliberately not `fixed`. A fixed attachment promotes a compositing
	 * layer the height of the whole document, which on a page this long
	 * repaints badly while scrolling. The gradients sit at the top and bottom
	 * of the document, so scrolling with the content is also what they want. */
	background-repeat: no-repeat;
	color: var(--ink);
	font-family: "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
	font-size: var(--step-0);
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3 {
	font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
	font-weight: 800;
	line-height: 1.06;
	text-wrap: balance;
	margin: 0;
	letter-spacing: -0.015em;
}

p {
	margin: 0;
}

a {
	color: var(--gold);
	text-decoration-color: rgba(242, 193, 107, 0.4);
	text-underline-offset: 3px;
}

a:hover {
	text-decoration-color: var(--gold);
}

:focus-visible {
	outline: 3px solid var(--gold);
	outline-offset: 3px;
	border-radius: 4px;
}

img {
	max-width: 100%;
	height: auto;
	display: block;
}

.shell {
	width: min(100% - 2.5rem, var(--shell));
	margin-inline: auto;
}

.eyebrow {
	font-size: var(--step--1);
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--ink-dim);
	margin: 0;
}

/* ---------- masthead ---------- */

.masthead {
	position: sticky;
	top: 0;
	z-index: 20;
	background: rgba(10, 20, 16, 0.82);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--panel-edge);
}

.masthead__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gap);
	padding-block: 0.85rem;
}

.masthead__mark {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: 1.25rem;
	color: var(--ink);
	text-decoration: none;
}

.masthead__mark img {
	width: 30px;
	height: 30px;
	border-radius: 8px;
}

.masthead__nav {
	display: flex;
	align-items: center;
	gap: clamp(0.9rem, 2.5vw, 1.9rem);
	font-size: var(--step--1);
	font-weight: 700;
}

.masthead__nav a {
	color: var(--ink-dim);
	text-decoration: none;
}

.masthead__nav a:hover {
	color: var(--ink);
}

@media (max-width: 620px) {
	.masthead__nav .is-optional {
		display: none;
	}
}

/* ---------- hero ---------- */

.hero {
	padding-block: clamp(2.5rem, 7vw, 5rem) var(--section-gap);
}

.hero__grid {
	display: grid;
	gap: clamp(2rem, 5vw, 3.5rem);
	grid-template-columns: 1fr;
	align-items: center;
}

@media (min-width: 900px) {
	.hero__grid {
		grid-template-columns: 1.05fr 0.95fr;
	}
}

.hero h1 {
	font-size: var(--step-4);
	margin-block: 0.6rem 0;
}

.hero h1 .muted {
	color: var(--ink-dim);
	display: block;
}

.hero h1 .lit {
	color: var(--gold);
	display: block;
}

.hero__lede {
	max-width: 46ch;
	margin-top: 1.25rem;
	color: var(--ink-faint);
	font-size: var(--step-1);
}

.hero__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.9rem;
	margin-top: 2rem;
}

/* The in-game PLAY control is a plank of wood; this is the one place the site
 * borrows that texture. Everywhere else stays flat so it keeps its impact. */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: 1.15rem;
	padding: 0.75rem 1.6rem;
	border-radius: 11px;
	border: 1px solid rgba(0, 0, 0, 0.35);
	background: linear-gradient(#a4713f, var(--wood-dark));
	color: var(--ink);
	text-decoration: none;
	box-shadow:
		inset 0 1px 0 rgba(255, 226, 176, 0.35),
		0 6px 0 -1px #40280f,
		0 12px 22px rgba(0, 0, 0, 0.45);
	transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
	transform: translateY(-1px);
}

.btn:active {
	transform: translateY(3px);
	box-shadow:
		inset 0 1px 0 rgba(255, 226, 176, 0.25),
		0 3px 0 -1px #40280f,
		0 6px 12px rgba(0, 0, 0, 0.45);
}

.btn--ghost {
	background: transparent;
	border: 1px solid var(--panel-edge);
	box-shadow: none;
	color: var(--ink-dim);
}

.btn--ghost:hover {
	color: var(--ink);
	border-color: rgba(155, 203, 155, 0.35);
	transform: none;
}

.badge {
	font-size: var(--step--1);
	font-weight: 700;
	letter-spacing: 0.06em;
	color: var(--ink-dim);
}

/* ---------- playable hero demo ---------- */

.demo {
	position: relative;
	border-radius: 20px;
	overflow: hidden;
	border: 1px solid var(--panel-edge);
	background: #0d1b15;
	box-shadow: 0 26px 60px rgba(0, 0, 0, 0.5);
	aspect-ratio: 1 / 1;
	/* The demo is square, so its width is also its height. Left uncapped it
	 * takes the full single-column width below 900px and becomes an ~860px
	 * tall wall that pushes everything else off the screen. Cap it against the
	 * viewport height too, so it always leaves room for the headline. */
	width: 100%;
	max-width: min(520px, 68vh);
	margin-inline: auto;
	/* pan-y, not none: `none` hands every gesture to the canvas, so a touch
	 * that starts on the demo cannot scroll the page and the whole thing feels
	 * stuck. This keeps vertical scrolling with the page and takes the
	 * horizontal axis for dragging the frame. */
	touch-action: pan-y;
}

.demo canvas {
	display: block;
	width: 100%;
	height: 100%;
}

.demo__hint {
	position: absolute;
	left: 50%;
	bottom: 1rem;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.45rem 0.95rem;
	border-radius: 999px;
	background: rgba(15, 31, 23, 0.85);
	color: var(--ink-dim);
	font-size: var(--step--1);
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	pointer-events: none;
	transition: opacity 0.4s ease;
}

.demo__readout {
	position: absolute;
	top: 1rem;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 0.6rem;
	pointer-events: none;
}

.pill {
	min-width: 104px;
	padding: 0.35rem 0.9rem 0.4rem;
	border-radius: 999px;
	background: rgba(15, 31, 23, 0.85);
	text-align: center;
}

.pill b {
	display: block;
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: 1.35rem;
	line-height: 1.05;
	font-variant-numeric: tabular-nums;
}

.pill span {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	color: var(--ink-dim);
}

/* ---------- generic section ---------- */

.section {
	padding-block: var(--section-gap);
	border-top: 1px solid var(--panel-edge);
}

.section__head {
	max-width: var(--prose);
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
}

.section__head h2 {
	font-size: var(--step-3);
}

.section__head p {
	color: var(--ink-faint);
	font-size: var(--step-1);
}

/* ---------- rules: a real sequence, so it is numbered ---------- */

.rules {
	display: grid;
	gap: var(--gap);
	grid-template-columns: 1fr;
	margin-top: clamp(2rem, 5vw, 3rem);
	counter-reset: rule;
}

@media (min-width: 760px) {
	.rules {
		grid-template-columns: repeat(3, 1fr);
	}
}

.rule {
	counter-increment: rule;
	background: var(--panel);
	border: 1px solid var(--panel-edge);
	border-radius: var(--radius);
	padding: 1.6rem 1.5rem 1.7rem;
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
}

.rule::before {
	content: counter(rule);
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: 2.4rem;
	line-height: 1;
	color: var(--gold);
	opacity: 0.85;
}

.rule h3 {
	font-size: var(--step-1);
}

.rule p {
	color: var(--ink-faint);
	font-size: var(--step--1);
	line-height: 1.6;
}

/* ---------- alternating feature blocks ---------- */

.feature {
	display: grid;
	gap: clamp(1.75rem, 5vw, 4rem);
	align-items: center;
	grid-template-columns: 1fr;
	margin-top: clamp(2rem, 5vw, 3rem);
}

@media (min-width: 860px) {
	.feature {
		grid-template-columns: 1fr 1fr;
	}
	.feature--flip .feature__art {
		order: -1;
	}
}

.feature__body {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	max-width: 52ch;
}

.feature__body h3 {
	font-size: var(--step-2);
}

.feature__body p {
	color: var(--ink-faint);
}

.feature__art img {
	border-radius: 18px;
	border: 1px solid var(--panel-edge);
	box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5);
	margin-inline: auto;
	max-height: 560px;
	width: auto;
}

.stat-row {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	margin-top: 0.4rem;
}

.stat {
	display: flex;
	flex-direction: column;
}

.stat b {
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: 1.9rem;
	color: var(--gold);
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
}

.stat span {
	font-size: var(--step--1);
	color: var(--ink-dim);
}

/* ---------- environments ---------- */

.gallery {
	display: grid;
	gap: var(--gap);
	grid-template-columns: repeat(2, 1fr);
	margin-top: clamp(2rem, 5vw, 3rem);
}

/* Three across, not four: there are six places, and four columns leaves a
   short second row that reads as two missing tiles. */
@media (min-width: 820px) {
	.gallery {
		grid-template-columns: repeat(3, 1fr);
	}
}

.tile {
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
}

.tile img {
	border-radius: var(--radius);
	border: 1px solid var(--panel-edge);
	box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
}

.tile b {
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: var(--step-1);
	font-weight: 800;
}

.tile span {
	font-size: var(--step--1);
	color: var(--ink-faint);
}

/* ---------- closing call to action ---------- */

.closer {
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1.2rem;
}

.closer h2 {
	font-size: var(--step-3);
	max-width: 18ch;
}

.closer p {
	color: var(--ink-faint);
	max-width: 48ch;
}

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

.foot {
	border-top: 1px solid var(--panel-edge);
	padding-block: 2.5rem 3rem;
	color: var(--ink-faint);
	font-size: var(--step--1);
}

.foot__inner {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem var(--gap);
	justify-content: space-between;
	align-items: center;
}

.foot__links {
	display: flex;
	flex-wrap: wrap;
	gap: 1.25rem;
}

.foot a {
	color: var(--ink-dim);
	text-decoration: none;
}

.foot a:hover {
	color: var(--ink);
	text-decoration: underline;
}

/* ---------- document pages (how-to, legal) ---------- */

.doc {
	padding-block: clamp(2.5rem, 6vw, 4rem) var(--section-gap);
}

.doc__head {
	display: flex;
	flex-direction: column;
	gap: 0.8rem;
	padding-bottom: 2rem;
	border-bottom: 1px solid var(--panel-edge);
}

.doc__head h1 {
	font-size: var(--step-3);
}

.doc__head p {
	color: var(--ink-faint);
	max-width: var(--prose);
}

.doc__body {
	max-width: var(--prose);
	margin-top: 2.5rem;
	display: flex;
	flex-direction: column;
	gap: 1.35rem;
}

.doc__body h2 {
	font-size: var(--step-2);
	margin-top: 1.4rem;
}

.doc__body h3 {
	font-size: var(--step-1);
	margin-top: 0.8rem;
}

.doc__body p,
.doc__body li {
	color: rgba(247, 244, 233, 0.82);
}

.doc__body ul,
.doc__body ol {
	margin: 0;
	padding-left: 1.3rem;
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
}

.doc__body table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--step--1);
}

.doc__body th,
.doc__body td {
	text-align: left;
	padding: 0.7rem 0.9rem;
	border-bottom: 1px solid var(--panel-edge);
	vertical-align: top;
}

.doc__body th {
	color: var(--ink-dim);
	text-transform: uppercase;
	letter-spacing: 0.1em;
	font-size: 0.75rem;
}

.scroll-x {
	overflow-x: auto;
	border-radius: var(--radius);
	border: 1px solid var(--panel-edge);
}

.callout {
	border-left: 3px solid var(--gold);
	background: var(--panel);
	border-radius: 0 var(--radius) var(--radius) 0;
	padding: 1.1rem 1.3rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.callout--draft {
	border-left-color: var(--escape);
}

.callout b {
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: var(--step-1);
}

.toc {
	background: var(--panel);
	border: 1px solid var(--panel-edge);
	border-radius: var(--radius);
	padding: 1.2rem 1.4rem;
}

.toc ol {
	padding-left: 1.2rem;
	gap: 0.4rem;
}


/* ---------- reference pages: trophies, scenes, rules ---------- */

/* The reference pages break out of --prose. A paragraph wants 64 characters;
   a grid of 118 trophies or 48 sprites wants the whole shell, and constraining
   it to reading width leaves a column of cards down the middle of a very empty
   page.

   The container opens up and the prose inside is capped instead, rather than
   the other way round: .doc__body caps everything by capping itself, so no
   amount of overriding on a child can widen a grid inside it. */
.doc__body--wide {
	max-width: none;
}

.doc__body--wide > p,
.doc__body--wide > ul,
.doc__body--wide > ol,
.doc__body--wide > h2,
.doc__body--wide > h3,
.doc__body--wide > .callout,
.doc__body--wide > .toc,
.doc__body--wide > .scroll-x {
	max-width: var(--prose);
}

.trophies {
	display: grid;
	gap: 0.9rem;
	grid-template-columns: 1fr;
	margin: 1.4rem 0 2.6rem;
}

@media (min-width: 700px) {
	.trophies {
		grid-template-columns: repeat(2, 1fr);
	}
}

.trophy {
	display: flex;
	gap: 1rem;
	align-items: flex-start;
	padding: 0.95rem 1.05rem;
	background: var(--panel);
	border: 1px solid var(--panel-edge);
	border-left: 3px solid var(--ink-dim);
	border-radius: var(--radius);
}

/* The tier is the difficulty, so it is the one thing on the card that should
   be readable without reading: the left edge carries it. */
.trophies--green .trophy { border-left-color: #7bbf6a; }
.trophies--amber .trophy { border-left-color: var(--gold-deep); }
.trophies--gold  .trophy { border-left-color: var(--gold); }

.trophy img {
	width: 64px;
	height: 64px;
	flex: none;
	image-rendering: auto;
}

.trophy__body {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
}

.trophy__body b {
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: var(--step-1);
	line-height: 1.15;
}

.trophy__cat {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--ink-dim);
}

.trophy__rule {
	font-size: var(--step--1);
	color: var(--gold);
}

.trophy__note {
	font-size: var(--step--1);
	color: var(--ink-faint);
}

.trophy__flavour {
	font-size: var(--step--1);
	font-style: italic;
	color: var(--ink-dim);
}

/* ---------- item grids ---------- */

.items {
	display: grid;
	gap: 0.6rem;
	grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
	margin: 1rem 0 2rem;
}

.item {
	/* figure carries a 40px left/right margin by default, which inside a 93px
	   grid column leaves a 13px sliver with the sprite squeezed out of it
	   entirely. The site's reset does not zero it because nothing else here
	   uses a figure. */
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.35rem;
	padding: 0.7rem 0.4rem 0.6rem;
	background: var(--ground-lift);
	border: 1px solid var(--panel-edge);
	border-radius: var(--radius);
	text-align: center;
}

.item img {
	width: 56px;
	height: 56px;
	object-fit: contain;
}

.item figcaption {
	font-size: 0.6875rem;
	color: var(--ink-faint);
	line-height: 1.25;
	text-transform: capitalize;
}

/* What an item does is a property of its group, and on a page listing 48 of
   them at once the group has to be visible without reading every caption. */
.item--falling { border-bottom: 2px solid rgba(232, 162, 76, 0.55); }
.item--windblown { border-bottom: 2px solid rgba(155, 203, 155, 0.55); }
.item--growing { border-bottom: 2px solid rgba(123, 191, 106, 0.55); }

.scene__shot {
	display: block;
	width: 100%;
	max-width: 420px;
	border-radius: var(--radius);
	border: 1px solid var(--panel-edge);
	box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
	margin: 1.2rem 0;
}

/* ---------- the things that cross the field ---------- */

.pickups {
	display: grid;
	gap: var(--gap);
	grid-template-columns: 1fr;
	margin: 1.4rem 0 2.4rem;
}

@media (min-width: 700px) {
	.pickups {
		grid-template-columns: repeat(2, 1fr);
	}
}

.pickup {
	display: flex;
	gap: 1.1rem;
	align-items: flex-start;
	padding: 1.1rem 1.2rem;
	background: var(--panel);
	border: 1px solid var(--panel-edge);
	border-radius: var(--radius);
}

.pickup img {
	width: 76px;
	height: 76px;
	flex: none;
	object-fit: contain;
}

.pickup__body {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	min-width: 0;
}

.pickup__body b {
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: var(--step-1);
}

.pickup__body p {
	font-size: var(--step--1);
	color: var(--ink-faint);
}

/* ---------- value tables ---------- */

.doc__body table {
	max-width: none;
	width: 100%;
	border-collapse: collapse;
	margin: 1.2rem 0 2.2rem;
	font-size: var(--step--1);
}

.doc__body th,
.doc__body td {
	text-align: left;
	padding: 0.6rem 0.8rem;
	border-bottom: 1px solid var(--panel-edge);
	vertical-align: top;
}

.doc__body th {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--ink-dim);
}

.doc__body td b {
	font-family: "Baloo 2", ui-rounded, sans-serif;
	font-size: var(--step-0);
	color: var(--gold);
	font-variant-numeric: tabular-nums;
}

/* A figure that comes from the game rather than from the writer. Nothing about
   it looks different; the attribute is there so check_site.py can hold every
   one of them against the game's own dump. */
[data-game] {
	font-variant-numeric: tabular-nums;
}

/* A single object dropped into running prose, rather than a card in a grid. */
.pickup-inline {
	display: block;
	width: 96px;
	height: 96px;
	object-fit: contain;
	margin: 0.4rem 0 1rem;
}
