/* Fragment Mono, served from the site (SIL Open Font License, fonts/OFL.txt); regular only, bold is synthesized */
@font-face {
	font-family: 'Fragment Mono';
	src: url('../fonts/fragment-mono-latin-400-normal.woff2') format('woff2');
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: 'Fragment Mono';
	src: url('../fonts/fragment-mono-latin-400-italic.woff2') format('woff2');
	font-weight: 400;
	font-style: italic;
	font-display: swap;
}

:root {
	--navy: #201E50;
	--blue: #2A5C8A;
	--teal: #3E8E9C;
	--orange: #E08A3C;
	--sky: #E3F4F6;
	--muted: #6b6a8c;
	--font: 'Fragment Mono', monospace;
	/* flat offset shadow, no blur: the retro "printed" look */
	--shadow: 4px 4px 0 var(--navy);
}

/* always reserve the scrollbar space: in short windows the scrollbar would come and go and shift the page sideways */
html {
	scrollbar-gutter: stable;
}

body {
	background-color: var(--sky);
	color: var(--navy);
	font-family: var(--font);
	font-size: 14px;
}

/* form controls don't inherit the font by default */
button, input, select, textarea {
	font: inherit;
}

/* one link style: underlined, blue and thicker on hover (menus, logo and buttons excepted) */
a, a:visited {
	color: var(--navy);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

a:hover {
	color: var(--blue);
	text-decoration-thickness: 2px;
}

/* one button for the whole site: outlined pill with a hard shadow, inverted on hover, pressed into its shadow on click */
button, input[type=submit], input[type=button], input[type=reset], a.button, a.card-button {
	display: inline-block;
	width: fit-content;
	padding: 8px 20px;
	border: 2px solid var(--navy);
	border-radius: 25px;
	background-color: #fff;
	color: var(--navy);
	letter-spacing: 1px;
	text-decoration: none;
	box-shadow: 3px 3px 0 var(--navy);
	cursor: pointer;
}

button:hover, input[type=submit]:hover, input[type=button]:hover, input[type=reset]:hover, a.button:hover, a.card-button:hover {
	background-color: var(--navy);
	color: var(--sky);
}

button:active, input[type=submit]:active, input[type=button]:active, input[type=reset]:active, a.button:active, a.card-button:active {
	transform: translate(2px, 2px);
	box-shadow: 1px 1px 0 var(--navy);
}

/* one field for the whole site: dotted underline, solid blue while typing (same thickness, so nothing moves);
   textareas too, growing downwards */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input:not([type]), textarea {
	color: var(--navy);
	background-color: transparent;
	border: none;
	border-bottom: 2px dotted var(--navy);
	border-radius: 0;
	padding: 3px 2px;
	outline: none;
}

/* textareas grow with their text where the browser can (field-sizing), at least 3 lines */
textarea {
	line-height: 1.5;
	resize: vertical;
	field-sizing: content;
	min-height: calc(4.5em + 8px);
}

select {
	color: var(--navy);
	background-color: transparent;
	border: 2px dotted var(--navy);
	border-radius: 0;
	padding: 3px 5px;
	outline: none;
}

input[type=text]:focus, input[type=email]:focus, input[type=password]:focus, input[type=number]:focus,
input[type=url]:focus, input:not([type]):focus, textarea:focus {
	border-bottom: 2px solid var(--blue);
}

select:focus {
	border: 2px solid var(--blue);
}

input[type=checkbox], input[type=radio] {
	accent-color: var(--navy);
	cursor: pointer;
}

/* cards: every form, the admin blocks, the Mimo settings; white, navy border, hard shadow */
.card, .admin-card {
	border: 2px solid var(--navy);
	border-radius: 10px;
	background-color: #fff;
	box-shadow: var(--shadow);
	padding: 10px 20px 20px;
	margin: 20px 0;
	color: var(--navy);
	display: flex;
	flex-direction: column;
	gap: 15px;
	max-width: 600px;
}

.card h3, .admin-card h3 {
	margin: 5px 0;
}

/* the site shows links as blocks with a margin; not inside the cards */
.card h3 a, .admin-card h3 a {
	display: inline;
}

.card a, .admin-card a, .card p, .admin-card p {
	margin: 0;
}

/* the card's gap spaces its rows; the button sits a bit lower, at the left */
.card .form-row, .admin-card .form-row {
	margin: 0;
}

.card input[type=submit], .admin-card input[type=submit] {
	align-self: flex-start;
	margin-top: 10px;
}

/* link cards: a whole card is the link, a name and a line of description (home page apps, Mimo modes) */
.app-cards {
	display: flex;
	flex-direction: column;
	gap: 15px;
	max-width: 600px;
	margin-top: 15px;
}

a.app-card, a.app-card:visited {
	display: flex;
	flex-direction: column;
	width: auto;
	gap: 4px;
	margin: 0;
	padding: 14px 20px;
	border: 2px solid var(--navy);
	border-radius: 10px;
	background-color: #fff;
	box-shadow: var(--shadow);
	color: var(--navy);
	text-decoration: none;
}

a.app-card:hover {
	color: var(--navy);
	border-color: var(--blue);
	box-shadow: 4px 4px 0 var(--blue);
}

a.app-card:active {
	transform: translate(2px, 2px);
	box-shadow: 2px 2px 0 var(--navy);
}

span.app-name {
	font-weight: bold;
	font-size: 1.1rem;
}

span.app-description {
	color: var(--muted);
	line-height: 1.5;
}

a.app-card.inactive {
	opacity: 0.5;
}

span.app-off {
	font-weight: normal;
	font-size: 0.8rem;
}

/* form rows (templates/_form.html): label and field on one line, the fields lined up after a label column;
   on phones the label goes above its field (media query below) */
.form-row {
	display: grid;
	grid-template-columns: 11rem minmax(0, 1fr);
	align-items: baseline;
	gap: 4px 12px;
	margin: 14px 0;
	max-width: 36rem;
}

.form-row > label {
	color: var(--navy);
}

/* a textarea's baseline moves as it scrolls: its row aligns to the top, the label on the first line */
.form-row:has(textarea) {
	align-items: start;
}

.form-row:has(textarea) > label {
	padding-top: 3px;
}

.form-input {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.form-input input[type=text], .form-input input[type=email], .form-input input[type=password],
.form-input input:not([type]), .form-input textarea {
	width: 100%;
	box-sizing: border-box;
}

.form-input select {
	width: fit-content;
	max-width: 100%;
}

/* checkboxes sit in the field column, their text beside them; at the left in a form that has only checkboxes */
.form-row.check > * {
	grid-column: 2;
}

form:not(:has(.form-row:not(.check))) .form-row.check > * {
	grid-column: 1 / -1;
}

.form-row.check > label {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
}

span.field-hint {
	font-size: 0.7rem;
	color: var(--muted);
}

span.field-error {
	font-size: 0.8rem;
	color: #B5471B;
}

@media (max-width: 600px) {
	.form-row {
		grid-template-columns: minmax(0, 1fr);
	}

	.form-row.check > * {
		grid-column: 1;
	}
}

/* keyboard navigation: a dotted blue outline on whatever has the focus */
:focus-visible {
	outline: 2px dotted var(--blue);
	outline-offset: 3px;
}

header {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	width: 1000px;
	margin: auto;
	max-width: 90%;
}

div.branding {
	text-align: left;
	width: 50%;
	padding-bottom: 25px;
}

span#dot {
	color: #2A5C8A;
	/* pulses every 3 seconds (20 bpm), and turns orange for about a second once a minute */
	animation: dot-pulse 3s ease-in-out infinite, dot-orange 60s linear infinite;
}

@keyframes dot-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.35; }
}

@keyframes dot-orange {
	0%, 97% { color: #2A5C8A; }
	98%, 99.5% { color: #E08A3C; }
	100% { color: #2A5C8A; }
}

@media (prefers-reduced-motion: reduce) {
	span#dot {
		animation: none;
	}
}

span#domain {
	color: #3E8E9C;
}

h1, h2 {
	font-family: var(--font);
	color: #201E50;
	text-decoration: none;
}

h1#site-title {
	font-size: 45px;
	margin: 20px 0 0;
	display: block;
	width: fit-content;
}

span#version-number {
	font-size: 1em;
	font-family: var(--font);
	color: #201E50;
	text-decoration: none;
	text-align: center;
	display: inline-block;
	font-weight: bold;
}

h2 {
	font-size: 2em;
}

nav#main-nav {
	max-width: calc(100% - 425px);
}

ul#nav-mainlist {
	width: 100%;
	height: 100%;
	display: flex;
	list-style-type: none;
	padding: 0;
	margin: 0;
	flex-direction: row;
	justify-content: center;
	align-items: flex-end;
}


ul#nav-mainlist > li {
	padding: 20px 25px;
	text-align: center;
	font-family: var(--font);
	position: relative;
}


ul#nav-mainlist li:hover ul.nav-sublist {
	display: flex;
	width: max-content;
	min-width: 100%;
	list-style-type: none;
	padding: 10px 20px;
	flex-direction: column;
	justify-content: center;
	position: absolute;
	left: 0;
	right: 0;
	margin: 15px auto;
	border: 2px solid var(--navy);
	background-color: var(--sky);
	box-shadow: 2px 2px 0 var(--navy);
}

ul#nav-mainlist li ul.nav-sublist {
	display: none;
}

nav#main-nav ul#nav-mainlist li ul.nav-sublist > li {
	margin: 10px 0;
	padding: 3px;
	white-space: nowrap;
	font-size: 0.85em;
}

nav a {
	display: block;
	width: fit-content;
}

nav#main-nav ul li a {
	color: #201E50;
	text-decoration: none;
	text-transform: uppercase;
	font-family: var(--font);
}

nav#main-nav ul li a:hover {
	text-decoration: underline;
	text-decoration-thickness: 2px;
}

nav#main-nav ul li a.current span {
	font-weight: bold;
}

p, h3, li, a {
	color: #201E50;
	font-family: var(--font);
}

p, h3 {
	margin: 10px 0;
}

section li, section a {
	color: #201E50;
	font-family: var(--font);
	margin: 10px 0;
}

a {
	display: block;
}

p > a {
	display: inline-block;
}

section ul {
	list-style-type: none;
	padding: 0;
}

section ul.users-list {
	padding-left: 10px;
}

section ul.users-list > li.user {
	margin: 20px 0;
}

section ul li h3 {
	display: inline-block;
	margin: 0;
	font-weight: bold;
}

section ul li h3 + span {
	font-weight: bold;
}

section ul li span {
	font-size: 16px;
}


header div.branding a {
	text-decoration: none;
}

section {
	width: 1000px;
	margin: 40px auto;
	max-width: 90%;
}

/* messages: white, with a colored edge and a small label (info / ok / erreur) */
div.alert {
	box-sizing: border-box;
	color: var(--navy);
	background-color: #fff;
	border-left: 4px solid var(--blue);
	border-radius: 6px;
	padding: 10px 16px;
	line-height: 1.5;
	overflow-wrap: anywhere;
}

div.alert::before {
	content: 'info';
	display: block;
	font-size: 0.7rem;
	letter-spacing: 1px;
	color: var(--blue);
}

div.alert-success {
	border-left-color: var(--teal);
}

div.alert-success::before {
	content: 'ok';
	color: var(--teal);
}

div.alert-danger {
	border-left-color: var(--orange);
}

div.alert-danger::before {
	content: 'erreur';
	color: #B5471B;
}

/* the page messages sit between the header and the page, aligned with it */
body > div.alert {
	width: 1000px;
	max-width: 90%;
	margin: 30px auto 0;
}

section div.alert {
	margin: 0 0 20px;
	max-width: 600px;
}


@media (max-width: 950px) {
	body header {
		flex-direction: column;
		align-items: center;
	}
	
	header div.branding {
		width: auto;
		max-width: 95%;
	}

	header nav#main-nav {
		width: auto;
		max-width: 95%;
	}
	
	header span#version-number {
		margin: auto;
		display: block;
	}
}

@media (max-width: 500px) {
	html body header {
		align-items: center;
	}
	
	div.branding h1#site-title {
		font-size: 30px;
	}
	nav#main-nav ul#nav-mainlist {
		justify-content: space-between;
	}

	/* the items are spread over the width anyway: small side padding so four fit on a phone,
	   and the padding is on the link so the whole block can be tapped */
	nav#main-nav ul#nav-mainlist > li {
		padding: 0;
	}

	nav#main-nav ul#nav-mainlist > li > a {
		padding: 15px 5px;
	}
	
	body header nav#main-nav {
		width: 100%;
		max-width: 100%;
	}
	
	nav#main-nav ul#nav-mainlist li:hover ul.nav-sublist {
		display: none;
	}
}

/* phones: taller buttons and links, easy to tap (about 44px) */
@media (max-width: 600px) {
	button, input[type=submit], input[type=button], input[type=reset], a.button, a.card-button {
		padding: 12px 22px;
	}

	/* links alone on their line: the tap area grows, not the text */
	section a {
		padding: 8px 0;
		margin: 2px 0;
	}

	/* links inside a sentence: inline, so the taller tap area doesn't move the lines */
	p a, p > a, span a {
		display: inline;
		padding: 8px 0;
	}
}

/* switched-off apps, only listed for admins */
nav#main-nav span.app-item.inactive, section a.inactive {
	opacity: 0.45;
}
