/* Layout and palette follow the lgm map editor's dark theme. */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #layout { height: 100%; }

/* Tell the engine the page is dark, so the parts of a form control the
 * page can't paint (the select's dropdown list, scrollbars, the number
 * field's spinner) come out dark too. */
html { color-scheme: dark; }

body {
	background: #10131a;
	color: #cfd6e4;
	font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
	overflow: hidden;
	user-select: none;
}

#layout { display: flex; }

#main {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
	position: relative;
}

#view {
	flex: 1;
	width: 100%;
	min-height: 0;
	cursor: grab;
	display: block;
	background: #0a0e16;
}

#coordinateDebug {
	position: absolute;
	top: 10px;
	left: 10px;
	padding: 5px 8px;
	background: rgba(10, 14, 22, 0.88);
	border: 1px solid #53617b;
	border-radius: 4px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
	color: #cfd6e4;
	font: 12px/1.4 ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
	z-index: 1;
}

#coordinateDebug span {
	display: inline-block;
	min-width: 9ch;
	text-align: right;
}

#dropHint {
	position: absolute;
	inset: 0 0 40px 0;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	color: #8b96ad;
	cursor: pointer; /* the whole hint is the open button */
}
#dropHint h1 { font-size: 20px; margin-bottom: 8px; color: #cfd6e4; }
#dropHintLink { margin-top: 8px; }
/* Set well below the rest: it's the afterthought, not part of how to open a log. */
#dropHintKeys { margin-top: 56px; }
#dropHintKeys:hover { color: #cfd6e4; }		/* its own click target, not part of the open button */
#dropHintLink a { color: #5b8def; }
#dropHint.hidden { display: none; }

#transport {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 10px;
	background: #161b26;
	border-top: 1px solid #262d3d;
}
#transport button {
	background: #232b3d;
	border: 1px solid #33405c;
	color: #cfd6e4;
	border-radius: 4px;
	width: 34px;
	height: 26px;
	font-size: 13px;
	cursor: pointer;
}
#transport button:hover { background: #2c3650; }
#soundBtn { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
#soundBtn[aria-pressed="true"] .sound-muted,
#soundBtn[aria-pressed="false"] .sound-waves { display: none; }
#transport select {
	background-color: #232b3d;
	border: 1px solid #33405c;
	color: #cfd6e4;
	border-radius: 4px;
	height: 26px;
}
/* Player lock active: the player selector takes the viewer's friendly
 * green, in shades matched to the dark controls. (background-color, not
 * the shorthand: the shorthand would wipe the chevron below.) */
#viewpoint.locked {
	background-color: #1e3d27;
	border-color: #418a54;
	color: #b5efc2;
}

/* Chromium and WebView2 drop a select to a plain styleable box as soon
 * as its border is set, but Safari keeps drawing the platform's popup
 * button and ignores the colours above, leaving a white menu in the dark
 * bar. Turn the native look off everywhere so every engine paints the
 * same box, and draw the chevron ourselves: two half-transparent
 * gradients meeting in a V, since the CSP's default-src 'self' blocks a
 * data: image and img-src is not opened just for this. */
#transport select, .exportRow select {
	appearance: none;
	-webkit-appearance: none;
	font: inherit;
	padding: 0 22px 0 8px;
	background-image:
		linear-gradient(45deg, transparent 50%, currentColor 50%),
		linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 13px) calc(50% - 1px), calc(100% - 8px) calc(50% - 1px);
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}
#seek { flex: 1; accent-color: #5b8def; }

/* Transport controls are mouse-driven (all keys are global), so never show
 * a focus highlight on them. */
#transport button:focus, #transport select:focus, #seek:focus { outline: none; }
#timeLabel { font-variant-numeric: tabular-nums; white-space: nowrap; }
#zoomLabel { color: #8b96ad; white-space: nowrap; }

#sidebar {
	width: 322px;
	background: #141925;
	border-left: 1px solid #262d3d;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.panel {
	padding: 10px 12px;
	border-bottom: 1px solid #232939;
}
.panel h2 {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #8b96ad;
	margin-bottom: 6px;
}
/* Integral line height: the inherited 1.45 works out to 17.4px at this
 * size, and the fractional pitch paints consecutive lines 18 then 17
 * physical pixels apart on a 1x display as each baseline snaps on its
 * own. Never multi-line, so nothing else moves. */
.hint { color: #8b96ad; font-size: 12px; line-height: 17px; }

#players .player {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 2px 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
#players .chip {
	width: 10px;
	height: 10px;
	border-radius: 2px;
	flex: none;
	border: 1px solid rgba(255, 255, 255, 0.35);
}
#players .player.gone { color: #667; text-decoration: line-through; }
#players .host { color: #8b96ad; font-size: 11px; }

#chatPanel {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	border-bottom: none;
}
/* Integral line height, as for .hint: the inherited 1.45 is 20.3px at
 * 14px, and the fractional pitch makes consecutive lines snap 20 then
 * 21 physical pixels apart. 20px is also the pitch the video export
 * paints the wire on (ex_chat_panel), so the two now agree. */
#chat {
	flex: 1;
	overflow-y: auto;
	font-size: 14px;
	line-height: 20px;
	min-height: 0;
}
/* Slim dark scrollbar to match the panel */
#chat { scrollbar-width: thin; scrollbar-color: #2c3650 transparent; }
#chat::-webkit-scrollbar { width: 8px; }
#chat::-webkit-scrollbar-track { background: transparent; }
#chat::-webkit-scrollbar-thumb {
	background: #2c3650;
	border-radius: 4px;
}
#chat::-webkit-scrollbar-thumb:hover { background: #3a4763; }

#chat .msg { padding: 1px 0; word-wrap: break-word; }
#chat .msg .t { color: #667a99; font-variant-numeric: tabular-nums; }
#chat .msg .who { font-weight: 600; }
#chat .msg.sys { color: #8b96ad; font-style: italic; }

/* Video export setup: the options dialog shown before the save dialog.
 * Same modal pattern as the progress overlay below. */
#exportSetup {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(10, 14, 22, 0.7);
}
#exportSetup.hidden { display: none; }
#exportSetupBox {
	width: 440px;
	background: #161b26;
	border: 1px solid #33405c;
	border-radius: 6px;
	padding: 18px 20px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
#exportSetupBox h1 { font-size: 15px; margin-bottom: 6px; }
#exportSetupCamera { margin-bottom: 12px; }
.exportRow {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 8px 0;
}
.exportRow > label {
	width: 160px;
	flex: none;
	display: flex;
	align-items: center;
	gap: 7px;
}
.exportRow select, .exportRow input[type="number"] {
	background-color: #232b3d;
	border: 1px solid #33405c;
	color: #cfd6e4;
	border-radius: 4px;
	height: 26px;
}
.exportRow input[type="number"] { width: 64px; padding: 0 6px; }
.exportRow select:disabled, .exportRow input[type="number"]:disabled { opacity: 0.45; }
.exportRow input[type="radio"], .exportRow input[type="checkbox"] { accent-color: #5b8def; }
.exportField { display: flex; align-items: center; gap: 7px; color: #8b96ad; }
#exportSetupEstimate { color: #8b96ad; font-size: 12px; margin-top: 10px; }
#exportSetupWarning {
	color: #e7c46a;
	font-size: 12px;
	margin-top: 8px;
}
#exportSetupWarning.hidden { display: none; }
.exportButtons {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 14px;
}
.exportButtons button {
	background: #232b3d;
	border: 1px solid #33405c;
	color: #cfd6e4;
	border-radius: 4px;
	height: 26px;
	padding: 0 14px;
	font-size: 13px;
	cursor: pointer;
}
.exportButtons button:hover { background: #2c3650; }
#exportSetupOk { background: #2c4a7c; border-color: #5b8def; }
#exportSetupOk:hover { background: #365a94; }

/* Unlike the transport (mouse-only, focus ring suppressed outright), the
 * dialog is keyboard-navigable — but the UA ring is platform-coloured and
 * lingers on a control after a mouse pick. Hide it for pointer use and
 * draw a themed ring only for keyboard focus. */
#exportSetup select:focus, #exportSetup input:focus,
#exportSetup button:focus { outline: none; }
#exportSetup select:focus-visible, #exportSetup input:focus-visible,
#exportSetup button:focus-visible {
	outline: 1px solid #5b8def;
	outline-offset: 1px;
}

/* Video export progress: a modal that also blocks pointer input while the
 * export borrows the renderer's state (keys are blocked in renderer.js). */
#exportOverlay {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(10, 14, 22, 0.7);
}
#exportOverlay.hidden { display: none; }
#exportBox {
	width: 420px;
	background: #161b26;
	border: 1px solid #33405c;
	border-radius: 6px;
	padding: 18px 20px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
#exportBox h1 { font-size: 15px; margin-bottom: 12px; }
#exportBar {
	height: 10px;
	background: #232b3d;
	border-radius: 5px;
	overflow: hidden;
	margin-bottom: 8px;
}
#exportBarFill {
	height: 100%;
	width: 0;
	background: #5b8def;
}
#exportCancel {
	margin-top: 12px;
	background: #232b3d;
	border: 1px solid #33405c;
	color: #cfd6e4;
	border-radius: 4px;
	height: 26px;
	padding: 0 14px;
	font-size: 13px;
	cursor: pointer;
}
#exportCancel:hover { background: #2c3650; }

/* Shortcut sheet: the apps write their keys in their menus, so this is
 * built and shown on the web page alone (renderer.js gates it). Same
 * modal shape as the export dialogs, laid out in two flowing columns so a
 * tall group doesn't leave a hole beside a short one. */
#shortcutSheet {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(10, 14, 22, 0.7);
}
#shortcutSheet.hidden { display: none; }
#shortcutBox {
	width: min(620px, 100%);
	max-height: 100%;
	overflow: auto;
	background: #161b26;
	border: 1px solid #33405c;
	border-radius: 6px;
	padding: 15px 17px 5px;		/* the last group's own margin makes up the rest */
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
#shortcutGroups { column-count: 2; column-gap: 22px; }
.shortcutGroup { break-inside: avoid; margin-bottom: 10px; }
.shortcutGroup h2 {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #8b96ad;
	margin-bottom: 4px;
	padding-bottom: 3px;
	border-bottom: 1px solid #262d3d;
}
.shortcutRow {
	display: flex;
	align-items: baseline;
	gap: 8px;
	padding: 2px 0;
}
.shortcutRow .what { flex: 1; min-width: 0; }
.shortcutRow .keys { display: flex; align-items: baseline; gap: 3px; flex: none; }
.shortcutRow .sep { color: #6f7a91; }
.shortcutRow .via { color: #8b96ad; font-size: 12px; flex: none; }
#shortcutSheet kbd, #dropHint kbd {
	display: inline-block;
	background: #232b3d;
	border: 1px solid #33405c;
	border-bottom-width: 2px;
	border-radius: 3px;
	padding: 1px 5px;
	min-width: 21px;
	text-align: center;
	font: 12px/1.5 ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
	color: #cfd6e4;
	white-space: nowrap;
}
/* A narrow browser window can't hold two columns of key caps. */
@media (max-width: 620px) {
	#shortcutGroups { column-count: 1; }
}
