/*
	THE STYLESHEET OF api.myweblog.se, in the same look as the admin site (admin.myweblog.se).

	Used by /index.php (start page, Main API v3.1, Mobile API, Support) and by the Main API
	documentation pages main/v4/index.html and main/v5dev/index.html.

	Light and dark follow the system setting. Every colour is a variable in :root, so a rule
	further down never needs a dark version of its own. Only the menu bar has fixed colours:
	it is navy in both.

	Contents:
	1. Colours and fonts
	2. Page basics
	3. The menu bar (nav.apinav)
	4. Page layout: the sheet, the side menu, the footer
	5. Text, tables and code
	6. The start page (one column per API, cards)
	7. Main API v3.1 and Mobile API (table.messageTable, .inData, .outData ...)
	8. Main API v4 and v5dev: the endpoints (div.req)
	9. Narrow screens and print
*/


/* 1. COLOURS AND FONTS (the admin palette) */

:root{
	--bg:#f4f6f9;
	--surface:#ffffff;
	--surface-2:#f0f3f7;
	--border:#d9dfe7;
	--text:#1d2430;
	--muted:#6b7684;
	--faint:#a4acb7;
	--accent:#2a6aa8;
	--accent-soft:#e3edf7;
	--danger:#b42318;
	--danger-soft:#fdecea;
	--sand:#8a5a00;
	--sand-soft:#fdf1d8;
	--good:#1e7a46;
	--good-soft:#e3f4ea;
	--violet:#7c3a9a;
	--font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
	--font-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}

@media (prefers-color-scheme: dark){
	:root{
		--bg:#17191c;
		--surface:#212428;
		--surface-2:#2a2e33;
		--border:#3a3f46;
		--text:#e3e6ea;
		--muted:#9aa3ad;
		--faint:#5f666e;
		--accent:#8fb8e0;
		--accent-soft:#22313f;
		--danger:#f19a90;
		--danger-soft:#3a2220;
		--sand:#f1d385;
		--sand-soft:#3a3120;
		--good:#7fd1a0;
		--good-soft:#1f3328;
		--violet:#d3a6e6;
		color-scheme:dark;
	}
}


/* 2. PAGE BASICS */

*{
	box-sizing:border-box;
}

html{
	/* A link to a heading stops below the menu bar, which stays at the top of the window */
	scroll-padding-top:68px;
}

body{
	margin:0;
	background:var(--bg);
	color:var(--text);
	font-family:var(--font);
	font-size:15px;
	line-height:1.5;
}

a{
	color:var(--accent);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible{
	outline:2px solid var(--accent);
	outline-offset:2px;
}


/* 3. THE MENU BAR (as nav.anav on the admin site) */

nav.apinav{
	position:sticky;
	top:0;
	z-index:9000;
	background-color:#0d1b2e;
	color:#e6ebf2;
	font-size:14px;
	line-height:1.4;
	box-shadow:0 1px 0 rgba(255,255,255,0.06), 0 2px 8px rgba(0,0,0,0.25);
}

nav.apinav .apinav-inner{
	max-width:1200px;
	margin:0 auto;
	padding:0 16px;
	display:flex;
	align-items:center;
	gap:18px;
	min-height:52px;
	flex-wrap:wrap;
}

nav.apinav a{
	color:inherit;
	text-decoration:none;
}

nav.apinav ul{
	list-style:none;
	margin:0;
	padding:0;
}

nav.apinav .apinav-brand{
	display:flex;
	align-items:center;
	gap:8px;
	font-weight:700;
	font-size:16px;
	letter-spacing:0.02em;
	white-space:nowrap;
}

nav.apinav .apinav-badge{
	font-size:11px;
	font-weight:700;
	letter-spacing:0.08em;
	text-transform:uppercase;
	background-color:#2a6aa8;
	color:#ffffff;
	border-radius:4px;
	padding:2px 6px;
}

nav.apinav .apinav-menu{
	display:flex;
	align-items:center;
	gap:2px;
	flex:1;
	flex-wrap:wrap;
}

nav.apinav .apinav-group{
	position:relative;
}

/* A choice in the bar: a link, or the button that opens a dropdown */
nav.apinav .apinav-top{
	display:inline-flex;
	align-items:center;
	gap:4px;
	font:inherit;
	color:#c9d3df;
	background:none;
	border:0;
	border-radius:6px;
	padding:7px 10px;
	cursor:pointer;
}

nav.apinav .apinav-top:hover,
nav.apinav .apinav-top[aria-expanded='true']{
	background-color:rgba(255,255,255,0.08);
	color:#ffffff;
}

/* The page being shown, or the group it belongs to */
nav.apinav .apinav-top[aria-current='page'],
nav.apinav .apinav-top.apinav-current{
	color:#ffffff;
	box-shadow:inset 0 -2px 0 #6fa8dc;
	border-radius:6px 6px 0 0;
}

nav.apinav .apinav-caret{
	font-size:10px;
	opacity:0.7;
}

nav.apinav .apinav-dropdown{
	position:absolute;
	left:0;
	top:calc(100% + 6px);
	z-index:9001;
	min-width:220px;
	background-color:var(--surface);
	border:1px solid var(--border);
	border-radius:8px;
	box-shadow:0 10px 30px rgba(0,0,0,0.25);
	padding:6px;
}

nav.apinav .apinav-dropdown[hidden]{
	display:none;
}

nav.apinav .apinav-dropdown a{
	display:flex;
	align-items:baseline;
	justify-content:space-between;
	gap:18px;
	padding:7px 10px;
	border-radius:6px;
	white-space:nowrap;
	color:var(--text);
}

nav.apinav .apinav-dropdown a:hover{
	background-color:var(--surface-2);
}

nav.apinav .apinav-dropdown a[aria-current='page']{
	background-color:var(--accent-soft);
	color:var(--accent);
	font-weight:600;
}

/* A small remark after a choice in a dropdown, e.g. "not supported" */
nav.apinav .apinav-note{
	font-size:12px;
	font-weight:400;
	color:var(--muted);
}

/* The right end of the bar */
nav.apinav .apinav-side{
	margin-left:auto;
	white-space:nowrap;
	color:#9fb0c4;
}

nav.apinav .apinav-side a:hover{
	color:#ffffff;
	text-decoration:underline;
}

/* The menu button (three lines) that unfolds the menu on a phone. Hidden on a wider screen,
   see section 9. */
nav.apinav .apinav-toggle{
	display:none;
	align-items:center;
	justify-content:center;
	width:40px;
	height:36px;
	margin-left:auto;
	background:none;
	border:0;
	border-radius:6px;
	cursor:pointer;
}

nav.apinav .apinav-toggle:hover,
nav.apinav .apinav-toggle[aria-expanded='true']{
	background-color:rgba(255,255,255,0.08);
}

nav.apinav .apinav-toggle-lines,
nav.apinav .apinav-toggle-lines::before,
nav.apinav .apinav-toggle-lines::after{
	display:block;
	width:20px;
	height:2px;
	border-radius:1px;
	background-color:#e6ebf2;
}

nav.apinav .apinav-toggle-lines{
	position:relative;
}

nav.apinav .apinav-toggle-lines::before,
nav.apinav .apinav-toggle-lines::after{
	content:"";
	position:absolute;
	left:0;
}

nav.apinav .apinav-toggle-lines::before{
	top:-6px;
}

nav.apinav .apinav-toggle-lines::after{
	top:6px;
}

nav.apinav a:focus-visible,
nav.apinav button:focus-visible{
	outline:2px solid #6fa8dc;
	outline-offset:2px;
}


/* 4. PAGE LAYOUT */

.page{
	max-width:1200px;
	margin:0 auto;
	padding:28px 16px 40px;
}

/* A page with the list of its headings to the left of the text */
.page.with-side-menu{
	display:grid;
	grid-template-columns:230px minmax(0,1fr);
	gap:28px;
	align-items:start;
}

/* The sheet: one long text on a surface of its own */
.sheet{
	background:var(--surface);
	border:1px solid var(--border);
	border-radius:10px;
	padding:28px 32px 36px;
	overflow-x:auto;
}

/* The side menu is filled in by /js/api.js. It stays in view while the text scrolls. */
.side-menu{
	position:sticky;
	top:76px;
	max-height:calc(100vh - 96px);
	overflow-y:auto;
	font-size:14px;
}

.side-menu summary{
	list-style:none;
	padding:4px 10px 8px;
	font-size:11px;
	font-weight:700;
	letter-spacing:0.06em;
	text-transform:uppercase;
	color:var(--muted);
	pointer-events:none;
}

.side-menu summary::-webkit-details-marker{
	display:none;
}

.side-menu a{
	display:block;
	padding:5px 10px;
	border-radius:6px;
	color:var(--text);
	text-decoration:none;
	overflow-wrap:anywhere;
}

.side-menu a:hover{
	background:var(--surface);
	color:var(--accent);
}

.side-menu a.level-1{
	font-weight:600;
	margin-top:6px;
}

.side-menu a.level-2{
	padding-left:22px;
}

.side-menu a.level-3{
	padding-left:36px;
	color:var(--muted);
}

footer.site-footer{
	max-width:1200px;
	margin:0 auto;
	padding:0 16px 40px;
	text-align:center;
	font-size:13px;
	color:var(--muted);
}


/* 5. TEXT, TABLES AND CODE */

h1{
	font-size:1.6em;
	line-height:1.25;
	margin:0 0 12px;
}

.sheet h2{
	font-size:1.2em;
	margin:36px 0 10px;
	padding-top:22px;
	border-top:1px solid var(--border);
}

.sheet h3{
	font-size:1.03em;
	margin:28px 0 8px;
}

p{
	margin:0 0 10px;
}

.sheet > p,
.sheet > ul,
.sheet > ol{
	max-width:85ch;
}

ul,
ol{
	margin:0 0 14px;
	padding-left:28px;
}

/* Space between the points of a list in the text, so each point reads on its own */
main li + li{
	margin-top:10px;
}

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

/* A warning in the text, and what is marked as development in v5dev */
.highLight,
.dev{
	color:var(--danger);
}

p.dev{
	border-left:3px solid var(--danger);
	padding-left:12px;
}

p.dev > a{
	color:var(--danger);
}

main table{
	width:100%;
	margin:12px 0 18px;
	border:1px solid var(--border);
	border-radius:8px;
	border-spacing:0;
	overflow:hidden;
	font-size:0.93em;
}

main th,
main td{
	padding:8px 12px;
	text-align:left;
	vertical-align:top;
	border-bottom:1px solid var(--border);
}

main tr:last-child > th,
main tr:last-child > td{
	border-bottom:0;
}

/* An address or a name in a cell may break anywhere, so a long one never makes the table wider than the sheet */
main td code,
main td a{
	overflow-wrap:anywhere;
}

/* Column headings. The v3.1 and Mobile API tables have no thead: there every th is a column heading. */
main thead th,
table.messageTable th{
	background:var(--surface-2);
	color:var(--muted);
	font-family:var(--font);
	font-size:0.88em;
	font-weight:600;
	white-space:normal;
}

/* thead is not the last row of its table, so it keeps its line */
main thead tr:last-child > th{
	border-bottom:1px solid var(--border);
}

/* Row headings: the name of a header, a filter, a status or an error code. A long one wraps, so the table stays inside the sheet. */
main tbody th{
	font-family:var(--font-mono);
	font-size:0.95em;
	font-weight:600;
}

/* Code examples. The line breaks and the indentation are in the text (<br> and &nbsp;). */
.code{
	margin:10px 0 16px;
	padding:12px 14px;
	background:var(--surface-2);
	border:1px solid var(--border);
	border-radius:8px;
	font-family:var(--font-mono);
	font-size:0.88em;
	line-height:1.55;
	overflow-wrap:anywhere;
}

.code > .fldname{
	color:var(--accent);
}

.code > .string{
	color:var(--danger);
}

.code > .int{
	color:var(--good);
}

.code > .comment{
	color:var(--muted);
	font-style:italic;
}

/* Small labels: a status, a response code */
.chip,
td.rsp div{
	display:inline-block;
	padding:2px 9px;
	border-radius:999px;
	background:var(--surface-2);
	color:var(--muted);
	font-family:var(--font);
	font-size:0.8em;
	font-weight:600;
	white-space:nowrap;
}

.chip.good,
td.ok div{
	background:var(--good-soft);
	color:var(--good);
}

.chip.danger,
td.err div{
	background:var(--danger-soft);
	color:var(--danger);
}

/* A version that is still working but will end */
.chip.ending{
	background:var(--sand-soft);
	color:var(--sand);
}


/* 6. THE START PAGE

	<div class="api-columns">                  the Main API and the Mobile API side by side
		<section class="api-column">           one API: its name, who it is for, its versions
			<a class="card card-current">       the current version, large
			<h3 class="older-heading">
			<a class="card card-old">           an older version, small and muted
*/

.lead{
	max-width:85ch;
	font-size:1.07em;
}

.api-columns{
	display:grid;
	grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr));
	gap:28px;
	margin:26px 0 28px;
}

.api-column h2{
	font-size:1.35em;
	margin:0 0 6px;
	padding-bottom:8px;
	border-bottom:3px solid var(--accent);
}

.api-column-intro{
	margin-bottom:16px;
}

.older-heading{
	font-size:0.8em;
	font-weight:600;
	text-transform:uppercase;
	letter-spacing:0.06em;
	color:var(--muted);
	margin:22px 0 8px;
}

.card{
	background:var(--surface);
	border:1px solid var(--border);
	border-radius:10px;
	padding:18px 20px;
	margin-bottom:14px;
}

.card h2,
.card h3,
.card h4{
	display:flex;
	align-items:center;
	gap:8px;
	flex-wrap:wrap;
	font-size:1.08em;
	margin:0 0 8px;
}

/* The current version of an API: it stands out */
a.card-current{
	border:2px solid var(--accent);
	box-shadow:0 2px 10px rgba(0,0,0,0.08);
	padding:22px 24px;
}

a.card-current h3{
	font-size:1.3em;
}

a.card-current .card-link{
	font-size:1em;
}

/* An older version of an API: it steps back */
a.card-old{
	background:var(--surface-2);
	padding:12px 16px;
	margin-bottom:8px;
	font-size:0.93em;
}

a.card-old h4{
	font-size:1em;
	margin-bottom:4px;
}

a.card-old p{
	color:var(--muted);
	margin-bottom:0;
}

.card p{
	max-width:95ch;
}

.card p:last-child{
	margin-bottom:0;
}

/* A card that is a link to a documentation page */
a.card{
	display:flex;
	flex-direction:column;
	color:var(--text);
	text-decoration:none;
}

a.card:hover{
	border-color:var(--accent);
}

a.card .card-link{
	margin-top:auto;
	padding-top:6px;
	color:var(--accent);
	font-weight:600;
	font-size:0.93em;
}


/* 7. MAIN API V3.1 AND MOBILE API */

/* The same column widths in every table, so the tables of a method line up */
table.messageTable th:first-child,
table.messageTable td:first-child{
	width:32%;
}

table.messageTable th:nth-child(2),
table.messageTable td:nth-child(2){
	width:22%;
}

/* Names in the text: an address, an input, an output */
span.webAddress,
span.inData,
span.outData{
	font-family:var(--font-mono);
	font-size:0.93em;
	font-weight:600;
	overflow-wrap:anywhere;
}

span.webAddress{
	color:var(--good);
}

span.inData{
	color:var(--violet);
}

span.outData{
	color:var(--accent);
}

/* A name that is new in this version */
span.newData{
	border-left:2px solid var(--sand);
	padding-left:5px;
}


/* 8. MAIN API V4 AND V5DEV: THE ENDPOINTS

	<div class="req">                       one resource, or one example
		<div><h3>users</h3></div>
		<div class="get">                   one endpoint; also post, put, patch, delete and tbi (to be implemented)
			<table><tr class="showhide">    the row to click: method, address, short text
			<div class="description hide">  the details, shown and hidden by mwlapi.js
*/

div.req{
	margin:0 0 22px;
}

div.req > div.get,
div.req > div.post,
div.req > div.put,
div.req > div.patch,
div.req > div.delete,
div.req > div.tbi{
	margin-top:8px;
	border:1px solid var(--border);
	border-radius:8px;
	overflow:hidden;
}

/* The row to click */
div.req > div > table{
	margin:0;
	border:0;
	border-radius:0;
	font-size:1em;
}

div.req > div > table td{
	padding:9px 12px;
	vertical-align:middle;
	border:0;
}

div.req > div > table td:first-child{
	width:92px;
}

div.req > div > table td:nth-child(2){
	width:36%;
	font-family:var(--font-mono);
	font-size:0.9em;
	overflow-wrap:anywhere;
}

tr.showhide{
	cursor:pointer;
}

tr.showhide:hover td{
	background:var(--surface-2);
}

/* The arrow at the end of the row: down when closed, up when the details are shown */
tr.showhide td:last-child{
	position:relative;
	padding-right:38px;
}

tr.showhide td:last-child::after{
	content:"";
	position:absolute;
	right:16px;
	top:50%;
	width:7px;
	height:7px;
	border-right:2px solid var(--muted);
	border-bottom:2px solid var(--muted);
	transform:translateY(-70%) rotate(45deg);
}

div.req > div:has(> .description:not(.hide)) tr.showhide td:last-child::after{
	transform:translateY(-30%) rotate(-135deg);
}

/* The method, coloured as the kind of endpoint */
div.req > div > table td:first-child div{
	min-width:66px;
	padding:3px 8px;
	border-radius:6px;
	text-align:center;
	font-family:var(--font-mono);
	font-size:0.8em;
	font-weight:700;
	letter-spacing:0.03em;
}

div.req > div.get > table td:first-child div{
	background:var(--accent-soft);
	color:var(--accent);
}

div.req > div.post > table td:first-child div{
	background:var(--good-soft);
	color:var(--good);
}

/* PUT sets an item and PATCH changes one: both look the same */
div.req > div.put > table td:first-child div,
div.req > div.patch > table td:first-child div{
	background:var(--sand-soft);
	color:var(--sand);
}

div.req > div.delete > table td:first-child div{
	background:var(--danger-soft);
	color:var(--danger);
}

/* To be implemented: faint (closer to the background than the muted text), and nothing to click */
div.req > div.tbi{
	border-style:dashed;
	color:var(--faint);
}

div.req > div.tbi > table td:first-child div{
	background:var(--surface-2);
	color:var(--faint);
}

/* The details of an endpoint */
div.description{
	border-top:1px solid var(--border);
	padding:2px 6px 8px;
	overflow-x:auto;
}

div.description > table{
	margin:0;
	border:0;
	border-radius:0;
	font-size:0.95em;
}

div.description > table thead th{
	background:none;
}

div.description > table td{
	border:0;
}

div.description > table td:first-child{
	width:48%;
	min-width:240px;
}

/* Filters, blocks and inputs are names, so they are written as code */
div.description > table td:not(:first-child):not(.rsp){
	font-family:var(--font-mono);
	font-size:0.9em;
	overflow-wrap:anywhere;
}

.hide{
	display:none;
}


/* 9. NARROW SCREENS AND PRINT */

@media (max-width:900px){

	/* The menu bar may take two rows here, so it scrolls away with the page */
	nav.apinav{
		position:static;
	}

	html{
		scroll-padding-top:12px;
	}

	/* The side menu becomes a box above the text, folded until it is clicked (js/api.js uses the same width) */
	.page.with-side-menu{
		display:block;
	}

	.side-menu{
		position:static;
		max-height:none;
		margin-bottom:16px;
		padding:8px;
		background:var(--surface);
		border:1px solid var(--border);
		border-radius:10px;
	}

	.side-menu summary{
		padding:6px 10px;
		pointer-events:auto;
		cursor:pointer;
	}

	.side-menu summary::after{
		content:" \25BE";
	}

	.side-menu a:hover{
		background:var(--surface-2);
	}

	.sheet{
		padding:20px 16px 26px;
	}

	/* Row headings may break inside a name here, so a table fits a narrow screen */
	main tbody th{
		overflow-wrap:anywhere;
	}

	div.description > table td:first-child{
		min-width:0;
	}
}

/* A phone: the bar shows only the name and the menu button. The button unfolds the menu below
   the name as a list, with a dropdown's choices indented under its group, and www.myweblog.se last.
   (The FFK and key pages have no menu and no button, so their www.myweblog.se link stays in the bar.) */
@media (max-width:700px){

	nav.apinav .apinav-inner{
		gap:0;
	}

	/* The first row keeps the height of the bar, also when the menu is unfolded below it */
	nav.apinav .apinav-brand{
		min-height:52px;
	}

	nav.apinav .apinav-toggle{
		display:inline-flex;
	}

	nav.apinav .apinav-toggle ~ .apinav-menu,
	nav.apinav .apinav-toggle ~ .apinav-side{
		display:none;
	}

	nav.apinav.apinav-open .apinav-toggle ~ .apinav-menu,
	nav.apinav.apinav-open .apinav-toggle ~ .apinav-side{
		display:block;
		flex-basis:100%;
	}

	nav.apinav .apinav-menu{
		padding:4px 0 8px;
	}

	nav.apinav .apinav-top{
		display:flex;
		justify-content:space-between;
		width:100%;
		padding:10px;
		text-align:left;
	}

	/* The page being shown: a line at the left instead of underneath */
	nav.apinav .apinav-top[aria-current='page'],
	nav.apinav .apinav-top.apinav-current{
		box-shadow:inset 3px 0 0 #6fa8dc;
		border-radius:0 6px 6px 0;
	}

	nav.apinav .apinav-dropdown{
		position:static;
		min-width:0;
		background:none;
		border:0;
		box-shadow:none;
		padding:0 0 4px 16px;
	}

	nav.apinav .apinav-dropdown a{
		padding:10px;
		white-space:normal;
		color:#c9d3df;
	}

	nav.apinav .apinav-dropdown a:hover{
		background-color:rgba(255,255,255,0.08);
		color:#ffffff;
	}

	nav.apinav .apinav-dropdown a[aria-current='page']{
		background-color:rgba(111,168,220,0.18);
		color:#ffffff;
	}

	nav.apinav .apinav-note{
		color:#9fb0c4;
	}

	nav.apinav .apinav-toggle ~ .apinav-side{
		margin-left:0;
		padding:10px 10px 14px;
		border-top:1px solid rgba(255,255,255,0.12);
	}
}

@media print{

	nav.apinav,
	.side-menu{
		display:none;
	}

	body{
		background:#ffffff;
	}

	.page.with-side-menu{
		display:block;
	}

	.sheet{
		border:0;
		padding:0;
	}
}
