/* css/variables.css - The Source of Truth */

/* Self-Hosted Variable Fonts (Zero CDN Latency / Zero Missing-Link Fallbacks) */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/packages/ui/css-vendor/fonts/InterVariable.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/packages/ui/css-vendor/fonts/InterVariable-Italic.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/packages/ui/css-vendor/fonts/JetBrainsMono-Variable.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: italic;
  font-weight: 100 800;
  font-display: swap;
  src: url("/packages/ui/css-vendor/fonts/JetBrainsMono-Variable-Italic.woff2") format("woff2");
}

:root {
  /* Brand Colors */
  --color-primary: #862633; /* The Valley Burgundy (Official) */
  --color-primary-light: #a52a2a; /* Lighter shade for hover */
  --color-primary-dark: #5e1b24; /* Darker shade for active/borders */

  --color-accent: #ffc72c; /* The Valley Gold */
  --color-accent-dark: #d4a017;

  --color-secondary: #6c757d; /* General secondary (gray) */

  /* Functional Colors */
  --color-success: #28a745;
  --color-success-bg: #d4edda;
  --color-success-dark: #1e7e34;
  --color-info: #17a2b8;
  --color-info-bg: #d1ecf1;
  --color-info-dark: #0c5460;
  --color-warning: #ffc107;
  --color-warning-bg: #fff3cd;
  --color-warning-dark: #856404;
  --color-danger: #dc3545;
  --color-danger-bg: #f8d7da;
  --color-danger-dark: #bd2130;

  /* Neutrals */
  --color-bg-app: #f4f6f8; /* Light Gray Background */
  --color-bg-white: #ffffff;
  --color-text-main: #1e293b; /* Crisp Dark Slate for primary text */
  --color-text-light: #64748b; /* Muted Slate for secondary text */
  --color-border: #dee2e6;

  /* Layout (Pattern B3 Standard Motif) */
  --sidebar-width: 58px;
  --sidebar-expanded-width: 252px;
  --sidebar-width-collapsed: 58px;
  --header-height: 58px;
  --container-max-width: 1400px;

  /* Typography — Two-Font Clinical System (Optically Locked x-height) */
  --font-main: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SFMono-Regular", "Consolas", monospace;
  --font-x-adjust: 0.53;

  /* Modular Type Scale (16px Base) */
  --text-xs: 0.75rem;       /* 12px — badges, micro-labels */
  --text-sm: 0.875rem;      /* 14px — metadata, compact controls */
  --text-table: 0.90625rem; /* 14.5px — EHR tables, accordions */
  --text-base: 1rem;        /* 16px — clinical prose, tutorials, stems */
  --text-h4: 1.03125rem;    /* 16.5px — H4 subheadings */
  --text-h3: 1.125rem;      /* 18px — H3 section headings */
  --text-h2: 1.25rem;       /* 20px — H2 major headings */
  --text-h1: 1.4375rem;     /* 23px — H1 titles */
  --leading-prose: 1.65;
  --leading-tight: 1.32;

  /* Spacing & Effects */
  --border-radius: 6px;
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.12);
  --transition-fast: 0.2s ease;
}

/* GLOBAL RESET & TYPOGRAPHY BASELINE */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

:where(html, body) {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* Tabular Numerals Utility for Vitals, Timers, & Lab/MAR Columns */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Optically Size-Locked Monospace Blocks & Technical Code Badges */
pre,
pre code,
kbd,
samp,
.mono-code {
  font-family: var(--font-mono);
  font-size-adjust: var(--font-x-adjust);
}

/* Zero-Specificity Inline `code` Emphasis Chip (prevents raw 13px browser monospace drops) */
:where(:not(pre)) > code:not(.pm-cs-math-chip):not(.cs-code-midword) {
  font-family: inherit;
  font-size: 0.95em;
  font-weight: 600;
  color: var(--color-primary, #862633);
  background-color: rgba(134, 38, 51, 0.075);
  border: 1px solid rgba(134, 38, 51, 0.18);
  padding: 1px 5px;
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Adaptive Inline `code` Chip Inside Colored Callout Alerts */
blockquote.md-alert :not(pre) > code:not(.pm-cs-math-chip):not(.cs-code-midword) {
  color: inherit;
  background-color: rgba(255, 255, 255, 0.65);
  background-color: color-mix(in srgb, currentColor 9%, rgba(255, 255, 255, 0.58));
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-color: color-mix(in srgb, currentColor 24%, transparent);
}

/* Seamless Mid-Word Mnemonic Backticks (e.g., Intercostal `V`ein) */
code.cs-code-midword {
  font-family: inherit;
  font-size: 1em;
  font-weight: 800;
  color: var(--color-primary, #862633);
  background: transparent;
  border: none;
  border-bottom: 2px solid currentColor;
  padding: 0;
  margin: 0;
  border-radius: 0;
}

blockquote.md-alert code.cs-code-midword {
  color: inherit;
}

/* Dark Mode Overrides */
body.dark-mode,
[data-theme="dark"] {
  --color-bg-app: #121212;
  --color-bg-white: #1e1e1e;
  --color-text-main: #e2e8f0;
  --color-text-light: #94a3b8;
  --color-border: #333333;
  
  --color-success-bg: #1e3a24;
  --color-info-bg: #0f3a44;
  --color-warning-bg: #3a2e0a;
  --color-danger-bg: #4a191f;

  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.6);
}

body.dark-mode :where(:not(pre)) > code:not(.pm-cs-math-chip):not(.cs-code-midword),
[data-theme="dark"] :where(:not(pre)) > code:not(.pm-cs-math-chip):not(.cs-code-midword) {
  color: #fda4af;
  background-color: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
}

body.dark-mode blockquote.md-alert :not(pre) > code:not(.pm-cs-math-chip):not(.cs-code-midword),
[data-theme="dark"] blockquote.md-alert :not(pre) > code:not(.pm-cs-math-chip):not(.cs-code-midword) {
  color: inherit;
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}

body.dark-mode code.cs-code-midword,
[data-theme="dark"] code.cs-code-midword {
  color: #fda4af;
}
