/* Shared by the rasterization demos, which sit in iframes inside the article or stand alone. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #111111;
  --muted: #555555;
  --rule: #d6d6d6;
  --grid: #e3e4e6;
  --dot: #b7b9bd;
  --line: #111111;
  --accent: #1b3fb5;
  --fragment: #9fb4f2;
  --empty-diamond: #8a8d93;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1c1f;
    --ink: #e8eaed;
    --muted: #a9afb8;
    --rule: #3a3d42;
    --grid: #303337;
    --dot: #5d6168;
    --line: #f4f5f6;
    --accent: #8fb2ff;
    --fragment: #35508f;
    --empty-diamond: #8d929a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1c1f;
  --ink: #e8eaed;
  --muted: #a9afb8;
  --rule: #3a3d42;
  --grid: #303337;
  --dot: #5d6168;
  --line: #f4f5f6;
  --accent: #8fb2ff;
  --fragment: #35508f;
  --empty-diamond: #8d929a;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 var(--sans);
}

.demo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bar sub { font-size: 0.75em; }
.vertex { display: inline-flex; align-items: center; gap: 6px; }
.vertex input[type="color"] { width: 22px; height: 22px; padding: 0; border: 1px solid var(--rule); background: none; cursor: pointer; }
.spacer { margin-left: auto; }

.stage { position: relative; flex: 1; min-height: 0; }

.stage canvas {
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
  transform: translateX(-50%);
  outline-offset: 2px;
  cursor: default;
  touch-action: pan-x pan-y;
  user-select: none;
}

.stage canvas:focus-visible { outline: 2px solid var(--accent); }
.stage canvas.can-grab { cursor: grab; }
.stage canvas.grabbing { cursor: grabbing; }

.readout {
  min-height: 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.hint { color: var(--muted); font-size: 12px; }

.modes { display: inline-flex; }

.modes button {
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  background: none;
  color: var(--ink);
  font: 12px var(--mono);
  cursor: pointer;
}

.modes button + button { border-left: 0; }
.modes button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }

@media (pointer: coarse) {
  .modes button { min-height: 44px; }
  .vertex input[type="color"] { width: 44px; height: 44px; }
}
