/* Custom properties more than one served document needs, defined once.
 *
 * The Studio document and the Grid3D popup viewer each used to define
 * `--ui-density-scale` and `--ui-cursor-readout-bottom` on their own --
 * studio/styles/theme-polish.css on `:root` and
 * grid3d/grid3d-viewer.css on `html.grid3d-popup-shell` (the same
 * element, higher specificity) -- with identical values kept in step by hand.
 * This file is now the source of truth for both.
 *
 * The Studio document inlines it (bluprint/server/studio/build.py inlines every
 * Studio stylesheet); the Grid3D popup viewer links it as
 * /assets/shared/tokens.css. Served with the extension-derived MIME like
 * every other shared asset.
 *
 * Not the page palettes. `--bg`, `--text`, `--muted`, `--line`,
 * `--line-strong`, `--mint`, `--blue` and `--amber` are defined by
 * landing.css and asset-library.css with DIFFERENT value sets (landing
 * #010307 / library #070b0f); their `--mono` is the shared `--font-mono`,
 * the one typeface like every other text. Collapsing them onto one palette
 * re-skins a page, which
 * is a design decision and not a refactor -- see frontend/README.md.
 */

/* The product's one typeface (OFL-1.1; resources/assets/fonts/pretendard/README.md).
   The variable font covers every weight from 45 to 920; the file name carries
   its content hash, so the server caches it as immutable. Two faces of one
   family: the whole font (2 MB, Hangul and CJK in it) and its Latin cut (0.2 MB:
   Latin, Greek, numerals, punctuation, arrows and symbols). A browser picks the
   face declared last whose range holds a character, so a page in English loads
   the Latin cut alone and the whole font only once a character outside it shows.
   The whole font's range is what it holds beyond the cut (its cmap less the
   cut's): a character neither has (the caret U+25BE) goes straight to the system
   font, as it did, instead of fetching 2 MB to find it missing. */
@font-face {
  font-family: 'Pretendard';
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
  src: url('/assets/fonts/pretendard/PretendardVariable.9599f12f.woff2') format('woff2-variations'),
       url('/assets/fonts/pretendard/PretendardVariable.9599f12f.woff2') format('woff2');
  unicode-range: U+0250-0258, U+025A-02AF, U+0400-052F, U+0E3F, U+1D43-1DFF, U+1F00-1FFE, U+20DB-20F0, U+2423,
    U+27EF-27FA, U+2985-2986, U+2B06-2B1C, U+2C7C-2C7F, U+2DFF-2E18, U+3000-318D, U+321C, U+3380-33DD, U+A69F,
    U+A7FF, U+A92E, U+AC00-D7A3, U+E000-E164, U+EE01-EE05, U+F000-F057, U+F6C3, U+FE20-FE2D, U+FF01-FF60,
    U+FFA1-FFE6, U+1F10B-1F189, U+1F850-1F852, U+F0000-F0002;
}
@font-face {
  font-family: 'Pretendard';
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
  src: url('/assets/fonts/pretendard/PretendardVariable-Latin.afea8880.woff2') format('woff2-variations'),
       url('/assets/fonts/pretendard/PretendardVariable-Latin.afea8880.woff2') format('woff2');
  unicode-range: U+0000-024F, U+0259, U+02B0-03FF, U+1E00-1EFF, U+2000-23FF, U+2460-24FF, U+2500-257F,
    U+25A0-27BF, U+FB00-FB06, U+FEFF, U+FFFD;
}

:root {
  /* Work status colours are shared by every planning and setup surface. */
  --status-not-started: #64748b;
  --status-in-progress: #e7c276;
  --status-complete: #92cfb6;
  --status-running: #7dd3fc;
  --status-error: #f87171;

  /* Global UI density: 100% browser zoom matches the prior ~80% zoom chrome.
   * bluprint/server/studio/build.py::_UI_DENSITY_SCALE emits the same 0.8 into the
   * Studio's Information.json-derived :root block. */
  --ui-density-scale: 0.8;

  /* Canvas HUD readout stack (UI chrome, not world coords). */
  --ui-cursor-readout-bottom: calc(80px * var(--ui-density-scale));

  /* Stacking scale for fixed-position layers, lowest to highest. A new modal,
   * popover or overlay takes the tier it belongs to (plus a small offset when
   * it must sit above a sibling in that tier) instead of guessing a number.
   * Values match the literals they replaced, so the order is unchanged. */
  --z-panel: 400;         /* floating Studio panels over the canvas (Flight adjustments) */
  --z-pane-modal: 5600;   /* dialogs scoped to a right-panel pane (Bulk +) */
  --z-popover: 10040;     /* Gantt drag ghost, tooltips, context menu, constraint dialog */
  --z-menu: 12000;        /* page context menus, the sim time tooltip, KPI compare */
  --z-workspace: 100000;  /* full-screen workspace overlays, the scenario gate and their modals */

  /* Type: one scale for every page (the Studio, the setup pages in its frame, the landing and the
   * standalone pages), density-scaled like the rest of the chrome. Text never goes below --fs-2xs;
   * a new rule takes a step, never a literal px. */
  --fs-2xs: calc(11px * var(--ui-density-scale));   /* badges, axis ticks, counters */
  --fs-xs: calc(12px * var(--ui-density-scale));    /* secondary labels, table meta */
  --fs-sm: calc(13px * var(--ui-density-scale));    /* buttons, inputs, table cells */
  --fs-md: calc(14px * var(--ui-density-scale));    /* body, menu rows */
  --fs-lg: calc(16px * var(--ui-density-scale));    /* section titles */
  --fs-xl: calc(20px * var(--ui-density-scale));    /* page and dialog titles */
  --lh-tight: 1.25;
  --lh-normal: 1.45;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  /* One typeface: Pretendard (resources/assets/fonts/pretendard, the @font-face above).
     The mono token names the same face. */
  --font-sans: 'Pretendard', sans-serif;
  --font-mono: 'Pretendard', sans-serif;

  /* Icons: Lucide only (frontend/shared/ui-core.js icon()), stroke 2, sized by step. */
  --icon-sm: calc(14px * var(--ui-density-scale));
  --icon-md: calc(16px * var(--ui-density-scale));
  --icon-lg: calc(20px * var(--ui-density-scale));
}

/* A finger is the primary pointer: the 80% chrome that suits a mouse leaves
 * 21px controls and 7px handles, so the density goes back to 1:1 and the
 * controls that scale with it become tappable. The server-emitted px values in
 * bluprint/server/studio/build.py do not follow (they are literals); the
 * [data-input-mode="touch"] rules in the page sheets cover those. */
@media (pointer: coarse) {
  :root {
    --ui-density-scale: 1;
  }
}
