@font-face {
	font-family: "iA Writer Duo";
	src: url("fonts/duo-regular.woff2") format("woff2");
	font-weight: 400;
	font-display: swap;
}

@font-face {
	font-family: "iA Writer Duo";
	src: url("fonts/duo-bold.woff2") format("woff2");
	font-weight: 700;
	font-display: swap;
}

@font-face {
	font-family: "iA Writer Duo";
	src: url("fonts/duo-italic.woff2") format("woff2");
	font-weight: 400;
	font-style: italic;
	font-display: swap;
}

@font-face {
	font-family: "iA Writer Mono";
	src: url("fonts/mono-regular.woff2") format("woff2");
	font-weight: 400;
	font-display: swap;
}

:root {
	/* carbon paper and a two-colour ribbon */
	--carbon: #120e1a;
	--rule: #2f2643;
	--leader: #5f4f82;
	--type: #ece6f5;
	--type-dim: #a99cc0;
	--violet: #a586f2;
	--violet-deep: #6c4fc4;
	--orange: #ff9a52;

	--duo: "iA Writer Duo", ui-monospace, monospace;
	--mono: "iA Writer Mono", ui-monospace, monospace;
	--pad: clamp(1.25rem, 0.6rem + 3vw, 3.5rem);
	--page: min(76rem, 100% - 2 * var(--pad));

	color-scheme: dark;
	scrollbar-color: var(--violet-deep) var(--carbon);
	accent-color: var(--orange);
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--carbon);
	color: var(--type);
	font-family: var(--duo);
	font-size: clamp(1rem, 0.94rem + 0.25vw, 1.125rem);
	line-height: 1.6;
	font-kerning: normal;
}

::selection {
	background: var(--orange);
	color: var(--carbon);
}

a {
	color: inherit;
	text-decoration-color: var(--orange);
	text-decoration-thickness: 1.5px;
	text-underline-offset: 0.25em;
}

a:hover {
	color: var(--orange);
}

:focus-visible {
	outline: 2px solid var(--orange);
	outline-offset: 4px;
}

/* ---------- top line ---------- */

.riga {
	width: var(--page);
	margin: 0 auto;
	padding-top: clamp(1.25rem, 3vw, 2rem);
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.5rem 1rem;
	font-family: var(--mono);
	font-size: 0.875rem;
	color: var(--type-dim);
}

.riga__nome {
	color: var(--type);
	text-decoration: none;
}

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

.lingue {
	display: flex;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* small type, generous hit area */
.lingue a {
	display: inline-block;
	padding: 0.65rem 0.6rem;
	margin: -0.65rem -0.25rem;
	color: var(--type-dim);
	text-decoration: none;
}

.lingue a:hover {
	color: var(--orange);
}

.lingue [aria-current="page"] {
	color: var(--type);
	text-decoration: underline;
	text-decoration-color: var(--violet);
	text-underline-offset: 0.35em;
}

/* ---------- first page ---------- */

.foglio {
	width: var(--page);
	margin: clamp(2.25rem, 5vw, 4rem) auto 0;
}

.battuta {
	max-width: 46rem;
}

/* on wide screens the footnote with the plate sits beside the headline, so the index starts sooner */
@media (min-width: 64rem) {
	.battuta {
		max-width: none;
		display: grid;
		grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
		column-gap: clamp(2.5rem, 5vw, 5rem);
		align-items: end;
	}

	.battuta > h1,
	.battuta > .battuta__testo {
		grid-column: 1;
	}

	.battuta > .nota {
		grid-column: 2;
		grid-row: 1 / span 2;
		align-self: end;
		margin: 0;
	}
}

.battuta h1 {
	margin: 0;
	font-weight: 700;
	font-size: clamp(1.75rem, 1.05rem + 2.4vw, 3.1rem);
	line-height: 1.15;
	letter-spacing: 0;
	overflow-wrap: anywhere;
}

.battuta h1 em {
	font-style: normal;
	color: var(--violet);
}

/* the ribbon caret: struck in orange, takes no room in the line */
.cursore {
	position: relative;
	display: inline;
}

.cursore::after {
	content: "";
	position: absolute;
	left: 0.08em;
	bottom: -0.02em;
	width: 0.55em;
	height: 0.09em;
	background: var(--orange);
	animation: lampeggia 1.1s steps(1) 8;
}

.battuto .cursore::after {
	animation: none;
}

@keyframes lampeggia {
	50% { opacity: 0; }
}

.battuta__testo {
	margin: clamp(1.25rem, 2.5vw, 1.75rem) 0 0;
	max-width: 52ch;
	color: var(--type-dim);
}

.battuta__testo strong {
	color: var(--type);
	font-weight: 700;
}

/* Dalinar as a small plate beside the footnote, like an illustration in a book */
.nota {
	display: grid;
	grid-template-columns: clamp(8rem, 5rem + 7vw, 11.5rem) minmax(0, 1fr);
	gap: 0 clamp(1rem, 2.5vw, 1.75rem);
	align-items: center;
	margin: clamp(1.75rem, 3.5vw, 2.5rem) 0 0;
	max-width: 46rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--rule);
}

.tavola {
	margin: 0;
}

.tavola img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1;
	border-radius: 2px;
}

.nota blockquote {
	margin: 0;
	align-self: center;
}

.nota blockquote p {
	margin: 0;
	color: var(--type);
	font-style: italic;
	font-size: 1.05em;
	line-height: 1.5;
}

.nota blockquote p::before {
	content: "*\00a0";
	font-style: normal;
	color: var(--orange);
}

.nota blockquote footer {
	margin-top: 0.4rem;
	font-family: var(--mono);
	font-size: 0.8rem;
	color: var(--type-dim);
}

/* ---------- typed index ---------- */

.indice {
	width: var(--page);
	margin: clamp(2.75rem, 6vw, 4.5rem) auto 0;
}

.indice > h2 {
	margin: 0 0 clamp(1rem, 2.4vw, 1.5rem);
	font-weight: 700;
	font-size: clamp(1.25rem, 1rem + 0.9vw, 1.7rem);
}

.indice > h2 span {
	color: var(--violet);
}

.voci {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: clamp(2rem, 5vw, 4.5rem);
	margin: 0;
	padding: 0;
	list-style: none;
}

.voce {
	position: relative;
	display: grid;
	align-content: start;
	row-gap: 0.35rem;
	padding: clamp(0.9rem, 1.8vw, 1.25rem) 0 clamp(1rem, 2vw, 1.4rem);
	border-top: 1px solid var(--rule);
	scroll-margin-top: 1rem;
}

/* name, dot leader and destination on one typed line */
.voce__riga {
	display: flex;
	align-items: baseline;
	gap: 0.75rem;
	min-width: 0;
}

.voce__titolo {
	flex: 0 1 auto;
	min-width: 0;
	margin: 0;
	font-weight: 700;
	font-size: clamp(1.1rem, 0.95rem + 0.6vw, 1.45rem);
	line-height: 1.2;
	overflow-wrap: anywhere;
}

.voce__titolo a {
	text-decoration: none;
}

/* the whole entry opens the project */
.voce__titolo a::after {
	content: "";
	position: absolute;
	inset: 0;
}

/* dot leader: grey at rest, typed out in orange towards the destination on hover */
.puntini {
	position: relative;
	flex: 1 1 2ch;
	min-width: 2ch;
	overflow: hidden;
	white-space: nowrap;
	font-size: 0.9rem;
	color: var(--leader);
	letter-spacing: 0.25em;
}

.puntini::before,
.puntini::after {
	content: ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .";
}

.puntini::after {
	position: absolute;
	inset: 0;
	color: var(--orange);
	clip-path: inset(0 100% 0 0);
	transition: clip-path 360ms steps(18, end);
}

.voce:hover .puntini::after,
.voce:focus-within .puntini::after {
	clip-path: inset(0 0 0 0);
}

.voce__dove {
	flex: 0 1 auto;
	min-width: 0;
	font-family: var(--mono);
	font-size: 0.875rem;
	color: var(--violet);
	white-space: nowrap;
	transition: color 160ms ease-out;
}

.voce__dove--stato {
	color: var(--type-dim);
}

.voce__descrizione {
	margin: 0;
	max-width: 60ch;
	font-size: 0.92em;
	line-height: 1.55;
	color: var(--type-dim);
}

.voce__dati {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	margin: 0.2rem 0 0;
	padding: 0;
	list-style: none;
	font-family: var(--mono);
	font-size: 0.75rem;
	color: var(--type-dim);
}

/* secondary links sit above the whole-entry link, with a finger-sized hit area */
.voce__dati a {
	position: relative;
	z-index: 1;
	display: inline-block;
	padding: 0.7rem 0.5rem;
	margin: -0.7rem -0.5rem;
	color: var(--type);
}

.voce:hover .voce__titolo a,
.voce:focus-within .voce__titolo a {
	color: var(--orange);
}

.voce:hover .voce__dove:not(.voce__dove--stato),
.voce:focus-within .voce__dove:not(.voce__dove--stato) {
	color: var(--orange);
}

.voce__titolo a:focus-visible {
	outline: none;
}

.voce:has(.voce__titolo a:focus-visible) {
	outline: 2px solid var(--orange);
	outline-offset: 6px;
}

/* ---------- end of page ---------- */

.fine {
	width: var(--page);
	margin: clamp(4rem, 9vw, 6rem) auto 0;
	padding: 0 0 clamp(2rem, 5vw, 3rem);
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: clamp(2rem, 5vw, 4.5rem);
	row-gap: 1rem;
	font-family: var(--mono);
	font-size: 0.8rem;
	color: var(--type-dim);
}

.fine p {
	margin: 0;
	overflow-wrap: anywhere;
}

.fine__segno {
	color: var(--violet);
}

@media (max-width: 52rem) {
	.voci,
	.fine {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 34rem) {
	.voce__riga {
		flex-wrap: wrap;
		row-gap: 0.1rem;
	}

	.voce__dove {
		white-space: normal;
		overflow-wrap: anywhere;
	}

	.nota blockquote {
		overflow-wrap: anywhere;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cursore::after {
		animation: none;
	}

	.puntini::after,
	.voce__dove {
		transition: none;
	}
}
