/*
 * klementine.net: one calm page. Warm off-white ground (as the Klementine app), ink near black,
 * the clementine as the only colour. System fonts for text; the wordmark's Instrument Sans is hosted
 * here (fonts/, OFL), so the page loads nothing but itself and needs no consent for fonts.
 */
@font-face {
	font-family: 'Instrument Sans';
	font-style: normal;
	font-weight: 600;
	font-display: block;
	src: url('fonts/instrument-sans-600.woff2') format('woff2');
}
:root {
	color-scheme: light dark;
	--ground: light-dark(#f5f3ee, #1b1916);
	--ink: light-dark(#24231d, #f2efe7);
	--ink-2: light-dark(#5c594e, #bdb6a8);
	--rule: light-dark(#e2ddd0, #34312b);
	--clementine: light-dark(#f26b1d, #f47a32);
	--leaf: light-dark(#4f7d3a, #6f9b55);
	--focus: light-dark(#5c594e, #bdb6a8);
	--measure: 34rem;
	font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: 100%;
	line-height: 1.55;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

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

html {
	background: var(--ground);
	color: var(--ink);
}

body {
	margin: 0;
	min-height: 100svh;
	display: flex;
	flex-direction: column;
	padding: max(env(safe-area-inset-top), 1.5rem) max(env(safe-area-inset-right), 1rem)
		max(env(safe-area-inset-bottom), 1.5rem) max(env(safe-area-inset-left), 1rem);
}

main {
	flex: 1;
	width: 100%;
	max-width: var(--measure);
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 1.75rem;
	padding-block: 3rem;
}

/*
 * The hero: the drawn tree and the wordmark share one font size, so the tree (3.2em wide) and the
 * clementine on the i keep their proportions at every width. The tree's left edge sits on the k's ink
 * (Instrument Sans 600: the k's left side bearing is 0.0634em).
 */
.hero {
	font-family: 'Instrument Sans', system-ui, sans-serif;
	font-weight: 600;
	font-size: clamp(3.25rem, 2.2rem + 5vw, 5rem);
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.35em;
}

/* The drawn clementine tree: ink lines, the fruit the only colour. */
.tree {
	width: 3.2em;
	height: auto;
	margin-left: 0.0634em;
	color: var(--ink);
	overflow: visible;
}

/* The wordmark: lowercase, tight. The i is the dotless ı; its dot is a clementine. */
.wordmark {
	font: inherit;
	font-size: 1em;
	letter-spacing: -0.035em;
	line-height: 1;
	margin: 0;
	white-space: nowrap;
}

.i {
	position: relative;
	display: inline-block;
	transform-origin: 50% 100%;
}

/* Placed from the measured glyph: the stem's centre 0.1275em from the glyph's left, its top 0.51em
   above the baseline, the baseline 0.1406em above the line box's bottom; the font's own gap above. */
.dot {
	--d: 0.2em;
	position: absolute;
	left: calc(0.1275em - var(--d) / 2);
	bottom: calc(0.1406em + 0.51em + 0.0875em);
	width: var(--d);
}

.dot-y {
	display: block;
	transform-origin: 50% 100%;
}

.dot svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/*
 * The intro (once the script is there, and only for people who don't ask for less motion), slow and
 * calm, one stage flowing into the next: the ground is drawn, the trunk grows up out of it, the crown
 * is drawn around, the fruit comes small and green and ripens. intro.js then lets the ripe one go:
 * it bounces twice on the ground and lands on the i, and the line below fades in.
 */
.tree .fruit-wrap {
	transform-box: fill-box;
	transform-origin: center;
}

@media (prefers-reduced-motion: no-preference) {
	.js .hero .ground {
		stroke-dasharray: 1;
		animation: draw-line 1s cubic-bezier(0.65, 0, 0.35, 1) both;
	}

	.js .hero .trunk {
		animation: reveal-up 1.3s 0.5s cubic-bezier(0.65, 0, 0.35, 1) both;
	}

	.js .hero .crown-line {
		stroke-dasharray: 1;
		animation: draw-line 1.9s 1.4s cubic-bezier(0.65, 0, 0.35, 1) both;
	}

	.js .hero .fruit-wrap {
		animation: grow-in 0.8s calc(2.9s + var(--n) * 90ms) cubic-bezier(0.23, 1, 0.32, 1) both;
	}

	.js .hero .fruit-body {
		animation: ripen 1.6s calc(3.1s + var(--n) * 90ms) cubic-bezier(0.45, 0, 0.55, 1) both;
	}

	.js .hero .fruit-pores {
		animation: fade-in 0.8s calc(4s + var(--n) * 90ms) ease-out both;
	}

	/* the dot waits in the tree until the script lets it fall */
	.js .hero .dot {
		opacity: 0;
	}

	/* intro.js fades the line in as the clementine lands; this only catches a script that never ran */
	.js .lede {
		animation: lede-in 0.9s 9s cubic-bezier(0.23, 1, 0.32, 1) both;
	}
}

@keyframes lede-in {
	from {
		opacity: 0;
		filter: blur(4px);
		transform: translateY(0.3em);
	}
}

@keyframes reveal-up {
	from {
		clip-path: inset(100% 0 0 0);
	}
	to {
		clip-path: inset(0 0 0 0);
	}
}

@keyframes grow-in {
	from {
		transform: scale(0.6);
		opacity: 0;
	}
}

@keyframes draw-line {
	from {
		stroke-dashoffset: 1;
	}
	to {
		stroke-dashoffset: 0;
	}
}

@keyframes ripen {
	from {
		fill: var(--leaf);
	}
	to {
		fill: var(--clementine);
	}
}

@keyframes fade-in {
	from {
		opacity: 0;
	}
}

.mark {
	width: 4.5rem;
	height: 4.5rem;
	border-radius: 50%;
	background: var(--clementine);
	flex: none;
}

h1 {
	margin: 0;
	font-size: clamp(2.25rem, 1.6rem + 3vw, 3.25rem);
	line-height: 1.05;
	font-weight: 700;
	letter-spacing: -0.02em;
}

p {
	margin: 0;
	font-size: 1.125rem;
	color: var(--ink-2);
	text-wrap: pretty;
}

/* Long legal text may hyphenate; the short lines on the home page never need to. */
.legal p {
	hyphens: auto;
}

p strong {
	color: var(--ink);
	font-weight: 600;
}

/* The lede is two lines: what we build, then the claim, each starting its own line. */
.lede .clause {
	display: block;
}

.lede {
	color: var(--ink-2);
	font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
	line-height: 1.4;
	text-wrap: balance;
}

a {
	color: inherit;
	text-decoration-color: var(--rule);
	text-decoration-thickness: 0.08em;
	text-underline-offset: 0.2em;
	transition: text-decoration-color 140ms;
}

@media (hover: hover) {
	a:hover {
		text-decoration-color: currentColor;
	}
}

a:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 3px;
	border-radius: 2px;
}

footer {
	width: 100%;
	max-width: var(--measure);
	margin: 0 auto;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.25rem;
	padding-top: 1.25rem;
	font-size: 0.875rem;
	color: var(--ink-2);
}

/* The copyright line: Phosphor's Copyright glyph at the text's size, in its ink. */
.copy {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
}

.copy-icon {
	width: 1.05em;
	height: 1.05em;
	flex: none;
}

footer .spacer {
	flex: 1;
}

/* The legal pages: a readable column, headings in ink. */
.legal main {
	justify-content: flex-start;
	gap: 1.25rem;
}

.legal h1 {
	font-size: 2rem;
}

.legal h2 {
	margin: 1rem 0 0;
	font-size: 1.125rem;
	line-height: 1.3;
}

.legal p,
.legal address {
	font-size: 1rem;
	font-style: normal;
	color: var(--ink-2);
}

.back {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	font-weight: 600;
	text-decoration: none;
}

.back .mark {
	width: 1.25rem;
	height: 1.25rem;
}

/* Placeholders Simon has to fill in before going live: impossible to overlook. */
.todo {
	background: light-dark(#fff1c2, #4a3f12);
	color: var(--ink);
	padding: 0 0.25em;
	border-radius: 0.25em;
}

@media (forced-colors: active) {
	.mark {
		forced-color-adjust: none;
	}
}
