* { box-sizing: border-box; }

#the_canvas {
	margin: 0;
	padding: 0;
	position: absolute;
}

#sidebar {
	background: #f2f3f6;
	margin: 0;
	position: absolute;
	display: flex;
	padding: 10px;
	gap: 8px;
}

#sidebar_buttons {
	display: flex;
	gap: 7px;
}

#sidebar button {
	border: none;
	border-radius: 10px;
	background: #ffffff;
	color: #2c2c3a;
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	padding: 6px 8px;
	box-shadow: 0 1px 3px rgba(30, 30, 60, 0.12);
	transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

#sidebar button:hover:not(:disabled) {
	background: #6c5ce7;
	color: #ffffff;
	box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
	transform: translateY(-1px);
}

#sidebar button:active:not(:disabled) {
	transform: translateY(1px);
	box-shadow: 0 1px 2px rgba(30, 30, 60, 0.2);
}

#sidebar button:disabled {
	opacity: 0.45;
	cursor: default;
}

/* a document button split into a wide "read" half and a narrow "destroy" (throw-it-around) half */
.split_button {
	display: flex;
	gap: 6px;
}
.split_button .read_half {
	flex: 1 1 auto;
	min-width: 0;
}
.split_button .destroy_half {
	flex: 0 0 auto;
	width: 2.8em;
	padding: 4px;
	font-size: 16px;
}

/* placeholder for a future ad unit */
#ad_slot {
	border: 2px dashed #c7cad4;
	border-radius: 10px;
	background: #fafbfc;
	color: #a2a6b4;
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
}

/* the chapter objective, above the buttons. Hidden on pages that have none. */
#objective_panel {
	flex: 0 0 auto;
	background: #ffffff;
	border-radius: 10px;
	border-left: 4px solid #6c5ce7;
	padding: 7px 9px;
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	color: #2c2c3a;
	font-size: 12px;
	line-height: 1.35;
}

#objective_panel.hidden { display: none; }

#objective_label {
	display: block;
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #6c5ce7;
	margin-bottom: 2px;
}

/* quiet progress, shown only once you are on the right track */
#objective_progress {
	display: block;
	margin-top: 3px;
	font-size: 10px;
	font-weight: 600;
	color: #8b90a0;
}

/* done: the objective goes green and gets a tick */
#objective_panel.done { border-left-color: #2f9e5e; }
#objective_panel.done #objective_label { color: #2f9e5e; }
#objective_panel.done #objective_text::before { content: "\2713  "; font-weight: 700; color: #2f9e5e; }

@media screen and (orientation: landscape) {
	#the_canvas { top: 0; left: 0; width: 80%; height: 100%; }
	#sidebar { top: 0; left: 80%; width: 20%; height: 100%; flex-direction: column; }
	/* Grid, not flex, so every row is EXACTLY the same height. With `flex: 1 1 0` the plain buttons and the
	   split-button pairs still came out at different heights (82px vs 70px) because flex sizing falls back
	   on each item's own content; `grid-auto-rows: 1fr` makes the rows equal by construction.
	   min-height:0 lets them shrink - a grid/flex item defaults to min-height:auto and will not go below
	   its own content, which is what pushed the last buttons out of sight behind the ad slot. */
	#sidebar_buttons { flex: 1 1 auto; min-height: 0; display: grid; grid-auto-rows: 1fr; gap: 7px; }
	#sidebar_buttons > button, #sidebar_buttons > .split_button { min-height: 0; }
	.split_button > button { min-height: 0; }
	/* the ad yields space when the column is tight, instead of squeezing the buttons out */
	#ad_slot { flex: 0 1 220px; min-height: 110px; }
}

/* portrait (e.g. a phone held upright): stack the sidebar below the canvas as two rows of buttons
   with a full-width ad banner at the very bottom. */
@media screen and (orientation: portrait) {
	#the_canvas { top: 0; left: 0; width: 100%; height: 70%; }
	#sidebar { top: 70%; left: 0; width: 100%; height: 30%; flex-direction: column; }
	#sidebar_buttons { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
	#ad_slot { flex: 0 0 56px; width: 100%; }
	#sidebar button { font-size: 12px; padding: 4px; }
}
