/*
 * Design tokens (FOUNDATION).
 * Direction: Apple (materials, motion, type), Bloomberg (editorial density,
 * crisp hierarchy), Google (restraint). Light first, dark via [data-theme].
 *
 * Theme state lives on <html data-theme="light|dark">. The header sets it
 * before first paint (see docs/CONTRACT.md → Dark mode).
 */

:root {
	color-scheme: light;

	/* Colour — light */
	--tpb-bg: #f5f5f7;
	--tpb-surface: #ffffff;
	--tpb-surface-2: #fbfbfd;
	--tpb-glass: rgba(255, 255, 255, 0.72);
	--tpb-text: #1d1d1f;
	--tpb-text-2: #424245;
	--tpb-muted: #6e6e73;
	--tpb-hairline: rgba(0, 0, 0, 0.08);
	--tpb-hairline-strong: rgba(0, 0, 0, 0.14);
	--tpb-accent: #0071e3;
	--tpb-accent-contrast: #ffffff;
	--tpb-positive: #1a7f37;
	--tpb-negative: #d70015;
	--tpb-tag-bg: rgba(0, 0, 0, 0.045);
	--tpb-overlay: rgba(0, 0, 0, 0.32);

	/* Text on photos (card backgrounds) — identical in light and dark */
	--tpb-on-media: #ffffff;
	--tpb-on-media-2: rgba(255, 255, 255, 0.88);
	--tpb-on-media-muted: rgba(255, 255, 255, 0.72);
	--tpb-on-media-hairline: rgba(255, 255, 255, 0.22);
	--tpb-on-media-tag: rgba(255, 255, 255, 0.16);
	--tpb-on-media-tag-hover: rgba(255, 255, 255, 0.28);
	--tpb-media-base: #111113;
	--tpb-card-scrim: 0.6;

	/* Card corner highlight colour (feed.js assigns .tpb-hue-1…8 at random) */
	--tpb-hue-highlight: 14%;

	/* Elevation */
	--tpb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.03);
	--tpb-shadow-card: 0 2px 6px rgba(0, 0, 0, 0.04), 0 18px 48px -12px rgba(0, 0, 0, 0.14);
	--tpb-shadow-lift: 0 4px 12px rgba(0, 0, 0, 0.06), 0 32px 80px -16px rgba(0, 0, 0, 0.22);

	/* Type — system stack only (no external font requests: fast + GDPR-friendly) */
	--tpb-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--tpb-font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--tpb-font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

	--tpb-fs-eyebrow: 0.75rem;   /* category label, uppercase, tracked */
	--tpb-fs-meta: 0.8125rem;
	--tpb-fs-body: 1.0625rem;
	--tpb-fs-title: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem);
	--tpb-fs-title-compact: clamp(1.375rem, 1rem + 1vw, 1.75rem); /* 4-up desktop */
	--tpb-lh-tight: 1.08;
	--tpb-lh-body: 1.55;
	--tpb-tracking-title: -0.022em;
	--tpb-tracking-eyebrow: 0.08em;

	/* Shape & space */
	--tpb-radius-sm: 10px;
	--tpb-radius: 18px;
	--tpb-radius-card: 28px;
	--tpb-radius-pill: 999px;
	--tpb-gutter: 16px;
	--tpb-space-1: 4px;
	--tpb-space-2: 8px;
	--tpb-space-3: 12px;
	--tpb-space-4: 16px;
	--tpb-space-5: 24px;
	--tpb-space-6: 32px;
	--tpb-space-7: 48px;
	--tpb-space-8: 64px;
	--tpb-header-h: 56px;
	--tpb-max-w: 1280px;

	/* Motion — Apple-like curves */
	--tpb-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
	--tpb-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
	--tpb-ease-spring: cubic-bezier(0.32, 0.72, 0, 1); /* iOS sheet */
	--tpb-dur-fast: 180ms;
	--tpb-dur: 420ms;
	--tpb-dur-slow: 680ms;
	--tpb-blur: saturate(180%) blur(20px);

	/* Layers */
	--tpb-z-feed: 1;
	--tpb-z-controls: 10;
	--tpb-z-header: 50;
	--tpb-z-sheet: 90;
	--tpb-z-menu: 100;
	--tpb-z-toast: 120;
}

/* Dark — explicit choice */
:root[data-theme="dark"] {
	color-scheme: dark;
	--tpb-bg: #000000;
	--tpb-surface: #1c1c1e;
	--tpb-surface-2: #161617;
	--tpb-glass: rgba(22, 22, 23, 0.72);
	--tpb-text: #f5f5f7;
	--tpb-text-2: #d2d2d7;
	--tpb-muted: #a1a1a6;
	--tpb-hairline: rgba(255, 255, 255, 0.1);
	--tpb-hairline-strong: rgba(255, 255, 255, 0.18);
	--tpb-accent: #2997ff;
	--tpb-positive: #30d158;
	--tpb-negative: #ff453a;
	--tpb-tag-bg: rgba(255, 255, 255, 0.08);
	--tpb-overlay: rgba(0, 0, 0, 0.56);
	--tpb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
	--tpb-shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 24px 60px -16px rgba(0, 0, 0, 0.8);
	--tpb-shadow-lift: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 40px 90px -20px rgba(0, 0, 0, 0.9);
}

/* Card hues — sapphire, emerald, amber, rose, violet, teal, coral, gold */
.tpb-hue-1 { --tpb-card-hue: #2f6bff; }
.tpb-hue-2 { --tpb-card-hue: #10b981; }
.tpb-hue-3 { --tpb-card-hue: #f59e0b; }
.tpb-hue-4 { --tpb-card-hue: #f43f5e; }
.tpb-hue-5 { --tpb-card-hue: #8b5cf6; }
.tpb-hue-6 { --tpb-card-hue: #06b6d4; }
.tpb-hue-7 { --tpb-card-hue: #fb7155; }
.tpb-hue-8 { --tpb-card-hue: #c9a227; }

:root[data-theme="dark"] {
	--tpb-hue-highlight: 22%;
}

/* Signal badge colours (inc/signals.php) */
.tpb-signal                   { --tpb-signal: var(--tpb-accent); }
.tpb-signal--high-impact      { --tpb-signal: #e5484d; }
.tpb-signal--low-impact       { --tpb-signal: #8e8e93; }
.tpb-signal--risk-off         { --tpb-signal: #f76b15; }
.tpb-signal--risk-on          { --tpb-signal: #30a46c; }
.tpb-signal--session-watch    { --tpb-signal: #0090ff; }
.tpb-signal--structural-risk  { --tpb-signal: #8e4ec6; }
.tpb-signal--regional-risk    { --tpb-signal: #e2a336; }
.tpb-signal--policy-shift     { --tpb-signal: #d6409f; }
.tpb-signal--corporate-action { --tpb-signal: #12a594; }
.tpb-signal--company-signal   { --tpb-signal: #3e63dd; }

/* "Subtle" motion setting and OS reduced-motion preference */
.tpb-motion-subtle {
	--tpb-dur: 300ms;
	--tpb-dur-slow: 420ms;
}

@media (prefers-reduced-motion: reduce) {
	:root {
		--tpb-dur-fast: 1ms;
		--tpb-dur: 1ms;
		--tpb-dur-slow: 1ms;
	}
}

/* Minimal reset every workstream can rely on */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--tpb-bg);
	color: var(--tpb-text);
	font-family: var(--tpb-font);
	font-size: var(--tpb-fs-body);
	line-height: var(--tpb-lh-body);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	transition: background-color var(--tpb-dur) var(--tpb-ease-out), color var(--tpb-dur) var(--tpb-ease-out);
}
img, svg, video { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--tpb-accent); outline-offset: 3px; border-radius: 6px; }

.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0);
	white-space: nowrap; border: 0;
}
.screen-reader-text:focus {
	clip: auto; width: auto; height: auto; margin: 0;
	padding: 12px 16px; z-index: 1000;
	top: 8px; left: 8px;
	background: var(--tpb-surface); color: var(--tpb-text);
	border-radius: var(--tpb-radius-sm); box-shadow: var(--tpb-shadow-lift);
}
