/* Colours: light here, dark under body.dark (script.js sets it). */
:root {
	--ease: cubic-bezier(.79, .2, .65, .97);
	--bg: #fff;
	--text: #212529;
	--panel: #f1f1f1;
	--tab: #f8f8f8;
	--code-bg: #fff;
	--field-bg: #fff;
	--field-border: #ced4da;
	--muted: #888;
	--accent: #007bff;
}

body.dark {
	--bg: #000;
	--text: #fff;
	--panel: #1d1d1d;
	--tab: #171717;
	--code-bg: #282828;
	--field-bg: #282828;
	--field-border: #000;
	--muted: #aaa;
	--accent: #4ea1ff;
}

body {
	background-color: var(--bg);
	color: var(--text);
	font-family: Verdana, sans-serif;
	overflow-y: scroll;
	text-rendering: geometricPrecision;
}

/* Only after the first theme switch, so the first load does not fade from white */
body.theme-smooth {
	transition: color .6s var(--ease), background-color .8s var(--ease);
}

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


/* Start: the big title fades in, then the page over it (script.js removes the two classes on body) */
#page,
#big-title > div {
	transition: opacity .3s var(--ease);
}

#big-title {
	align-items: center;
	display: flex;
	height: 95vh;
	justify-content: center;
	left: 0;
	pointer-events: none;
	position: fixed;
	right: 0;
	text-align: center;
	top: 0;
}

/* Above the fixed big title */
#page { position: relative; z-index: 1; }

.page-waiting #page,
.title-waiting #big-title > div { opacity: 0; }


/* Tabs: a column on the left of the sheet on wide screens, a row above it on small ones */
.sheet { position: relative; }

.tabs {
	display: flex;
	flex-wrap: wrap;
	margin-top: 6px;
	user-select: none;
}

.tabs > a {
	background-color: var(--tab);
	box-shadow: 0 -32px 10px -20px var(--bg) inset;
	color: var(--text);
	font-weight: 600;
	margin: 0 4px -1px 0;
	padding: 15px 25px;
	text-align: center;
	text-decoration: none;
	transition: all .3s var(--ease);
}

.tabs > a:hover { color: var(--muted); }
.tabs > a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.tabs > a[aria-current="page"] {
	background-color: var(--panel);
	box-shadow: none;
}

@media (max-width: 575.98px) {
	.tabs > a { padding: 15px 14px; }
}

@media (min-width: 1300px) {
	/* Read bottom to top, so the first tab sits at the bottom */
	.tabs {
		flex-wrap: nowrap;
		margin-top: 0;
		position: absolute;
		right: 100%;
		top: 0;
		transform: rotate(180deg);
		writing-mode: vertical-rl;
	}

	.tabs > a {
		/* rotate(180deg) mirrors this: +32px ends up on the right, the side of the content */
		box-shadow: 32px 0 10px -20px var(--bg) inset;
		margin: 0 -1px 4px 0;
		padding: 25px 15px;
	}
}


/* The open sheet */
.tab {
	background-color: var(--panel);
	display: none;
	/* The browser scrolls to the #hash section on load: this keeps the page at the top, tabs in view */
	scroll-margin-top: 100vh;
	margin-bottom: 20px;
	padding: 15px;
}

.tab.open,
.tab:target { display: flex; }

/* script.js opens a tab with .open; :target is the fallback without JS. Both at once never happens, except here: */
.js .tab:target:not(.open) { display: none; }

.tab > div { font-size: 14px; }


/* Headings */
h1, h2, h3 { user-select: none; }
h2 { font-size: 36px; font-weight: bold; margin-top: 25px; }
h3 { display: inline-block; font-size: 1.75rem; margin: 0; }


/* Code */
code { margin-right: 10px; }

/* `code` inside notes and explainers */
.note code,
.explainer code { margin: 0; padding: 0 2px; }

pre {
	background: var(--code-bg) !important;
	border: none !important;
	border-radius: 3px;
	max-height: 250px;
}

code[class*="language-"],
pre[class*="language-"] { text-shadow: none !important; }

/* Prism's light theme gives these a pale background that looks wrong on the dark one */
body.dark .token.operator,
body.dark .token.entity,
body.dark .token.url,
body.dark .language-css .token.string,
body.dark .style .token.string { background: none; }

pre::-webkit-scrollbar { height: 8px; width: 8px; }
pre::-webkit-scrollbar-corner,
pre::-webkit-scrollbar-track { background-color: transparent; }
pre::-webkit-scrollbar-thumb { background-color: #88888842; border-radius: 8px; }


/* One line: [copy|code] note */
.line {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 0 10px;
	margin-bottom: .5rem;
}

.snippet {
	display: inline-flex;
	max-width: 100%;
}

.oneline {
	background: var(--code-bg) !important;
	border-radius: 0 3px 3px 0;
	font-size: 13px;
	line-height: 1.8 !important;
	margin: 0;
	overflow-x: auto;
	padding: 8px 15px !important;
	white-space: nowrap !important;
}

.note { padding: 4px 0; }


/* A block: [copy] title, then the code */
.block { margin: .5rem 0 1rem; }
.block-title { align-items: center; display: flex; gap: 10px; margin-bottom: .5rem; }
.block .caption { font-size: 1rem; font-weight: 500; margin: 0; }
.block .explainer { margin: .5rem 0; }


/* Copy button, with a "Copied!" bubble */
.copy {
	border: none;
	border-radius: 3px 0 0 3px;
	flex: none;
	padding: 6px 10px;
	position: relative;
}

.block .copy { border-radius: 3px; }
.copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy img { vertical-align: middle; width: 20px; }

.copy::after {
	background: var(--accent);
	border-radius: 4px;
	bottom: calc(100% + 6px);
	color: #fff;
	content: attr(data-copied);
	font-size: 13px;
	font-weight: bold;
	left: 50%;
	opacity: 0;
	padding: 4px 8px;
	pointer-events: none;
	position: absolute;
	transform: translateX(-50%);
	transition: opacity .1s;
	white-space: nowrap;
	z-index: 10;
}

.copy[data-copied]::after { opacity: 1; }


/* Dropdowns and the key code tester */
.picker { margin: 1rem 0 .5rem; }
.picker select { margin-top: .5rem; }

.key-tester { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }
.key-tester label { display: flex; flex: 1 1 8rem; flex-direction: column; font-weight: 600; margin: 0; }
.key-tester .press { flex-basis: 100%; }

.form-control,
.form-control:focus,
.form-control[readonly] {
	background-color: var(--field-bg);
	border-color: var(--field-border);
	color: var(--text);
}


/* Bottom bar: window width and height, theme button */
#bottom-bar {
	align-items: center;
	bottom: 0;
	display: flex;
	gap: .5rem;
	left: 0;
	padding: .5rem;
	pointer-events: none;
	position: fixed;
	right: 0;
	z-index: 5;
}

#bottom-bar > * { pointer-events: auto; }

#bottom-bar label {
	align-items: center;
	background: var(--tab);
	border: 1px solid var(--field-border);
	border-radius: 4px;
	display: flex;
	margin: 0;
	padding-left: 10px;
}

#bottom-bar input {
	background: var(--field-bg);
	border: none;
	border-left: 1px solid var(--field-border);
	color: var(--text);
	margin-left: 10px;
	padding: 6px 10px;
	width: 5.5rem;
}

#theme-switch {
	background: var(--tab);
	color: var(--text);
	margin-left: auto;
}

@media (max-width: 575.98px) {
	#bottom-bar label { display: none; }
}
