:root {
	--gen-width: calc(100vw - 2rem);
	
	color-scheme: light dark;
	color: light-dark(black,whitesmoke);
	background-color: light-dark(whitesmoke,#404040);
}

body {
	width: clamp(var(--gen-width), var(--gen-width), 800px);
	margin: 0.5rem auto;
	font-size: 1.2rem;
}

h1, h2, h3, p, table, form, dl {
	margin: 0.5rlh 0.5rem;
}
heading {
	h1:has(+h3) {
		margin-bottom: 0.2rlh;
	}
	h1+h3 {
		margin-top: 0.2rlh;
	}
}

dialog#helpdialog {
	position: fixed;
	box-sizing: border-box;
	width: 100%;
	height: 60%;
	border: none;
	overflow: scroll;
	padding: 1em;
	border: 2px solid gainsboro;
	
	&:focus {
		outline: none;
	}
	
	&::backdrop {
		background-color: rgba(0,0,0,0.4);
	}
	
	button#closehelp {
		position: absolute;
		display: block;
		height: 2lh;
		top: calc(1em + 0.5rlh);
		right: calc(1em + 0.5rem);
		width: 4em;
		
		&:focus {
			outline: none;
		}
	}
	
	p:first-of-type {
		width: calc(100% - 4em);
	}
	
	dd {
		display: list-item;
		list-style-type: disc;
	}
	
	table {
		border-collapse: collapse;
		border: 1px solid black;
		
		td,th {
			border: 1px solid black;
			padding: 0.2rlh 0.3rem;
		}
		td:first-of-type {
			padding-top: 0.1rlh;
			padding-bottom: 0.3rlh;
		}
	}
}

form {
	display: grid;
	grid-template-rows: auto;
	justify-items: stretch;
	gap: 0 0.5rem;
	fieldset#maincontrols {
		grid-area: gencon;
	}
	fieldset#tagbuttons {
		grid-area: tags;
	}
	fieldset.input {
		grid-area: input;
	}
	fieldset.output {
		grid-area: output;
	}
	h3.ioheaders {
		grid-area: iohead;
	}
	fieldset.iocontrols {
		grid-area: iocon;
	}
	textarea.ioboxes {
		grid-area: iobox;
	}
	
	textarea {
		/* height: 10lh; */
		margin-bottom: 0.25rlh;
	}
	
	h3 {
		margin: 0.5lh 0 0.25lh;
	}
	
	button {
		font-size: 1.0rem;
		height: 2lh;
		border: 0.1em solid grey;
		border-radius: 0.2em;
	}
	
	fieldset {
		border: none;
		margin: 0;
		padding: 0.2em 0;
		
		&.generalcontrols {
			display: flex;
			flex-flow: row wrap;
			gap: 0.3em;
			
			.tagbutton {
				flex: 1 1 max-content;
				padding: 0 1em;
				&.on {
					background-color: #1F9EFB;
				}
			}
			.controlbutton {
				padding: 0 2em;
			}
		}
		&#maincontrols {
			justify-content: space-between;
		}
		
		&.iocontrols button {
			margin-right: 0.25em;
			font-size: 1.2rem;
			padding: 0;
		}
		&.input, &.output {
			display: grid;
			grid-template-rows: auto;
			gap: 0 0.5rem;
		}
	}
}
label#modecontrol {
	cursor: pointer;
	align-self: center;
	font-family: sans-serif;
	
	.switch {
		position: relative;
		display: inline-block;
		width: 2.4em;
		height: 1.2em;
		
		input {
			opacity: 0;
			width: 0;
			height: 0;
			
			&:checked + .slider {
				background-color: #1F9EFB;
				
				&:before {
					-webkit-transform: translateX(1.0em);
					transform: translateX(1.0em);
				}
			}
		}
		
		.slider {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			background-color: silver;
			border-radius: 0.3em;
			-webkit-transition: 0.4s;
			transition: 0.4s;
			
			&:before {
				position: absolute;
				content: "";
				width: 1.0em;
				height: 0.8em;
				left: 0.2em;
				bottom: 0.2em;
				background-color: #404040;
				border-radius: 0.1em;
				-webkit-transition: 0.4s;
				transition: 0.4s;
			}
		}
	}
}

/* https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer */
@media (max-width: 450px) {
	heading {
		h1 { font-size: 2.0rem; }
		h3 { font-size: 1.2rem; }
	}
}
@media (pointer: coarse) {
	textarea {
		height: 10lh;
		font-size: 1.5rem;
	}
	
	dialog#helpdialog {
		width: 100%;
		height: 100%;
	}
	heading > * {
		text-shrink: per-line font-size;
	}
	
	fieldset.iocontrols {
		display: flex;
		button {
			flex: 1 1 max-content;
			font-size: 1.0 rem;
		}
	}
}
@media (pointer: coarse), (orientation: portrait) and (pointer: fine) {
	form {
		grid-template-columns: 1fr;
		grid-template-areas:
			"gencon"
			"tags"
			"input"
			"output";
		fieldset.input {
			grid-template-columns: 1fr;
			grid-template-areas:
				"iohead"
				"iocon"
				"iobox";
		}
		fieldset.output {
			grid-template-columns: max-content;
			grid-template-areas:
				"iocon iohead"
				"iobox iobox";
		}
	}
}
@media (pointer: fine) {
	textarea {
		height: 16lh;
		font-size: 1.2rem;
	}
	
	dialog#helpdialog {
		width: 60%;
		height: 60%;
	}
}
@media (pointer: fine) and (min-width: 450px) {
	fieldset.iocontrols button {
		width: 6em;
	}
}
@media (orientation: landscape) and (pointer: fine) {
	form {
		grid-template-columns: 1fr 1fr;
		grid-template-areas:
			"gencon gencon"
			"tags tags"
			"input output";
		fieldset.input, fieldset.output {
			grid-template-columns: max-content;
			grid-template-areas:
				"iocon iohead"
				"iobox iobox";
		}
	}
}

/*
	Copyright 2025 Calyo Delphi (dragon-architect)

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

		http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/