/**
 * lib_tisdesign — design tokens
 *
 * Single source of truth for colour, type, spacing, radius, elevation and motion.
 * Every token is namespaced with --tis- to avoid collisions with Bootstrap and Atum.
 *
 * Dark values follow, in order: explicit app theme, Atum colour scheme,
 * Bootstrap theme attribute, operating system preference.
 *
 * @package  lib_tisdesign
 * @license  GNU General Public License version 2 or later
 */

:root {
	/* Brand */
	--tis-navy: #1a3f64;
	--tis-navy-strong: #122e4a;
	--tis-navy-deep: #0e2338;
	--tis-teal: #38b9c3;
	--tis-teal-ink: #0d6f79;

	/* Surfaces */
	--tis-bg: #f1f4f7;
	--tis-surface: #ffffff;
	--tis-sunken: #e8eef3;
	--tis-row: #f7f9fb;
	--tis-line: #d5dee6;
	--tis-line-strong: #7b8d9c;

	/* Text */
	--tis-ink: #14222f;
	--tis-ink-2: #4d5f6e;
	--tis-on-navy: #ffffff;
	--tis-on-navy-2: #b9cde0;

	/* Feedback */
	--tis-ok: #1d7a4f;
	--tis-ok-bg: #e2f3ea;
	--tis-warn: #8f5300;
	--tis-warn-bg: #fdf0db;
	--tis-bad: #b3261e;
	--tis-bad-bg: #fbe9e7;
	--tis-info: var(--tis-teal-ink);
	--tis-info-bg: var(--tis-sunken);

	/* Focus and overlay */
	--tis-focus: #c25e00;
	--tis-scrim: rgba(10, 24, 38, 0.55);

	/* Elevation */
	--tis-shadow-sm: 0 1px 2px rgba(20, 34, 47, 0.06);
	--tis-shadow-md: 0 1px 2px rgba(20, 34, 47, 0.06), 0 4px 14px rgba(20, 34, 47, 0.06);

	/* Type */
	--tis-font-display: "Montserrat", "Segoe UI", system-ui, sans-serif;
	--tis-font-body: "PT Sans", "Segoe UI", system-ui, sans-serif;
	--tis-fs-xs: 0.75rem;
	--tis-fs-sm: 0.8125rem;
	--tis-fs-base: 0.875rem;
	--tis-fs-md: 0.9375rem;
	--tis-fs-lg: 1rem;
	--tis-fs-xl: 1.125rem;
	--tis-fs-2xl: 1.375rem;
	--tis-fs-3xl: 1.75rem;
	--tis-lh-tight: 1.2;
	--tis-lh-base: 1.5;

	/* Spacing */
	--tis-space-1: 4px;
	--tis-space-2: 8px;
	--tis-space-3: 12px;
	--tis-space-4: 16px;
	--tis-space-5: 20px;
	--tis-space-6: 24px;
	--tis-space-7: 32px;
	--tis-space-8: 48px;
	--tis-space-9: 64px;

	/* Shape */
	--tis-radius-s: 6px;
	--tis-radius-m: 10px;
	--tis-radius-l: 14px;
	--tis-radius-pill: 999px;
	--tis-border-width: 1.5px;

	/* Controls */
	--tis-progress-color: var(--tis-navy);
	--tis-control-height: 38px;
	--tis-control-height-sm: 32px;
	--tis-control-padding: 0 14px;

	/* Layers */
	--tis-z-scrim: 1040;
	--tis-z-dialog: 1050;
	--tis-z-toast: 1060;

	/* Motion */
	--tis-transition: 120ms ease-out;
}

/* Dark values — explicit application theme wins over every other signal. */
:root[data-tis-theme="dark"],
:root[data-color-scheme="dark"],
:root[data-bs-theme="dark"] {
	--tis-navy: #20476f;
	--tis-navy-strong: #17375a;
	--tis-navy-deep: #0b1823;
	--tis-teal: #4fd0da;
	--tis-teal-ink: #6fd9e2;

	--tis-bg: #0d1720;
	--tis-surface: #14212c;
	--tis-sunken: #1b2b38;
	--tis-row: #172632;
	--tis-line: #2a3b4a;
	--tis-line-strong: #71879a;

	--tis-ink: #e7eef4;
	--tis-ink-2: #a8b8c6;
	--tis-on-navy: #ffffff;
	--tis-on-navy-2: #b9cde0;

	--tis-ok: #62d39b;
	--tis-ok-bg: #12301f;
	--tis-warn: #f2b25c;
	--tis-warn-bg: #352611;
	--tis-bad: #ff8f86;
	--tis-bad-bg: #3a1714;
	--tis-info: var(--tis-teal-ink);
	--tis-info-bg: var(--tis-sunken);

	--tis-focus: #ffb36b;
	--tis-scrim: rgba(0, 0, 0, 0.6);
	--tis-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
	--tis-shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4);
	--tis-progress-color: var(--tis-teal);
}

/* Operating system preference — ignored when a light theme is set explicitly. */
@media (prefers-color-scheme: dark) {
	:root:not([data-tis-theme="light"]):not([data-color-scheme="light"]):not([data-bs-theme="light"]) {
		--tis-navy: #20476f;
		--tis-navy-strong: #17375a;
		--tis-navy-deep: #0b1823;
		--tis-teal: #4fd0da;
		--tis-teal-ink: #6fd9e2;

		--tis-bg: #0d1720;
		--tis-surface: #14212c;
		--tis-sunken: #1b2b38;
		--tis-row: #172632;
		--tis-line: #2a3b4a;
		--tis-line-strong: #71879a;

		--tis-ink: #e7eef4;
		--tis-ink-2: #a8b8c6;
		--tis-on-navy: #ffffff;
		--tis-on-navy-2: #b9cde0;

		--tis-ok: #62d39b;
		--tis-ok-bg: #12301f;
		--tis-warn: #f2b25c;
		--tis-warn-bg: #352611;
		--tis-bad: #ff8f86;
		--tis-bad-bg: #3a1714;
		--tis-info: var(--tis-teal-ink);
		--tis-info-bg: var(--tis-sunken);

		--tis-focus: #ffb36b;
		--tis-scrim: rgba(0, 0, 0, 0.6);
		--tis-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
		--tis-shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4);
		--tis-progress-color: var(--tis-teal);
	}
}
