/* tokens.css - every custom property the site reads, loaded first on every
   page (parent_builder.py), before base.css. css-token-def: the token
   families are defined nowhere else. The :root values are ui/tokens.py
   TOKENS (tests/test_ui_tokens.py keeps the two equal). */

:root {
	/* Dark is the only rendered theme. Colours are named by role. */
	--bg: #15181c;
	--surface-2: #1b1f24;
	--surface-3: #242a31;
	--code-bg: #22272e;
	--text: #e4e7eb;
	--text-muted: #9ba4ae;
	--border: #30363d;
	--border-strong: #6e7781;
	/* One accent: links, primary actions, selection. */
	--accent: #8fb3d9;
	--accent-hover: #b5cde8;
	--accent-soft: #1c2a3a;
	--on-accent: #15181c;
	/* Status: one value per meaning, each with a soft ground for fills. */
	--ok: #6cc58a;
	--ok-soft: #16271d;
	--warn: #e0ac4f;
	--warn-soft: #2b2316;
	--danger: #f08a80;
	--danger-soft: #2e1b1a;
	--chart-grid: #262c33;
	/* Chart series, in this fixed order. A chart with one series draws in
	   --accent. Literal hex: the chart scripts parse them. */
	--series-1: #3987e5;
	--series-2: #d95926;
	--series-3: #199e70;
	--series-4: #c98500;
	--series-5: #d55181;
	--series-6: #008300;
	--series-7: #9085e9;
	--series-8: #e66767;
	/* Market up/down pair (finance pages, screener stars, movers). Defined
	   here so portfolio/screener/analytics share one value; --mkt-neutral is
	   the flat/unchanged grey. */
	--mkt-pos: #2e7d32;
	--mkt-neg: #c62828;
	--mkt-neutral: #6e7681;
	/* Page widths: a form or a single card, and the reading column. Every
	   other page fills the space beside the sidebar (components.css .l-w-*). */
	--w-narrow: 34rem;
	--w-page: 48rem;


	/* Two radii: panels and fields, then chips and small marks. True circles
	   use 50% inline. */
	--radius-sm: 4px;
	--radius-md: 6px;

	/* Sans for interface and prose; mono for terminals, logs, code and copied
	   values. Inter is served from this site (base.css @font-face). */
	--font-sans: "Inter", "Inter fallback", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
	--font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

	/* Type scale: 13, 14, 16, 18, 22 and 28 px. Body leading is 1.6, heading
	   and control leading 1.25. */
	--fs-xs: 0.8125rem;
	--fs-sm: 0.875rem;
	--fs-base: 1rem;
	--fs-title: 1.125rem;
	--fs-xl: 1.375rem;
	--fs-2xl: 1.75rem;    /* the page h1 */
	/* Padding of the legacy small button and the compact search fields. */
	--ctl-pad-btn: 3px 12px;
	--ctl-pad-field: 3px 8px;

	/* Page gutter: 24 px; 16 px on phones on ui pages (body.ui, below). Read
	   by the footer, /bridge, the tools pages and the ui page frame. */
	--page-gutter: 24px;

	/* Focus ring - shared across all interactive elements */
	--focus-ring: 0 0 0 3px rgba(152, 152, 152, 0.12);


	/* Modal / overlay */
	--modal-backdrop: rgba(0, 0, 0, 0.45);

	/* Game player colours (popugame) */
	--player-0-color: #3fa86a;
	--player-1-color: #6b93f0;

	/* Spacing scale (ruling 13): the only spacing values ui layout emits. */
	--sp-1: 4px;
	--sp-2: 8px;
	--sp-3: 12px;
	--sp-4: 16px;
	--sp-5: 24px;
	--sp-6: 32px;
	--sp-7: 48px;
	--sp-8: 64px;

	/* Table rows, list items and skeleton rows (ruling 16); 44 px in the
	   touch layer below. */
	--row-h: 30px;

	/* Control heights by context (ruling 15). These are the compact bases;
	   .l-ctx-form raises them and the touch layer below floors them. ui
	   controls read the derived --ctl-h-* (body.ui), never these. */
	--ctl-h-chip-base: 24px;
	--ctl-h-btn-base: 28px;
	--ctl-h-field-base: 28px;
	--ctl-h-primary-base: 28px;

	/* The shell (chrome.css). The header is one height at every width, and
	   whatever sticks under it (table heads, sub-navigation) reads it. */
	--header-h: 3.5rem;
	--sidebar-w: 16rem;
	--outline-w: 13rem;

	/* Layers, bottom to top: the sticky header, the phone drawer, a hover
	   card or tooltip, a modal, a menu, the toast, a confirm dialog. Stacking
	   inside one component stays a small literal. */
	--z-header: 900;
	--z-drawer: 950;
	--z-tip: 960;
	--z-modal: 1000;
	--z-menu: 1010;
	--z-toast: 1020;
	--z-dialog: 100000;
}

/* Form context: box pages and public request forms. */
.l-ctx-form {
	--ctl-h-btn-base: 36px;
	--ctl-h-field-base: 36px;
	--ctl-h-primary-base: 36px;
}

/* Derived values are declared on every context element: var() resolves where
   a property is declared, so a value computed on body.ui alone would not see
   .l-ctx-form's bases. */
body.ui,
body.ui .l-ctx-form {
	--ctl-h-chip: var(--ctl-h-chip-base);
	--ctl-h-btn: var(--ctl-h-btn-base);
	--ctl-h-field: var(--ctl-h-field-base);
	--ctl-h-primary: var(--ctl-h-primary-base);
	--ctl-fs: var(--fs-sm);
	--ctl-fs-field: var(--fs-sm);
}


@media (max-width: 600px) {
	body.ui { --page-gutter: 16px; }
}

/* The one touch layer (ruling 19), replacing the per-page copies as pages
   migrate. Legacy pages keep their own touch blocks until then. */
@media (max-width: 600px), (pointer: coarse) {
	body.ui,
	body.ui .l-ctx-form {
		--ctl-h-chip: 44px;
		--ctl-h-btn: 44px;
		--ctl-h-field: 44px;
		--ctl-h-primary: 44px;
		--ctl-fs-field: 16px;         /* iOS zooms below 16 px */
	}
	/* Rows are tapped here: table rows, list items, skeleton rows and the
	   reserves counted in them. The game lobbies keep their recorded rows. */
	body.ui:not(:has(.popugame-landing)) { --row-h: 44px; }
}

/* A viewer who asks for more contrast: muted text at 10:1 and hairlines at
   3.9:1 on the ground. The game pin keeps its recorded values. */
@media (prefers-contrast: more) {
	body.ui:not(.ff-pin > *) {
		--text-muted: #c3c9d0;
		--border: #6e7781;
		--border-strong: #9ba4ae;
	}
}

/* The game pin. A Forgetful Fish table document sets the class on <html>:
   its own monospace face, type scale, radii, shadows and control heights, so
   the table keeps its geometry while the global values above move. Colours
   are the site's. Change a value here only with the geometry baselines
   (tests/e2e/test_ff_geometry.py). */
html.ff-pin {
	/* The table's seat colours stay as they were (the lobbies' are lighter). */
	--player-0-color: #1a7f45;
	--player-1-color: #2b5dd1;
	--shadow-md: 0 1px 3px rgba(0, 0, 0, 0.5);
	--shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.55);
	--radius-sm: 3px;
	--radius-md: 5px;
	--radius-lg: 7px;
	--font-sans: Consolas, Menlo, "Liberation Mono", "Courier New", monospace;
	--font-mono: var(--font-sans);
	--fs-xs: 0.72rem;
	--fs-sm: 0.78rem;
	--fs-base: 0.85rem;
	--fs-md: 0.9rem;
	--fs-title: 1.05rem;
	--fs-xl: 1.125rem;
	--fs-2xl: 1.6rem;
	--row-h: 26px;
	--ctl-h-chip-base: 20px;
	--ctl-h-btn-base: 23px;
	--ctl-h-field-base: 25px;
	--ctl-h-primary-base: 23px;
}
