/* ==========================================================================
   vectorize.html

   Wide: the image and the settings in a column on the left, the two panes
   (original, vector) side by side on the right. Narrow: the image, then the
   panes one above the other, then the settings, and the page scrolls.
   ========================================================================== */

.vz-content { overflow: hidden; }

.vz {
  --vz-side: 318px;
  --vz-ck-a: #ffffff;
  --vz-ck-b: #e9ecef;
  height: 100%;
  display: grid;
  grid-template-columns: var(--vz-side) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "input main" "settings main";
  font-size: 14px;
}
/* The checker stands for a transparent page, and the result is usually dark
   lines: it stays light in the dark theme too, only a little dimmer. */
[data-theme="dark"] .vz { --vz-ck-a: #e4e7ea; --vz-ck-b: #d3d8dd; }

.vz-input, .vz-settings {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 14px 16px;
}
.vz-input { grid-area: input; border-bottom: 1px solid var(--border-color); }
.vz-settings { grid-area: settings; overflow-y: auto; padding-bottom: 22px; }
.vz-main { grid-area: main; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }

.vz-h { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary); margin: 0 0 8px; }
.vz-lead { margin: 0 0 10px; color: var(--text-secondary); line-height: 1.45; }
kbd {
  font-family: var(--font-mono); font-size: 12px;
  padding: 1px 5px; border: 1px solid var(--border-color); border-bottom-width: 2px;
  border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-primary);
}

.vz-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vz-row-fill { flex-wrap: nowrap; }
.vz-row-fill > input { flex: 1 1 auto; min-width: 0; }
.vz-row-center { justify-content: center; }

.vz-url { margin-top: 12px; }
.vz-url label { display: block; margin-bottom: 5px; color: var(--text-secondary); }
.vz-url input {
  font: inherit; height: 34px; padding: 0 9px;
  border: 1px solid var(--input-border); border-radius: var(--radius);
  background: var(--input-bg); color: var(--input-text);
}
.vz-url input:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }
.vz-source { margin: 10px 0 0; color: var(--text-muted); font-size: 13px; overflow-wrap: anywhere; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.vz-btn {
  font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 4px 13px; white-space: nowrap;
  border: 1px solid var(--input-border); border-radius: var(--radius);
  background: var(--bg-primary); color: var(--text-primary); cursor: pointer;
}
.vz-btn:hover:not(:disabled) { border-color: var(--accent-line); }
.vz-btn:focus-visible, .vz-iconbtn:focus-visible, .vz-zoomval:focus-visible, .vz-seg button:focus-visible {
  outline: 2px solid var(--accent-line); outline-offset: 2px;
}
.vz-btn:disabled { opacity: .5; cursor: default; }
.vz-btn-go { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; font-weight: 600; }
.vz-btn-go:hover:not(:disabled) { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); }
.vz-btn-quiet { background: transparent; border-color: var(--border-color); }
.vz-btn-sm { min-height: 30px; padding: 2px 11px; }

/* ── Settings ────────────────────────────────────────────────────────────── */

.vz-settings-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.vz-settings-head .vz-h { margin: 0; }
.vz select {
  font: inherit; height: 30px; padding: 0 6px; max-width: 100%;
  border: 1px solid var(--input-border); border-radius: var(--radius);
  background: var(--input-bg); color: var(--input-text);
}
#vz-preset { min-width: 0; flex: 0 1 190px; }

.vz-group { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
.vz-group legend {
  padding: 0; margin-bottom: 6px; font-weight: 600; color: var(--text-primary);
}
.vz-field { margin: 0 0 10px; }
.vz-field label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.vz-field output { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-secondary); }
.vz-field input[type="range"] { width: 100%; margin: 4px 0 0; }
.vz-hint { margin: 2px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--text-muted); }
.vz-check { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.vz-out-row { gap: 14px; }
.vz-inline { display: inline-flex; align-items: center; gap: 7px; }
.vz input[type="color"] {
  width: 38px; height: 28px; padding: 1px; cursor: pointer;
  border: 1px solid var(--input-border); border-radius: var(--radius); background: var(--input-bg);
}
#vz-reset { margin-top: 16px; }

/* ── The bar over the panes ──────────────────────────────────────────────── */

.vz-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 8px 12px; border-bottom: 1px solid var(--border-color); background: var(--bg-primary);
}
.vz-spacer { flex: 1 1 auto; }
.vz-seg { display: inline-flex; border: 1px solid var(--input-border); border-radius: var(--radius); overflow: hidden; }
.vz-seg button {
  font: inherit; min-height: 30px; padding: 2px 11px; border: 0; cursor: pointer;
  background: transparent; color: var(--text-primary);
}
.vz-seg button + button { border-left: 1px solid var(--input-border); }
.vz-seg button[aria-pressed="true"] { background: var(--accent-fill); color: #fff; }
.vz-zoom { display: inline-flex; align-items: center; gap: 4px; }
.vz-iconbtn, .vz-zoomval {
  font: inherit; min-height: 30px; border: 1px solid var(--border-color); border-radius: var(--radius);
  background: transparent; color: var(--text-primary); cursor: pointer;
}
.vz-iconbtn { width: 30px; font-size: 17px; line-height: 1; }
.vz-zoomval { min-width: 62px; font-family: var(--font-mono); font-size: 12.5px; }
.vz-iconbtn:hover, .vz-zoomval:hover { border-color: var(--accent-line); }

/* ── The panes ───────────────────────────────────────────────────────────── */

.vz-panes {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--border-color); min-height: 0;
}
.vz-pane {
  position: relative; overflow: hidden; min-height: 0;
  background: var(--bg-secondary); touch-action: none; cursor: grab;
}
.vz-pane.vz-grabbing { cursor: grabbing; }
.vz-pane canvas, .vz-pane svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.vz-ck-a { fill: var(--vz-ck-a); }
.vz-ck-b { fill: var(--vz-ck-b); }
.vz-pane-label {
  position: absolute; top: 8px; left: 8px; pointer-events: none;
  padding: 2px 8px; border-radius: var(--radius-sm); font-size: 12.5px;
  background: var(--bg-primary); color: var(--text-secondary); border: 1px solid var(--border-color);
}
.vz-busy { color: var(--accent-text); margin-left: 6px; }
.vz-busy::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 5px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: vz-spin .8s linear infinite;
}
@keyframes vz-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .vz-busy::before { animation: none; } }

.vz-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 24px; text-align: center; background: var(--bg-secondary); color: var(--text-secondary);
}
.vz-empty[hidden] { display: none; }
.vz-empty > svg { color: var(--text-muted); margin-bottom: 6px; }
.vz-empty p { margin: 0 0 6px; max-width: 30em; line-height: 1.5; }
.vz-empty-title { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.vz-empty .vz-row { margin-top: 8px; }

.vz-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px;
  padding: 6px 12px; min-height: 30px; box-sizing: border-box;
  border-top: 1px solid var(--border-color); background: var(--bg-primary); font-size: 13px;
}
.vz-status { color: var(--text-secondary); }
.vz-status.vz-error { color: var(--accent-text); }
.vz-stats { color: var(--text-muted); font-family: var(--font-mono); font-size: 12.5px; }

/* ── Dragging a file over the page ───────────────────────────────────────── */

.vz-dropveil {
  position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center;
  background: var(--overlay-bg); pointer-events: none;
}
.vz-dropveil > div {
  padding: 34px 48px; border: 3px dashed var(--color-kvot-bright); border-radius: 12px;
  background: var(--bg-primary); color: var(--text-primary); font-size: 20px; font-weight: 600;
}
.vz-dragging .vz-dropveil { display: flex; }

/* ── The poster dialog ───────────────────────────────────────────────────── */

.vz-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: min(92vh, 860px);
  max-height: min(92dvh, 860px);
  box-sizing: border-box; padding: 0;
  border: 1px solid var(--border-color); border-radius: 14px;
  background: var(--modal-bg); color: var(--text-primary);
  box-shadow: 0 18px 50px var(--shadow-color);
  font-family: var(--font-sans); font-size: 14px;
  overflow: hidden;
}
.vz-dialog[open] { display: flex; flex-direction: column; }
.vz-dialog::backdrop { background: var(--overlay-bg); }
.vz-dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px 10px 20px; border-bottom: 1px solid var(--border-color);
}
.vz-dialog-head h2 { margin: 0; font-size: 1.2rem; font-weight: 600; }
.vz-dialog-body { padding: 14px 20px 6px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.vz-dialog-body .vz-lead { line-height: 1.5; }
.vz-dialog-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 20px 14px; border-top: 1px solid var(--border-color);
}

.vz-pp { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 18px; align-items: start; margin: 4px 0 12px; }
.vz-pp-view { padding: 10px; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-secondary); }
/* As tall as the poster's shape needs (vectorize.js sets the aspect ratio),
   up to a limit. */
.vz-pp-view svg { display: block; width: 100%; height: auto; max-height: min(46vh, 420px); }
/* The poster is printed on white paper, in either theme. */
.vz-pp-bg { fill: #ffffff; stroke: #9aa3ad; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.vz-pp-seam { stroke: #1a6fd9; stroke-width: 1.3px; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.vz-pp-name {
  font-family: var(--font-sans); font-weight: 600; fill: #1a6fd9;
  paint-order: stroke; stroke: #ffffff; stroke-width: 0.28em; stroke-linejoin: round;
}
.vz-pp-opts { display: grid; gap: 12px; }
.vz-pp-opts label { display: block; margin-bottom: 4px; color: var(--text-secondary); }
.vz-pp-opts input, .vz-pp-opts select {
  font: inherit; width: 100%; box-sizing: border-box; height: 34px; padding: 0 8px;
  border: 1px solid var(--input-border); border-radius: var(--radius);
  background: var(--input-bg); color: var(--input-text);
}
.vz-pp-opts input:focus-visible, .vz-pp-opts select:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }
.vz-pp-size { margin: 2px 0 2px; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.vz-pp-msg { min-height: 1.45em; margin: 8px 0 0; color: var(--text-secondary); }
.vz-pp-note:empty { display: none; }
.vz-pp-note { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--accent-line); background: var(--bg-secondary); }

@media (max-width: 640px) {
  .vz-pp { grid-template-columns: minmax(0, 1fr); }
  .vz-pp-view svg { max-height: min(38vh, 300px); }
  .vz-pp-opts { grid-template-columns: 1fr 1fr; }
}

/* ── Narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 880px) {
  .vz-content { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .vz {
    height: auto; display: grid;
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto;
    grid-template-areas: "input" "main" "settings";
  }
  .vz-input, .vz-settings { border-right: 0; }
  .vz-settings { overflow: visible; border-top: 1px solid var(--border-color); }
  .vz-main { display: block; }
  .vz-panes { grid-template-columns: minmax(0, 1fr); }
  /* Dragging on a pane moves the picture, not the page, so the two panes
     together are kept short enough to leave room above or below them to
     scroll the page by. */
  .vz-pane { height: min(62vw, 34vh); min-height: 190px; }
  .vz-empty { position: relative; grid-row: 1 / span 2; }
  .vz-panes:has(.vz-empty:not([hidden])) .vz-pane { display: none; }
  .vz-check-bar { order: 5; }
}
/* A touch screen has no key to paste with; the Paste button is there. */
@media (pointer: coarse) { .vz-keyhint { display: none; } }

@media (max-width: 520px) {
  .vz-save { width: 100%; }
  .vz-save .vz-btn { flex: 1 1 0; }
}
