/*
 * shared/scaling.css — hand-maintained (NOT synced by sync-web-tokens.py).
 * AB#4427 Parts 3+4 (space-editing UI compaction + uniform scaling).
 *
 * One canonical `--ui-scale` + a uniform size/radius/text/tooltip token
 * vocabulary, built on top of the already-shared `design-tokens.css`
 * (colors / --mdui-shape-corner-* / --fb-spacing-* / type scale). Every
 * space-editing webview page imports this AFTER design-tokens.css and
 * replaces its own bespoke `--px` scaling block with these tokens, so
 * corner radii, text sizes, control heights, and tooltip sizes are
 * identical across every surface (toolbar, view controls, context menu,
 * more panel).
 *
 * ---- --ui-scale is now PUSHED by Unity, not reconstructed from vmin ----
 * AB#4427 scale refactor: the per-page `vmin` reconstruction of the
 * Unity-side scale factor (this file's previous `clamp(0.85, Nvmin, 1.4)`
 * formulas, one constant per surface's own reference height) was fragile
 * and, worse, was derived from Screen.height WITHOUT accounting for
 * devicePixelRatio — on hi-DPI/retina displays Unity's RectTransform sizing
 * clamped to 1.4 while the CSS vmin reconstruction did too, so the bug was
 * masked rather than avoided; the two just happened to agree on the wrong
 * (too-large) number.
 *
 * Unity now computes ONE DPI-correct scale —
 *   uiScale = clamp((Screen.height / devicePixelRatio) / 1080, 0.85, 1.4)
 * (see `UIWindowBaseFactory.ComputeUiScale`) — and both sizes each webview's
 * RectTransform AND posts it verbatim to the page as a `SetUiScale` message.
 * Each page's inline script sets `--ui-scale` directly from that payload:
 *   case 'SetUiScale': document.documentElement.style.setProperty('--ui-scale', parsedMessage.payload); break;
 * so the default below is just a same-tab/pre-bridge fallback (e.g. opening
 * this file directly in a browser tab with no Unity host) — it does NOT try
 * to reconstruct the Unity scale from this page's own viewport.
 *
 * XR pages keep a fixed `--ui-scale: 1` (world-space, no viewport-relative
 * concept) and are NOT part of this push. The WebGL parent template
 * (`Assets/WebGLTemplates/HaloclineWebGL/index.html`) is not a Vuplex webview
 * either, so nothing pushes to it — it mirrors the same clamp from its own
 * viewport in a small inline SCRIPT. That has to be JavaScript: `--ui-scale` is
 * unitless, and the CSS form needs length/length division
 * (`calc(100vh / 1080px)`), which only Chromium implements — in Firefox it is
 * invalid at computed-value time, and since the property is still *declared*
 * the `var(--ui-scale, 1)` fallbacks do NOT rescue it, so every dependent
 * declaration dies. Never reintroduce that expression.
 */
:root {
    --ui-scale: 1;

    /* ===========================================
       UNIFORM CONTROL VOCABULARY
       Consumed by every space-editing webview page instead of a
       page-local --px / --size-* / --radius-* block.
       =========================================== */

    /* Primary control height (toolbar bar, undo/redo, view-controls buttons). */
    --ctl-height: calc(48px * var(--ui-scale));
    /* Menu-style icon button (smaller than the primary controls; 36-40 range). */
    --ctl-height-menu: calc(36px * var(--ui-scale));

    /* Corner radii come straight from the shared design tokens and are
       intentionally NOT multiplied by --ui-scale — MD3 corner radii stay
       fixed regardless of viewport. */
    --ctl-radius: var(--mdui-shape-corner-medium);       /* 12 */
    --ctl-radius-small: var(--mdui-shape-corner-small);  /* 8 */

    --icon-size: calc(24px * var(--ui-scale));

    /* Text — Label/Large (14/20) is the default control label size. */
    --text-label: calc(14px * var(--ui-scale));
    --text-label-line-height: calc(20px * var(--ui-scale));
    --text-small: calc(12px * var(--ui-scale));

    /* Gaps/padding, sourced from the shared --fb-spacing-* scale
       (quarter=6px, sixth=4px, twelfth=2px, half=12px at the default 16px
       root font-size) and scaled uniformly with the rest of the controls. */
    --ui-gap: calc(var(--fb-spacing-quarter) * var(--ui-scale));        /* 6px */
    --ui-gap-small: calc(var(--fb-spacing-sixth) * var(--ui-scale));    /* 4px */
    --ui-gap-tight: calc(var(--fb-spacing-twelfth) * var(--ui-scale));  /* 2px */
    --ui-padding: calc(var(--fb-spacing-half) * var(--ui-scale));       /* 12px */

    /* Tooltip tokens — unified across all surfaces. Consumed directly by
       shared/tooltip-render.js (the one tooltip box definition, rendered
       either in-page on XR/editor/standalone or in the WebGL parent
       template above all iframes — see AB#4427 Parts 3+4, Task P34.6). The
       WebGL template (`Assets/WebGLTemplates/HaloclineWebGL/index.html`)
       imports this file too so the tokens resolve in that render path. */
    --tooltip-padding-v: calc(var(--fb-spacing-twelfth) * var(--ui-scale)); /* 2px */
    --tooltip-padding-h: calc(var(--fb-spacing-quarter) * var(--ui-scale)); /* 6px */
    --tooltip-radius: var(--mdui-shape-corner-small);                       /* 8 */
    --tooltip-text: calc(12px * var(--ui-scale));
    --tooltip-line-height: calc(16px * var(--ui-scale));
    --tooltip-letter-spacing: calc(0.5px * var(--ui-scale));
    /* Anchor→tooltip gap re-uses --ui-gap; the viewport clamp margin
       re-uses --tooltip-offset — both already the exact px values the
       tooltip previously hardcoded (6px/4px @ scale 1). */
    --tooltip-offset: calc(var(--fb-spacing-sixth) * var(--ui-scale));      /* 4px */
}
