/**
 * Copyright 2022 Google LLC
 *
 * 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.
 */

html,
body {
	margin: 0;
	height: 100%;
	display: flex;
	flex: 1;
	align-items: stretch;
	justify-content: stretch;
	background-color: #eef1f6;
	font: 100%/1.3 system-ui, 'Helvetica Neue', Helvetica, Verdana, sans-serif;
	color: #2d353d;
	overflow: hidden;
}

* {
	box-sizing: border-box;
}

#testContainer {
	position: fixed;
	top: 0;
	left: 50%;
	width: var(--viewport-width, 800px);
	height: var(--viewport-height, 600px);
	margin: 0 0 0 calc(var(--viewport-width, 800px) / -2);
	overflow: hidden;
	z-index: 2;
}

img,
svg {
	user-select: none;
	-webkit-user-drag: none;
}

.btn {
	padding: 0.3rem 1rem;
	font-weight: 500;
	color: #e8ecf3;
	background: #073c6e;
	border: none;
	border: 2px solid #073c6e;
	border-radius: 1.2rem;
	font-size: 1.2rem;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
}
.btn:hover,
.btn:focus {
	background: #064e91;
}
.btn.alt {
	background: #66696c;
	border-color: #66696c;
}
.btn.alt:hover,
.btn.alt:focus {
	background: #76797c;
}

.btn > i {
	position: relative;
	display: inline-block;
	font-style: normal;
	transform: translateX(-0.2em);
	transition: transform 150ms ease;
}
.btn:hover > i {
	transform: translateX(-0.3em);
}

main {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: stretch;
	justify-content: stretch;
	overflow: hidden;
	min-height: var(--viewport-height, 600px);
	min-width: var(--viewport-width, 800px);
}
main > header {
	display: flex;
	align-items: center;
	padding: 0.5rem;
	gap: 0.5rem;
	background: #fff;
}
header h3 {
	flex: 1;
	margin: 0;
	font: inherit;
	font-size: 1.5rem;
	text-align: center;
}
main > h1 {
	flex: 0 0 auto;
	margin: 0;
	text-align: center;
}

/** Intro view */
.intro {
	display: flex;
	flex: 1;
	flex-wrap: wrap;
	justify-content: space-evenly;
	align-items: center;
	align-content: center;
	overflow: hidden;
}
.intro .overview {
	flex: 0 0 auto;
	display: flex;
	justify-content: center;
	align-items: center;
}
.intro .overview > div {
	max-width: 30em;
}
.intro .benchmarks-list {
	flex: 0 0 auto;
	white-space: nowrap;
}
.benchmarks-list {
	display: flex;
	flex-direction: column;
}
.benchmarks-list > h3 {
	margin: 0;
	padding: 0.5em 0.5em 0;
}
.benchmarks-list > :last-child {
	flex: 1;
	padding: 0 0.5em 0 0.25em;
	overflow: auto;
}
.benchmarks-list label {
	display: block;
	padding: 0.1em 0.5em;
	display: flex;
	align-items: center;
	border-radius: 5px;
}
.benchmarks-list label:hover,
.benchmarks-list label:focus {
	color: #000;
	background-color: rgba(255, 255, 255, 0.5);
}
.benchmarks-list input {
	position: relative;
	left: -0.3em;
}
.benchmarks-list .disabled {
	opacity: 0.85;
	text-decoration: line-through;
	text-decoration-color: rgba(104, 75, 108, 0.2);
	text-decoration-thickness: 0.5em;
}

/** Running view */
.running {
	display: flex;
	flex-direction: column;
	padding-top: var(--viewport-height, 600px);
	text-align: center;
}
.running .status {
	position: relative;
	z-index: 1001;
}
.progress {
	position: relative;
	margin: 5px auto 2px;
	width: 500px;
	height: 14px;
	border-radius: 7px;
	background: #fff;
	border: 1px solid #aaa;
	font-size: 12px;
}
.progress .progress-completed {
	position: relative;
	width: 0;
	height: 14px;
	top: -1px;
	border-radius: 7px;
	background: #073c6e;
	color: #fff;
	overflow: hidden;
	z-index: 2;
}
.progress span {
	position: absolute;
	display: block;
	left: 100px;
	top: -1px;
	width: 300px;
	z-index: 1;
}

.config {
	margin: 20px auto;
}
.config form {
	padding: 20px;
}
.config h3 {
	margin: 0;
	padding: 0.5em;
	box-shadow: 0 -1px 0 -0.5px #c2cdd7;
	font: inherit;
	font-size: 80%;
	opacity: 0.6;
}
.config code {
	font: 90%/1.3 'Source Sans Pro', Menlo, Consolas, monospace;
	color: #073c6e;
}
.config fieldset {
	padding: 1em;
	margin: 0 0 0.5em;
	border: none;
	border-radius: 5px;
}
.config fieldset.options label + label {
	padding: 0.1em 0;
	font-size: 90%;
}
.config fieldset:hover {
	background: rgba(255, 255, 255, 0.2);
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}
body .config fieldset:focus-within {
	background: rgba(255, 255, 255, 0.35);
	box-shadow: 0 0 0 1px #fff;
}
.config label {
	display: block;
	min-width: 20em;
}
.config input,
.config textarea,
.config select {
	margin: 0 1em;
	padding: 0.25em 0.5em;
	border: 1px solid #073c6e;
	border-radius: 0.25em;
	max-width: 11.5em;
	background: #fff;
	font: inherit;
}
.config input[type='number'] {
	width: 5em;
}
.config input[type='checkbox'],
.config input[type='radio'] {
	margin: 0 0.4em;
	vertical-align: -0.2em;
	zoom: 1.25;
}
.config aside {
	display: block;
	font-size: 80%;
	opacity: 0.3;
	min-width: 10em;
}
.config fieldset:hover aside,
.config fieldset:focus-within aside {
	opacity: 0.7;
}

/** Results view */
.results {
	text-align: center;
	overflow: auto;
}
.results h4 {
	font: inherit;
	font-size: 1.6rem;
	color: #677b8e;
	max-width: 600px;
	margin: 1rem auto;
	padding: 0.5rem;
	box-shadow: 0 -1px 0 -0.5px #c2cdd7;
}
.results .score {
	display: flex;
	align-items: center;
	justify-content: center;
}
.results .score dt {
	font-size: 2.5rem;
	color: #677b8e;
}
.results .score output {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 3rem;
	padding: 2px 0.5rem;
	margin: 0 0.5rem;
	border-radius: 10px;
	background: #fff;
	line-height: 1.1;
}
.results .score dd {
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 0 0 1rem;
}
.results .score small {
	margin-left: 0.5rem;
	font-size: 2rem;
	color: #677b8e;
}
.results .score .unit {
	color: #677b8e;
	font-size: 1rem;
}

.results .test-steps {
	margin: auto;
}

.results .test-steps dl {
	display: flex;
	align-items: center;
	justify-content: center;
}
.results .test-steps dt {
	flex: 0 0 12em;
	padding-bottom: 16px;
	text-align: right;
}
.results .test-steps dd {
	display: flex;
	margin-left: 1em;
}
.results .test-steps ul {
	margin: 3px 0 0 3px;
	padding: 0;
	list-style: none;
	font-size: 11px;
	line-height: 1;
	text-align: left;
	white-space: nowrap;
	width: 12em;
}
.results .test-steps li::before {
	content: '● ';
	opacity: 0.3;
}

.intro footer,
.results footer {
	display: flex;
	flex: 0 0 100%;
	margin: 10px auto;
	padding: 10px;
	box-shadow: 0 -1px 0 -0.5px #c2cdd7;
	flex-direction: row;
	justify-content: center;
	gap: 20px;
}

.details-toggle {
	display: inline-block;
	padding: 2px 10px 2px 5px;
	margin: 0 300px 2px 0;
	background: #fff;
	border-radius: 5px;
	border: 1px solid #ddd;
	opacity: 0.7;
	cursor: pointer;
	user-select: none;
	transition: border-color 250ms ease, opacity 250ms ease;
}
.details-toggle:hover,
.details-toggle:focus-within {
	border-color: #bbb;
	opacity: 1;
}
.details-toggle input {
	display: inline-block;
	appearance: none;
	width: 1em;
	height: 1em;
	border: none;
	background: none;
}
.details-toggle input:after {
	content: '▶';
	opacity: 0.5;
	display: inline-block;
	transform-origin: 50%;
	position: relative;
	transition: all 250ms ease;
}
.details-toggle input:checked:after {
	opacity: 1;
	transform: rotate(90deg);
}

table.test-details {
	table-layout: fixed;
	width: auto;
	margin: auto;
	border-collapse: collapse;
	font-size: 11px;
	text-align: left;
	background: #f9f9f9;
}
.test-details th {
	background: #def;
	padding: 2px 5px;
	line-height: 1;
	font-size: 110%;
	text-align: center;
}
.test-details td {
	min-width: 10em;
	padding: 2px 5px;
}
.test-details td[rowSpan] {
	text-align: right;
	font-weight: bold;
}
.test-details td[rowSpan] ~ td {
	border-top: 1px solid grey;
}
.test-details td:not(:last-child) {
	border-right-color: #ccc;
}
.test-details tr:not(:last-child) td:not([rowSpan]) {
	border-bottom-color: #ccc;
}
.test-details small {
	font-size: 9px;
	font-weight: normal;
	opacity: 0.8;
}

/* Charts (lib/charts.js) */
.bar-chart text,
.scatter-plot text {
	font-size: 11px;
	fill: #777;
	dominant-baseline: hanging;
}
.bar-chart .axis,
.scatter-plot .axis {
	stroke: #aaa;
}
.bar-chart .minMax {
	stroke: #777;
	stroke-width: 1;
	stroke-opacity: 0.5;
	stroke-dasharray: 2;
}
.bar-chart .mean {
	stroke: #777;
	stroke-width: 2;
	stroke-opacity: 0.5;
}
.bar-chart .mean:hover {
	stroke-opacity: 1;
}
.bar-chart g.bar {
	fill: #8ad;
}
.bar-chart g.bar.large text {
	display: none;
}
.bar-chart g.bar:hover {
	filter: brightness(1.1);
}
.bar-chart g.bar text {
	fill: #ddd;
	text-anchor: middle;
	text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
.bar-chart g.bar:hover text {
	display: block;
	fill: #fff;
	text-shadow: 0 0 5px #000;
}
.bar-chart .label {
	text-anchor: end;
	dominant-baseline: middle;
}

.scatter-plot .marker {
	stroke-width: 1px;
	fill: currentColor;
	opacity: 0.6;
	fill-opacity: 0.3;
}
.scatter-plot .marker:hover {
	opacity: 1;
	filter: drop-shadow(0 0 2px currentColor);
}
.scatter-plot .percentile {
	fill: currentColor;
	opacity: 0.6;
	fill-opacity: 0.3;
	stroke-width: 0px;
}
.scatter-plot .percentile line {
	stroke-width: 1px;
}
.scatter-plot .percentile:hover {
	opacity: 1;
}

/* Chart colors */
.chart .blue {
	color: #4081ec;
	stroke: #4081ec;
}

.chart .green {
	color: #699023;
	stroke: #699023;
}

.chart .purple {
	color: #391d74;
	stroke: #391d74;
}

.chart .orange {
	color: #fe8f06;
	stroke: #fe8f06;
}

.chart .violet {
	color: #8711ac;
	stroke: #8711ac;
}

.chart .green-light {
	color: #3bb502;
	stroke: #3bb502;
}
