/* @elixpo/lixsketch/react — host-agnostic styles for <LixSketchCanvas />.
 * Bundles boxicons (used by toolbar + sidebars). Tokens (--lixsketch-*)
 * are the theming hooks; hosts can override them at any ancestor scope. */

@import 'boxicons/css/boxicons.min.css';

/* Product CSS — toolbars + per-shape sidebars (copied from sketch.elixpo).
 *
 * NOT bundled here:
 *   - canvasStroke.css: ships destructive globals (`* { margin: 0 }`,
 *     `svg { width: 100vw }`) that escape the canvas root and break the
 *     host page. SVGCanvas.jsx styles its own <svg> directly.
 *   - canvasTools.css: hardcodes sketch's dark palette for fixed-position
 *     toolbars (`background: #232329`, etc.). The React Toolbar component
 *     positions / styles itself via Tailwind utility classes, which pick
 *     up the consumer's theme tokens — so we let those drive instead. */
@import './styles/squareSidebar.css';
@import './styles/circleSidebar.css';
@import './styles/arrowSidebar.css';
@import './styles/lineSidebar.css';
@import './styles/paintbrushSidebar.css';
@import './styles/writeText.css';

.lixsketch-canvas-root {
  --lix-icon-filter: brightness(0) invert(1);
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--lixsketch-bg, #15111f);
  color: var(--lixsketch-fg, #f5effb);
  font-family: var(--lixsketch-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  overflow: hidden;
  isolation: isolate;
}

.theme-light .lixsketch-canvas-root {
  --lix-icon-filter: none;
  /* Soft off-white rather than pure white: easier on the eyes. */
  --lixsketch-bg: #fafaf9;
  --lixsketch-fg: #1e1e1e;
}

.theme-light .lixsketch-canvas-root :is(
  .anchor,
  .resize-anchor,
  .resize-handle,
  .rotate-anchor,
  .rotation-anchor,
  .multi-selection-anchor,
  .multi-selection-rotation-anchor
) {
  fill: #ffffff !important;
}

.theme-dark .lixsketch-canvas-root {
  --lix-icon-filter: brightness(0) invert(1);
}

.lixsketch-canvas-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  cursor: default;
}

/* ── Loading overlay ── */

.lixsketch-canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lixsketch-bg, #15111f);
  z-index: 50;
}

.lixsketch-canvas-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(155, 123, 247, 0.25);
  border-top-color: #9b7bf7;
  border-radius: 50%;
  animation: lixsketch-spin 0.7s linear infinite;
}

@keyframes lixsketch-spin {
  to { transform: rotate(360deg); }
}

/* ── Toolbar ── */

.lixsketch-toolbar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: var(--lixsketch-toolbar-bg, rgba(20, 22, 28, 0.95));
  border: 1px solid var(--lixsketch-border, rgba(255, 255, 255, 0.08));
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
}

.lixsketch-toolbar-spacer {
  width: 1px;
  height: 18px;
  background: var(--lixsketch-border, rgba(255, 255, 255, 0.08));
  margin: 0 4px;
}

.lixsketch-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--lixsketch-fg-muted, rgba(230, 232, 236, 0.7));
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s, transform 0.06s;
}

.lixsketch-tool-btn:hover {
  background: var(--lixsketch-hover, rgba(255, 255, 255, 0.06));
  color: var(--lixsketch-fg, #e6e8ec);
}

.lixsketch-tool-btn:active {
  transform: scale(0.94);
}

.lixsketch-tool-btn.is-active {
  background: var(--lixsketch-accent-bg, rgba(155, 123, 247, 0.18));
  color: var(--lixsketch-accent, #b69aff);
}

.lixsketch-tool-btn:focus-visible {
  outline: 2px solid var(--lixsketch-accent, #9b7bf7);
  outline-offset: 1px;
}

.lixsketch-tool-btn--exit {
  width: auto;
  padding: 0 10px 0 8px;
  color: var(--lixsketch-fg-muted, rgba(230, 232, 236, 0.7));
}

.lixsketch-tool-btn-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ── Embedded content adjustments ──
   When sitting inside another app's layout, hosts often scope the canvas
   to a flex container. Make sure children stay inside our root.            */

.lixsketch-canvas-root * {
  box-sizing: border-box;
}

.lixsketch-exit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(20, 22, 28, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(230, 232, 236, 0.85);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.lixsketch-exit-btn:hover {
  background: rgba(155, 123, 247, 0.12);
  border-color: rgba(155, 123, 247, 0.3);
  color: #b69aff;
}
.lixsketch-exit-btn .bx { font-size: 16px; }
