:root {
	--section: 124px;        /* one 12" (300 mm) section; each section's size is set by app.js, to scale */
	--board: 40px;           /* the backboard's margin around the head (~ 100 mm at this scale) */
	--board-yellow: #ffcd00; /* traffic yellow */
	--board-black: #1d1f21;
	--reflective: 18px;      /* a reflective backboard's border (~ 50 mm) */
	--bg: #eef1f4;
	--ink: #1b1f23;
	--muted: #5b636b;
	--accent: #1f6fc5;
	--red: #ff4a30;
	--yellow: #ffb81c;
	--green: #10c494;
	--transit: #f6f6ee;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
	margin: 0;
	font: 15px/1.45 system-ui, "Segoe UI", Arial, sans-serif;
	background: var(--bg);
	color: var(--ink);
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

header { padding: 14px 32px 4px; }
/* the configurators, as tabs */
.pages { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid #d3d9df; }
.pages a {
	padding: 7px 14px;
	color: var(--muted);
	text-decoration: none;
	border-bottom: 3px solid transparent;
	margin-bottom: -1px;
	font-size: 14px;
	font-weight: 600;
}
.pages a:hover { color: var(--ink); }
.pages a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
header h1 { margin: 0 0 6px; font-size: 24px; }
header p { margin: 0; max-width: 80ch; color: var(--muted); }

main {
	display: flex;
	gap: 48px;
	align-items: flex-start;
	padding: 22px 32px 60px;
}
h2 { margin: 0; font-size: 17px; }

/* ---- the head side ---- */
#light-side { flex: 0 0 auto; min-width: 360px; }
.side-title { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.options { display: flex; gap: 10px; flex-wrap: wrap; }
.options label {
	display: inline-flex;
	gap: 8px;
	align-items: center;
	cursor: pointer;
	background: #fff;
	border: 1px solid #d3d9df;
	border-radius: 10px;
	padding: 9px 14px;
}
.options label:hover { border-color: #94a6b8; }
.options label:has(input:checked) { border-color: var(--accent); background: #f2f7fd; font-weight: 600; }
.link-button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; font-size: 14px; }
.link-button:hover { text-decoration: underline; }

.stage { position: relative; display: inline-block; padding: 6px 166px 6px 6px; border-radius: 10px; }
.stage.drop-target { background: rgba(31, 111, 197, .07); outline: 2px dashed rgba(31, 111, 197, .45); }

/* the backboard: none, or yellow or black aluminium, either with a retroreflective yellow border around its edge */
.backboard { position: relative; display: inline-block; }
.backboard:not([data-backboard="none"]) {
	padding: var(--board);
	background: var(--board-yellow);
	border-radius: 6px;
	box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.18);
}
.backboard[data-backboard^="black"] { background: var(--board-black); }
/* the reflective border: prismatic sheeting (a fine diamond grid), a seam at its inner edge */
.backboard[data-backboard$="-reflective"]::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 6px;
	padding: var(--reflective);
	background:
		repeating-linear-gradient(45deg, rgba(255,255,255,.28) 0 1px, transparent 1px 6px),
		repeating-linear-gradient(-45deg, rgba(255,255,255,.28) 0 1px, transparent 1px 6px),
		linear-gradient(135deg, #ffd83a, #ffc400 45%, #ffdc4a 70%, #ffc000);
	box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
	/* only the border: the board inside shows through */
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
	pointer-events: none;
}
/* its inner edge, where the sheeting stops */
.backboard[data-backboard$="-reflective"]::after {
	content: '';
	position: absolute;
	inset: var(--reflective);
	border-radius: 2px;
	box-shadow: 0 0 0 1px rgba(0,0,0,.22);
	pointer-events: none;
}

/* the head: black polycarbonate sections, one on top of the other */
.head {
	display: flex;
	flex-direction: column;
	filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
}
/* a row per section, as wide as the head: a smaller section is centred under the bigger ones (its height and its svg's
   width are set by app.js) */
.head { width: max-content; }
.section { position: relative; cursor: grab; touch-action: none; user-select: none; }
.section > svg { display: block; height: 100%; margin: 0 auto; }
.head > .section:first-child > svg { border-radius: 7px 7px 0 0; }
.head > .section:last-child > svg { border-radius: 0 0 7px 7px; }
.head > .section:only-child > svg { border-radius: 7px; }
.section.dragging { display: none; }
.section.selected > svg { outline: 3px solid var(--accent); outline-offset: 2px; position: relative; z-index: 1; }
.section:hover > svg { filter: brightness(1.08); }

/* the controls beside each section, outside the head (and the backboard) */
.tools {
	position: absolute;
	top: 50%;
	left: calc(100% + 14px);
	transform: translateY(-50%);
	display: flex;
	gap: 8px;
	align-items: center;
}
.backboard:not([data-backboard="none"]) .tools { left: calc(100% + var(--board) + 14px); }
/* the cycle (what it shows), the gear (colour and size) and the x (take off): the same round button */
.tools button {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	padding: 0;
	cursor: pointer;
	border: 0;
	background: #fff;
	box-shadow: 0 0 0 1px #c9d0d8, 0 1px 2px rgba(0,0,0,.08);
	display: flex;
	align-items: center;
	justify-content: center;
}
.settings, .cycle { color: #3d454d; }
.cycle svg { width: 24px; height: 24px; fill: currentColor; }
.cycle:hover { background: #eef3f8; color: var(--accent); }
.settings svg { width: 24px; height: 24px; fill: currentColor; }
.settings:hover { background: #eef3f8; color: var(--accent); }
.remove { color: #b3261e; font: 400 30px/1 system-ui, sans-serif; padding-bottom: 3px !important; }
.remove:hover { background: #b3261e; color: #fff; box-shadow: none; }

/* where a dragged section will go */
.slot {
	align-self: center;
	background: repeating-linear-gradient(45deg, rgba(31,111,197,.18) 0 8px, rgba(31,111,197,.08) 8px 16px);
	border: 2px dashed var(--accent);
}

.empty-head {
	width: var(--section);
	height: calc(var(--section) * 1.5);
	border: 2px dashed #aab4be;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	color: var(--muted);
	font-size: 14px;
	padding: 10px;
}
.empty-head.over { border-color: var(--accent); color: var(--accent); }

/* ---- the sections to add ---- */
.right-side { flex: 1 1 auto; min-width: 0; }
.right-side h2 { margin-bottom: 18px; line-height: 30px; }
.option-side { margin-bottom: 28px; }
#palette-side { border-radius: 12px; padding: 0 0 12px; margin-bottom: 16px; }
#palette-side.drop-target { outline: 2px dashed #aab4be; outline-offset: 8px; }
#palette-side.over { outline-color: var(--accent); background: rgba(31, 111, 197, .06); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, 150px); gap: 14px; }
.choice {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	background: #fff;
	border: 1px solid #d3d9df;
	border-radius: 10px;
	padding: 14px 10px 10px;
	cursor: grab;
	touch-action: none;
	user-select: none;
	font: inherit;
	color: inherit;
}
.choice:hover { border-color: #94a6b8; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.choice.dragging { opacity: .35; }
.choice-section { height: 84px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.choice-section svg { display: block; border-radius: 6px; }
.choice-label { font-size: 14px; font-weight: 600; }

/* ---- the dragged section, under the pointer ---- */
.ghost {
	position: fixed;
	z-index: 100;
	width: 100px;
	height: 100px;
	pointer-events: none;
	opacity: .9;
	filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
}
.ghost svg { display: block; width: 100%; height: 100%; border-radius: 6px; }

/* ---- the colour popover ---- */
.popover {
	position: absolute;
	z-index: 50;
	background: #fff;
	border: 1px solid #c9d0d8;
	border-radius: 10px;
	box-shadow: 0 6px 18px rgba(0,0,0,.16);
	padding: 8px;
	display: flex;
	flex-direction: column;
	min-width: 170px;
}
.popover-title { font-size: 12px; color: var(--muted); padding: 2px 6px 6px; }
.swatch {
	display: flex;
	align-items: center;
	gap: 10px;
	border: 0;
	background: none;
	border-radius: 6px;
	padding: 6px;
	font: inherit;
	text-align: left;
	cursor: pointer;
}
.swatch:hover { background: #eef3f8; }
.swatch[aria-pressed="true"] { background: #e2ecf7; font-weight: 600; }
.sizes { display: flex; gap: 6px; padding: 0 6px 4px; }
.popover > .popover-title:not(:first-child) { margin-top: 6px; border-top: 1px solid #e3e7eb; padding-top: 8px; }
.size {
	flex: 1;
	border: 1px solid #c9d0d8;
	background: #fff;
	border-radius: 6px;
	padding: 5px 8px;
	font: inherit;
	font-size: 13px;
	white-space: nowrap;
	cursor: pointer;
}
.size:hover { background: #eef3f8; }
.size[aria-pressed="true"] { background: #e2ecf7; border-color: var(--accent); font-weight: 600; }

/* the popover's colour dots */
.dot { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #22262a; flex: none; }
.dot[data-color="red"] { background: var(--red); }
.dot[data-color="yellow"] { background: var(--yellow); }
.dot[data-color="green"] { background: var(--green); }
.dot[data-color="transit"] { background: var(--transit); }
.dot[data-color="bicolour"] { background: linear-gradient(90deg, var(--green) 50%, var(--yellow) 50%); }

footer { padding: 18px 32px 28px; border-top: 1px solid #d3d9df; margin: 0 32px; padding-left: 0; font-size: 14px; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* a phone: the head, then the backboard and the sections */
@media (max-width: 760px) {
	header { padding: 16px 16px 0; }
	header h1 { font-size: 20px; }
	header p { font-size: 14px; }
	main { flex-direction: column; align-items: stretch; gap: 26px; padding: 18px 16px 40px; }
	footer { margin: 0 16px; }
	#light-side { min-width: 0; width: 100%; }
	/* room for three buttons: closer together */
	.stage { padding-right: 132px; }
	.tools { gap: 6px; left: calc(100% + 8px); }
	.backboard:not([data-backboard="none"]) .tools { left: calc(100% + var(--board) + 8px); }
	.palette { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
	/* a swipe on the list scrolls the page (a tap adds); the head's sections still drag */
	.choice { touch-action: pan-y; }
}
