/* Design tokens: the only place raw colours, sizes, radii and opacities are written.
   Loaded first (Views/Shared/_Layout.cshtml); site.css, ui.css and every page stylesheet use these.

   Rules (StyleTests checks them):
   - Colours, font sizes, radii and opacities are always a token: var(--c-*), var(--fs-*),
     var(--r-*), var(--o-*). Mixing tokens (color-mix) is fine.
   - Padding, margin and gap are a step of the space scale (var(--s-*)), 0 or auto. Hairline
     adjustments may use px (1px, -1px).
   - Layout sizes (column widths, max-widths, breakpoints) are not tokens: they belong to one layout.
   - Add a token only when two places need it.

   Dark mode needs no second set: the greys are translucent, and the page is Canvas / CanvasText. */

:root {
	color-scheme: light dark;

	/* ---- Colour: roles, not hues ---- */
	--c-primary: #0f766e; /* sidebar, buttons, links */
	--c-ok: #2b8a3e; /* on track */
	--c-warn: #d97706; /* ahead of pace (spending) or behind it (income); another year */
	--c-danger: #c62828; /* errors, delete, over budget, money out */

	/* Each role as a tinted background (notices, pills, the error line). Opaque, so it can be sticky. */
	--c-primary-bg: color-mix(in srgb, var(--c-primary) 14%, Canvas);
	--c-ok-bg: color-mix(in srgb, var(--c-ok) 14%, Canvas);
	--c-warn-bg: color-mix(in srgb, var(--c-warn) 14%, Canvas);
	--c-danger-bg: color-mix(in srgb, var(--c-danger) 14%, Canvas);

	/* Buckets (Domain/CategoryBucket.cs): one hue each, for the budget rows' tags. */
	--c-bucket-recurring: #16a34a; /* green */
	--c-bucket-exceptional: #ea580c; /* orange */
	--c-bucket-reimbursement: #dc2626; /* red */
	--c-bucket-financial: #7c3aed; /* purple */
	--c-bucket-personal-fund: #2563eb; /* blue */

	/* Links: the primary colour, lightened in dark mode (below). */
	--c-link: var(--c-primary);

	/* Translucent greys that read well in both light and dark mode */
	--border-soft: #8884; /* row dividers, card edges */
	--border: #8886; /* inputs, list headings */
	--fill-faint: #8881; /* panels: totals, summaries */
	--fill-hover: #8882; /* a row under the pointer */
	--fill: #8883; /* pills, empty bars */

	/* On the primary colour (the sidebar): white text, white-ish fills, a darker well. */
	--on-primary: white;
	--on-primary-fill: #fff2; /* hover, the current page */
	--on-primary-fill-strong: #fff4; /* hover on a filled control */
	--on-primary-line: #fff4; /* dividers */
	--on-primary-well: #0002; /* the year picker */
	--on-primary-neg: #ffd0d0; /* a negative balance (the page's red is unreadable there) */

	--focus-ring: color-mix(in srgb, CanvasText 65%, transparent);
	--shadow-lifted: 0 10px 30px #0002; /* the sign-in card */

	/* ---- Space ---- */
	--s-0: 0.125rem; /* 2px: between tight rows */
	--s-1: 0.25rem;
	--s-2: 0.375rem; /* between fields */
	--s-3: 0.5rem;
	--s-4: 0.75rem; /* inside boxes */
	--s-5: 1rem;
	--s-6: 1.5rem; /* between sections */
	--s-7: 2rem;

	/* ---- Type ---- */
	--fs-xs: 0.75rem; /* field labels, uppercase headings, pills */
	--fs-sm: 0.875rem; /* secondary text, memos, table detail */
	--fs-md: 1rem; /* body, inputs */
	--fs-lg: 1.125rem; /* h2, figures that stand out */
	--fs-xl: 1.4rem; /* h1, headline figures */

	/* ---- Shape ---- */
	--r-sm: 0.4rem; /* pills inside text, small marks */
	--r-md: 0.6rem; /* inputs, buttons, notices */
	--r-lg: 1rem; /* cards, panels, boxes */
	--r-pill: 999px;

	/* Control heights: inputs and buttons side by side line up. */
	--h-sm: 2rem; /* compact inputs, small buttons */
	--h-md: 2.5rem;
	--h-lg: 3rem;

	/* ---- Emphasis ---- */
	--o-soft: 0.85; /* a touch quieter: table headings, sidebar links */
	--o-muted: 0.7; /* secondary text */
	--o-faint: 0.45; /* disabled, zero, hints of a mark */
}

@media (prefers-color-scheme: dark) {
	:root {
		--c-link: color-mix(in srgb, var(--c-primary) 55%, white);
	}
}
