/*
 * Heluca theme bridge — light/dark semantics + daisyUI v5 mapping.
 *
 * UPSTREAMED into the design system so consuming apps copy it verbatim, exactly
 * like tokens/*.css. It is NOT @imported by styles.css (it references daisyUI's
 * --color-* slots and resolved --t-* neutrals that belong to the consuming app,
 * not to the token layer). Copy it into your app's stylesheet AFTER the daisyUI
 * plugin — see readme.md "Svelte implementation" and @heluca/svelte's README.
 *
 * Two jobs the token layer leaves to the app:
 *   1. Re-point the semantic aliases per [data-theme], so Heluca's own
 *      component vocabulary (--bg, --surface-card) works in both themes, and
 *      expose resolved --t-* neutrals.
 *   2. Map those onto daisyUI v5's --color-* variables, so existing markup
 *      (.btn, .input, .card, .badge, .menu, .alert …) inherits the brand with
 *      no per-component edits — the highest-leverage part of adoption.
 *
 * Heluca is dark-native (Hecate is "dark, torch-lit"); light is a first-class
 * daytime mapping. Your app sets data-theme="light|dark" on <html>; this file
 * defines nothing without it.
 *
 * NOTE ON --text-body: it is the 16px body SIZE (defined once, in
 * tokens/typography.css, consistent with --text-heading / --text-label /
 * --text-caption). The old conflicting colour alias was removed from
 * tokens/colors.css at source, so `font-size: var(--text-body)` is valid and
 * this file must NOT re-point it to a colour. Body/label colour is --t-text.
 */

/* ── Semantic aliases: dark (Heluca's native) ─────────────────────── */
[data-theme='dark'] {
	color-scheme: dark;
	--bg: var(--ink);
	--surface-card: var(--surface);

	/* resolved neutrals for this theme */
	--t-base: var(--ink);
	--t-base-200: var(--base-200);
	--t-surface: var(--surface);
	--t-surface-raised: var(--surface-raised);
	--t-text: var(--text);
	--t-text-muted: var(--text-muted);
	--t-text-faint: var(--text-faint);
	--t-hairline: var(--hairline);
	--t-divider: var(--divider);
}

/* ── Semantic aliases: light ──────────────────────────────────────── */
[data-theme='light'] {
	color-scheme: light;
	--bg: var(--paper);
	--surface-card: var(--paper-surface);

	--t-base: var(--paper);
	--t-base-200: #ece7dc; /* between --paper and --paper-hairline */
	--t-surface: var(--paper-surface);
	--t-surface-raised: #ffffff;
	--t-text: var(--text-dark);
	--t-text-muted: var(--text-grey);
	--t-text-faint: var(--text-lightgrey);
	--t-hairline: var(--paper-hairline);
	--t-divider: var(--paper-hairline);

	/* On light, elevation-1's hairline ring must use the paper hairline. */
	--elev-1: 0 0 0 1px var(--paper-hairline);
	/* Shadows tuned for dark are far too heavy on paper. */
	--elev-2: 0 6px 16px -6px rgba(38, 35, 43, 0.18);
	--elev-3: 0 18px 44px -12px rgba(38, 35, 43, 0.28);
	--glow: 0 10px 28px -8px rgba(255, 164, 21, 0.45);
}

/*
 * ── daisyUI v5 bridge ─────────────────────────────────────────────
 * daisyUI reads --color-* custom properties. Wiring them to Heluca tokens is
 * what makes existing markup on-brand with no per-component edits.
 * Radii come from Heluca's shape scale: one radius per element class.
 */
[data-theme='light'],
[data-theme='dark'] {
	--color-base-100: var(--t-base);
	--color-base-200: var(--t-base-200);
	--color-base-300: var(--t-surface-raised);
	--color-base-content: var(--t-text);

	--color-primary: var(--orange);
	--color-primary-content: var(--on-orange);
	--color-secondary: var(--blue);
	--color-secondary-content: var(--on-blue);
	--color-accent: var(--orange-bright);
	--color-accent-content: var(--on-orange);

	--color-neutral: var(--t-surface);
	--color-neutral-content: var(--t-text);

	--color-info: var(--info);
	--color-success: var(--success);
	--color-warning: var(--warning);
	--color-error: var(--danger);
	--color-info-content: var(--on-blue);
	--color-success-content: #04140d;
	--color-warning-content: var(--on-orange);
	--color-error-content: #ffffff;

	/* Shape scale — daisyUI radius slots mapped to Heluca element classes. */
	--radius-selector: var(--radius-input); /* checkbox, radio, toggle, badge */
	--radius-field: var(--radius-input); /* input, select, textarea */
	--radius-box: var(--radius-card); /* card, modal, alert */
}

/*
 * daisyUI v5 sizing slots — pinned by the SYSTEM, applied to every Heluca
 * theme. Previously this block named only light/dark, so the temperament
 * themes silently fell back to daisyUI's built-in `--border` / `--size-*` /
 * `--depth` — wrong for Terminal especially, whose entire aesthetic is a 1px
 * border. A temperament may still override any of these in its own block
 * (Business/Terminal set their own radii); the point is that they're never
 * left to daisyUI's defaults by accident.
 */
[data-theme='light'],
[data-theme='dark'],
[data-theme='consulting'],
[data-theme='business'],
[data-theme='business-dark'],
[data-theme='terminal'],
[data-theme='terminal-light'] {
	--size-selector: 0.25rem;
	--size-field: 0.25rem;
	--border: 1px;
	--depth: 0;
	--noise: 0;
}

/*
 * daisyUI's .btn inherits --radius-field (8px, correct for inputs) but Heluca
 * specifies 14px for buttons. One radius per element class is a stated rule,
 * so buttons are corrected explicitly rather than by bending --radius-field.
 */
.btn {
	border-radius: var(--radius-button);
	font-family: var(--font-sans);
	font-weight: 700;
}

/*
 * Pills stay pills. Badges are CHROME by default — across the estate the common
 * case is system status ("revoked", health, counts), which is app-authored →
 * Public Sans, consistent with every other label. Opt into the content face
 * with .badge-content (or Badge userContent) for genuinely user-authored values
 * such as tag names or device labels.
 */
.badge {
	border-radius: var(--radius-pill);
	font-family: var(--font-sans);
}
.badge-content {
	font-family: var(--font-work);
}

/* Sheets/modals use the sheet radius, not the card radius. */
.modal-box {
	border-radius: var(--radius-sheet);
}

/*
 * ── Type: chrome vs content ───────────────────────────────────────
 * "The app is Public Sans, the user's words are Plex." Chrome is the default;
 * fields the user types into are switched to the work face.
 */
body {
	font-family: var(--font-sans);
	font-size: var(--text-body);
	line-height: var(--lh-body);
	background: var(--bg);
	color: var(--t-text);
}

/*
 * Fields hold user content → work face. Do NOT set font-size on these directly:
 * daisyUI v5 size classes read `max(var(--font-size, floor), floor)`, and a
 * direct font-size here has equal specificity but lands later in the cascade,
 * so it defeats every -sm/-xs modifier (16px in a 24px box). Set only the
 * --font-size override point per size and let daisyUI's own rules apply.
 */
.input,
.textarea,
select.select {
	font-family: var(--font-work);
}
.input,
.textarea {
	--font-size: var(--text-work);
} /* 16px — clears the .875rem floor */
.input-sm,
.textarea-sm {
	--font-size: var(--text-label);
} /* 13px — clears the .75rem floor */
.input-xs,
.textarea-xs {
	--font-size: var(--text-caption);
} /* 12px — clears the .6875rem floor */
/*
 * .select and .file-input set font-size DIRECTLY (no --font-size indirection),
 * so the override above can't reach them. We keep the work FACE and leave
 * daisyUI's own size scale intact rather than restating font-size per size
 * (which would re-clamp small sizes). The face is what the chrome≠content rule
 * cares about; the numeric scale is daisyUI's and is correct.
 */
.file-input {
	font-family: var(--font-work);
}

/*
 * Fields need a SURFACE against the page. daisyUI defaults .input et al. to
 * --color-base-100, which the bridge maps to --t-base (the page background) —
 * leaving a field with no fill. Lift them to --t-surface in both themes
 * (also matches Heluca's own TextField, which uses --t-surface). Do NOT retune
 * --color-base-100 — that IS the page background and is correct.
 */
.input,
.textarea,
select.select,
.file-input,
.modal-box {
	background-color: var(--t-surface);
}

/*
 * The native <select> POPUP is painted by the browser, not the page: with no
 * option colours it renders the stock white list on every theme. Chromium
 * honours these; macOS's native popup ignores them and follows the per-theme
 * color-scheme instead — which is why every theme block also declares one.
 */
select.select option {
	background-color: var(--t-surface);
	color: var(--t-text);
}

/* Form field *labels* are chrome, even though the field itself is content. */
.label,
.label-text,
.fieldset-legend {
	font-family: var(--font-sans);
	font-size: var(--text-label);
	font-weight: var(--wt-label);
}

/* Data, metrics and big numbers. */
.font-mono,
.stat-value,
code,
kbd,
pre {
	font-family: var(--font-mono);
}

/* Titles and product names. Never below ~22px, 400 only. */
.heluca-display {
	font-family: var(--font-display);
	font-weight: var(--wt-display);
	line-height: var(--lh-display);
}

/* Small overlines/eyebrows — the one place UPPERCASE is allowed. */
.heluca-overline {
	font-family: var(--font-sans);
	font-size: var(--text-overline);
	font-weight: var(--wt-overline);
	letter-spacing: var(--ls-overline);
	text-transform: uppercase;
	color: var(--t-text-muted);
}

/*
 * ── Motion ────────────────────────────────────────────────────────
 * Signature torch glow, active elements only. Honour reduced motion.
 */
.heluca-glow {
	animation: heluca-glow var(--dur-pulse) var(--ease-standard) infinite;
}

@media (prefers-reduced-motion: reduce) {
	.heluca-glow {
		animation: none;
	}
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/*
 * ══════════════════════════════════════════════════════════════════
 *  TEMPERAMENTS — one brand, product-specific moods.
 *  Each is a self-contained daisyUI theme: set data-theme on any
 *  subtree and the existing components inherit that mood. Promoted
 *  verbatim from the "One brand, five temperaments" pairing study;
 *  all fonts (Marcellus, Public Sans, JetBrains Mono) already ship in
 *  tokens/fonts.css. Experiments (Fredoka) is deliberately omitted —
 *  it's still an idea, not a shipping mood.
 * ══════════════════════════════════════════════════════════════════ */

/* ── Consulting — warm paper, serif gravitas, gilt amber ──────────── */
[data-theme='consulting'] {
	color-scheme: light;
	--bg: #f6f2e9;
	--surface-card: #fffdf8;
	--t-base: #f6f2e9;
	--t-base-200: #f1ecdf;
	--t-surface: #fffdf8;
	--t-surface-raised: #ffffff;
	--t-text: #26232b;
	--t-text-muted: #57545e;
	--t-text-faint: #a39e90;
	--t-hairline: #e7e1d0;
	--t-divider: #efe9da;

	--color-base-100: #f6f2e9;
	--color-base-200: #f1ecdf;
	--color-base-300: #ffffff;
	--color-base-content: #26232b;
	--color-primary: #ffa415; /* amber steps back to gilt */
	--color-primary-content: #1a1206;
	--color-secondary: #4b96ff;
	--color-secondary-content: #ffffff;
	--color-accent: #ffc219;
	--color-accent-content: #1a1206;
	--color-neutral: #26232b; /* ink carries dark actions */
	--color-neutral-content: #f6f2e9;
	--color-info: #0891b2;
	--color-success: #059669;
	--color-warning: #d99b06;
	--color-error: #dc143c;
	--color-info-content: #ffffff;
	--color-success-content: #ffffff;
	--color-warning-content: #1a1206;
	--color-error-content: #ffffff;

	--elev-1: 0 0 0 1px #e7e1d0;
	--elev-2: 0 6px 16px -6px rgba(38, 35, 43, 0.16);
	--elev-3: 0 18px 44px -14px rgba(38, 35, 43, 0.22);
}
[data-theme='consulting'] body {
	font-family: var(--font-sans);
	background: var(--bg);
	color: var(--t-text);
}
[data-theme='consulting'] .heluca-display {
	font-family: var(--font-display); /* Marcellus */
}

/* ── Business — cool neutrals, dense, mono for every value ────────── */
[data-theme='business'] {
	color-scheme: light;
	--bg: #f3f5f6;
	--surface-card: #ffffff;
	--t-base: #f3f5f6;
	--t-base-200: #eaedef;
	--t-surface: #ffffff;
	--t-surface-raised: #ffffff;
	--t-text: #14181c;
	--t-text-muted: #5a6673;
	--t-text-faint: #8894a0;
	--t-hairline: #e4e7ea;
	--t-divider: #edeff1;

	--color-base-100: #f3f5f6;
	--color-base-200: #eaedef;
	--color-base-300: #ffffff;
	--color-base-content: #14181c;
	--color-primary: #ffa415; /* amber = action */
	--color-primary-content: #1a1206;
	--color-secondary: #4b96ff; /* blue = data */
	--color-secondary-content: #ffffff;
	--color-accent: #3a7bd0;
	--color-accent-content: #ffffff;
	--color-neutral: #14181c;
	--color-neutral-content: #f3f5f6;
	--color-info: #06b6d4;
	--color-success: #10b981;
	--color-warning: #eab308;
	--color-error: #dc143c;
	--color-info-content: #06202a;
	--color-success-content: #04140d;
	--color-warning-content: #1a1206;
	--color-error-content: #ffffff;

	/* Tight rhythm: smaller field radius than the core system. */
	--radius-field: 8px;
	--radius-box: 10px;
	--elev-1: 0 0 0 1px #e4e7ea;
	--elev-2: 0 18px 40px -28px rgba(20, 24, 28, 0.35);
}
[data-theme='business'] body {
	font-family: var(--font-sans);
	background: var(--bg);
	color: var(--t-text);
}
[data-theme='business'] .heluca-display {
	font-family: var(--font-display);
}
/* Every numeric value is mono in Business. */
[data-theme='business'] .stat-value,
[data-theme='business'] .font-num {
	font-family: var(--font-mono);
}

/* ── Terminal — near-black tty, mono-only, phosphor amber, sharp ──── */
[data-theme='terminal'] {
	color-scheme: dark;
	--bg: #0a0b0a;
	--surface-card: #0e100d;
	--t-base: #0a0b0a;
	--t-base-200: #070806;
	--t-surface: #0e100d;
	--t-surface-raised: #12140f;
	--t-text: #e6e2d6;
	--t-text-muted: #8a9179;
	--t-text-faint: #5a6152;
	--t-hairline: #1e2119;
	--t-divider: #2b2f26;

	--color-base-100: #0a0b0a;
	--color-base-200: #070806;
	--color-base-300: #12140f;
	--color-base-content: #e6e2d6;
	--color-primary: #ffb21b; /* phosphor glow */
	--color-primary-content: #0a0b0a;
	--color-secondary: #58c0ff; /* link */
	--color-secondary-content: #04131f;
	--color-accent: #ffb21b;
	--color-accent-content: #0a0b0a;
	--color-neutral: #12140f;
	--color-neutral-content: #e6e2d6;
	--color-info: #22d3ee;
	--color-success: #34d399;
	--color-warning: #fbbf24;
	--color-error: #ff4d67;
	--color-info-content: #04131f;
	--color-success-content: #04140d;
	--color-warning-content: #1a1206;
	--color-error-content: #0a0b0a;

	/* No rounded anything. */
	--radius-input: 3px;
	--radius-button: 3px;
	--radius-card: 4px;
	--radius-selector: 3px;
	--radius-field: 3px;
	--radius-box: 4px;
	--elev-1: 0 0 0 1px #1e2119;
	--elev-2: 0 22px 50px -24px rgba(0, 0, 0, 0.85);
	/* Amber "on" glow ring for active surfaces. */
	--glow: 0 0 0 1px rgba(255, 178, 27, 0.12), 0 0 18px -2px rgba(255, 178, 27, 0.35);
}
/* Terminal is mono end to end — chrome AND content. */
[data-theme='terminal'] body,
[data-theme='terminal'] .input,
[data-theme='terminal'] .textarea,
[data-theme='terminal'] .btn,
[data-theme='terminal'] .badge,
[data-theme='terminal'] .label,
[data-theme='terminal'] .heluca-display {
	font-family: var(--font-mono);
	background: var(--bg);
	color: var(--t-text);
}
/* Optional CRT scanline wash for full-screen tty surfaces. */
[data-theme='terminal'] .heluca-scanlines {
	background-image: repeating-linear-gradient(
		0deg,
		rgba(255, 255, 255, 0.028) 0px,
		rgba(255, 255, 255, 0.028) 1px,
		transparent 1px,
		transparent 3px
	);
}

/* ── Terminal (light) — paper tty, ink-on-cream, mono, sharp ─────────
 * Daytime counterpart to Terminal. Same sharp, border-driven, mono-only
 * aesthetic; the phosphor amber darkens to a gilt so it holds contrast as
 * ink on paper instead of glowing off a black field. */
[data-theme='terminal-light'] {
	color-scheme: light;
	--bg: #f4f2ea;
	--surface-card: #fffdf6;
	--t-base: #f4f2ea;
	--t-base-200: #eae8dc;
	--t-surface: #fffdf6;
	--t-surface-raised: #ffffff;
	--t-text: #16180f;
	--t-text-muted: #565b48;
	--t-text-faint: #878c74;
	--t-hairline: #dcdccb;
	--t-divider: #e6e6d5;

	--color-base-100: #f4f2ea;
	--color-base-200: #eae8dc;
	--color-base-300: #ffffff;
	--color-base-content: #16180f;
	--color-primary: #b3760a; /* phosphor amber, darkened to gilt for ink-on-paper */
	--color-primary-content: #fffdf6;
	--color-secondary: #2f6fd0; /* link */
	--color-secondary-content: #ffffff;
	--color-accent: #b3760a;
	--color-accent-content: #fffdf6;
	--color-neutral: #16180f;
	--color-neutral-content: #f4f2ea;
	--color-info: #0e7490;
	--color-success: #047857;
	--color-warning: #8a7c00;
	--color-error: #c01430;
	--color-info-content: #ffffff;
	--color-success-content: #ffffff;
	--color-warning-content: #fffdf6;
	--color-error-content: #ffffff;

	/* No rounded anything. */
	--radius-input: 3px;
	--radius-button: 3px;
	--radius-card: 4px;
	--radius-selector: 3px;
	--radius-field: 3px;
	--radius-box: 4px;
	--elev-1: 0 0 0 1px #dcdccb;
	--elev-2: 0 8px 20px -10px rgba(22, 24, 15, 0.2);
	--glow: 0 0 0 1px rgba(179, 118, 10, 0.2), 0 0 14px -4px rgba(179, 118, 10, 0.3);
}
[data-theme='terminal-light'] body,
[data-theme='terminal-light'] .input,
[data-theme='terminal-light'] .textarea,
[data-theme='terminal-light'] .btn,
[data-theme='terminal-light'] .badge,
[data-theme='terminal-light'] .label,
[data-theme='terminal-light'] .heluca-display {
	font-family: var(--font-mono);
	background: var(--bg);
	color: var(--t-text);
}
[data-theme='terminal-light'] .heluca-scanlines {
	background-image: repeating-linear-gradient(
		0deg,
		rgba(22, 24, 15, 0.03) 0px,
		rgba(22, 24, 15, 0.03) 1px,
		transparent 1px,
		transparent 3px
	);
}

/* ── Business (dark) — cool near-black dashboard, dense, mono values ──
 * Night counterpart to Business. Cool near-black neutrals (not the warm
 * torch-black of Hecate's dark), amber for action, blue for data, every
 * numeric value in mono, tight radii. */
[data-theme='business-dark'] {
	color-scheme: dark;
	--bg: #0f1315;
	--surface-card: #171c20;
	--t-base: #0f1315;
	--t-base-200: #0a0d0f;
	--t-surface: #171c20;
	--t-surface-raised: #1e252b;
	--t-text: #e8ecef;
	--t-text-muted: #9aa5ad;
	--t-text-faint: #68727a;
	--t-hairline: rgba(255, 255, 255, 0.08);
	--t-divider: rgba(255, 255, 255, 0.11);

	--color-base-100: #0f1315;
	--color-base-200: #0a0d0f;
	--color-base-300: #1e252b;
	--color-base-content: #e8ecef;
	--color-primary: #ffa415; /* amber = action */
	--color-primary-content: #1a1206;
	--color-secondary: #4b96ff; /* blue = data */
	--color-secondary-content: #04131f;
	--color-accent: #58c0ff;
	--color-accent-content: #04131f;
	--color-neutral: #1e252b;
	--color-neutral-content: #e8ecef;
	--color-info: #22d3ee;
	--color-success: #34d399;
	--color-warning: #d4c81a;
	--color-error: #ff4d67;
	--color-info-content: #04131f;
	--color-success-content: #04140d;
	--color-warning-content: #1a1206;
	--color-error-content: #1a0509;

	/* Tight rhythm: smaller field radius than the core system. */
	--radius-field: 8px;
	--radius-box: 10px;
	--elev-1: 0 0 0 1px rgba(255, 255, 255, 0.08);
	--elev-2: 0 18px 40px -24px rgba(0, 0, 0, 0.7);
}
[data-theme='business-dark'] body {
	font-family: var(--font-sans);
	background: var(--bg);
	color: var(--t-text);
}
[data-theme='business-dark'] .heluca-display {
	font-family: var(--font-display);
}
/* Every numeric value is mono in Business. */
[data-theme='business-dark'] .stat-value,
[data-theme='business-dark'] .font-num {
	font-family: var(--font-mono);
}
