/* SvgPlayground design-system tokens.
   Prefix: --svgp-

   This sheet is the source of truth for the numeric colour / space / radius
   scale. svgedit.css @imports it (so tokens exist before JS boots) and aliases
   legacy names onto it where the values already match:

     --svgp-surface      → --svgp-color-surface
     --svgp-accent       → --svgp-color-focus  (interactive blue, not gold)
     --svgp-space-sm/md/lg → --svgp-space-4/8/12
     --svgp-radius       → --svgp-radius-6

   Intentionally not aliased (different values, keep each surface as it is):
     --svgp-text        (#fff) vs --svgp-color-text (#e2e8f0)
     --svgp-text-muted  (#a0aec0 dark chrome / #4a5568 light chrome)
                        vs --svgp-color-muted (#94a3b8, AA 6.4:1 on surface)
     --svgp-space-xs (2px), --svgp-space-xl (20px)
     --svgp-border (0.15) vs --svgp-color-border (0.14)

   --svgp-color-accent is the gold brand accent (badges, current-state chips).
   Chrome interactive colour is --svgp-color-focus / --svgp-color-link (and
   the legacy --svgp-accent alias).

   Light chrome: .svgp-theme-light on <html> (ext-dark-theme) restyles
   .svg_editor. Floating / docked .svgp-panel stays on the dark tokens.

   Custom properties inherit into shadow trees, so tokens work inside
   shadow DOM automatically. Component classes do not; load components.css
   into the shadow root with loadDesignSystem(shadowRoot) from load.js.

   WCAG 2.2 AA notes are inline where a raw palette colour is not used
   as-is for text. */

:root {
  /* Colour — surfaces */
  --svgp-color-surface: #1e1e1e;
  --svgp-color-raised: #262626;
  --svgp-color-sunken: #141414;
  --svgp-color-checker-bg: #161616;
  --svgp-color-checker: #2a2a2a;
  --svgp-color-thumb-bg: #1a1a1a;

  /* Colour — borders
     .14 is decorative only (dividers). Interactive edges use .42,
     which meets the 3:1 non-text contrast minimum on surface. */
  --svgp-color-border: rgba(255, 255, 255, 0.14);
  --svgp-color-border-strong: rgba(255, 255, 255, 0.42);

  /* Colour — overlays / preview tiles (dark-panel) */
  --svgp-color-overlay-subtle: rgba(255, 255, 255, 0.06);
  --svgp-color-overlay: rgba(255, 255, 255, 0.08);
  --svgp-color-overlay-strong: rgba(255, 255, 255, 0.25);
  --svgp-color-preview-tile: rgba(255, 255, 255, 0.92);

  /* Colour — text
     #e2e8f0 on #1e1e1e ≈ 13.3:1
     #94a3b8 on #1e1e1e ≈ 6.4:1  (AA for body and helper text) */
  --svgp-color-text: #e2e8f0;
  --svgp-color-muted: #94a3b8;
  --svgp-color-on-primary: #fff;

  /* Colour — accent (active segmented control, Current badge)
     #f6c27a on #4a3220 ≈ 7.1:1 */
  --svgp-color-accent: #f6c27a;
  --svgp-color-accent-bg: #4a3220;
  --svgp-color-accent-border: #b8742f;

  /* Colour — primary
     #3182ce is the brand blue, but white text on it is only ~4.0:1.
     Filled buttons use the darker solid; links use the lighter focus
     blue so both stay AA on this dark surface. */
  --svgp-color-primary: #3182ce;
  --svgp-color-primary-solid: #1f6fbf; /* white text ≈ 5.3:1 */
  --svgp-color-primary-solid-hover: #1a62aa;
  --svgp-color-focus: #63b3ed;
  --svgp-color-link: #63b3ed; /* on surface ≈ 7.3:1 */

  /* Colour — status
     Both are light enough for 12px+ text on surface / sunken. */
  --svgp-color-success: #68d391;
  --svgp-color-danger: #fc8181;

  /* Spacing scale (numeric, alongside the existing xs/sm/md/lg/xl tokens) */
  --svgp-space-4: 4px;
  --svgp-space-8: 8px;
  --svgp-space-10: 10px;
  --svgp-space-12: 12px;
  --svgp-space-16: 16px;
  --svgp-space-24: 24px;

  /* Radius (numeric, alongside --svgp-radius / -sm / -lg / -xl) */
  --svgp-radius-6: 6px;
  --svgp-radius-10: 10px;

  /* Type sizes (do not redefine --svgp-font or --svgp-font-size) */
  --svgp-font-size-10: 10px;
  --svgp-font-size-11: 11px;
  --svgp-font-size-12: 12px;
  --svgp-font-size-13: 13px;
  --svgp-font-size-14: 14px;
  --svgp-font-size-16: 16px;
  --svgp-line-12: 16px;
  --svgp-line-13: 18px;
  --svgp-line-14: 20px;
  --svgp-line-16: 24px;
  --svgp-weight-regular: 400;
  --svgp-weight-medium: 500;
  --svgp-weight-semibold: 600;

  /* Focus ring width / offset. The existing --svgp-focus-ring token is a
     colour, so width lives on a different name. */
  --svgp-focus-width: 2px;
  --svgp-focus-offset: 2px;

  /* Control height — buttons, chips, icon buttons (WCAG 2.2 AA is 24px) */
  --svgp-control-size: 28px;

  /* Shared shadows */
  --svgp-shadow-focus: 0 0 0 var(--svgp-focus-offset) var(--svgp-color-surface),
    0 0 0 calc(var(--svgp-focus-offset) + var(--svgp-focus-width)) var(--svgp-color-focus);
}

/*
 * Light chrome (ext-dark-theme toggle). Mirrors the legacy light values in
 * svgedit.css so design-system components used in chrome follow the theme.
 * Gold brand accent stays; interactive blue becomes the light-theme link.
 */
.svgp-theme-light .svg_editor {
  --svgp-color-surface: #f4f5f7;
  --svgp-color-raised: #ffffff;
  --svgp-color-sunken: #e2e4e8;
  --svgp-color-border: rgba(0, 0, 0, 0.14);
  --svgp-color-border-strong: rgba(0, 0, 0, 0.42);
  --svgp-color-overlay-subtle: rgba(0, 0, 0, 0.04);
  --svgp-color-overlay: rgba(0, 0, 0, 0.08);
  --svgp-color-overlay-strong: rgba(0, 0, 0, 0.18);
  --svgp-color-text: #1a202c;
  --svgp-color-muted: #4a5568;
  --svgp-color-focus: #3182ce;
  --svgp-color-link: #3182ce;
  --svgp-color-primary: #3182ce;
}

/*
 * Floating / docked panels keep the dark palette in light chrome.
 */
.svgp-theme-light .svgp-panel {
  --svgp-color-surface: #1e1e1e;
  --svgp-color-raised: #262626;
  --svgp-color-sunken: #141414;
  --svgp-color-checker-bg: #161616;
  --svgp-color-checker: #2a2a2a;
  --svgp-color-thumb-bg: #1a1a1a;
  --svgp-color-border: rgba(255, 255, 255, 0.14);
  --svgp-color-border-strong: rgba(255, 255, 255, 0.42);
  --svgp-color-overlay-subtle: rgba(255, 255, 255, 0.06);
  --svgp-color-overlay: rgba(255, 255, 255, 0.08);
  --svgp-color-overlay-strong: rgba(255, 255, 255, 0.25);
  --svgp-color-preview-tile: rgba(255, 255, 255, 0.92);
  --svgp-color-text: #e2e8f0;
  --svgp-color-muted: #94a3b8;
  --svgp-color-focus: #63b3ed;
  --svgp-color-link: #63b3ed;
  --svgp-color-primary: #3182ce;
}
