/* ChemTrust design system — "regulatory instrument panel".
 *
 * Deep-blue brand (Green Trust family: same dark, disciplined character as
 * eudr-x's forest green, hue-shifted to navy for this product): white
 * surfaces that lift off a blue-tinted canvas, a disciplined neutral ramp,
 * and hazard-status colors reserved strictly for regulatory meaning.
 * Legacy variable names (--primary-color, --card-bg, …) are kept as aliases so
 * existing rules keep resolving while the new scale drives the redesign.
 */

:root {
  /* ── Canvas & surfaces ──
     Light mode is LIGHT. It used to paint the navy hero art on the shell body
     in both themes, so "light mode" was really a dark app wearing white cards:
     near-black text on white, on navy, beside a near-black sidebar — contrast
     stacked on contrast. The art is now dark-mode only (dark.css) and light
     mode gets an airy canvas that white cards settle onto rather than fight. */
  --canvas: #eef3f9;
  --canvas-art:
    radial-gradient(1100px 620px at 14% -8%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 62%),
    linear-gradient(158deg, #f1f5fa 0%, #e9eff7 52%, #eef3f9 100%);

  /* Text painted directly on the canvas (page titles, filter labels, the back
     link) rather than inside a card. Follows the canvas, so it must flip with
     it — see dark.css. */
  --canvas-text: #21303f;
  --canvas-text-muted: #55697d;
  --canvas-text-subtle: #7c8ea0;

  --bg: var(--canvas);
  --surface: #ffffff;     /* cards & panels lift off the canvas */
  --surface-2: #f6f9fc;   /* table headers, insets, hover */
  --surface-3: #eef3f8;
  --border: #e0e8f1;
  --border-strong: #c6d3e0;

  /* ── Text ──
     Softened off near-black: #22303f still clears AAA on white (~12.5:1) but
     reads as ink rather than a hard edge. */
  --text: #22303f;
  --text-muted: #5a6d80;
  --text-subtle: #8394a3;
  --text-invert: #f2f6fa;

  /* ── Brand ── */
  --primary: #24486a;
  --primary-hover: #2f5b83;
  --primary-soft: #e7eef6;
  --accent: #5b7488;
  --accent-light: #7b93a6;
  --header-bg: #1a2b3d;
  --header-text: #dce6ef;
  --focus: #4b83a0;

  /* ── Dashboard shell (eudr-x sidebar.css:6-20, navy-mapped per
        spec-shell §16). The sidebar/topbar chrome is deliberately dark in
        BOTH themes — layout.css re-asserts these for body:not(.dark-mode),
        and dark.css never flips them. ── */
  --sidebar-width: clamp(200px, 3.13vw + 160px, 260px);
  --sidebar-collapsed-width: 60px;
  --sidebar-bg: #1a2b3d;
  --sidebar-border: #24384c;
  --sidebar-hover: #24394f;
  --sidebar-active: #2c445c;
  --sidebar-active-border: #9fc0d6;
  --sidebar-text: rgba(220, 230, 239, 0.8);
  --sidebar-text-active: #eaf2f8;
  --topbar-bg: #1a2b3d;

  /* ── Regulatory status signals (hazard = red, attention = amber,
        unknown = cool slate, clear = green).
        Desaturated a step and the tints lifted: these chips sit several to a
        row in a table, and at the old saturation a portfolio screen read as a
        warning light rather than a list. Meaning stays legible; loudness
        drops. ── */
  --confirmed: #b04a3f;      --confirmed-tint: #fbeeec;   --confirmed-edge: #eecdc7;
  --potential: #a1770f;      --potential-tint: #fbf3e0;   --potential-edge: #ecd9ac;
  --indeterminate: #61788d;  --indeterminate-tint: #eff3f8; --indeterminate-edge: #d1dce6;
  --clear: #367a3d;          --clear-tint: #e9f4ea;       --clear-edge: #bcdcbf;
  --neutral-status: #667789; --neutral-tint: #eef2f7;

  /* Legacy semantic aliases */
  --danger: var(--confirmed);
  --warning: var(--potential);
  --ok: var(--clear);

  /* ── Typography — the eudr-x house stack: Nunito (Latin), Source Sans 3
        next for Greek glyph coverage (Nunito has none; chemtrust is
        EL-first), then the system ramp. Self-hosted in fonts.css. ── */
  --font-sans: "Nunito", "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --font-body: var(--font-sans);
  --font-display: var(--font-sans);

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;

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

  /* ── Radii ── */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Fluid radii + house transition (eudr-x operator-react.css:25-34
     verbatim): card chrome scales gently between small laptops and 27"
     monitors, staying proportional to the fluid root font-size below. */
  --radius-fluid: clamp(12px, 0.42vw + 6.6px, 18px);
  --radius-fluid-sm: clamp(8px, 0.21vw + 5.3px, 12px);
  --radius-fluid-xs: clamp(5px, 0.16vw + 3px, 8px);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Elevation ── */
  /* Lighter now that cards sit on a light canvas: on the old navy ground a
     card needed a heavy drop to separate, which on a pale ground turns into
     grime under every panel. */
  --shadow-sm: 0 1px 2px rgba(31, 52, 76, 0.04), 0 1px 3px rgba(31, 52, 76, 0.05);
  --shadow-md: 0 1px 3px rgba(31, 52, 76, 0.05), 0 8px 20px rgba(31, 52, 76, 0.06);
  --shadow-lg: 0 14px 36px rgba(31, 52, 76, 0.11);

  /* Legacy aliases (untouched rules keep working) */
  --bg-color: var(--bg);
  --card-bg: var(--surface);
  --border-color: var(--border);
  --text-color: var(--text);
  --muted-color: var(--text-muted);
  --primary-color: var(--primary);
  --secondary-color: var(--accent);
}

* {
  box-sizing: border-box;
}

/* Fluid root font-size (eudr-x style.css:45-49 verbatim): the whole
   rem-based UI scales 13.74px @1366 → 14.05px @1440 → 16.06px @1920 →
   18px @2560 (ceiling). Mobile ≤768px is excluded on purpose so inputs keep
   the 16px anchor that prevents iOS focus-zoom. */
@media (min-width: 769px) {
  html {
    font-size: clamp(13px, 0.42vw + 8px, 18px);
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--text);
}

a {
  color: var(--primary-hover);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

/* Technical identifiers (CAS, EC, H-codes, request IDs, UUIDs) read as data. */
.ct-mono,
code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.92em;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
