/* Spot On website. CUBE CSS: tokens, then composition, utilities, blocks, exceptions.
   The palette is the app's own (Sources/SpotOn/App/Theme.swift): deep violet at night,
   lavender by day, a yellow beam for the moment a key lands. */

/* Tokens */
:root {
	color-scheme: light dark;
	--window: #fbfaff;
	--well: #efecfb;
	--ink: #1a1740;
	--mute: #6f6a9c;
	--beam: #f2a900;
	--on-beam: #1a1200;
	--hot: #e0245e;
	--key: #ffffff;
	--key-ink: #1a1740;
	--line: #dcd7f3;
	--key-shadow: #c9c2ec;

	--font: system-ui, -apple-system, "Segoe UI", sans-serif;
	--font-key: ui-rounded, system-ui, -apple-system, sans-serif;
	--space-s: 0.75rem;
	--space-m: 1.5rem;
	--space-l: 3rem;
	--space-xl: 6rem;
	--measure: 38rem;
	--radius: 14px;
	/* The "Our Mac apps" strip (/shared/apps.css) lines up with .wrapper. */
	--apps-width: min(100% - 2 * var(--space-m), 60rem);
}

@media (prefers-color-scheme: dark) {
	:root {
		--window: #15132e;
		--well: #1d1a3d;
		--ink: #f4f1ff;
		--mute: #8d88b8;
		--beam: #ffd84a;
		--hot: #ff4f7b;
		--key: #efeaff;
		--key-ink: #15132e;
		--line: #2c2856;
		--key-shadow: #6b64a8;
	}
}

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

body {
	margin: 0;
	background: var(--window);
	color: var(--ink);
	font: 1.0625rem/1.55 var(--font);
	-webkit-font-smoothing: antialiased;
}

img {
	display: block;
	max-width: 100%;
	height: auto;
}

a {
	color: inherit;
}

h1,
h2,
h3 {
	line-height: 1.1;
	letter-spacing: -0.02em;
	margin: 0;
}

h1 {
	font-size: clamp(2.5rem, 7vw, 4.5rem);
	font-weight: 850;
	letter-spacing: -0.04em;
}

h2 {
	font-size: clamp(1.6rem, 3.5vw, 2.2rem);
	font-weight: 800;
}

:focus-visible {
	outline: 3px solid var(--beam);
	outline-offset: 3px;
}

/* Composition */
.wrapper {
	width: min(100% - 2 * var(--space-m), 60rem);
	margin-inline: auto;
}

.flow > * + * {
	margin-block-start: var(--flow-space, 1em);
}

.cluster {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--gap, var(--space-s));
}

.section {
	padding-block: var(--space-xl) 0;
}

/* Utilities */
.measure {
	max-width: var(--measure);
}

.mute {
	color: var(--mute);
}

.small {
	font-size: 0.875rem;
}

.lead {
	font-size: clamp(1.15rem, 2.2vw, 1.35rem);
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Blocks */
.site-header {
	--gap: var(--space-s);
	justify-content: space-between;
	padding-block: var(--space-m);
	font-weight: 700;
}

.brand {
	--gap: 0.6rem;
	text-decoration: none;
	font-size: 1.1rem;
}

.button {
	display: inline-block;
	padding: 0.75rem 1.4rem;
	border-radius: 999px;
	background: var(--beam);
	color: var(--on-beam);
	font-weight: 700;
	text-decoration: none;
	border: 0;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.button:active {
	transform: translateY(1px);
}

.button[data-variant="quiet"] {
	background: transparent;
	color: var(--ink);
	box-shadow: inset 0 0 0 2px var(--line);
}

.hero {
	padding-block: var(--space-l) 0;
}

/* The demo: Caps Lock, a letter, and the app, with nothing in between. */
.demo {
	--gap: var(--space-m);
	padding: var(--space-l) var(--space-m);
	border-radius: var(--radius);
	background: var(--well);
	justify-content: center;
	font-family: var(--font-key);
}

.demo__keys {
	--gap: 0.6rem;
	color: var(--mute);
	font-weight: 700;
}

.keycap {
	display: inline-grid;
	place-items: center;
	min-width: 3.6rem;
	height: 3.6rem;
	padding-inline: 0.9rem;
	border-radius: 0.8rem;
	background: var(--key);
	color: var(--key-ink);
	font-weight: 800;
	font-size: 1.5rem;
	box-shadow: 0 5px 0 var(--key-shadow);
	transition: transform 60ms, box-shadow 60ms;
}

.keycap[data-wide] {
	font-size: 1rem;
}

.keycap.is-down {
	transform: translateY(4px);
	box-shadow: 0 1px 0 var(--key-shadow);
}

.demo__app {
	min-width: 11rem;
	padding: 1rem 1.5rem;
	border-radius: var(--radius);
	background: var(--window);
	border: 2px solid var(--line);
	font-size: 1.6rem;
	font-weight: 800;
	text-align: center;
	/* Arrival is instant; only the beam fades. */
	transition: background-color 600ms ease-out, color 600ms ease-out;
}

.demo__app.is-hit {
	background: var(--beam);
	color: var(--on-beam);
	transition: none;
}

/* Jump times: bar length is the median time, on one scale. */
.race {
	display: grid;
	gap: var(--space-s);
	padding: var(--space-m);
	border-radius: var(--radius);
	background: var(--well);
}

.race__row {
	display: grid;
	grid-template-columns: 10.5rem 1fr 4rem;
	align-items: center;
	gap: var(--space-s);
}

.race__track {
	height: 1.1rem;
	border-radius: 999px;
	background: var(--window);
	overflow: hidden;
}

.race__bar {
	display: block;
	height: 100%;
	width: var(--share);
	border-radius: inherit;
	background: var(--mute);
}

.race__row[data-with] .race__bar {
	background: var(--beam);
}

.race p {
	margin: 0;
}

.race__time {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	text-align: end;
}

/* The main window, lifted off the page: leaning back a touch, straight on, so nothing
   looks skewed, with a deep shadow under it. It settles flat on hover. The button turns
   it over: the back is the same window in the other mode. */
.window-stage {
	position: relative;
	padding-block: var(--space-m);
}

.window-space {
	perspective: 2400px;
}

.window-card {
	--lean: 5deg;
	--turn: 0deg;
	display: grid;
	width: min(100%, 52rem);
	margin-inline: auto;
	transform-style: preserve-3d;
	transform: rotateX(var(--lean)) rotateY(var(--turn));
	transition: transform 700ms cubic-bezier(0.3, 0.7, 0.2, 1);
}

.window-stage:hover .window-card {
	--lean: 0deg;
}

.window-card.is-flipped {
	--turn: 180deg;
}

/* Both faces share one grid cell; each hides when it faces away. The shadow is a box
   shadow rounded like the window's own corners (20 px in a 1908 × 1354 picture): a
   drop-shadow filter would blur the turning window, or be clipped by it. */
.window-face {
	grid-area: 1 / 1;
	border-radius: 1.05% / 1.48%;
	box-shadow:
		0 2px 3px rgb(0 0 0 / 0.15),
		0 36px 44px -8px rgb(0 0 0 / 0.35);
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}

.window-face--back {
	transform: rotateY(180deg);
}

.window-shot {
	width: 100%;
}

.window-flip {
	position: absolute;
	inset-block-end: 0;
	inset-inline-end: 0;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	border: 0;
	border-radius: 999px;
	background: var(--well);
	color: var(--ink);
	box-shadow: inset 0 0 0 2px var(--line);
	cursor: pointer;
}

.window-flip:hover {
	color: var(--beam);
}

.fill-shot {
	width: min(100%, 52rem);
	margin-inline: auto;
	filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.15)) drop-shadow(0 24px 36px rgb(0 0 0 / 0.3));
}

/* One key, three jobs: the same keys on each card; only the app's state changes. */
.jobs {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	gap: var(--space-m);
	padding: 0;
	list-style: none;
	counter-reset: job;
}

.jobs > li {
	--flow-space: var(--space-s);
	padding: var(--space-m);
	border-radius: var(--radius);
	background: var(--well);
}

.jobs__keys {
	--gap: 0.4rem;
	padding-block-end: var(--space-s);
	color: var(--mute);
	font-family: var(--font-key);
	font-weight: 700;
}

.jobs .keycap {
	min-width: 2.6rem;
	height: 2.6rem;
	padding-inline: 0.6rem;
	font-size: 1.1rem;
	box-shadow: 0 4px 0 var(--key-shadow);
}

.jobs .keycap[data-wide] {
	font-size: 0.8rem;
}

.jobs__when {
	counter-increment: job;
	color: var(--mute);
	font-size: 0.875rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.jobs__when::before {
	content: counter(job) " · ";
	color: var(--beam);
}

.jobs h3 {
	font-size: 1.3rem;
}

.jobs p {
	margin-block-end: 0;
}

.jobs > li > p:last-child {
	color: var(--mute);
}

.features {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
	gap: var(--space-m) var(--space-l);
	padding: 0;
	list-style: none;
}

.features h3 {
	font-size: 1.1rem;
	margin-block-end: 0.3rem;
}

.features p {
	margin: 0;
	color: var(--mute);
}

.kbd {
	font-family: var(--font-key);
	font-weight: 700;
	padding: 0.05em 0.4em;
	border-radius: 0.35em;
	background: var(--well);
	border: 1px solid var(--line);
	white-space: nowrap;
}

.price {
	padding: var(--space-l) var(--space-m);
	border-radius: var(--radius);
	background: var(--well);
	text-align: center;
}

.price .cluster {
	justify-content: center;
}

.site-footer {
	--gap: var(--space-m);
	justify-content: space-between;
	margin-block-start: var(--space-xl);
	padding-block: var(--space-m) var(--space-l);
	border-block-start: 1px solid var(--line);
	color: var(--mute);
	font-size: 0.875rem;
}

.site-footer nav {
	--gap: var(--space-m);
}

/* Exceptions */
@media (max-width: 34rem) {
	.race__row {
		grid-template-columns: 1fr 3.5rem;
	}

	.race__track {
		grid-column: 1 / -1;
		grid-row: 2;
	}
}

@media (prefers-reduced-motion: reduce) {
	.keycap,
	.demo__app,
	.window-card {
		transition: none;
	}
}

.supply h2 {
	display: flex;
	align-items: center;
	gap: 0.4em;
}

.supply-icon {
	flex: none;
	width: 0.9em;
	height: 0.9em;
	color: var(--beam);
}

.supply li + li {
	margin-top: var(--space-s);
}

.more {
	font-weight: 700;
	text-decoration: none;
}

.more::after {
	content: " →";
}

.more:hover {
	text-decoration: underline;
}

/* The supply chain text, in a dialog opened from the short section above. */
.modal {
	width: min(100% - 2 * var(--space-s), 42rem);
	max-width: none;
	max-height: min(100% - 2 * var(--space-s), 56rem);
	padding: 0;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--window);
	color: var(--ink);
	box-shadow: 0 1.5rem 4rem rgb(21 19 46 / 0.3);
	overscroll-behavior: contain;
}

.modal::backdrop {
	background: rgb(21 19 46 / 0.5);
	backdrop-filter: blur(4px);
}

.modal[open] {
	animation: modal-in 180ms ease-out;
}

@keyframes modal-in {
	from {
		opacity: 0;
		transform: translateY(0.75rem) scale(0.98);
	}
}

@media (prefers-reduced-motion: reduce) {
	.modal[open] {
		animation: none;
	}
}

body:has(.modal[open]) {
	overflow: hidden;
}

/* The close button stays in the corner as the text scrolls. */
.modal__close {
	position: sticky;
	top: 0;
	float: right;
	padding: var(--space-s);
}

.modal__close form {
	margin: 0;
}

.close {
	display: grid;
	place-content: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 999px;
	background: var(--well);
	color: var(--ink);
	cursor: pointer;
}

.modal__body {
	padding: var(--space-m) var(--space-m) var(--space-l);
}

.modal__body > :first-child {
	margin-block-start: 0;
}

.modal__body > :last-child {
	margin-block-end: 0;
}
