/* The docs viewer (docs/index.html): header, index and frame. The pages themselves use style.css. */

:root {
	--bg: #ffffff;
	--panel: #f6f6f4;
	--line: #dcdcd8;
	--text: #1d1d1f;
	--muted: #5c5c62;
	--link: #0a58ca;
	--hover: rgba(0, 0, 0, 0.05);
	--common: #868e96;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #18181a;
		--panel: #202023;
		--line: #38383d;
		--text: #ececee;
		--muted: #a2a2aa;
		--link: #7fb2ff;
		--hover: rgba(255, 255, 255, 0.06);
	}
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
}

body {
	display: flex;
	flex-direction: column;
}

button, input, select { font: inherit; color: inherit; }

/* ── header: the app's color along the top, the breadcrumb, the search ── */
.viewer-head {
	--app: var(--common);
	display: flex;
	align-items: center;
	gap: 8px 20px;
	flex-wrap: wrap;
	padding: 8px 16px;
	border-top: 4px solid var(--app);
	border-bottom: 1px solid var(--line);
	background: color-mix(in srgb, var(--app) 9%, var(--panel));
}

.viewer-title {
	font-weight: 600;
	color: var(--muted);
	text-decoration: none;
}

.viewer-title:hover { color: var(--text); }

.crumbs {
	display: flex;
	align-items: baseline;
	gap: 8px;
	min-width: 0;
	flex: 1 1 200px;
	font-size: 17px;
}

.crumb-app {
	font-weight: 700;
	color: var(--app);
	text-decoration: none;
	white-space: nowrap;
}

.viewer-head:not(.has-app) .crumb-app { color: var(--text); }

a.crumb-app:hover { text-decoration: underline; }

.crumb-group {
	color: var(--muted);
	text-decoration: none;
	white-space: nowrap;
}

a.crumb-group:hover { color: var(--text); text-decoration: underline; }

.crumb-sep { color: var(--muted); }

.crumb-page {
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.viewer-search {
	display: flex;
	gap: 6px;
	flex: 0 1 420px;
	min-width: 0;
	margin: 0;
}

.viewer-search input, .viewer-search select {
	padding: 4px 8px;
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 4px;
}

.viewer-search input { flex: 1; min-width: 0; }

.viewer-search input:focus, .viewer-search select:focus {
	outline: none;
	border-color: var(--app);
}

/* ── body: index, splitter, page ── */
.viewer-body {
	flex: 1;
	min-height: 0;
	display: flex;
}

.viewer-index {
	width: 260px;
	flex: none;
	overflow-y: auto;
	background: var(--panel);
	padding: 6px 0 32px;
}

.viewer-splitter {
	width: 7px;
	flex: none;
	cursor: col-resize;
	touch-action: none;
	user-select: none;
	background: linear-gradient(to right, transparent 3px, var(--line) 3px, var(--line) 4px, transparent 4px);
}

.viewer-splitter:hover, .viewer-splitter.dragging, .viewer-splitter:focus-visible {
	outline: none;
	background: linear-gradient(to right, transparent 2px, var(--link) 2px, var(--link) 5px, transparent 5px);
}

.viewer-main {
	flex: 1;
	min-width: 0;
	display: flex;
	overflow: auto;
}

.viewer-frame {
	flex: 1;
	border: 0;
	background: var(--bg);
}

.viewer-frame[hidden] { display: none; }

/* ── the index tree ── */
.tree, .tree ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tree ul { display: none; }

.tree li.open > ul { display: block; }

.tree .row {
	display: flex;
	align-items: center;
}

.tree .toggle {
	flex: none;
	width: 22px;
	height: 26px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--muted);
	cursor: pointer;
}

/* A drawn chevron: right when closed, down when open. */
.tree .toggle::before {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(-45deg);
	transition: transform 0.15s;
}

.tree li.open > .row > .toggle::before { transform: rotate(45deg); }

.tree a, .tree .label {
	display: block;
	flex: 1;
	min-width: 0;
	padding: 3px 12px 3px 0;
	line-height: 1.35;
	color: var(--text);
	text-decoration: none;
	font-size: 14px;
}

.tree .label {
	color: var(--muted);
	font-weight: 600;
	cursor: pointer;
	user-select: none;
}

.tree a:hover, .tree .label:hover { color: var(--link); }

/* Indents: --indent is where an entry's name starts, 14px past its parent's; a branch's chevron
   sits just left of it. */
.tree li { --indent: 30px; }
.tree ul li { --indent: 44px; }
.tree ul ul li { --indent: 58px; }
.tree ul ul ul li { --indent: 72px; }
.tree ul ul ul ul li { --indent: 86px; }
.tree li > .row { padding-left: calc(var(--indent) - 22px); }
.tree li > a { padding-left: var(--indent); }

/* An app: its name in its color, the one being read marked along the left. */
.tree > li.tree-app {
	border-left: 3px solid transparent;
	margin-top: 2px;
}

.tree > li.tree-app.current { border-left-color: var(--app); }

.tree a.app-link {
	font-size: 15px;
	font-weight: 700;
	color: var(--app);
	padding-top: 5px;
	padding-bottom: 5px;
}

.tree a.active {
	color: var(--app, var(--link));
	font-weight: 600;
	background: color-mix(in srgb, var(--app) 14%, transparent);
}

.tree .tbd {
	font-size: 0.8em;
	color: var(--muted);
}

/* ── search results, in place of the index while the box has text ── */
.viewer-index.searching .tree { display: none; }

.search-group { margin-bottom: 10px; }

.search-group h2 {
	margin: 8px 12px 2px;
	padding-left: 8px;
	border-left: 3px solid var(--app);
	font-size: 13px;
	font-weight: 700;
	color: var(--app);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.search-result {
	display: block;
	padding: 6px 12px 6px 23px;
	color: var(--text);
	text-decoration: none;
}

.search-result:hover { background: var(--hover); }

.search-title {
	display: block;
	font-size: 14px;
	font-weight: 600;
}

.search-snippet {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-top: 2px;
	font-size: 12px;
	line-height: 1.4;
	color: var(--muted);
}

.search-snippet b { color: var(--text); }

.search-empty {
	margin: 8px 16px;
	font-size: 14px;
	color: var(--muted);
}

/* ── the start view: no page named ── */
.start {
	max-width: 48rem;
	margin: 0 auto;
	padding: 32px 16px;
}

.start[hidden] { display: none; }

.start-apps {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 12px;
	list-style: none;
	padding: 0;
}

.start-app {
	display: block;
	padding: 14px 16px;
	border: 1px solid var(--line);
	border-top: 4px solid var(--app);
	border-radius: 8px;
	background: var(--panel);
	color: var(--app);
	font-weight: 600;
	text-decoration: none;
}

.start-app:hover { border-color: var(--app); }
/* Pixelapp's name in its UI font, Aseprite's own (Aseprite Font) (capitals 6/8 of the size; crisp at 16/32, multiples of its 8 px grid); only the name. */
@font-face { font-family: "Aseprite Font"; src: url("/user/fonts/AsepriteFont.ttf") format("truetype"); font-weight: 400; }
@font-face { font-family: "Aseprite Font"; src: url("/user/fonts/AsepriteFont-Bold.ttf") format("truetype"); font-weight: 700; }
.start-app[data-page="pixelapp/index.html"] { font-family: "Aseprite Font", monospace; font-size: 16px; font-weight: 700; -webkit-font-smoothing: none; }


@media (max-width: 640px) {
	.viewer-index { width: 180px; }
	.viewer-search { flex-basis: 100%; }
}
