/* Level viewer (j2l/view.php). Colours follow the site: black, orange #F60, yellow links. */
:root {
	--bg: #000;
	--panel: #0e0e10;
	--line: #2a2a2e;
	--text: #f2f2f2;
	--muted: #9d9da6;
	--accent: #f60;
	--link: #fc0;
	--btn: #1a1a1d;
	--btn-hover: #27272c;
	--btn-line: #3b3b42;
	color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
	height: 100%;
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 13px Tahoma, Geneva, Verdana, sans-serif;
}

body { overflow: hidden; }

a { color: var(--link); text-decoration: none; }
a:hover { color: #fff; }

#app {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-rows: auto minmax(0, 1fr);
	height: 100vh;
	height: 100dvh;
}

/* ------------------------------------------------------------ top bar */

#bar {
	grid-column: 1 / -1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 12px;
	padding: 6px 10px;
	background: linear-gradient(#17171a, #0b0b0c);
	border-bottom: 2px solid var(--accent);
	min-width: 0;
}

#bar .back { font-weight: bold; white-space: nowrap; }

#bar h1 {
	flex: 1 1 200px;
	min-width: 0;
	margin: 0;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#bar .ltitle { color: var(--muted); font-weight: normal; margin-left: 10px; }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

button {
	font: inherit;
	color: var(--text);
	background: var(--btn);
	border: 1px solid var(--btn-line);
	border-radius: 4px;
	padding: 5px 10px;
	cursor: pointer;
	line-height: 1.2;
}

button:hover { background: var(--btn-hover); border-color: #5a5a62; }
button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { background: var(--btn); border-color: var(--btn-line); }
button:focus-visible, #stage:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

button[aria-pressed="true"] {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
	text-shadow: 1px 1px 1px rgba(0, 0, 0, .35);
}
button[aria-pressed="true"]:hover { background: #ff7a1f; }

.group {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--btn-line);
	border-radius: 4px;
	background: var(--btn);
}
.group button { border: 0; border-radius: 0; padding: 5px 10px; font-weight: bold; }
.group button:first-child { border-radius: 3px 0 0 3px; }
.group button:last-child { border-radius: 0 3px 3px 0; }

#zoomLabel {
	min-width: 54px;
	padding: 0 4px;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- stage */

#stage {
	position: relative;
	overflow: hidden;
	background: #000;
	cursor: grab;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}
#stage.dragging { cursor: grabbing; }

#gl, #overlay {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}
#overlay { pointer-events: none; }

#msg {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	max-width: min(520px, 90%);
	padding: 14px 20px;
	background: rgba(12, 12, 14, .94);
	border: 1px solid #3a3a40;
	border-radius: 6px;
	text-align: center;
	line-height: 1.5;
	cursor: default;
	z-index: 6;
}
#msg.error { border-color: #d33; color: #ffd2d2; }
#msg[hidden] { display: none; }

#coords {
	position: absolute;
	left: 8px;
	bottom: 6px;
	font-size: 12px;
	color: #e8e8e8;
	text-shadow: 0 1px 2px #000, 0 0 4px #000;
	pointer-events: none;
	font-variant-numeric: tabular-nums;
}

#tip {
	position: absolute;
	z-index: 4;
	max-width: 320px;
	padding: 6px 9px;
	background: rgba(12, 12, 14, .95);
	border: 1px solid #45454c;
	border-left: 4px solid var(--cat, #888);
	border-radius: 4px;
	font-size: 12px;
	line-height: 1.45;
	box-shadow: 0 3px 14px rgba(0, 0, 0, .6);
	pointer-events: none;
}
#tip[hidden] { display: none; }
#tip .name { font-weight: bold; color: #fff; }
#tip .muted { color: var(--muted); }
#tip .text { font-style: italic; color: #ffe9a8; }

/* ------------------------------------------------------------ minimap */

#minimap {
	position: absolute;
	right: 10px;
	bottom: 10px;
	z-index: 3;
	line-height: 0;
	background: #1a1a22;
	border: 1px solid rgba(255, 102, 0, .9);
	box-shadow: 0 2px 12px rgba(0, 0, 0, .75);
	cursor: crosshair;
	touch-action: none;
}
#minimap[hidden] { display: none; }
#mmCanvas { display: block; }

#mmView {
	position: absolute;
	border: 1px solid #fff;
	background: rgba(255, 255, 255, .1);
	box-shadow: 0 0 0 1px rgba(0, 0, 0, .7);
	pointer-events: none;
}

#mmHide {
	position: absolute;
	top: -11px;
	right: -11px;
	width: 22px;
	height: 22px;
	padding: 0;
	border-radius: 50%;
	font-size: 15px;
	line-height: 18px;
	opacity: 0;
	transition: opacity .15s;
}
#minimap:hover #mmHide, #mmHide:focus-visible { opacity: 1; }
@media (hover: none) { #mmHide { opacity: 1; } }

#mmShow {
	position: absolute;
	right: 10px;
	bottom: 10px;
	z-index: 3;
}
#mmShow[hidden] { display: none; }

/* -------------------------------------------------------------- panel */

#panel {
	width: 290px;
	overflow-y: auto;
	background: var(--panel);
	border-left: 1px solid var(--line);
}
#app:not(.panel-open) #panel { display: none; }

#panel section { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); }

#panel h2 {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 0 8px;
	font-size: 12px;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--accent);
}

button.small { padding: 2px 8px; font-size: 11px; letter-spacing: 0; text-transform: none; }

#layers { list-style: none; margin: 0; padding: 0; }

#layers li {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 1px 8px;
	padding: 5px 6px;
	border-radius: 4px;
}
#layers li:hover { background: #19191d; }
#layers li.empty { opacity: .5; }

#layers label {
	display: contents;
	cursor: pointer;
}
#layers input {
	width: 15px;
	height: 15px;
	margin: 0;
	accent-color: var(--accent);
	cursor: pointer;
}
#layers .lname {
	font-weight: bold;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
#layers .lnum { color: var(--muted); font-weight: normal; margin-right: 4px; }
#layers .lmeta { grid-column: 2 / 4; color: var(--muted); font-size: 11px; line-height: 1.35; }
#layers .solo { padding: 1px 7px; font-size: 11px; opacity: 0; }
#layers li:hover .solo, #layers .solo:focus-visible { opacity: 1; }
@media (hover: none) { #layers .solo { opacity: 1; } }

#info {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 3px 10px;
	margin: 0;
}
#info dt { color: var(--muted); white-space: nowrap; }
#info dd { margin: 0; overflow-wrap: anywhere; }

#warnings { margin: 10px 0 0; padding-left: 16px; color: #ffb27a; line-height: 1.4; }
#warnings:empty { display: none; }

.help p { margin: 0; color: #c9c9cf; line-height: 1.55; }

/* Narrow screens: the panel opens over the level instead of beside it. */
@media (max-width: 760px) {
	#app { grid-template-columns: minmax(0, 1fr); }
	#panel {
		grid-row: 2;
		grid-column: 1;
		justify-self: end;
		width: min(300px, 88vw);
		z-index: 7;
		box-shadow: -6px 0 18px rgba(0, 0, 0, .65);
	}
	#bar .ltitle { display: none; }
	#bar h1 { font-size: 14px; }
	button { padding: 5px 8px; }
}

/* ------------------------------------------------------- error page */

body.j2lv-error {
	overflow: auto;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100%;
	padding: 20px;
}
.errbox {
	max-width: 480px;
	padding: 20px 26px;
	background: #111114;
	border: 1px solid #333;
	border-top: 3px solid var(--accent);
	border-radius: 6px;
	text-align: center;
	line-height: 1.5;
}
.errbox h1 { margin: 0 0 10px; font-size: 18px; }
