/* The docs site's stylesheet: the design tokens, and the base every page starts from (its elements,
   untouched by any class). Everything else is a component's, in its own scoped <style> (site/Ui,
   site/Demos), or a page's, at the top of its file; `just dev` shows them at /__rocx/stories, and
   Ui/Tokens.rocx shows these. */

/* The tokens: every colour, size, space, radius and shadow, named for its role. Neon, and always
   dark: near-black surfaces, neon in the accents, the headings and the code, surfaces instead of
   borders, and a little glow. A component never writes a colour or a size: it writes the token. */
:root {
	color-scheme: dark;

	/* Surfaces, from the page up. A fill is a quiet surface on any of them: a button, inline code. */
	--bg: #0c0b12;
	--bg-sunken: #100e19;
	--bg-code: #13111c;
	--bg-raised: #15131f;
	--bg-hover: #1c1929;
	--fill: rgb(255 255 255 / 0.07);
	--fill-strong: rgb(255 255 255 / 0.12);

	/* Text, and the few lines that mean something (a table's rows, a step's thread). */
	--text: #f1eefc;
	--text-muted: #aca6c8;
	--text-faint: #8a84ab;
	--rule: #1f1c2e;
	--rule-strong: #2c2842;

	/* Neon: cyan for what you can follow or press, magenta for where you are, violet between, and
	   Roc's own deeper violet under them (the mark's body and slab). */
	--accent: #2ee8ff;
	--accent-strong: #8ff4ff;
	--accent-soft: rgb(46 232 255 / 0.1);
	--accent-text: #0c0b12;
	--magenta: #ff4fd0;
	--magenta-soft: rgb(255 79 208 / 0.12);
	--violet: #a99bff;
	--violet-deep: #7c38f5;
	--gradient: linear-gradient(90deg, #ff4fd0, #a99bff 50%, #2ee8ff);

	/* What a thing says: a tip or a pass, a warning, a failure. */
	--good: #b6ff4a;
	--good-soft: rgb(182 255 74 / 0.08);
	--warn: #ffd447;
	--warn-soft: rgb(255 212 71 / 0.08);
	--bad: #ff5c9a;
	--bad-soft: rgb(255 92 154 / 0.1);

	/* Code, by token. */
	--t-keyword: #ff4fd0;
	--t-type: #2ee8ff;
	--t-string: #b6ff4a;
	--t-comment: #8a84ab;
	--t-tag: #ff6fb0;
	--t-attr: #ffd447;
	--t-hole: #2ee8ff;
	--t-number: #ffd447;
	--t-call: #a99bff;
	--t-op: #aca6c8;

	/* Depth, and the glow: a halo for what is lit (the main button, what you point at); the mark's
	   is a filter, so it follows the bird's shape. */
	--shadow: 0 24px 60px rgb(0 0 0 / 0.3);
	--glow: 0 0 24px -6px rgb(46 232 255 / 0.55);
	--glow-mark: drop-shadow(0 0 18px rgb(169 155 255 / 0.35));
	--glow-text: 0 0 12px rgb(46 232 255 / 0.45);

	/* Type: the system's sans and monospace, on one scale. */
	--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
	--size-2xs: 0.72rem;
	--size-xs: 0.8rem;
	--size-sm: 0.875rem;
	--size-md: 1rem;
	--size-lg: 1.15rem;
	--size-xl: 1.6rem;
	--size-2xl: clamp(2rem, 4vw, 3rem);
	--size-3xl: clamp(2.6rem, 6.5vw, 4.6rem);

	/* Space, on one scale: margins, paddings and gaps. */
	--space-1: 0.25rem;
	--space-2: 0.5rem;
	--space-3: 0.75rem;
	--space-4: 1rem;
	--space-5: 1.25rem;
	--space-6: 1.5rem;
	--space-7: 2rem;
	--space-8: 3rem;
	--space-9: 4rem;

	/* Shape. */
	--radius-sm: 6px;
	--radius: 10px;
	--radius-lg: 16px;
	--pill: 999px;

	/* The frame: the bar's height, and the width a line of prose is read at. */
	--bar: 3.5rem;
	--measure: 46rem;
}

/* The base. */

* {
	box-sizing: border-box;
}

html {
	scroll-padding-top: calc(var(--bar) + var(--space-6));
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: var(--size-md) / 1.65 var(--font);
}

::selection {
	background: rgb(46 232 255 / 0.28);
}

a {
	color: var(--accent-strong);
	text-underline-offset: 0.2em;
	text-decoration-thickness: 1px;
}

a:hover {
	text-decoration-thickness: 2px;
}

h1,
h2,
h3,
h4 {
	line-height: 1.25;
	letter-spacing: -0.015em;
}

h2 {
	margin: var(--space-9) 0 var(--space-4);
	font-size: var(--size-xl);
}

h3 {
	margin: var(--space-7) 0 var(--space-2);
	font-size: var(--size-lg);
}

h4 {
	margin: var(--space-6) 0 var(--space-2);
	font-size: var(--size-md);
}

/* Prose, in the page: a line no longer than it reads well. */
main > p,
main > ul,
main > ol {
	max-width: var(--measure);
}

code,
kbd,
pre,
var {
	font-family: var(--mono);
	font-size: 0.9em;
}

:not(pre) > code {
	padding: 0.05em 0.35em;
	border-radius: 5px;
	background: var(--fill);
	white-space: nowrap;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}

/* A phone hasn't the width for a long one on one line. */
@media (max-width: 40rem) {
	:not(pre) > code {
		white-space: normal;
		overflow-wrap: anywhere;
	}
}

var {
	font-style: italic;
}

table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--size-sm);
}

th,
td {
	padding: var(--space-2) var(--space-3);
	border-bottom: 1px solid var(--rule);
	text-align: left;
	vertical-align: top;
}

th {
	color: var(--text-muted);
	font-size: var(--size-xs);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

details {
	margin: var(--space-3) 0;
}

summary {
	color: var(--text-muted);
	font-weight: 600;
	cursor: pointer;
}

summary:hover {
	color: var(--text);
}

/* Controls: quiet surfaces, no borders; a component says what is primary. */
button {
	padding: var(--space-2) var(--space-4);
	border: 0;
	border-radius: var(--radius-sm);
	background: var(--fill);
	color: var(--text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

button:hover:not(:disabled) {
	background: var(--fill-strong);
}

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

input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"],
input:not([type]) {
	padding: var(--space-2) var(--space-3);
	border: 0;
	border-radius: var(--radius-sm);
	background: var(--fill);
	color: var(--text);
	font: inherit;
}

input::placeholder {
	color: var(--text-faint);
}

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

/* A demo's element (`<div data-demo="…">`, for site.js): the page laid out as if it weren't there. */
[data-demo] {
	display: contents;
}

/* Page transitions. The layout's <html data-rocx-transitions> makes each navigation in place a View
   Transition (D-040), where the browser has them and less motion isn't asked for (the runtime
   starts none then). The bar and the sidebar are named (Ui/Topbar.rocx, Ui/Sidebar.rocx), so they
   stay where they are and only change where they differ; the rest, the page, fades out quickly and
   the next one fades in, rising a little. Short, since a page can't be clicked while it runs. */
::view-transition-old(root) {
	animation: 90ms ease-in both page-leave;
}

::view-transition-new(root) {
	animation: 210ms cubic-bezier(0.2, 0, 0, 1) 50ms both page-enter;
}

::view-transition-group(site-bar),
::view-transition-group(site-sidebar) {
	animation-duration: 200ms;
}

@keyframes page-leave {
	to {
		opacity: 0;
	}
}

@keyframes page-enter {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
}
