/*
 * What osz looks like to whoever has not come in: the page that says what it is and the one where
 * one comes in. They are not part of osz as it is built, which is handed to nobody without a
 * session, so what they share with it is said again here: the greys, the rough surface and the
 * card (src/routes/layout.css, src/lib/components/Plate.svelte).
 */

:root {
	color-scheme: light dark;

	--color-page: #e9e9eb;
	--color-ink: #1f1f23;
	--color-muted: #6b6b74;
	--color-card: #ffffff;
	--color-line: rgb(31 31 35 / 0.1);
	--color-line-strong: rgb(31 31 35 / 0.2);
	--color-problem: #b4372d;

	--ease-fluid: cubic-bezier(0.22, 1, 0.36, 1);

	--relief-opacity: 0.6;
	--grain-opacity: 0.5;
	--vignette: rgb(31 31 35 / 0.1);
	--sheen: rgb(255 255 255 / 0.55);

	--radius: 0.875rem;
	--surface: color-mix(in oklab, var(--color-card) 88%, transparent);
	--glow: rgb(255 255 255 / 0.12);
}

@media (prefers-color-scheme: dark) {
	:root {
		--color-page: #2b2b2f;
		--color-ink: #e7e7ea;
		--color-muted: #8e8e98;
		--color-card: #26262a;
		--color-line: rgb(231 231 234 / 0.09);
		--color-line-strong: rgb(231 231 234 / 0.2);
		--color-problem: #ee8d84;

		--relief-opacity: 1;
		--grain-opacity: 0.35;
		--vignette: rgb(0 0 0 / 0.4);
		--sheen: rgb(255 255 255 / 0.06);
		--glow: rgb(255 255 255 / 0.018);
	}
}

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 0 solid;
}

html {
	background-color: var(--color-page);
	color: var(--color-ink);
	font-family: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	-webkit-tap-highlight-color: transparent;
	-webkit-text-size-adjust: 100%;
	text-rendering: optimizeLegibility;
}

body {
	position: relative;
	min-height: 100dvh;
	/* Light that falls from above and fades toward the edges. */
	background-image:
		radial-gradient(120% 80% at 50% 0%, var(--sheen), transparent 60%),
		radial-gradient(140% 120% at 50% 45%, transparent 55%, var(--vignette));
}

/* The rough surface: a lit relief under a fine grain, over everything that is not content. */
body::before,
body::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
}

body::before {
	background-image: url('/front/relief.svg');
	background-size: 400px 400px;
	mix-blend-mode: multiply;
	opacity: var(--relief-opacity);
}

body::after {
	background-image: url('/front/grain.svg');
	background-size: 200px 200px;
	mix-blend-mode: soft-light;
	opacity: var(--grain-opacity);
}

a {
	color: inherit;
	text-decoration: none;
}

button,
input {
	background: none;
	color: inherit;
	font: inherit;
}

svg {
	display: block;
}

[hidden] {
	display: none !important;
}

/* Said to whoever cannot see the page, and shown to nobody. */
.unseen {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* What sits on the surface. */
.card {
	border-radius: var(--radius);
	background-color: var(--surface);
	box-shadow:
		inset 0 0 0 1px var(--color-line),
		0 1px 0 var(--glow);
}

.button {
	display: inline-grid;
	grid-auto-flow: column;
	place-items: center;
	gap: 0.375rem;
	height: 2.25rem;
	padding: 0 0.875rem;
	border-radius: 0.5rem;
	color: var(--color-muted);
	font-size: 0.875rem;
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
	outline-offset: 2px;
	transition:
		color 180ms var(--ease-fluid),
		background-color 180ms var(--ease-fluid),
		opacity 180ms var(--ease-fluid),
		transform 180ms var(--ease-fluid);
}

@media (hover: hover) {
	.button:hover:not(:disabled, .primary) {
		background-color: var(--color-line);
		color: var(--color-ink);
	}
}

.button:active:not(:disabled) {
	transform: scale(0.97);
}

.button.primary {
	background-color: var(--color-ink);
	color: var(--color-page);
}

.button:disabled {
	cursor: default;
	opacity: 0.45;
}

.button:focus-visible {
	outline: 2px solid var(--color-ink);
}

/* A row that grows from nothing to its content's height, and back, instead of popping in. */
.fold {
	display: grid;
	grid-template-rows: 1fr;
	transition:
		grid-template-rows 280ms var(--ease-fluid),
		opacity 220ms var(--ease-fluid);
}

.fold[inert] {
	grid-template-rows: 0fr;
	opacity: 0;
}

.fold > * {
	overflow: hidden;
	min-height: 0;
}

::selection {
	background-color: color-mix(in oklab, var(--color-ink) 18%, transparent);
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
