/*
 * Vectura Studio — skin/tokens.css
 *
 * Mode-independent structural tokens shared across every skin (classic-*, lark, meridian-*).
 * Per-skin palette files (./classic-dark.css, ./meridian-dark.css, etc.) override --ui-*
 * palette tokens; this file provides the layout / spacing / typography scale.
 *
 * Sourced verbatim from docs/design/themes-mockup.html :root block.
 *
 * Skin-swap transition suppression:
 *   App.applyTheme() sets data-skin-swapping="true" for ~60 ms while the active <link>
 *   stylesheet swaps. The rule below disables transitions during that window so users
 *   never see a half-styled flash mid-swap.
 */

:root {
  /* TUX-032: on-screen keyboard height; written by src/ui/keyboard-inset.js, 0 unless an editable has focus. */
  --kb-inset: 0px;
  /* TUX-037: safe-area + toast tokens (Playwright reports env() as 0; tests override the --tux-safe-* tokens). */
  --tux-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tux-safe-left: env(safe-area-inset-left, 0px);
  --tux-safe-right: env(safe-area-inset-right, 0px);
  --tux-toast-gap: 12px;
  /* Default color-scheme — overwritten by App.applyTheme via the active skin's
   * manifest.colorScheme. The default lets pre-JS form-control rendering use a
   * dark UA appearance (matches the meridian-dark default skin). */
  color-scheme: dark;

  /* Layout / pane widths. */
  --pane-left-width: 290px;
  --pane-right-width: 258px;
  --pane-collapsed-width: 56px;
  --bottom-pane-height: 180px;
  --row-height: 30px;

  /* Layers-panel accent (skin-agnostic affordance color — drag-drop hints,
   * source-mask outlines, active filter buttons). Used only by `.lvl-*`
   * selectors in components.css; not part of the per-skin --ui-* palette. */
  --lvl-cyan: #67e8f9;
  --lvl-cyan45: rgba(103, 232, 249, 0.45);
  --lvl-b2: #2d2d30;

  --font-ui: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-size-base: 12px;
  --font-size-sm: 11px;
  --font-size-xs: 10px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;

  /* Motion defaults; per-skin manifests overwrite these via App.applyTheme(). */
  --motion-slider-pulse-dur: 550ms;
  --motion-slider-pulse-ease: ease-out;
  --motion-slider-pulse-peak: 0.36;
  --motion-thumb-release-dur: 350ms;
  --motion-thumb-release-ease: ease-out;
  --motion-btn-fade-dur: 300ms;
  --motion-btn-fade-ease: ease-out;
  --motion-btn-fade-dip: 0.42;
  --motion-dial-wave-dur: 520ms;
  --motion-dial-wave-ease: cubic-bezier(0.23, 1, 0.32, 1);
  --motion-dial-wave-peak: 0.63;
  --motion-dial-wave-max-r: 24;
  --motion-panel-slide-dur: 220ms;
  --motion-panel-slide-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-modal-enter-dur: 220ms;
  --motion-toast-in-dur: 260ms;
  --motion-toast-out-dur: 200ms;
  /* Contextual task bar: the dropdown carets pivot through 180° when the bar
     crosses the midline and its menus swap between opening down and up. Eased
     so the turn settles rather than snapping. */
  --motion-ctxbar-caret-pivot-dur: 180ms;
  --motion-ctxbar-caret-pivot-ease: cubic-bezier(0.22, 1, 0.36, 1);

  /*
   * Foreground-on-accent tokens (CSS-5).
   *
   * Semantic colors for text/icons rendered ON TOP of an accent/danger/
   * warning background. Default to #fff because every shipped skin uses
   * saturated accents dark enough for white to clear WCAG AA contrast.
   * Per-skin palette files may override these where contrast demands a
   * darker on-color (see classic-* overrides for .seg-opt.active).
   */
  --ui-on-accent: #fff;
  --ui-on-danger: #fff;
  --ui-on-warning: #fff;
  /* Accent / danger as TEXT on a panel (links, small labels). Defaults to the fill color; a skin whose fill
     misses 4.5:1 as text on its panels overrides these (WCAG 1.4.3). */
  --ui-accent-text: var(--ui-accent);
  --ui-danger-text: var(--ui-danger);

  /* === SG: smart-guide accent (Tools Parity, Lane A) ===
   * Magenta family for object-to-object alignment guides, semantic labels,
   * and hover highlight of unselected geometry. Read by the canvas renderer
   * (drawGuides / hover highlight) via getThemeToken('--render-smart-guide').
   * Skin-agnostic: magenta clears both light and dark canvases. */
  --render-smart-guide: #e6007e;
  --render-smart-guide-label: #e6007e;
  --render-smart-guide-label-text: #ffffff;
  /* === /SG === */

  /* Corner-rounding fillet preview at max radius (the "can't
   * go further" cue). Skin-agnostic: red reads as a limit warning on both
   * light and dark canvases, so it is not overridden per-skin. */
  --render-corner-max-radius: #ef4444;
}

[data-skin-swapping="true"] *,
[data-skin-swapping="true"] *::before,
[data-skin-swapping="true"] *::after {
  transition: none !important;
  animation: none !important;
}

/* === ISO: isolation breadcrumb tokens (Phase 2 Lane I — ISO-1/2) === */
:root {
  /*
   * ISO-2 top-edge isolation accent. Deliberately an explicit accent-blue
   * default rather than var(--ui-accent): several skins set --ui-accent to a
   * near-white (#fafafa), which would make the "isolation scope" edge line
   * invisible. Per-skin palette files may override --iso-edge-color where a
   * different isolation hue reads better.
   */
  --iso-edge-color: #2680eb;
  --iso-edge-height: 2px;
  /* ISO-1 breadcrumb strip height. */
  --iso-bc-height: 30px;
}
/* === END ISO tokens === */

/* === TUX-034: touch hold + context menus tokens === */
:root {
  --touch-target-min: 44px;
  --touch-hold-ring-size: 64px;
  --touch-hold-ring-color: var(--ui-accent, #2680eb);
  --touch-hold-ring-fill: var(--ui-accent-2, rgba(38, 128, 235, 0.35));
}
/* === END TUX-034 tokens === */

/* === TUX-004: app viewport height ===
 * 100vh is the LARGE viewport on iOS Safari (URL bar collapsed), so bottom chrome sized from it
 * can sit under the toolbar. --app-vh is the dynamic viewport where supported. Use it for every
 * full-height calc; never write a bare 100vh in the skin (tests/unit/touch-shell-vh.test.js). */
:root { --app-vh: 100vh; /* touch-ok: TUX-004 no-dvh fallback; @supports below redefines it as 100dvh */ }
@supports (height: 100dvh) {
  :root { --app-vh: 100dvh; }
}
/* === END TUX-004 app viewport height === */
/* === TUX-015: all tools drawer stacking === */
:root {
  /* Above the force-open pane (70), #tool-bar (60), slivers and the touch modifier bar (55/54); below .modal-overlay (100).
     TUX-010 folds this into its --z-* scale. */
  --z-tool-drawer: 80;
}
/* === END TUX-015 tokens === */

/* === TUX-041 / TUX-042: touch tokens (lane C1) ===
 * Sizes only. Consumed by the coarse-pointer blocks at the end of components.css.
 * Skin files must not override these. */
:root {
  --touch-target-min: 44px;
  --touch-target-floor: 24px;
  --input-font-touch: 16px;
}
/* === END TUX-041 / TUX-042 tokens === */

/* === TUX-048: toast tokens === */
:root {
  --z-toast: 9000;
  --toast-chrome-gap: 8px;
  --toast-edge: 16px;
}
/* === END TUX-048 toast tokens === */

/* === TUX-005: safe-area tokens ===
 * The ONLY place env(safe-area-inset-*) may appear (tests/unit/touch-safe-area-tokens.test.js).
 * Every consumer reads var(--safe-*). e2e injects these on <html> because Playwright WebKit cannot
 * emulate env(). The sheet/toast contract (TUX-046, TUX-048): use the tokens and cap height at
 * calc(var(--app-vh) - var(--safe-top) - var(--safe-bottom)). */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
/* === END TUX-005 safe-area tokens === */

/* === TUX-043: slider tokens ===
 * Consumed by the "TUX-043: sliders" block at the end of components.css (coarse pointers only).
 * The thumb is 28px; the track stays a 4px (pen: 3px) line drawn inside a 44px input box. */
:root {
  --touch-slider-thumb: 28px;
  --touch-slider-track: 4px;
  --touch-slider-track-pen: 3px;
}
/* === END TUX-043 tokens === */

/* === TUX-026: floating sheet stacking ===
 * The phone Petal Designer sheet sits above the mobile drawer, its backdrop, #touch-modifier-bar and
 * .header-main (z 200-220) and below #modal-overlay (900) and .vectura-modal-backdrop (1000). */
:root {
  --z-floating-sheet: 850;
}
/* === END TUX-026 tokens === */

/* === TUX-008: pane stacking ===
 * Drawer order, bottom to top: pane/sliver 55, tool rail 60 (phone), backdrop 65, open drawer 70. The interim
 * tablet openers live in #app-header and sit above its menubar (300). TUX-010 extends this scale. */
:root {
  --z-pane: 55;
  --z-toolbar: 60;
  --z-backdrop: 65;
  --z-drawer: 70;
  --z-pane-opener: 300; /* inside #app-header, above .top-menubar (260), which spans the header width */
}
/* === END TUX-008 tokens === */

/* === TUX-010: z scale ===
 * Order, bottom to top: canvas < pane/sliver < tool rail < backdrop < open drawer < phone header < modal.
 * --z-pane, --z-toolbar, --z-backdrop and --z-drawer are defined above (TUX-008). The TUX-010/011 block at
 * the end of components.css reads every pane-shell z from this scale.
 * --z-drawer-handle: tablet edge handles. They sit in the header band (inside #app-header, see
 * --z-pane-opener), so a tap on the open drawer's own handle closes it and the other handle swaps drawers.
 * --touch-target-min (44 px) is defined above (TUX-034/041). TUX-010 owns the size of #btn-pane-toggle-*,
 * .mobile-pane-handle and the header drawer buttons; lane C must not resize them. */
:root {
  /* TUX-051: collapsed bottom pane height on coarse pointers (44 px chevron + 1 px pane border; the 6 px resizer above it stays clear of the canvas share grid). */
  --touch-bottom-collapsed-h: 44px;
  --z-canvas: 0;
  --z-drawer-handle: 68;
  --z-phone-header: 75;
  --z-modal: 1000;
}
/* === END TUX-010 tokens === */

/* TUX-045: canvas badge that names active modifier tasks. Top-left of #viewport-container, inside the
 * safe-area insets. The toast host and #notification-area sit top-right, the rail and bar outside. */
:root {
  --touch-mod-badge-top: calc(var(--safe-top, 0px) + 8px);
  --touch-mod-badge-left: calc(var(--safe-left, 0px) + 8px);
}
