/* Ulti-Care 360 — shared design layer for every portal.
 *
 * Twenty portals each grew their own palette, type scale and elevation, so the product looked like several
 * products: `apps/web` alone carried 46 linear gradients, 9 radial glows, 72 box-shadows, 15 border radii and
 * three font families. The citizen portal was put in order first; this is the layer the rest adopt.
 *
 * It sets brand tokens, a stacking scale, corner radii, a visible focus ring, and removes elevation from cards.
 * It does not restyle layouts - a shared file that reflows twenty screens cannot be verified screen by screen.
 *
 * What was learned building it:
 *   * `:where()` has zero specificity, so the first version did nothing against a portal's own `.card` rule;
 *   * plain selectors still lost to `health-theme.css`, which sets `box-shadow: var(--shadow) !important` and is
 *     injected a second time at runtime, after this sheet;
 *   * so elevation is removed in two places: at the source (`--shadow: none` in health-theme.css) and here, with
 *     `html body` + `!important` for the portals that paint their own card shadow.
 *
 * Load it LAST in each portal's <head>.
 */

:root {
  --uc-navy: #123a4d;
  --uc-navy-deep: #0b2633;
  --uc-teal: #12707c;
  --uc-teal-bright: #1b8b95;
  --uc-amber: #e3a455;
  --uc-mint: #a9c4bc;

  /* Text on a brand-coloured fill. A token rather than a literal because a coloured button needs a readable
     foreground, and that is a design decision - the same one in both themes, since the fill does not change. */
  --uc-on-brand: #ffffff;

  --uc-ink: #0f1d26;
  --uc-body: #4a5a63;
  --uc-line: #dfe6e9;
  --uc-surface: #ffffff;
  --uc-canvas: #f6f9fa;

  --z-dock: 900;
  --z-dock-panel: 950;
  --z-sheet: 980;
  --z-modal: 1000;
  --z-toast: 1100;

  /* A depth scale, not a 3D effect. Depth is reserved for things that genuinely sit above the page - a modal,
     a sheet, a popover - and each step is one shadow. There are no transforms, no parallax and no perspective:
     on a clinical product those read as a demo reel, and they break under `prefers-reduced-motion`, on
     projectors and on the low-end tablets field workers actually carry. Depth here means "this is on top of
     that", nothing more. */
  --uc-elev-1: 0 1px 2px rgba(15, 29, 38, 0.06);
  --uc-elev-2: 0 6px 16px rgba(15, 29, 38, 0.10);
  --uc-elev-3: 0 18px 40px rgba(15, 29, 38, 0.16);

  /* ── the closed vocabulary ──────────────────────────────────────────────────────────────────────────
     Six type sizes, seven spacing steps, three radii, one family. A value that is not on this list does
     not exist, and `tooling/check_design_tokens.py` fails when one is added (with a baseline that may
     fall but never rise).

     Measured before this existed: the twenty portal stylesheets carried **51 distinct font sizes, 319
     hex colours, 38 border radii and 20 font-family declarations**, and the largest portal used a token
     for only 46% of its colour and size values. That is why no two screens quite match - not a lack of
     taste, but the absence of anything to be consistent with. */
  --uc-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --uc-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --uc-text-xs: 12px;    /* chips, table meta, the tagline */
  --uc-text-sm: 13px;    /* table cells, secondary copy */
  --uc-text-md: 14px;    /* body */
  --uc-text-lg: 16px;    /* card titles, section headings */
  --uc-text-xl: 22px;    /* page title */
  --uc-text-2xl: 30px;   /* the one number a screen is about */

  /* A 4px rhythm. Seven steps, not fifteen: 4, 8, 12, 16, 24, 32, 48. */
  --uc-space-1: 4px;
  --uc-space-2: 8px;
  --uc-space-3: 12px;
  --uc-space-4: 16px;
  --uc-space-5: 24px;
  --uc-space-6: 32px;
  --uc-space-7: 48px;

  --uc-radius-sm: 4px;   /* chips, inputs, buttons */
  --uc-radius-md: 6px;   /* cards, panels */
  --uc-radius-lg: 10px;  /* sheets, modals */

  /* Semantic states, one vocabulary. The portals each invented their own greens and reds per file, which
     is how "resolved" in one panel and "resolved" in another ended up two different colours.
     The amber is darker than it looks like it needs to be because it is used as *text on its own tint*
     (`--warning-bg` #fef3c7), not only on white: at #a8641a the donors and doctor warning badges measured
     4.19:1 and failed AA, while on white the same colour read a comfortable 4.66:1. Text has to pass on
     the surface it actually sits on, so the token is set for the tint: 5.47:1 there, 6.09:1 on white. */
  --uc-ok: #1f7a4d;
  --uc-warn: #8f5416;
  --uc-danger: #b3261e;
  --uc-info: var(--uc-teal);
}

/* On dark surfaces the same four states need lifting, or a "danger" reads as body text. */
[data-theme="dark"] {
  --uc-ok: #6ec59a;
  --uc-warn: #e0aa63;
  --uc-danger: #ef8a84;
  --uc-info: var(--uc-teal-bright);
}

[data-theme="dark"] {
  --uc-ink: #e6eef0;
  --uc-body: #a3b3ba;
  --uc-line: #223540;
  --uc-surface: #10222c;
  --uc-canvas: #0b1a21;
}

/* Elevation on every card is what makes a dense dashboard read as a template: if everything floats, nothing is
   in front. Grouping is done by borders and background. The `html body` prefix puts this above any single-class
   selector and `!important` above the theme's own, so it holds whatever order the sheets load in. Modals use
   `.modal`, not `.card`, so a dialog that needs to sit above the page is unaffected. */
html body .card, html body .panel, html body .kpi-card, html body .stat-card,
html body .metric-card, html body .tile {
  box-shadow: none !important;
  border-radius: 8px !important;
}

/* Sixteen-pixel corners everywhere is a house style nobody chose. */
html body .btn, html body button.btn, html body .chip, html body .pill,
html body .badge, html body input, html body select, html body textarea {
  border-radius: 6px !important;
}

/* Headlines tracked loosely at display sizes look unset. */
h1, h2, h3 {
  letter-spacing: -0.01em;
}

/* A visible focus ring on every interactive element, in brand teal. Accessibility that is also a design
   decision: the portals mostly had none, or a browser default that vanished against the surface. */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--uc-teal-bright);
  outline-offset: 2px;
}

main a:hover, .main a:hover, .content a:hover, .page a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
