
/****************************
Structure générale de la page
*****************************/

:root {
	--fontsize: calc(9px + 1vmin);
}

* {
	margin: 0;
	padding: 0;
	font-family: Arial, sans-serif;
	box-sizing: border-box;
}

*:focus {
	outline: none;
}

@font-face {
	font-family: "Inconsolata";
	src: url("../fonts/Inconsolata.ttf") format("truetype");
	font-display: swap;
}

body, button {
	font-size: var(--fontsize);
	color: black;
}

body {
	overflow: hidden;
	height: 100svh;
	width: 100svw;
	/* Attention au calcul précis de la hauteur du header et du footer : taille des polices + paddings + margins */
	background-image: linear-gradient(0deg, darkolivegreen 0svh, transparent calc(var(--fontsize) + 4vmin), transparent calc(100svh - 4.3 * var(--fontsize) - 5vmin), #f2fdf2 100svh), url("../images/background.png");
	background-repeat: no-repeat, repeat;
	/*background-color: #C2DBC2;*/
	display: flex;
	align-items: center;
	flex-direction: column;
}

p {
	width: 100%;
	max-width: 100%;
	text-align: justify;
}

ul, li {
	text-align: justify;
}

li {
	margin-left: 2ch;
}

a {
	color: #0B4F8A;
	text-decoration: underline;
	transition: color 0.3s ease, text-shadow 0.3s ease;
}

a:visited {
	color: #5C3D7A;
}

a:hover {
	color: #0E6BB8;
	text-shadow: 0 0 0.4vmin rgba(255, 255, 224, 0.8);
}

a:active {
	color: #08385F;
}

/****************************
Écran de chargement
*****************************/

#loadingScreen {
	position: fixed;
	top: 0;
	left: 0;
	width: 100svw;
	height: 100svh;
	justify-content: center;
	align-items: center;
	background-color: black;
	z-index: 10;
}

.notloading {
	display: none;
}

.isloading {
	display: flex;
}

.isloading::after {
	content: "";
	width: 20vmin;
	height: 20vmin;
	border: 6vmin solid lightgray;
	border-top-color: mediumseagreen;
	border-radius: 50%;
	animation: loading 0.75s ease infinite;
}

@keyframes loading {
	from {
		transform: rotate(0turn);
	}
	to {
		transform: rotate(1turn);
	}
}

/****************************
Entête et pied-de-page
*****************************/

#flags {
	position: absolute;
	top: 1vmin;
	left: 1vmin;
	display: flex;
	flex-direction: row;
	gap: 1vmin;
}

#flags img {
	height: 3vmin;
	width: 4.5vmin;
	margin: 0;
	padding: 0;
	border: 1px solid black;
	border-radius: 1vmin;
}

#flags a {
	display: inline-block;
	margin: 0;
	padding: 0;
	height: 3vmin;
	border-radius: 1vmin;
	transition: box-shadow 0.3s ease;
}

#flags a:hover {
	box-shadow: 0 0 0.5vmin 0.5vmin lightyellow;
}

#flags .selected {
	cursor: not-allowed;
	outline: 0.3vmin solid black;
}

#suggestLang {
	position: absolute;
	top: calc(100% + 1vmin);
	left: 0;
	padding: 0.8vmin;
	border: 1px solid black;
	border-radius: 1vmin;
	background-color: lightyellow;
	white-space: nowrap;
	font-size: calc(0.8 * var(--fontsize));
	box-shadow: 0 0.25vmin 0.5vmin 0.25vmin rgba(0, 0, 0, 0.25);
	z-index: 1;
	opacity: 0;
	pointer-events: none;
	animation: suggestLangBubble 5s ease forwards;
}

#suggestLang::before {
	content: "";
	position: absolute;
	top: calc(-0.8vmin - 1px);
	width: calc(2vmin + 2px);
	height: calc(0.8vmin + 1.5px);
	background-color: black;
	aspect-ratio: 1/cos(30deg);
	clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
#suggestLang::after {
	content: "";
	position: absolute;
	top: -0.8vmin;
	width: 2vmin;
	height: calc(0.8vmin + 0.5px);
	background-color: lightyellow;
	clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

#suggestLang.to-fr::before {
	left: calc(1.25vmin - 1px);
}
#suggestLang.to-en::before {
	left: calc(6.75vmin - 1px);
}
#suggestLang.to-es::before {
	left: calc(12.25vmin - 1px);
}
#suggestLang.to-fr::after {
	left: 1.25vmin;
}
#suggestLang.to-en::after {
	left: 6.75vmin;
}
#suggestLang.to-es::after {
	left: 12.25vmin;
}
@keyframes suggestLangBubble {
	0% {
		opacity: 0;
		font-size: calc(0.6 * var(--fontsize));
	}
	10% {
		opacity: 1;
		font-size: calc(0.85 * var(--fontsize));
	}
	22% {
		opacity: 1;
		font-size: calc(0.8 * var(--fontsize));
	}
	70% {
		opacity: 1;
		font-size: calc(0.8 * var(--fontsize));
	}
	100% {
		opacity: 0;
		font-size: calc(0.8 * var(--fontsize));
		visibility: hidden;
	}
}

main {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	flex-grow: 1;
	overflow-x: hidden;
	overflow-y: auto;
}

main, footer {
	width: 100svw;
}

footer {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1vmin;
	padding: 1vmin;
}

#title {
    width: 100svw;
    display: flex;
	justify-content: center;
}

#title > div {
    display: flex;
    flex-direction: column;
    align-items: center;
	position: relative;
}

#title > div > img {
	top: 1vmin;
	left: 100%;
	height: calc(100% - 2vmin);
	position: absolute;
}

h1 {
	font-family: "Inconsolata", "Consolas", monospace;
	font-weight: bold;
	margin: 1vmin;
	padding: 0.5vmin;
	color: black;
	text-align: center;
	font-size: calc(3 * var(--fontsize));
	position: relative;
}

h1::before {
	content: "";
	position: absolute;
	width: 5ch;
	bottom: 0;
	left: 0.5vmin;
	border-bottom: calc(2px + 0.4vmin) solid black;
}

h1::after {
	content: "";
	position: absolute;
	width: 7ch;
	top: 0;
	right: 0.5vmin;
	border-top: calc(2px + 0.4vmin) solid black;
}

h2 {
	font-size: calc(1.3 * var(--fontsize));
	text-align: center;
	margin: 1vmin;
	width: fit-content;
	font-style: italic;
}

h3 {
	font-size: calc(1.3 * var(--fontsize));
	text-decoration: underline;
	margin: 0;
	padding: 0;
}

/****************************
Boutons
*****************************/

button {
	margin-bottom: 0.4vmin;
	padding: 1vmin;
	cursor: pointer;
	border: 1px solid gray;
	border-radius: 1vmin;
	background: linear-gradient(-45deg, lightblue 0%, aliceblue 50%, lightblue 100%);
	box-shadow: 0 0.4vmin gray;
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
}

button:disabled {
	color: gainsboro;
	background: aliceblue;
	cursor: not-allowed;
}

button:not(:disabled):active {
	background: linear-gradient(-45deg, #8EB1BD 0%, lightblue 50%, #8EB1BD 100%);
	transform: translateY(0.4vmin);
	box-shadow: none;
}

.button-line, .tag-line {
	display: flex;
	flex-direction: row;
	justify-content: center;
	align-items: center;
	width: 100%;
}

.button-line {
	gap: 1vmin;
}

/****************************
Tableaux et Légendes
*****************************/

table {
	border-spacing: 0;
	border-collapse: separate;
}

td, th {
	font-weight: normal;
	border: 1px solid black;
	text-align: center;
	padding: 0.5vmin;
	background-color: white;
	background-clip: padding-box;
}

.one {
	background-color: lightskyblue;
	color: royalblue;
}

.zero {
	background-color: peru;
	color: maroon;
}

.legend-table {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 1vmin;
}

.legend-table h3 {
	margin: 0;
	font-size: var(--fontsize);
}

.legend-table td {
	border-radius: 1vmin;
}

.all-columns {
	border-bottom: none;
	text-align: right;
}

.all-lines {
	border-top: none;
}

/* Ces cases du tableau fonctionnent comme des boutons */
.char {
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	cursor: pointer;
}


/****************************
Écran d'accueil et Exercices
*****************************/

.exercise {
	display: flex;
	width: 98svw;
	margin: 1svw;
	gap: 2svw;
	flex-grow: 1;
}

.upper, .lower {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 2vmin;
	padding: 1vmin;
	border-radius: 1vmin;
	position: relative;
}
.lower {
	max-height: 50svh;
}
.upper *, .lower * {
	z-index: 1;
}
.upper::before, .lower::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: radial-gradient(lightyellow -30%, transparent 80%);
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}
.upper:hover::before, .lower:hover::before {
	opacity: 1;
}

@media (orientation: landscape) {
	.exercise {
		flex-direction: row;
	}
	.upper, .lower {
		width: 48svw;
	}
	.upper::after {
		content: "";
		position: absolute;
		right: -1.5vmin;
		top: 0;
		bottom: 0;
		border-right: 3px dashed black;
	}
}

@media (orientation: portrait) {
	.exercise {
		flex-direction: column;
	}
	.upper, .lower {
		width: 98svw;
	}
}

#exo-choice .lower div {
	display: flex;
	flex-direction: column;
	margin: 0 auto;
	max-width: fit-content;
	align-items: stretch;
	text-align: center;
	gap: 1.5vmin;
}

#exo-choice .lower {
	max-height: 100svh;
}

#exo-choice ul {
	border: 3px dashed black;
	border-radius: 1svw;
	padding: 1svw;
}

.exercise .upper h3 {
	align-self: flex-start;
}

#exo-choice .upper h3 {
	align-self: center;
}


#exo-choice .lower button {
	position: relative;
	margin-left: 0;
	margin-right: 0;
}

.star {
	display: inline-block;
	line-height: 100%;
	position: absolute;
	left: 100%;
	margin-left: 1vmin;
}

button:not(:disabled):active .star {
	transform: translateY(-0.4vmin);
}

.difficulty {
	position: absolute;
	top: 0.5vmin;
	right: 0;
	border-radius: 1vmin;
	background-color: darkred;
	color: white;
	padding: 0.5vmin;
	box-shadow: 0 0 1vmin darkred;
}

#oddone-exo .lower, #root-exo .lower, #associate-exo .lower {
	gap: 0;
}

#DACSpeciesA, #DACSpeciesB, #closestSpeciesA, #closestSpeciesB, #closestSpeciesX {
	font-weight: bold;
}

canvas {
	margin-left: auto;
	margin-right: auto;
	background-color: white;
	border: 1px solid black;
	cursor: pointer;
	max-height: 100%;
	max-width: 100%;
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
}

.multiple-canvas {
	display: flex;
	align-items: center;
	justify-content: center;
	max-height: 50%;
	max-width: 50%;
}

:not(.multiple-canvas) > canvas {
	border-radius: 1vmin;
}

.top-left {
	border-top-left-radius: 1vmin;
}

.top-right {
	border-top-right-radius: 1vmin;
}

.bottom-left {
	border-bottom-left-radius: 1vmin;
}

.bottom-right {
	border-bottom-right-radius: 1vmin;
}

/****************************
Boites de dialogue
*****************************/

dialog {
	position: fixed;
	top: 0;
	left: 0;
	width: 100svw;
	height: 100svh;
	background-color: rgba(0, 0, 0, 0.5);
	border: none;
	z-index: 3;
}

dialog > div {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background-color: #C2DBC2;
	border-radius: 2vmin;
	margin: auto;
	padding: 2vmin;
	width: 100ch;
	max-width: 80svw;
	max-height: 80svh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1.5vmin;
	overflow-x: hidden;
	overflow-y: auto;
	box-shadow: 0 0 5vmin black;
}

dialog h2 {
	margin: 0;
	padding: 1vmin 0;
	text-align: center;
	border-radius: 2vmin;
	background-color: #D1EBD1;
	width: 100%;
}

dialog p {
	text-align: justify;
	align-self: stretch;
}

#licenceImage, #emailImage {
	float: right;
	margin-left: 1ch;
	background-color: white;
	padding: 0.3vmin;
	border-radius: 0.3vmin;
}

#licenceImage {
	height: calc(3 * var(--fontsize) + 0.6vmin); /* Il faut tenir compte du padding */
}

#emailImage {
	height: calc(var(--fontsize) + 0.6vmin); /* Idem ici */
}

#QR-window p {
	text-align: center;
}

#qrcode-container {
	position: relative;
	align-self: stretch;
	aspect-ratio: 1 / 1;
	border-radius: 2vmin;
	overflow: hidden;
}

#qrcode-container img {
	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	max-height: 100%;
	max-width: 100%;
	border: 2vmin solid white;
	border-radius: 2vmin;
	background-color: white;
}

.tag {
	font-family: "Inconsolata", "Consolas", monospace;
	display: flex;
	white-space: nowrap;
	text-align: left;
	border: 1px solid gray;
	border-radius: 1vmin;
	padding: 0.5vmin;
	min-width: 1ch;
	height: calc(var(--fontsize) + 1vmin);
	background-color: whitesmoke;
	overflow: hidden;
}

.extensionSpan {
	font-family: "Inconsolata", "Consolas", monospace;
}

#fileNameSpan {
	width: calc(50ch + 1vmin);
}

#save-window > div, #character-window > div, #photo-window > div {
	width: fit-content;
}

#save-window .tag {
	text-align: right;
	justify-content: flex-end;
}

#photo-window > div {
	overflow: hidden;
	justify-content: flex-start;
}

#photoInfo {
	display: flex;
	flex-direction: column;
}

#photo-window p {
	text-align: left;
	width: fit-content;
}

#photoLatin {
	font-style: italic;
}

#photoDialogImageContainer {
	display: flex;
	overflow: hidden;
}

#photoDialogImageContainer > div {
	display: flex;
	justify-content: center;
	overflow: hidden;
}

#photoDialogImage {
	border-radius: 2vmin;
	max-width: 76svw;
}

#photoSource {
	overflow-wrap: anywhere;
	word-wrap: break-word;
}

#notice {
	position: fixed;
	top: 0;
	left: 0;
	width: 100svw;
	height: 100svh;
	background-color: rgba(0, 0, 0, 0.5);
	border: none;
	z-index: 3;
}

#notice > div {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background-color: lightyellow;
	border: 1px solid black;
	border-radius: 2vmin;
	padding: 2vmin;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2vmin;
	width: max-content;
	max-width: 80svw;
}

/****************************
Galerie d'images
*****************************/

#exoImagesContainer {
	overflow-x: auto;
	width: 100%;
	margin-left: auto;
	margin-right: auto;
}

#exoImages {
	display: flex;
	width: max-content;
	margin-left: auto;
	margin-right: auto;
}

#exoImages > div {
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 1vmin;
	max-height: 100%;
	overflow: hidden;
}

#exoImages img {
	max-height: calc(100% - 1vmin - var(--fontsize));
	border-radius: 1vmin;
	cursor: pointer;
}

#exoImages span {
	margin-top: 0.5vmin;
	font-size: calc(var(--fontsize));
	font-style: italic;
	text-align: center;
}

/****************************
Feu d'artifice
*****************************/

#fireworksScene {
	position: fixed;
	inset: 0;
	width: 100svw;
	height: 100svh;
	pointer-events: none;
	z-index: 2;
	overflow: hidden;
}

.firework {
	position: absolute;
	left: var(--x);
	bottom: 0;
	width: 0;
	height: 100%;
}

.rocket {
	position: absolute;
	left: 0;
	bottom: 0;
	width: 0;
	height: 0;
}

.rocket::before {
	content: "";
	position: absolute;
	left: 50%;
	bottom: 0;
	width: 1vmin;
	height: var(--peak);
	transform: translateX(-50%) scaleY(0);
	transform-origin: bottom center;
	border-radius: 0;
	background: linear-gradient(
		to top,
		rgba(255,255,255,0),
		hsl(var(--hue) 100% 60% / 0.35) 30%,
		hsl(var(--hue) 100% 70% / 0.9) 72%,
		#ffffff 100%
	);
	filter: drop-shadow(0 0 2vmin hsl(var(--hue) 100% 65%));
	opacity: 0;
	animation: rocket-trail-rise 1s ease-out var(--delay) 1 forwards;
}

.rocket::after {
	content: "";
	position: absolute;
	left: 50%;
	bottom: 0;
	width: 1.5vmin;
	height: 1.5vmin;
	transform: translate(-50%, 0);
	border-radius: 50%;
	background: #fff;
	box-shadow:
		0 0 1vmin #fff,
		0 0 2vmin hsl(var(--hue) 100% 70%);
	opacity: 0;
	animation: rocket-head-rise 1s ease-out var(--delay) 1 forwards;
}

@keyframes rocket-trail-rise {
	0% {
		opacity: 0;
		transform: translateX(-50%) scaleY(0);
	}
	10% {
		opacity: 1;
	}
	80% {
		opacity: 1;
	}
	100% {
		opacity: 0;
		transform: translateX(-50%) scaleY(1);
	}
}

@keyframes rocket-head-rise {
	0% {
		opacity: 0;
		transform: translate(-50%, 0) translateY(0);
	}
	10% {
		opacity: 1;
	}
	80% {
		opacity: 1;
	}
	100% {
		opacity: 0;
		transform: translate(-50%, 0) translateY(calc(-1 * var(--peak)));
	}
}

.flash {
	position: absolute;
	left: 0;
	bottom: var(--peak);
	width: 12vmin;
	height: 12vmin;
	transform: translate(-50%, 50%) scale(0.2);
	border-radius: 50%;
	background: #fff;
	box-shadow:
		0 0 4vmin #fff,
		0 0 7vmin hsl(var(--hue) 100% 72%),
		0 0 10vmin hsl(var(--hue) 100% 62%);
	opacity: 0;
	animation: explosion-flash 0.3s ease-out calc(var(--delay) + 0.95s) 1 forwards;
}

@keyframes explosion-flash {
	0% {
		opacity: 0;
		transform: translate(-50%, 50%) scale(0.1);
	}
	30% {
		opacity: 1;
		transform: translate(-50%, 50%) scale(1);
	}
	100% {
		opacity: 0;
		transform: translate(-50%, 50%) scale(0.2);
	}
}

.particle {
	position: absolute;
	left: 0;
	bottom: var(--peak);
	width: 0;
	height: 0;
	transform: rotate(var(--angle));
}

.particle::before {
	content: "";
	position: absolute;
	left: 0;
	top: -0.25vmin;
	width: calc(var(--dist) * 2);
	height: 0.5vmin;
	transform-origin: left center;
	transform: scaleX(0);
	border-radius: 0;
	background: linear-gradient(
		to right,
		rgba(255,255,255,0.95) 0%,
		hsl(var(--hue) 100% 68%) 40%,
		rgba(255,255,255,0) 100%
	);
	opacity: 0;
	animation: streak 1s ease-out calc(var(--delay) + 1s) 1 forwards;
}

.particle::after {
	content: "";
	position: absolute;
	left: -0.5vmin;
	top: -0.5vmin;
	width: 1vmin;
	height: 1vmin;
	border-radius: 50%;
	background: hsl(var(--hue) 100% 72%);
	box-shadow:
		0 0 1vmin #fff,
		0 0 2vmin hsl(var(--hue) 100% 70%),
		0 0 3vmin hsl(var(--hue) 100% 60%);
	transform: translateX(0) scale(0.25);
	opacity: 0;
	animation: particle-move 1s ease-out calc(var(--delay) + 1s) 1 forwards;
}

@keyframes streak {
	0% {
		opacity: 0;
		transform: scaleX(0);
	}
	12% {
		opacity: 1;
	}
	100% {
		opacity: 0;
		transform: scaleX(1);
	}
}

@keyframes particle-move {
	0% {
		opacity: 0;
		transform: translateX(0) scale(0.25);
	}
	10% {
		opacity: 1;
	}
	100% {
		opacity: 0;
		transform: translateX(calc(var(--dist) * 2)) scale(1);
	}
}