/* Fake Lab - page structure, page-specific rules and the small-screen overrides. Linked after site.css, which it builds on. */

/* Page structure */

[id] {
	scroll-margin-top: 1rem;
}

.crumbs {
	margin: 0 0 0.4rem;
	font-size: 0.9rem;
}

.page-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem 1.5rem;
	margin-bottom: 1rem;
}

.page-head h1 {
	margin: 0;
}

.subtitle {
	font-size: 0.6em;
	font-weight: 400;
}

h2 .subtitle {
	font-size: 0.75em;
}

.actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
}

.card-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.4rem 1rem;
	margin-bottom: 0.6rem;
}

.card-head h2 {
	margin: 0;
}

.stack {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	min-width: 0;
}

/* Wide content (tables, forms) on the left, a narrower column of panels on the right; one column on small screens. */
.layout-main-side {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
	gap: 1.25rem;
	align-items: start;
}

.layout-main-side > *,
.grid > * {
	min-width: 0;
}

.stack > .card,
.grid > .card,
.layout-main-side > .card {
	margin-bottom: 0;
}

.id {
	font-size: 0.7rem;
	font-weight: 400;
	color: var(--muted);
	vertical-align: middle;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.nowrap {
	white-space: nowrap;
}

/* Long URLs and IDs wrap rather than widen the page. */
.url,
.kv dd {
	overflow-wrap: anywhere;
}

.inline-list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.counts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
}

/* Tables scroll sideways inside their container; the page itself never does. */
.table-wrap {
	/* Positioned, so visually hidden (absolute) text in a scrolled cell stays inside it rather than widening the page. */
	position: relative;
	max-width: 100%;
	overflow-x: auto;
}

.table .outcome {
	min-width: 16rem;
}

.table .url {
	min-width: 14rem;
}

.table td code {
	white-space: nowrap;
	word-break: normal;
}

.row-actions {
	white-space: nowrap;
	text-align: right;
}

.row-actions > * + * {
	margin-left: 0.35rem;
}

.row-retired td,
.row-off td {
	color: var(--muted);
}

.row-retired td:nth-child(2) {
	text-decoration: line-through;
}

.row-editing td {
	background: #eef6fb;
}

.row-new td {
	animation: row-new 4s ease-out;
}

@keyframes row-new {
	from {
		background: #fff1c2;
	}

	to {
		background: transparent;
	}
}

@media (prefers-reduced-motion: reduce) {
	.row-new td {
		animation: none;
		background: #fffaeb;
	}
}

/* Forms, beyond the basics above */

.help {
	color: var(--muted);
	font-size: 0.85rem;
	font-weight: 400;
}

fieldset {
	min-width: 0;
	margin: 0 0 1rem;
	padding: 0.6rem 1rem 0.4rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

legend {
	padding: 0 0.35rem;
	font-weight: 600;
	font-size: 0.9rem;
}

fieldset > .help {
	display: block;
	margin-bottom: 0.6rem;
}

.form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
	gap: 0 1rem;
}

.form-grid-2 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 500;
	cursor: pointer;
}

.check.field {
	display: flex;
	flex-direction: row;
}

input[type="checkbox"],
input[type="radio"] {
	flex: none;
	width: 1.05rem;
	height: 1.05rem;
	margin: 0;
	accent-color: var(--accent);
}

input[type="file"] {
	max-width: 100%;
	font: inherit;
}

input[type="file"]::file-selector-button {
	margin-right: 0.75rem;
	padding: 0.4rem 0.85rem;
	font: inherit;
	font-weight: 600;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
	background: #eef2f6;
}

.choices {
	display: grid;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.choice {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	padding: 0.6rem 0.75rem;
	font-weight: 400;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	cursor: pointer;
}

.choice:has(input:checked) {
	background: #f0f7fb;
	border-color: var(--accent);
}

.choice input {
	margin-top: 0.2rem;
}

.choice .help {
	display: block;
	margin-top: 0.15rem;
}

.filters {
	display: grid;
	gap: 0.25rem;
}

.filter-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
	gap: 0 1rem;
}

.filter-grid .field {
	margin-bottom: 0.6rem;
}

.filter-actions,
.refresh-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem 1rem;
}

.refresh-bar {
	margin: 0 0 0.75rem;
}

/* Confirm steps: a disclosure that explains the consequences before the real button */

details.confirm {
	margin-bottom: 0.75rem;
}

details.confirm > summary {
	list-style: none;
}

details.confirm > summary::-webkit-details-marker {
	display: none;
}

.confirm-body {
	margin-top: 0.6rem;
	padding: 0.75rem 0.9rem;
	background: #fdf6f5;
	border: 1px solid #f3b8b3;
	border-left: 4px solid #b42318;
	border-radius: var(--radius);
}

.confirm-body p {
	margin-bottom: 0.65rem;
}

/* A card whose content folds away behind its heading */

details.panel > summary {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.25rem 0.5rem;
	list-style: none;
	cursor: pointer;
}

details.panel > summary::-webkit-details-marker {
	display: none;
}

/* A right-pointing triangle that turns down when open. */
details.panel > summary::before {
	content: "\25B6";
	flex: none;
	font-size: 0.75rem;
	color: var(--muted);
	transition: transform 0.15s ease;
}

details.panel[open] > summary::before {
	transform: rotate(90deg);
}

details.panel > summary h2,
details.panel > summary h3 {
	min-width: 0;
	margin: 0;
	overflow-wrap: anywhere;
}

details.panel[open] > summary {
	margin-bottom: 0.9rem;
}

/* Inline outcome of an action, e.g. a ping */

.result-box {
	margin-top: 0.85rem;
	padding: 0.7rem 0.9rem;
	border: 1px solid var(--border);
	border-left-width: 4px;
	border-radius: var(--radius);
}

.result-ok {
	background: #ecf9f0;
	border-color: #a6dbb7;
	border-left-color: #1d6b3a;
}

.result-failed {
	background: #fdeeed;
	border-color: #f3b8b3;
	border-left-color: #b42318;
}

/* Direction badges */

.badge-inbound {
	background: #e6eef6;
	color: #334e68;
	border-color: #c5d4e3;
}

.badge-outbound {
	background: #efe9fb;
	color: #4c2f8a;
	border-color: #d4c6f1;
}

/* Dashboard fault banner */

.fault-banner h2 {
	margin-bottom: 0.3em;
	font-size: 1.05rem;
}

.fault-banner p {
	margin-bottom: 0.3rem;
}

.fault-banner ul {
	margin: 0 0 0.5rem;
	padding-left: 1.25rem;
}

/* Catalogue */

.catalogue h3 {
	margin: 1.1rem 0 0.4rem;
	font-size: 1rem;
}

.catalogue h2 + h3 {
	margin-top: 0.4rem;
}

/* Message bodies */

.body-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem 1rem;
	margin-bottom: 0.6rem;
}

.body-head h2 {
	margin: 0;
}

pre.body {
	max-height: 70vh;
	margin: 0;
	overflow: auto;
	white-space: pre;
	tab-size: 2;
}

/* Samples */

.result-warning {
	background: #fff8e6;
	border-color: #f0d48a;
	border-left-color: #b77900;
}

.outcomes {
	display: grid;
	gap: 0.75rem;
	margin-bottom: 1.25rem;
}

.outcomes .result-box {
	margin-top: 0;
}

/* A disabled button cannot show its own tooltip in every browser, so the reason sits on a wrapper. */
.action-wrap {
	display: inline-block;
}

.action-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
}

.lab-actions form + form {
	margin-top: 0.9rem;
	padding-top: 0.9rem;
	border-top: 1px solid var(--border);
}

.lab-actions .help {
	margin: 0.35rem 0 0;
}

fieldset.bare {
	margin: 0;
	padding: 0;
	border: 0;
}

details.panel.sub {
	margin-top: 1rem;
	padding-top: 0.8rem;
	border-top: 1px solid var(--border);
}

.plain-list,
.notes {
	margin: 0 0 0.9rem;
	padding-left: 1.1rem;
}

.plain-list {
	margin: 0;
}

.attrs {
	margin: 0;
	padding: 0;
	list-style: none;
}

.test-id {
	display: inline-block;
	margin-top: 0.15rem;
}

/* GUID test IDs (Original dialect) may break anywhere rather than widen the table. */
.table td code.test-id {
	white-space: normal;
	word-break: break-all;
}

.sample-tests .test-name {
	min-width: 9rem;
}

.sample-tests .id-note {
	min-width: 10rem;
	margin-top: 0.2rem;
}

.result-cell {
	min-width: 13rem;
}

.result-cell > input[type="text"] {
	margin-bottom: 0.3rem;
}

details.raw > summary {
	cursor: pointer;
	color: var(--accent);
	font-size: 0.85rem;
}

.raw-grid {
	display: grid;
	grid-template-columns: max-content minmax(8rem, 1fr);
	gap: 0.3rem 0.6rem;
	align-items: center;
	margin: 0.4rem 0;
}

.raw-grid label {
	font-weight: 400;
	font-size: 0.85rem;
}

.row-removed .test-name,
.row-removed .test-id {
	text-decoration: line-through;
	color: var(--muted);
}

.row-changed td {
	background: #fffaeb;
}

/* A fault rule's effect on ID gets its own line under the rule. */
.faults .rule-row td {
	border-bottom: 0;
}

.faults .effect-row td {
	padding-top: 0;
	font-size: 0.9rem;
	color: var(--muted);
}

.save-bar,
.preset-bar,
.pager {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.6rem 1rem;
	margin: 0.9rem 0 0.5rem;
}

.preset-bar .field {
	margin-bottom: 0;
	min-width: min(22rem, 100%);
}

.block {
	display: block;
}

/* A time that may wrap between its date and its time of day. */
.table .time {
	min-width: 6.5rem;
}

[data-for-behaviour][hidden] {
	display: none;
}

@media (max-width: 960px) {
	.layout-main-side {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (max-width: 640px) {
	.header-inner {
		gap: 0.75rem;
		padding-top: 0.5rem;
		padding-bottom: 0.5rem;
	}

	.header-end {
		margin-left: 0;
	}

	.kv {
		grid-template-columns: 1fr;
		gap: 0.1rem;
	}

	.kv dd {
		margin-bottom: 0.5rem;
	}

	.form-grid-2 {
		grid-template-columns: minmax(0, 1fr);
	}

	.container,
	.header-inner {
		padding-left: 0.75rem;
		padding-right: 0.75rem;
	}

	main.container {
		padding-top: 1rem;
	}

	h1 {
		font-size: 1.35rem;
	}

	.card {
		padding: 0.9rem;
	}

	fieldset {
		padding-left: 0.75rem;
		padding-right: 0.75rem;
	}
}
