/* ============================================================
   MEA Theme: Default (Light)
   Base semantic token layer — maps theme-agnostic variable names
   to the concrete design tokens. All other themes override these.
   ============================================================ */

:root,
[data-theme="default"] {

	--t-font-family: var(--mea-font-body);
	--t-font-family-heading: var(--mea-font-citizen);
	--t-font-family-mono: var(--mea-font-mono);
	--t-font-size-hero: var(--mea-text-hero);
	--t-font-weight-interactive: var(--mea-w-bold);
	--t-font-size-interactive: var(--mea-text-md);
	--t-font-weight-semibold: var(--mea-w-semibold);
	--t-font-size-sm: var(--mea-text-sm);
	--t-font-size-md: var(--mea-text-md);
	--t-font-size-lg: var(--mea-text-lg);
	--t-font-size-xs: var(--mea-text-xs);
	--t-font-weight-bold: var(--mea-w-bold);
	--t-font-weight-normal: var(--mea-w-regular);
	/* A section heading names one part of a page, so it sits lighter than
	   the page title above it. */
	--t-font-weight-section-heading: var(--mea-w-semibold);
	/* A stat tile's value: a count read at a glance. */
	--t-font-size-2xl: var(--mea-text-2xl);
	--t-font-weight-extrabold: var(--mea-w-extrabold);
	--t-line-height-tight: var(--mea-lh-tight);

	--t-radius-lg: var(--mea-radius-lg);
	--t-radius-md: var(--mea-radius-md);
	--t-radius-xl: var(--mea-radius-4xl);
	--t-radius-pill: var(--mea-radius-pill);

	--t-border-width-interactive: var(--mea-line-hairline);
	--t-border-width-focus: 2px;
	--t-border-width-strong: 2px;
	--t-border-style-interactive: solid;
	/* The edge of something still empty, such as a file drop with no file. */
	--t-border-style-empty: dashed;
	--t-opacity-busy: 0.72;
	--t-opacity-disabled: 0.5;


	/* The page is one dark colour, with a blue glow near the top. The body
	   (--t-bg) and the lowest surface both paint from these. */
	--t-bg-color: #0C1739;
	--t-bg-glow-color: #2D4AA4;
	--t-bg-radial-gradient: radial-gradient(circle min(12rem, 50vmin) at 50% 12rem, var(--t-bg-glow-color), transparent);

	/* ── Surfaces ── */
	--t-bg: var(--t-bg-radial-gradient) var(--t-bg-color);
	--t-bg-elevated: var(--mea-surface-card);
	--t-bg-recessed: var(--mea-gray-50);
	--t-bg-hover: var(--mea-gray-100);
	--t-bg-active: var(--mea-gray-200);
	--t-bg-overlay: rgba(0, 0, 0, 0.5);
	--t-bg-input: var(--mea-surface-card);

	/* ── Text ── */
	--t-text: var(--mea-gray-900);
	--t-text-secondary: var(--mea-gray-700);
	--t-text-muted: var(--mea-gray-600);
	--t-text-placeholder: var(--mea-gray-400);
	--t-text-inverse: var(--mea-white);

	/* ── Text on the branded page background (--t-bg) ── */
	/* --t-bg is dark; these are light.
	   --t-text* stays for text on light surfaces (cards, elevated panels). */
	--t-bg-text: var(--mea-white);
	--t-bg-text-secondary: var(--mea-cg-3);
	--t-bg-text-muted: var(--mea-cg-4);

	/* ── Borders ── */
	--t-border: var(--mea-gray-200);
	--t-border-subtle: var(--mea-gray-100);
	--t-border-strong: var(--mea-gray-300);
	--t-border-input: var(--mea-gray-200);
	--t-border-focus: var(--mea-blue);

	/* ── Accent ── */
	--t-accent: var(--mea-blue);
	--t-accent-hover: var(--mea-blue-dark);
	--t-accent-light: var(--mea-blue-50);
	--t-accent-text: var(--mea-white);
	--t-accent-border: var(--mea-baby-blue);

	/* ── Status ── */
	--t-success: var(--mea-green);
	--t-success-bg: var(--mea-green-light);
	--t-success-text: var(--mea-green-dark);
	--t-error: var(--mea-red);
	--t-error-bg: var(--mea-red-light);
	--t-error-text: var(--mea-red-dark);
	--t-warning: var(--mea-amber);
	--t-warning-bg: var(--mea-amber-light);
	--t-warning-text: var(--mea-amber-dark);

	/* ── Go / no-go buttons ── Dark enough for white text in every theme, so
	   no theme redefines them. */
	--t-go-fill: var(--mea-green-dark);
	--t-no-go-fill: var(--mea-red-hover);
	--t-go-text: var(--mea-white);

	/* ── Interactive ── */
	--t-link: var(--mea-blue);
	--t-link-hover: var(--mea-blue-dark);
	--t-focus-ring: var(--mea-baby-blue);

	/* ── Components ── */
	--t-card-bg: var(--mea-surface-card);
	--t-card-border: var(--mea-gray-200);
	--t-card-accent: var(--mea-baby-blue);
	--t-sidebar-bg: var(--mea-surface-sidebar);
	--t-sidebar-text: var(--mea-white);
	--t-topbar-text: var(--mea-gray-900);
	--t-modal-bg: var(--mea-surface-card);
	--t-table-header-bg: var(--mea-gray-50);
	--t-table-hover: var(--mea-gray-50);
	--t-badge-bg: var(--mea-gray-100);
	--t-badge-text: var(--mea-gray-700);
	--t-chip-bg: var(--mea-surface-card);
	--t-chip-border: var(--mea-gray-200);
	--t-chip-active-bg: var(--mea-blue-50);
	--t-chip-active-border: var(--mea-blue);

	/* ── Typography scale (can be overridden for accessibility) ── */
	@media (max-width: 48rem) {
		--mea-text-base: 1.2rem;
	}

	--t-font-base: var(--mea-desk-lg);
	--t-font-sm: var(--mea-desk-sm);
	--t-font-lg: var(--mea-desk-xl);
	--t-line-height: var(--mea-lh-normal);
	--t-letter-spacing: var(--mea-ls-normal);

	/* ── Layout ── */
	--t-content-max-w: none;
	--t-target-min-size: 44px;
	--t-target-min: var(--t-target-min-size);
	/* minimum touch/click target */
	--t-spacing-scale: 1;
	/* multiplier for voice/accessibility */
	/* The widest a signed-out page grows (shells/signed_out.html). */
	--t-max-inline-size-page: var(--mea-app-max-w-desktop);
	/* A signed-out page of a few lines, such as an error. */
	--t-max-inline-size-page-narrow: var(--mea-app-max-w-tablet);
	/* The phone's top bar stays over the page as it scrolls. The open nav
	   drawer covers everything, the participant's tab bar included (which
	   sits at --mea-z-top). */
	--t-z-index-sticky: var(--mea-z-sticky);
	--t-z-index-drawer: calc(var(--mea-z-top) + 1);
}

/* Spacing scale. Declared again on every [data-theme] element so a theme's
   --t-spacing-scale reaches it wherever the theme is applied. */
:root,
[data-theme] {
	--t-space-1: calc(var(--mea-space-1) * var(--t-spacing-scale));
	--t-space-2: calc(var(--mea-space-2) * var(--t-spacing-scale));
	--t-space-3: calc(var(--mea-space-3) * var(--t-spacing-scale));
	--t-space-4: calc(var(--mea-space-4) * var(--t-spacing-scale));
	--t-space-5: calc(var(--mea-space-5) * var(--t-spacing-scale));
	--t-space-6: calc(var(--mea-space-6) * var(--t-spacing-scale));
	--t-space-7: calc(var(--mea-space-7) * var(--t-spacing-scale));
	--t-space-8: calc(var(--mea-space-8) * var(--t-spacing-scale));
	--t-space-10: calc(var(--mea-space-10) * var(--t-spacing-scale));
	--t-space-12: calc(var(--mea-space-12) * var(--t-spacing-scale));
	--t-space-16: calc(var(--mea-space-16) * var(--t-spacing-scale));
}

/* Surfaces: each sets the full --c-surface-* set its children read.
   See design-system/components/surfaces/README.md. */
@layer theme {
	.surface.lowest {
		--c-surface-background-color: var(--t-bg-color);
		--c-surface-background-image: var(--t-bg-radial-gradient);
		--c-surface-text-color-base: #FFFFFF;
		--c-surface-text-color-muted: #EEF0F6;
		--c-surface-text-color-highlight: #FFFFFF;
		--c-surface-text-color-interactive: #E3F3FD;
		--c-surface-text-color-info: #E7F2FA;
		--c-surface-text-color-error: #FEEDED;
		--c-surface-text-color-success: #D3F9E1;
		--c-surface-text-color-warning: #FEF0C0;
		--c-surface-border-color-interactive: #82CBF5;
	}

	.surface.raised {
		--c-surface-background-color: #FFFFFF;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #0A1628;
		--c-surface-text-color-muted: #2A5E79;
		--c-surface-text-color-highlight: #1E4D6B;
		--c-surface-text-color-interactive: #1442D9;
		--c-surface-text-color-info: #1E4D6B;
		--c-surface-text-color-error: #8C1D1D;
		--c-surface-text-color-success: #166534;
		--c-surface-text-color-warning: #92400E;
		--c-surface-border-color-interactive: #7390DD;
	}

	.surface.recessed {
		--c-surface-background-color: #F7F9FE;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #0A1628;
		--c-surface-text-color-muted: #345A71;
		--c-surface-text-color-highlight: #295B75;
		--c-surface-text-color-interactive: #1442D9;
		--c-surface-text-color-info: #1E4D6B;
		--c-surface-text-color-error: #8C1D1D;
		--c-surface-text-color-success: #156132;
		--c-surface-text-color-warning: #8D3E0E;
		--c-surface-border-color-interactive: #6E8BDC;
	}

	.surface.interactive {
		--c-surface-background-color: #093EF2;
		--c-surface-background-image: linear-gradient(160deg, #0040F0 0%, #093EF2 55%, #144AD6 100%);
		--c-surface-text-color-base: #FFFFFF;
		--c-surface-text-color-muted: #FFFFFF;
		--c-surface-text-color-highlight: #FFFFFF;
		--c-surface-text-color-interactive: #FFFFFF;
		--c-surface-text-color-info: #FFFFFF;
		--c-surface-text-color-error: #FFFFFF;
		--c-surface-text-color-success: #FFFFFF;
		--c-surface-text-color-warning: #FFFFFF;
		--c-surface-border-color-interactive: #FFFFFF;
	}

	.surface.info {
		--c-surface-background-color: #D2E6F5;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #1E4D6B;
		--c-surface-text-color-muted: #1E4D6B;
		--c-surface-text-color-highlight: #1E4D6B;
		--c-surface-text-color-interactive: #1E4D6B;
		--c-surface-text-color-info: #1E4D6B;
		--c-surface-text-color-error: #8C1D1D;
		--c-surface-text-color-success: #12542B;
		--c-surface-text-color-warning: #78350C;
		--c-surface-border-color-interactive: #1E4D6B;
	}

	.surface.error {
		--c-surface-background-color: #FEE2E2;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #8C1D1D;
		--c-surface-text-color-muted: #8C1D1D;
		--c-surface-text-color-highlight: #8C1D1D;
		--c-surface-text-color-interactive: #8C1D1D;
		--c-surface-text-color-info: #8C1D1D;
		--c-surface-text-color-error: #8C1D1D;
		--c-surface-text-color-success: #13562C;
		--c-surface-text-color-warning: #7D370C;
		--c-surface-border-color-interactive: #8C1D1D;
	}

	.surface.input {
		--c-surface-background-color: #FFFFFF;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #0A1628;
		--c-surface-text-color-muted: #285A74;
		--c-surface-text-color-highlight: #1E4D6B;
		--c-surface-text-color-interactive: #1442D9;
		--c-surface-text-color-info: #1E4D6B;
		--c-surface-text-color-error: #8C1D1D;
		--c-surface-text-color-success: #166534;
		--c-surface-text-color-warning: #92400E;
		--c-surface-border-color-interactive: #7390DD;
	}

	/* An input the page is not taking typing into right now (disabled, or
	   readonly while a script keeps its value in the payload): the recessed
	   set, so it reads as part of the page rather than a box to fill. */
	.surface.input:is(:disabled, [readonly]) {
		--c-surface-background-color: #F7F9FE;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #0A1628;
		--c-surface-text-color-muted: #345A71;
		--c-surface-text-color-highlight: #295B75;
		--c-surface-text-color-interactive: #1442D9;
		--c-surface-text-color-info: #1E4D6B;
		--c-surface-text-color-error: #8C1D1D;
		--c-surface-text-color-success: #156132;
		--c-surface-text-color-warning: #8D3E0E;
		--c-surface-border-color-interactive: #6E8BDC;
	}

	.surface.success {
		--c-surface-background-color: #DCFCE7;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #155F31;
		--c-surface-text-color-muted: #155F31;
		--c-surface-text-color-highlight: #155F31;
		--c-surface-text-color-interactive: #155F31;
		--c-surface-text-color-info: #155F31;
		--c-surface-text-color-error: #8C1D1D;
		--c-surface-text-color-success: #155F31;
		--c-surface-text-color-warning: #893C0D;
		--c-surface-border-color-interactive: #155F31;
	}

	.surface.warning {
		--c-surface-background-color: #FEF3C7;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #863B0D;
		--c-surface-text-color-muted: #863B0D;
		--c-surface-text-color-highlight: #863B0D;
		--c-surface-text-color-interactive: #863B0D;
		--c-surface-text-color-info: #863B0D;
		--c-surface-text-color-error: #8C1D1D;
		--c-surface-text-color-success: #145D30;
		--c-surface-text-color-warning: #863B0D;
		--c-surface-border-color-interactive: #863B0D;
	}

	/* The one thing a page leads with, such as the participant's current
	   task. Purple at the top left darkens to navy at the bottom, under a
	   bright blue glow at the top right and a mauve one in the bottom-right
	   corner. Each colour is the design's, darkened until white reaches 7:1. */
	.surface.featured {
		--c-surface-background-color: #31418A;
		--c-surface-background-image: radial-gradient(ellipse 70% 90% at 80% 0%, #2352B6, transparent), radial-gradient(ellipse 55% 75% at 100% 100%, #4F475F, transparent), linear-gradient(#4A529B, #31418A);
		--c-surface-text-color-base: #FFFFFF;
		--c-surface-text-color-muted: #FFFFFF;
		--c-surface-text-color-highlight: #FFFFFF;
		--c-surface-text-color-interactive: #FFFFFF;
		--c-surface-text-color-info: #FFFFFF;
		--c-surface-text-color-error: #FFFFFF;
		--c-surface-text-color-success: #FFFFFF;
		--c-surface-text-color-warning: #FFFFFF;
		--c-surface-border-color-interactive: #FFFFFF;
	}

	/* Set into a featured surface, such as a progress track or an icon's
	   circle. */
	.surface.inset {
		--c-surface-background-color: #0C1739;
		--c-surface-background-image: none;
		--c-surface-text-color-base: #FFFFFF;
		--c-surface-text-color-muted: #EEF0F6;
		--c-surface-text-color-highlight: #FFFFFF;
		--c-surface-text-color-interactive: #3BEBA7;
		--c-surface-text-color-info: #E7F2FA;
		--c-surface-text-color-error: #FEEDED;
		--c-surface-text-color-success: #D3F9E1;
		--c-surface-text-color-warning: #FEF0C0;
		--c-surface-border-color-interactive: #FFFFFF;
	}

	/* Category badges: one fixed hue per data category, carrying no
	   severity meaning. They label data (a charge category) where the four
	   meaning badges cannot tell the categories apart. They are not
	   surfaces: nothing else can sit on them. */
	.badge.category.violet {
		--c-category-background-color: #EDE9FE;
		--c-category-text-color: #5B21B6;
	}

	.badge.category.orange {
		--c-category-background-color: #FFEDD5;
		--c-category-text-color: #7C2D12;
	}

	.badge.category.teal {
		--c-category-background-color: #F0FFFE;
		--c-category-text-color: #115E59;
	}
}
