﻿/* Right column: run header, pipeline stepper, printer row, stage views,
   paper preview, error panel */

#right {
  background: var(--bg);
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
  container: right / inline-size;   /* named container so the header can adapt to its width */
}
.right-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.right-head .chip { min-width: 0; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; }
/* "Processing…" note shown next to Run while a render is in flight (Run is disabled then) */
.run-busy { flex: none; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.run-busy::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 5px;
  vertical-align: -1px; border: 1.5px solid var(--faint); border-top-color: var(--accent);
  border-radius: 50%; animation: run-spin .7s linear infinite; }
@keyframes run-spin { to { transform: rotate(360deg); } }
.layout-btns { margin-left: auto; flex: none; display: flex; gap: 2px; }
.lay-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 550; color: var(--muted);
  white-space: nowrap;
}
.lay-btn:hover { background: var(--sel); color: var(--ink); }
.lay-btn.toggled { background: var(--sel); color: var(--ink); }
/* narrow results pane: drop the layout-button labels (Templates/Test data/Assistant) to
   icons only, so the three toggles + status chip still fit. Container query on #right. */
@container right (max-width: 340px) {
  .lay-btn span { display: none; }
  .lay-btn { padding: 3px 6px; }
}

#pipeErr {
  flex: none; padding: 5px 14px;
  font-size: 11.5px; font-weight: 550; color: var(--danger);
  background: var(--danger-soft);
  border-bottom: 1px solid var(--border);
}
#right.stale #pipeErr { opacity: .5; }

#staleNote {
  flex: none; padding: 6px 12px;
  font-size: 11.5px; color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
  border-bottom: 1px solid var(--border);
}
#right.stale .stage-body { opacity: .45; }

/* pipeline stepper: emphasized flow between stages */
/* stage stepper — INLINE in the action row (between Run and the printer): a compact
   horizontal "● Compile › ● Format › ● Print", each a clickable tab. */
.pipe { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.pnode {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 7px; border-radius: 6px;
  position: relative;
  color: var(--muted); font-size: 11px; font-weight: 550; white-space: nowrap;
}
.pnode:hover { color: var(--ink); background: var(--sel); }
.pnode.on { color: var(--ink); }
.pnode.on .pdot { box-shadow: 0 0 0 2px var(--accent-soft); }
.pnode .pdot {
  position: relative; z-index: 1;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint); flex: none;
}
.pnode.ok .pdot { background: var(--accent); }
.pnode.err .pdot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.pnode.err { color: var(--danger); }
.pnode.skip .pdot { background: transparent; border: 1.5px solid var(--faint); }
/* a modest "›" between stages */
.pnode + .pnode::before {
  content: "›"; color: var(--faint); font-size: 12px; line-height: 1;
  margin-right: 2px;
}
.right-sub {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
/* Preview = the results pane's primary action: filled accent, prominent, always highlighted.
   It does NOT dim with the stale output below it — it's the thing you press to refresh. */
.run-primary {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 7px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font-weight: 600; font-size: 12px;
  white-space: nowrap; cursor: pointer;
}
[data-theme="dark"] .run-primary { color: #0c1f14; }
.run-primary .run-ic { flex: none; color: currentColor; }
.run-primary:hover { filter: brightness(1.06); }
.run-primary:disabled { opacity: .5; cursor: default; filter: none; }
/* when results are stale/absent, dim EVERYTHING below the Preview button (stepper, any pipe
   error, and the output body) — so the bright Preview button stands out as the next step.
   The button itself and the printer row stay full-strength. */
#right.stale .pipe,
#right.stale #pipeErr,
#right.stale .stage-body { opacity: .45; transition: opacity .15s; }
.right-sub select {
  font: inherit; font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--surface); color: var(--ink);
  max-width: 230px;
}
.dev-lbl {
  flex: none;
  font-size: 10px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint);
}
/* printer chooser pinned to the RIGHT edge — "<name> ▾". Styled like the engine select in the
   editor header: subtle, unobtrusive, hover-lit, with the SAME SVG caret. */
.printer-pick {
  margin-left: auto; flex: 0 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 7px;
}
.printer-pick #printerDD { min-width: 0; }
.printer-pick .dd-btn {
  border: 1px solid transparent; background: none; border-radius: 6px;
  padding: 2px 18px 2px 7px; font-size: 11px; font-weight: 550; color: var(--muted);
  max-width: 100%; min-width: 0;
  /* identical caret + placement to .engine-sel */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath d='M1 2.5 4 5.5 7 2.5' stroke='%23888' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 5px center;
}
.printer-pick .dd-btn:hover { background-color: var(--sel); color: var(--ink); }
/* hide the dropdown's built-in text caret — the SVG one above replaces it */
.printer-pick .dd-arr { display: none; }
/* the picker sits at the right edge, so its popup must open RIGHT-aligned (grow leftward) —
   else the 230px+ list overflows past the screen's right border. */
.printer-pick .dd-pop { left: auto; right: 0; }

.stage-body { flex: 1; overflow: auto; min-height: 0; }
.stage-code {
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  padding: 14px 16px;
  white-space: pre;
  color: var(--ink);
}
.stage-note {
  padding: 8px 16px 0; color: var(--faint); font-size: 11px; font-family: var(--mono);
}

/* zoom control for the rendered document */
.zoom-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 0;
  font-size: 11px; color: var(--muted);
}
.zoom-row input[type="range"] { width: 130px; accent-color: var(--accent); }
.zoom-val { font-family: var(--mono); font-size: 10.5px; min-width: 36px; }
.zoom-reset {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 7px; border-radius: 6px;
  border: 1px solid var(--border-strong); color: var(--muted);
}
.zoom-reset:hover { border-color: var(--faint); color: var(--ink); }

/* paper */
/* counter the workspace interface zoom so the print-form preview depends only on
   its own zoom slider (root zoom × --preview-unscale = 1 for this subtree) */
.paper-wrap { padding: 26px 0 40px; display: flex; flex-direction: column; align-items: center; gap: 22px; transform-origin: top center; zoom: var(--preview-unscale, 1); }
/* EPL: labels share one continuous liner roll — no gap between them */
.paper-wrap.epl-roll { gap: 0; }
.paper {
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: var(--shadow);
  font-family: var(--mono);
}
/* a frame around the preview sheet so it reads as a sheet against the backdrop
   — in BOTH themes (subtle in light via --paper-frame, a light outline on the
   dark sheet in dark). Labels are a plain rectangle → a border. The receipt is
   clip-path'd (torn top+bottom) and a clip-path clips a CSS border too, so the
   receipt outline is a separate backing layer (.receipt-frame) wearing the SAME
   torn clip (set inline in right.js), 1px larger, behind the paper; the 1px
   frame colour shows through as the torn outline. */
.receipt-frame {
  display: inline-block;
  background: var(--paper-frame);
  padding: 1px;
  box-shadow: var(--shadow);
}
.receipt-frame .paper.receipt { box-shadow: none; }
/* the torn clip-path (top+bottom teeth, matched phase so adjacent pages line up)
   is generated and set inline in right.js (receiptClip) on both the receipt and
   its frame backing — kept out of CSS so it stays parametric */
.paper.label { border: 1px solid var(--paper-frame); border-radius: 3px; }
/* EPL liner: the silicone-coated backing the labels are stuck to (see a real
   label roll) — a band around each label; the label sits on top */
.liner {
  background: var(--paper-liner);
  box-shadow: var(--shadow);
  display: inline-block;
}
.liner .paper.label { box-shadow: none; }
/* dot-space canvas: 1 dot = 1 px, lines absolutely positioned (same model as
   the printify document viewer; font classes live in fonts.css) */
.pcanvas { position: relative; margin: 0 auto; }
.pl {
  position: absolute; left: 0;
  white-space: pre;
  transform-origin: left top;
}
.pl.b { font-weight: 700; }
.pimg { position: absolute; left: 0; width: 100%; display: flex; justify-content: center; }
.pimg svg { display: block; }
/* device images (qrcode/barcode/image) are 1-bit black-on-transparent PNGs used
   as a MASK; the visible "ink" is the paper-ink colour, so the colour scheme
   governs images exactly like text — transparent pixels stay unprinted (the
   paper shows through). One mechanism for every printed element. */
.pink { background: var(--paper-ink); image-rendering: pixelated; }
/* a clipped <image>: a window onto the native-size masked ink, cropped by overflow */
.pimg-clip { position: absolute; overflow: hidden; }
.pimg-clip .pink { position: absolute; }
.pimg-cap {
  position: absolute; left: 0; width: 100%;
  text-align: center; font-size: 10px; letter-spacing: .25em;
  font-family: var(--mono);
}

/* error panel */
/* error strip at the bottom of the template editor: a tight, accurate message
   with the line references embedded as inline links, and a collapsed stack trace */
#errPanel {
  flex: none;
  max-height: 42%;
  overflow: auto;
  border-top: 2px solid var(--danger);
  background: var(--surface);
  padding: 9px 12px;
  /* the message, the suggestion and the stack trace are meant to be copied —
     keep the whole panel freely selectable */
  user-select: text;
  -webkit-user-select: text;
}
#errPanel .e-msg { font-weight: 600; font-size: 12.5px; line-height: 1.5; }
/* inline clickable line references embedded right in the message */
.e-jump {
  background: none; border: 0; padding: 0 1px; font: inherit; font-size: 11.5px; font-weight: 500;
  color: var(--accent-ink); text-decoration: underline dotted; cursor: pointer; white-space: nowrap;
}
.e-jump:hover { text-decoration-style: solid; }
#errPanel .e-hint { margin-top: 4px; font-size: 11.5px; color: var(--muted); }
/* the full exception chain + stack traces, collapsed by default */
.e-trace { margin-top: 8px; }
.e-trace summary { cursor: pointer; font-size: 11px; color: var(--muted); user-select: none; }
.e-trace summary:hover { color: var(--ink); }
.e-trace pre {
  margin-top: 6px;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.55;
  color: var(--muted);
  white-space: pre-wrap;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
}

/* line of the compiled markup a format error points at - red, full width */
.mark-line { background: rgba(229, 72, 77, 0.22); display: inline-block; min-width: 100%; border-radius: 3px; }

/* <nodoc/> "nothing to print" — a calm, centered note (not an error): the run
   succeeded, the template just produces no print */
.no-print-note {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px 28px; text-align: center;
}
.no-print-note .np-title { font-size: 15px; font-weight: 650; color: var(--muted); }
.no-print-note .np-sub { font-size: 12px; color: var(--faint); max-width: 320px; line-height: 1.5; }
.no-print-note code { font-family: var(--mono); font-size: 11.5px; }


/* line numbers in the Compile/Format stage views */
.stage-code.numbered { counter-reset: cl; }
.stage-code.numbered .cl { counter-increment: cl; }
.stage-code.numbered .cl::before { content: counter(cl); display: inline-block; width: 3.5ch; margin-right: 12px; text-align: right; color: var(--faint); user-select: none; }

/* source-linked lines in the Compile view */
.stage-code.numbered .cl[data-src] { cursor: pointer; }
.stage-code.numbered .cl[data-src]:hover { background: rgba(88, 134, 255, 0.08); }
.stage-code.numbered .cl[data-src]::before { color: #5886ff; }

/* actionable error suggestion — more prominent than the stack trace. It lives
   in an error panel, so it's danger-toned (red), not the app's green accent —
   a green "tip" box in a failure context reads as success and is confusing. */
.e-suggest {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 8px 0; padding: 8px 10px; border-radius: 7px;
  background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger);
  font-size: 12.5px; font-weight: 550;
}
.e-suggest .e-suggest-ic { flex: none; margin-top: 1px; opacity: .9; }
.e-suggest span { user-select: text; -webkit-user-select: text; }
/* the global ::selection is the green accent-soft — the same color as several
   panel backgrounds, which makes a selection invisible. Give the error panel
   its own contrasting selection highlight so selected text actually shows. */
#errPanel ::selection { background: rgba(196, 58, 48, 0.28); }
#errPanel ::-moz-selection { background: rgba(196, 58, 48, 0.28); }
