* {
	box-sizing: border-box;
}

body {
	margin: 0;
	height: 100vh;
	overflow: hidden;
	font-family:
		ui-monospace, "Cascadia Mono", "Source Code Pro", Menlo, Consolas, monospace;
	background: #f5f5f5;
	color: #222;
}

/* author display rules must never defeat the hidden attribute */
[hidden] {
	/* biome-ignore lint/complexity/noImportantStyles: standard reset pattern */
	display: none !important;
}

#app {
	height: 100%;
}

main > section {
	height: 100%;
	display: flex;
	flex-direction: column;
}

/* scrollable content region between the section top and the bottom bar */
.scroll {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 0.5rem;
}

h2 {
	font-size: 1.1rem;
}

button {
	font: inherit;
	cursor: pointer;
}

input,
textarea {
	font: inherit;
	display: block;
	width: 100%;
	margin-bottom: 0.5rem;
	padding: 0.4rem;
	border: 1px solid #999;
	border-radius: 4px;
}

textarea {
	height: 4rem;
	resize: vertical;
}

button[type="submit"] {
	background: steelblue;
	color: white;
	border: none;
	border-radius: 0.5rem;
	padding: 0.5rem 1.2rem;
}

.error {
	color: #b33;
}

/* bottom bars: back button, title left, buttons right; fixed height, in flow */
.bottom-bar {
	flex: none;
	height: 3.2rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.4rem;
	padding: 0 0.75rem;
	background: #333;
	z-index: 10;
}

.bar-title {
	color: white;
	font-weight: bold;
	font-size: 1.05rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bar-buttons {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

#draw-bar {
	justify-content: space-between;
}

#draw-hint {
	color: white;
	margin-right: auto;
	margin-left: 0.5rem;
}

/* disabled buttons: greyed out */
.btn:disabled,
.nav-icon:disabled {
	opacity: 0.35;
	border-color: #999;
	color: #999;
	background: #ddd;
	cursor: default;
}

/* shared button look: steelblue on white, 3px outline, one height */
.btn,
.tool,
.nav-icon {
	height: 2.4rem;
	border: 3px solid steelblue;
	border-radius: 0.5rem;
	background: white;
	color: steelblue;
	font: inherit;
	font-weight: bold;
	cursor: pointer;
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0 0.8rem;
}

.nav-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.4rem;
	padding: 0;
}

.nav-icon svg {
	scale: 1.1;
}

.tool {
	padding: 0 0.8rem;
}

.tool.active {
	background: steelblue;
	color: white;
}

/* popovers */
.popover {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(51, 51, 51, 0.8);
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: center;
}

.popover form {
	background: white;
	padding: 1rem;
	border-radius: 8px;
	width: min(28rem, 90vw);
}

/* front page thumbnails */
.thumbnails {
	display: grid;
	gap: 2px;
	grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
}

.thumb {
	position: relative;
	display: block;
	text-decoration: none;
	color: inherit;
}

.thumb img {
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	display: block;
}

.thumb .name {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	color: white;
	background-color: rgba(51, 51, 51, 0.8);
	padding: 2px 5px;
	font-weight: bold;
}

/* topo view: .topo is the visible viewport */
.topo {
	position: relative;
	overflow: hidden;
	flex: 1;
	min-height: 0;
	touch-action: none;
	cursor: grab;
}

.topo.panning {
	cursor: grabbing;
}

.topo img {
	width: 100%;
	height: 100%;
	display: block;
	/* the browser must not start a native image drag on left-drag:
	   it cancels the pointer stream and breaks panning */
	-webkit-user-drag: none;
	user-select: none;
}

#topo-canvas {
	position: absolute;
	inset: 0;
	transform-origin: 0 0;
	will-change: transform;
}

/* the fitted image box, positioned + sized by js */
#topo-fit {
	position: absolute;
}

#topo-fit > svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	/* clicks go to the container so the popout is never shadowed */
	pointer-events: none;
}

#topo-fit > svg .route-start {
	pointer-events: auto;
}

.route-popout {
	position: absolute;
	z-index: 15;
	width: min(20rem, 90vw);
	background: rgba(51, 51, 51, 0.92);
	color: white;
	border-radius: 8px;
	padding: 0.6rem;
	font-size: 0.9rem;
}

.route-popout .route-name {
	font-weight: bold;
}

.route-popout .route-grade {
	color: #ffd60a;
	margin-left: 0.4rem;
}

.route-popout .route-desc {
	margin: 0.3rem 0;
}

.route-popout .submit-row {
	display: flex;
	gap: 0.4rem;
	margin-top: 0.4rem;
}

.route-popout .submit-row input {
	margin: 0;
	flex: 1;
}

.route-popout .toggle {
	padding: 0.3rem 0.5rem;
	border: 1px solid #aaa;
	border-radius: 4px;
	background: white;
	color: #222;
	white-space: nowrap;
}

.route-popout .send {
	background: steelblue;
	color: white;
	border: none;
	border-radius: 4px;
	padding: 0.3rem 0.5rem;
	display: flex;
	align-items: center;
}

.route-popout .expand-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 0.4rem;
	border-top: 1px solid #666;
	padding-top: 0.3rem;
}

.route-popout .expand-row button {
	background: transparent;
	color: white;
	border: none;
	padding: 0.2rem;
}

.route-popout .tri-state {
	background: #555;
	color: white;
	border: 1px solid #888;
	border-radius: 4px;
	padding: 0.2rem 0.5rem;
	font-size: 0.8rem;
}

.comment-list {
	max-height: 8rem;
	overflow-y: auto;
	margin: 0.3rem 0 0;
	padding-left: 1rem;
}

.comment-list .kind {
	color: #8fd3ff;
	font-size: 0.8rem;
}

.route-popout .own-actions {
	margin-top: 0.4rem;
	display: flex;
	gap: 0.4rem;
}

.route-popout .own-actions button {
	background: #555;
	color: white;
	border: none;
	border-radius: 4px;
	padding: 0.2rem 0.5rem;
	display: flex;
	align-items: center;
	gap: 0.3rem;
}

/* colours */
.colour-picker {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-bottom: 0.5rem;
}

.colour-picker .swatch {
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	border: 3px solid transparent;
}

.colour-picker .swatch.selected {
	border-color: #222;
}

.anchor-attrs {
	display: flex;
	gap: 0.4rem;
	margin-bottom: 0.5rem;
}

.anchor-attrs label {
	display: flex;
	align-items: center;
	gap: 0.2rem;
	border: 1px solid #999;
	border-radius: 4px;
	padding: 0.2rem 0.4rem;
}

/* topo svg */
#topo-fit > svg .route-glow {
	fill: none;
	stroke-linecap: round;
	stroke-linejoin: round;
	opacity: 0.45;
}

#topo-fit > svg .route-line {
	fill: none;
	stroke-linecap: round;
	stroke-linejoin: round;
}

#topo-fit > svg .route-name {
	font-size: 18px;
	font-weight: bold;
	paint-order: stroke;
	stroke: white;
	stroke-width: 4px;
	fill: #222;
	pointer-events: none;
}

#topo-fit > svg .route-start {
	r: 6;
}

/* user page: two-column label/value grid */
#user-grid {
	display: grid;
	grid-template-columns: max-content 1fr;
	column-gap: 1rem;
	row-gap: 0.4rem;
	align-items: center;
}

#user-rows {
	display: contents;
}

#user-rows .cell-label {
	font-weight: bold;
}

#user-rows .admin-link {
	grid-column: 1 / -1;
	margin-top: 0.3rem;
}

#invite-generate {
	grid-column: 1 / -1;
	justify-self: start;
	margin-top: 0.8rem;
}

#invite-rows {
	grid-column: 1 / -1;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	margin-top: 0.6rem;
}

#invite-rows .invite-row {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

#invite-rows .invite-used {
	text-decoration: line-through;
	color: #999;
}

#admin-table {
	border-collapse: collapse;
	width: 100%;
}

#admin-table th,
#admin-table td {
	border: 1px solid #bbb;
	padding: 0.3rem 0.6rem;
	text-align: left;
}
