/*** BASICS ***/

form {
	display: flex;
	flex-flow: column nowrap;
	gap: 1em;
	margin: 0 0 1em 0;
	clear: both;
	counter-reset: fieldsets;
}
form fieldset {
	display: flex;
	flex-flow: column nowrap;
	gap: 1em;
	position: relative;
	margin: 0;
	border: none;
	border-top: thin solid #666;
	padding: .5em .5em .75em .5em;
	counter-increment: fieldsets;
}
form fieldset:active, form fieldset:focus-within, form fieldset:hover {
	box-shadow: 0 0 5em 0 rgba(170, 170, 170, .5);
}
form legend {
	margin: 0 auto;
	padding: 0 .5em;
	font-weight: bold;
}
.dialogToggle ~ form legend {
	margin-left: -1em;
}
form hr {
	width: calc(100% + 1em);
	margin: 0 -.5em;
}
form > *, form fieldset > :not(legend, hr), form fieldset > .inputWrapper {
	margin: 0;
}
form .buttonBar.center {
	justify-content: center;
}

form .inputWrapper {
	display: inline-flex;
	position: relative;
	margin: 0 3em 1em 0;
	flex-flow: row nowrap;
	justify-content: space-between;
	align-items: baseline;
	gap: 1em;
	max-width: 20em;
}
form .buttonBar .inputWrapper {
	margin-bottom: 0;
}
form .gridLayout .inputWrapper {
	max-width: none;
	margin: 0;
	gap: .5em;
}
form .inputWrapper[data-unit]::after {
	content: attr(data-unit);
	position: absolute;
	right: 2em;
	font-size: .8rem;
	line-height: 1.875;
	opacity: .5;
	pointer-events: none;
}
form fieldset > button, form fieldset > .button {
	margin: .25em .75em .75em 0;
}
form .gridLayout > button, form .gridLayout > .button {
	margin: 0;
	justify-self: left;
	align-self: center;
}
form .gridLayout p, form .gridLayout object {
	margin: 0;
	grid-column: 1 / -1;
}

#helpText {
	position: absolute;
	right: clamp(-25em, calc((100vw - 62em) / -2), -15em);
	display: flex;
	flex-flow: column nowrap;
	gap: 0 2em;
	width: clamp(15em, calc((100vw - 62em) / 2), 25em);
	padding: 1em .75em .25em 1em;
	background: #EEE;
}
#helpText h2 {
	font-size: 1rem;
}
#helpText p {
	text-align: justify;
	font-size: .8rem;
}

.dialogToggle {
	position: relative;
	margin-bottom: -.75em;
	z-index: 5;
}
* + .dialogToggle {
	margin-top: .75em;
}
.dialogToggle > * {
	border-bottom-left-radius: 0 !important;
	border-bottom-right-radius: 0 !important;
}
.dialogToggle .current {
	background: #EEE;
	font-weight: bold;
}

#formSeparator {
	margin: 1em -1em 1.25em -1em;
	border: 2px dashed #666;
	border-bottom: none;
}


/*** INPUTS ***/

form input, form select, form textarea {
	margin: 0;
	width: 10em;
	min-height: 1.5rem;
	border: thin solid #999;
	outline: none;
	box-shadow: none;
	color: inherit;
	background: inherit;
	font: inherit;
	font-size: .8rem;
}
form input[type=text], form input[type=password], form input[type=email], form input[type=tel],
form input[type=number], form input[type=date], form input[type=search],
form select {
	padding: 2px;
}
form input[type=checkbox], form input[type=radio] {
	width: auto !important;
	min-width: inherit !important;
	min-height: inherit;
}
form input[type=file] {
	width: auto !important;
	max-width: 30em;
	padding-right: 2px;
}
form textarea {
	width: 20em;
	min-height: 4em;
	height: auto;
	padding: 2px;
	resize: none;
}
form .textarea {
	align-self: start;
	align-items: start;
}
#uploadResults textarea, #contact textarea, #newUser textarea, #lpcmUpload textarea {
	width: calc(100% - 10em);
}
form .minMaxInput input, form .minMaxInput select {
	width: 5.7em;
}
form .minMaxInput div {
	white-space: nowrap;
}
form .shortInput input, form .shortInput select {
	width: 7.5em;
	min-width: 7.5em;
}
form .longInput input, form .longInput select {
	width: 12.5em;
	min-width: 12.5em;
}
form .labelInput {
	border-top: none;
	border-left: none;
	border-right: none;
}
form .flexEnd {
	margin-left: auto;
}

form input:invalid, form select:invalid, form textarea:invalid {
	border-color: #900;
	box-shadow: 0 0 .5em 0 #900;
}
form input:active, form input:focus, form input:hover,
form select:active, form select:focus, form select:hover,
form textarea:active, form textarea:focus, form textarea:hover {
	border-color: #048;
	box-shadow: 0 0 .5em 0 #048;
}
form input:disabled, form select:disabled, form textarea:disabled {
	background: #CCC;
	border-color: #999;
	box-shadow: none;
}
form input[readonly], form textarea[readonly] {
	border: thin dashed #333;
	box-shadow: none;
}

form .inputWrapper.fileInput {
	flex-flow: row wrap;
	justify-content: normal;
	align-items: center;
	gap: .5em 1em;
}
form .fileInput .clearFile {
	margin: 0 0 0 .5em;
}
form .fileInput > img {
	max-width: 100px;
	max-height: 50px;
}

form .passwordInput {
	margin-bottom: .75em !important;
}
form .passwordInput .info {
	position: absolute;
	top: 2em;
	right: 3em;
}
form .longInput.passwordInput .info {
	right: 5em;
}

form output {
	align-self: center;
	margin: 0 .5em;
	font: inherit;
}

form .inputWrapper input + .hangingText {
	display: inline-block;
	margin-top: -1.5em;
	margin-left: 1.5em;
}


/*** FORM SPECIFIC ***/

#inputLens fieldset:active::before, #inputLens fieldset:focus-within::before, #inputLens fieldset:hover::before {
	content: counter(fieldsets);
	position: absolute;
	left: -3rem;
	font-size: 2rem;
	font-weight: bold;
	line-height: 1;
	color: #FFF;
}

#userSettings img {
	max-width: 500px;
	max-height: 200px;
	margin: 0 2em 0em 0;
	vertical-align: middle;
}
#userSettings table {
	border-collapse: separate;
	border-spacing: .5em .125em;
	max-width: 50em;
}
#userSettings table th ,
#userSettings table td:nth-of-type(3) {
	text-align: center;
	font-weight: normal;
	font-style: italic;
}

#editUser .pwSet, #editUser .otpwSet {
	margin: 0 5em 1em 0;
}
#verificationPhoto {
	margin: .25em 0 .75em 0;
	border-top: thin solid #666;
	text-align: center;
}
#verificationPhoto img {
	max-width: 100%;
	max-height: 25em;
	vertical-align: middle;
}

#contact .inputWrapper [type=text], #contact .inputWrapper [type=email] {
	width: 20em;
}

#lpcmInput #case table {
	width: 90%;
}
#lpcmInput #case .eye {
	position: absolute;
	top: .25rem;
	right: .5rem;
}
#inputLens #powers select, #editLens #powers select,
#lpcmInput #exam select, #lpcmUpload select {
	width: auto;
}
#lpcmInput #outcome .caution {
	position: relative;
	width: max-content;
}
#lpcmInput .caution input {
	color: #600;
}
#lpcmInput .caution::after {
	content: '!';
	font-weight: bold;
	color: #C00;
	opacity: 1;
}
#lpcmInput .lensGood {
	background-color: #9F9;
}
#lpcmInput .lensWarning {
	background-color: #EE0;
}

#lpcmInput #eyeCanvas {
	margin: -1em;
	align-self: start;
}
#lpcmInput table, #lpcmInput .scrollable {
	border-collapse: collapse;
	line-height: 1.2;
}
#lpcmInput table tr > :first-child {
	padding-left: 0;
}
#lpcmInput table th {
	padding: .25em .5em;
}
#lpcmInput #selectedLens th:first-child {
	text-align: left;
}
#lpcmInput table td {
	padding: .5em .75em;
}
#lpcmInput #ambientLenses th[data-cylinder] {
	border-bottom: 2px solid #333;
}
#lpcmInput #ambientLenses th[data-equivalent] {
	border-right: 2px solid #333;
}
#lpcmInput table input {
	margin: -.25em;
	font-size: inherit;
	width: 5em;
	min-width: 5em;
	padding: 1px 3px;
}

#lpcmInput #ambientLenses .arrowhead {
	position: relative;
}
#lpcmInput #ambientLenses .arrowhead::after {
	content: '\27A4';
	position: absolute;
	right: -.2em;
	bottom: -.65em;
	color: #333;
	font-size: 1.25em;
}
#lpcmInput #ambientLenses [data-equivalent].arrowhead::after {
	transform: rotate(90deg);
	right: -.6em;
	bottom: -.3em;
}
#lpcmInput #strikethroughOutcome {
	position: absolute;
	top: 0;
}

/*#qrScan #video-container {
	position: relative;
	width: max-content;
	height: max-content;
	overflow: hidden;
}
#qrScan #video-container .scan-region-highlight {
	border-radius: 1.5em;
	outline: rgba(0, 0, 0, .25) solid 50vmax;
}
#qrScan #video-container .scan-region-highlight svg {
	display: none;
}*/


/* MEDIA QUERIES */

@media screen and (max-width: 40em) {
	#helpText h2 {
		flex: auto !important;
	}
	
	form, form fieldset {
		gap: 1.5em;
	}
	form legend {
		margin: 0 auto !important;
	}
	.dialogToggle {
		width: 100%;
		margin-bottom: .75em;
	}
	.dialogToggle > * {
		width: inherit;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	
	form .inputWrapper {
		width: 100%;
		max-width: inherit !important;
		margin-right: 0 !important;
		margin-bottom: 2em;
		gap: 1em !important;
	}
	.inputWrapper input, .inputWrapper select {
		font-size: inherit;
	}
	form .inputWrapper[data-unit]::after, #lpcmInput .caution::after {
		font-size: inherit;
		line-height: 1.75;
	}
	#uploadResults textarea, #contact textarea, #newUser textarea, #lpcmUpload textarea {
		width: 100%;
	}
	form .fileInput > div {
		margin-left: auto;
	}
	form .buttonBar {
		justify-content: center;
	}
	form .longInput, form .longInput .inputWrapper, form .textarea {
		flex-wrap: wrap;
	}
	form .gridLayout .roundButton {
		justify-self: center;
	}
	form .passwordInput .info {
		top: 2.5em;
	}
	
	#contact .inputWrapper [type=text], #contact .inputWrapper [type=email] {
		width: 15em;
	}
	#lpcmInput .scrollable {
		max-width: calc(100vw - 3em);
		overflow-x: auto;
	}
	#lpcmInput .buttonBar {
		max-width: 25em;
		margin: 0 auto;
	}
	#lpcmInput .buttonBar .flexEnd {
		margin-left: 0 !important;
	}
}

@media screen and (max-width: 50em) {
	#lpcmInput #eyeCanvas {
		/* grid-row: 2 / 4; */
		/* grid-column: unset; */
		margin: -1em -4em -1em -.5em;
	}
}

@media screen and (max-width: 91em) {
	#helpText {
		position: fixed;
		right: auto !important;
		bottom: 0;
		width: 100vw;
		max-width: 60em;
		margin: 0em -1em;
		flex-direction: row;
		align-items: baseline;
	}
	#helpText h2 {
		flex: 0 0 content;
	}
	#helpText p {
		max-height: 30vh;
		overflow: auto;
	}
}

@media screen and (min-width: 100em) {
	#helpText {
		right: clamp(-25em, calc((100vw - 77em) / -2), -15em);
		width: clamp(15em, calc((100vw - 77em) / 2), 25em);
	}
}

@media print {
	form fieldset {
		padding-bottom: .5em;
	}
	form .inputWrapper::after, #lpcmInput .caution::after {
		right: 3px !important;
	}
	form input, form select {
		min-height: unset !important;
		padding: 1px 3px !important;
	}
	input[type="number"] {
		-moz-appearance: textfield;
	}
	input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button {
		-webkit-appearance: none;
		margin: 0;
	}
	.inputWrapper [type=radio], .inputWrapper label:has(> [type=radio]:not(:checked)) {
		display: none;
	}
	.inputWrapper label:has(> [type=radio]:checked:not(:disabled)) {
		text-decoration: underline;
	}
	#lpcmInput #exam .gridLayout:nth-of-type(2) .inputWrapper {
		max-width: 24em;
	}
	#lpcmInput #outcome table input {
		width: 5em;
		min-width: 5em;
	}
}
