
/*======= Font declarations =======*/

@font-face {
	font-family: "Baskerville";
	src: url("baskvl.ttf");
}

@font-face {
	font-family: "Crom";
	src: url("Crom.ttf");
}

@font-face {
	font-family: "Inconsolata";
	src: url("Inconsolata-Regular.ttf");
}

/*======= Page setup =======*/

:root {
	--PW: 210mm;	/* Page width (A4) */
	--PH: 296.6mm;	/* Page height (A4); slightly less than 297mm to avoid potential overflow */
	--margin-horizontal: 6mm;
	--margin-vertical: 6mm;
	--ControlW: 80ch;	/* Width of control box */
	--edit-colour: #ffffee;	/* Colour for click-to-edit elements */
}

html {
	background-color: #000000;
	font-family: Baskerville;
	font-size: 10pt;
}

body {
	margin: 0;
	padding: 0;
}

/*======= Component controls =======*/

body.boxblack {
	--titlebg: #000000;
	--titlefg: #ffffff;
	--titleborder: #000000;
}

body.boxgrey {	/* This is the default */
	--titlebg: #c0c0c0;
	--titlefg: #000000;
	--titleborder: #c0c0c0;
}

body.boxwhite {
	--titlebg: #ffffff;
	--titlefg: #000000;
	--titleborder: #000000;
}

/*======= A section.page is a virtual paper so we can layout for printing =======*/

section.page {
	width: calc( var(--PW) - 2 * var(--margin-horizontal) );
	height: calc( var(--PH) - 2 * var(--margin-vertical) );
	background-color: #ffffff;
	box-shadow: 0px 0px 12px #ffff00;
	margin: 0;
	margin-left: auto;
	margin-right: max(5mm , ( 100% - var(--ControlW) - 5mm - var(--PW) ) / 2 );
	padding-left: var(--margin-horizontal);
	padding-right: var(--margin-horizontal);
	padding-top: var(--margin-vertical);
	padding-bottom: var(--margin-vertical);
	page-break-inside: avoid;
	page-break-after: auto;

	display: flex;
	margin-bottom: 10mm;
	position: relative;
}

.page .selected {
	box-shadow: 0 0 2mm 2mm #80aa80;
}

/*======= Layout/main =======*/

#main {
	margin-top: 1em;
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	gap: 1em;
}

.hbox {
	display: flex;
	flex-direction: row;
	gap: 1em;
}

.vbox {
	display: flex;
	flex-direction: column;
	gap: 1em;
}

.toppad {
	margin-top: 0.3em;
}


@media screen and (max-width: 1279px) {
	.rowbox {
		flex-wrap: wrap;
	}

	#main #controls {
		min-width: 290px;
		padding: 0.5em;
	}

	#controls .toppad {
		margin-top: 0.2em;
	}

	#controls h1 {
		margin-top: 0;
		margin-bottom: 0.3em;
	}

	.page {
		width: calc((210mm - 2 * var(--margin-horizontal) ) * 0.8333) !important;
	}
	.page > * {
		&:is(am-grog) {
			width: calc(210mm - 2 * var(--margin-horizontal) ) !important;
		}
		&:is(am-trinket) {
			width: calc( (210mm - 2 * var(--margin-horizontal) - 5mm ) / 2 ) !important;
		}
		transform-origin: top left;
		transform: scale(0.8333);
		margin-right: -20mm;
	}
}

/*======= Controls slab =======*/

#controls {
	position: sticky;
	top: 1em;
	padding: 1em;
	width: calc( 100% - var(--PW) - 10mm - 10mm );
	padding-top: 0.5em;
	padding-bottom: 2em;
	max-width: var(--ControlW);
}

.slab {
	color: #000000;
	background-color: #aaaaa5;
	background-image: url(../images/noise256.png);
	text-shadow: 1px 1px 2px #ffff00;
	box-shadow: inset 2px 2px 3px 3px #cccccc , inset -2px -2px 3px 3px #858585;
	border-radius: 5px;
}

/*======= Styling of actual controls =======*/

.slab label {
	font-weight: bold;
	display: inline-block;
}

#selectedgrog,
#selecteditem {
	font-size: 80%;
}

.slab select,am-dialogue select {
	background-color: #ccccc2;
	color: #000000;
	text-shadow: 1px 1px 4px #a0a0ff;
	box-shadow: inset 2px 2px 2px 2px #808080;
	padding: 4px;
	border: 2px solid #aaaaff;
	border-top-left-radius: 6px;
	border-bottom-left-radius: 6px;
}

.slab button {
	color: #ffffff;
	background-color: #404040;
	background-image: url(../images/noise256.png);
	padding: 4px;
	border: 2px solid #aaaaff;
	border-radius: 6px;
}

.slab button:disabled {
	color: #808080;
	background-color: #404040;
	border: 2px solid #a0a0a0;
	border-radius: 6px;
}

.slab button:not(:disabled):active {
	background-color: #4040a0;
	background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 0%, #a0a0ff 100% );
	animation: 1s linear 0.1s infinite alternate buttonbg;
}

@keyframes buttonbg {/*{{{*/
	0% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 0%, #a0a0ff 100% );
	}
	
	10% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -10%, #a0a0ff 90%, #4040a0 190% );
	}
	
	20% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -20%, #a0a0ff 80%, #4040a0 180% );
	}
	
	30% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -30%, #a0a0ff 70%, #4040a0 170% );
	}
	
	40% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -40%, #a0a0ff 60%, #4040a0 160% );
	}
	
	50% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -50%, #a0a0ff 50%, #4040a0 150% );
	}
	
	60% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -60%, #a0a0ff 40%, #4040a0 140% );
	}
	
	70% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -70%, #a0a0ff 30%, #4040a0 130% );
	}
	
	80% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -80%, #a0a0ff 20%, #4040a0 120% );
	}

	90% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #4040a0 -90%, #a0a0ff 10%, #4040a0 110% );
	}
	
	100% {
		background-image: url(../images/noise256.png), linear-gradient( 45deg, #a0a0ff 0%, #4040a0 100% );
	}
}/*}}}*/

.slab h1,am-dialogue h1 {
	font-family: 'Crom';
	font-size: 150%;
	text-align: center;
	margin-left: 0.5ch;
	margin-right: 0.5ch;
}

.slab legend {
	font-size: 120%;
}

.slab h1[title]::after {
	content: attr(title);
	font-family: Baskerville;
	font-size: 50%;
	width: 100%;
	height: 1em;
	display: block;
}

#printbox label {
	display: inline-block;
	text-align: right;
	width: 8rem;
}

#printbox select {
	width: calc( 100% - 8.5rem );
}

#printbox .colbox {
	flex-grow: 4;
}

button#print {
	font-weight: bold;
	min-width: 12ch;
	color: #ccffcc;
	text-shadow: 0 0 30px #ff00ff;
}

fieldset.closed {
	height: 0;
	padding: 0;
	overflow: hidden;
	margin-top: 1em;
	margin-bottom: 1em;
}

fieldset.closed legend::after {
	content: " ▶ (click to open)";
}

#controls input:where([type=text],[type=number]):invalid {
	border: 2px solid #ff0000;
}

.rowbox {
	display: flex;
	flex-direction: row;
}

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

.slab input:where([type=text],[type=number]) {
	background-color: #ccccc2;
	color: #000000;
	text-shadow: 1px 1px 4px #a0a0ff;
	box-shadow: inset 2px 2px 2px 2px #808080;
	border: 2px solid #aaaaff;
	border-radius: 6px;
	text-align: center;
	appearance: textfield;
}

.slab input:where([type=text],[type=number]):invalid {
	border: 2px solid #ff0000;
}

/*======= Styled checkbox → toggle =======*/

.slab input[type=checkbox] {
	--W: 4ch;
	--H: 1.2em;
	appearance: none;
	position: relative;
	width: var(--W);
	height: var(--H);
	margin-bottom: -3px;
	border: 1px solid black;
	box-shadow: 0px 0px 3px 3px #aaaaff;
	border-radius: 3px;
	background-color: rgba(0,0,0,0.4);
}

.slab input[type=checkbox]::before {
	content: " ";
	text-align: center;
	color: #aaaaaa;
	position: absolute;
	left: 0px;
	top: 0px;
	width: calc( var(--H) - 1px );
	height: 100%;
	border-radius: 3px;
	background-color: #404040;
	background-image: url(images/noise256.png);
	box-shadow: inset 0px 0px 2px 1px #ffff;
	transition: all 0.2s;
}

.slab input[type=checkbox]:checked {
	background-color: rgba(0,255,0,0.3);
}

.slab input[type=checkbox]:checked::before {
	left: calc( var(--W) - var(--H));
	content: "✓";
	color: #ffffaa;
}

/*======= Popup dialogue ======= */

am-dialogue {
	background-color: #aaaaa5;
	background-image: url(../images/noise256.png);
}

am-dialogue h1 {
	text-shadow: 1px 1px 2px #ffff00;
}

am-dialogue select {
	width: 100%;
	font-family: Baskerville;
	font-size: 133%;
}

/*==== Common printing stuff like hiding controls and set papersize  =====*/

@page {
	size: A4;
	margin: 0mm;
}

@media print {
	html,body {
		overflow: hidden;
	}

	#main {
		margin: 0;
	}

	#pages section.page {
		margin: 0;
		box-shadow: none;
		overflow: hidden;
	}

	#controls {
		display: none;
	}

	section.page .selected {
		box-shadow: none;
	}
}

/* vi: set ts=3 foldmethod=marker: */

