/* Stationery Designer — the suite's pieces, the card at its printed size,
 * and the selected item.
 *
 * The card itself is drawn in the suite's own colours, never the site's:
 * it is what will be printed. The bleed shading, trim line, safe area and
 * snap guides are fixed colours that read on any paper. Everything around
 * the card takes the site's preset.
 */

.product[data-product="stationery-designer"] {
  --sd-line: color-mix(in srgb, var(--text) 14%, transparent);
  --sd-soft: color-mix(in srgb, var(--text) 4%, var(--surface));
  --sd-desk: color-mix(in srgb, var(--text) 9%, var(--surface));
  --sd-focus: #2563eb;
  --sd-bad: #b42318;
  --sd-attention: #b45309;
  --sd-good: #15803d;
}
.product[data-product="stationery-designer"] .tone-bad { color: var(--sd-bad); }
.product[data-product="stationery-designer"] .tone-attention { color: var(--sd-attention); }
.product[data-product="stationery-designer"] .tone-good { color: var(--sd-good); }
.sd-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sd-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sd-h { font-size: 1.05rem; margin: 1.2rem 0 .3rem; }

/* Text drawn on a card: kerning and standard ligatures off, because the PDF
   writes plain glyph advances and the two must break lines identically. */
.sd-type { font-kerning: none; font-variant-ligatures: no-common-ligatures no-discretionary-ligatures; }

/* Tool buttons: a quiet bordered button rather than the site's link-style
   quiet button, because a row of underlined words does not read as a
   toolbar. */
.product[data-product="stationery-designer"] .sd-toolbar button.btn-quiet,
.product[data-product="stationery-designer"] .sd-actions button.btn-quiet,
.product[data-product="stationery-designer"] .sd-seg button.btn-quiet,
.product[data-product="stationery-designer"] .sd-recordrow button.btn-quiet,
.product[data-product="stationery-designer"] .sd-insphead button.btn-quiet,
.product[data-product="stationery-designer"] .sd-inspector > button.btn-quiet,
.product[data-product="stationery-designer"] .sd-filebtn {
  padding: .3rem .65rem; border: 1px solid var(--sd-line); border-radius: calc(var(--radius) / 1.5);
  background: var(--surface); color: var(--text); text-decoration: none; line-height: 1.3; font-size: .9rem;
}
.product[data-product="stationery-designer"] .sd-toolbar button.btn-quiet:hover:not(:disabled),
.product[data-product="stationery-designer"] .sd-actions button.btn-quiet:hover,
.product[data-product="stationery-designer"] .sd-inspector > button.btn-quiet:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--sd-line));
}
.product[data-product="stationery-designer"] button.btn-quiet:disabled { opacity: .45; cursor: default; }
.product[data-product="stationery-designer"] button.btn-quiet[aria-pressed="true"] {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.product[data-product="stationery-designer"] .sd-actions button.tone-bad { color: var(--sd-bad); }

/* ── Toolbar ──────────────────────────────────────────────────────── */

.sd-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .6rem; }
.sd-add, .sd-history, .sd-zoom { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.sd-zoom button { min-width: 2.4rem; }
.sd-check { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.sd-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

/* ── Workspace ────────────────────────────────────────────────────── */

.sd-workspace {
  display: grid; gap: .8rem;
  grid-template-columns: 13rem minmax(0, 1fr) 17rem;
  align-items: start;
}
.sd-workspace[hidden], .sd-empty[hidden] { display: none; }
.sd-empty {
  display: grid; gap: .6rem; padding: 1.2rem; border: 1px dashed var(--sd-line);
  border-radius: var(--radius); background: var(--sd-soft);
}

.sd-rail { display: grid; gap: .5rem; align-content: start; }
.sd-pieces { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.sd-piece {
  display: grid; grid-template-columns: 56px 1fr; gap: .55rem; align-items: center; width: 100%;
  padding: .4rem; text-align: left; border: 1px solid var(--sd-line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
}
.sd-piece:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--sd-line)); }
.sd-piece.is-on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.sd-piece:focus-visible { outline: 3px solid var(--sd-focus); outline-offset: 2px; }
.sd-piece .sd-thumb { justify-self: center; max-height: 64px; width: auto; box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.sd-piece-text { display: grid; gap: .1rem; min-width: 0; }
.sd-piece-text strong { font-size: .92rem; line-height: 1.2; }
.sd-piece-text span { font-size: .78rem; color: var(--muted); }
.sd-piece-text .sd-badge { font-weight: 600; }
.sd-piece-text .sd-badge.tone-bad { color: var(--sd-bad); }
.sd-piece-text .sd-badge.tone-attention { color: var(--sd-attention); }
.sd-addpiece select { width: 100%; }

/* ── Stage ────────────────────────────────────────────────────────── */

.sd-stagewrap { display: grid; gap: .6rem; min-width: 0; }
.sd-stage {
  overflow: auto; background: var(--sd-desk); border-radius: var(--radius);
  padding: .5rem; display: grid; place-items: center; min-height: 320px; touch-action: none;
}
.sd-canvas { display: block; max-width: none; user-select: none; -webkit-user-select: none; }
.sd-trim { stroke: rgb(0 0 0 / .55); stroke-width: 1; }
.sd-safe { stroke: #2563eb; stroke-width: 1; stroke-dasharray: 4 3; opacity: .7; }
.sd-hit { fill: transparent; stroke: transparent; cursor: move; outline: none; }
.sd-hit:hover { stroke: rgb(37 99 235 / .55); stroke-width: 1; stroke-dasharray: 3 2; }
.sd-hit.is-on { stroke: #2563eb; stroke-width: 1.5; }
.sd-hit:focus-visible { stroke: #2563eb; stroke-width: 3; }
.sd-handle { fill: #fff; stroke: #2563eb; stroke-width: 1.5; cursor: nwse-resize; }
.sd-handle[data-handle="ne"], .sd-handle[data-handle="sw"] { cursor: nesw-resize; }
.sd-guide { stroke: #db2777; stroke-width: 1; }
.sd-hint { font-family: system-ui, sans-serif; pointer-events: none; }

.sd-recordbar { display: grid; gap: .2rem; }
.sd-recordrow { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.sd-recordpick { max-width: 22rem; }
.sd-recordcount { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

.sd-photos { display: grid; gap: .35rem; }
.sd-photohead { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; }
.sd-file { position: absolute; width: 1px; height: 1px; opacity: 0; }
.sd-file:focus-visible + .sd-filebtn, .sd-filebtn:focus-within { outline: 3px solid var(--sd-focus); }
.sd-filebtn { cursor: pointer; }
.sd-photostrip { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.sd-photothumb {
  width: 72px; height: 54px; border-radius: calc(var(--radius) / 2); border: 1px solid var(--sd-line);
  background: var(--sd-soft) center / cover no-repeat; cursor: grab; padding: 0;
}
.sd-photothumb:focus-visible { outline: 3px solid var(--sd-focus); outline-offset: 2px; }

.sd-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.sd-issue { font-size: .9rem; padding-left: 1.1rem; position: relative; }
.sd-issue::before { content: '●'; position: absolute; left: 0; font-size: .7rem; top: .2rem; }
.sd-issue-link {
  background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.sd-ok { margin: 0; font-size: .9rem; }

/* ── Inspector ────────────────────────────────────────────────────── */

.sd-inspector {
  display: grid; gap: .7rem; padding: .8rem; border: 1px solid var(--sd-line);
  border-radius: var(--radius); background: var(--surface); align-content: start;
  position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto;
}
.sd-inspector h3 { margin: 0; font-size: 1rem; }
.sd-insphead { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.sd-field { display: grid; gap: .25rem; align-content: start; }
.sd-field > label { font-size: .85rem; font-weight: 600; }
.sd-field .input, .sd-field select, .sd-field textarea { width: 100%; box-sizing: border-box; }
.sd-textbox { min-height: 4.5rem; resize: vertical; font-family: inherit; }
.sd-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.sd-row4 { grid-template-columns: 1fr 1fr; }
.sd-seg { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.sd-seg .is-on, .sd-actions .is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sd-chips { display: flex; flex-wrap: wrap; gap: .25rem; padding-top: .4rem; }
.sd-chip { font-size: .78rem; padding: .15rem .4rem; font-family: ui-monospace, monospace; }
.sd-colors { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.sd-swatch {
  width: 1.9rem; height: 1.9rem; padding: 0; border-radius: 50%;
  border: 2px solid var(--sd-line); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12);
}
.sd-swatch.is-on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sd-focus); }
.sd-swatch-none { width: auto; border-radius: 999px; padding: 0 .5rem; font-size: .78rem; }
.sd-colorpick { width: 2.4rem; height: 1.9rem; padding: 0; border: 1px solid var(--sd-line); background: none; }
.sd-range { width: 100%; accent-color: var(--accent); }
.sd-dpi { margin: 0; font-size: .9rem; }
.sd-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.sd-layers { list-style: none; margin: .3rem 0 0; padding-left: 0; display: grid; gap: .15rem; }
.sd-layer { background: none; border: 0; padding: .1rem 0; text-align: left; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ── Details, looks, guest cards and print ────────────────────────── */

.sd-looks { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .5rem; }
.sd-look {
  display: grid; gap: .25rem; padding: .6rem; text-align: left; font: inherit; color: var(--text);
  border: 1px solid var(--sd-line); border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.sd-look.is-on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.sd-look:focus-visible { outline: 3px solid var(--sd-focus); outline-offset: 2px; }
.sd-look > span:last-child { font-size: .8rem; color: var(--muted); }
.sd-look-swatches { display: flex; height: 1.4rem; border-radius: calc(var(--radius) / 2); overflow: hidden; border: 1px solid var(--sd-line); }
.sd-look-swatches span { flex: 1; }
.sd-palette, .sd-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .6rem .9rem; margin-top: .6rem; }
.sd-palette input[type="color"] { height: 2.3rem; padding: .1rem; }

.sd-cardset { margin-top: .4rem; }
.sd-cardgrid { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.sd-card {
  display: grid; gap: .25rem; justify-items: center; padding: .35rem; font: inherit; color: var(--text);
  border: 1px solid var(--sd-line); border-radius: var(--radius); background: var(--sd-desk); cursor: pointer;
}
.sd-card .sd-thumb { box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.sd-card.is-flagged { border-color: var(--sd-bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sd-bad) 30%, transparent); }
.sd-card:focus-visible { outline: 3px solid var(--sd-focus); outline-offset: 2px; }
.sd-cardlabel { font-size: .75rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sd-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.sd-mode {
  display: grid; grid-template-columns: auto 1fr; gap: .5rem; align-items: start; padding: .7rem;
  border: 1px solid var(--sd-line); border-radius: var(--radius); cursor: pointer;
}
.sd-mode.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.sd-mode > span { display: grid; gap: .15rem; }
.sd-tablewrap { overflow-x: auto; margin: .6rem 0; }
.sd-printtable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.sd-printtable th, .sd-printtable td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--sd-line); vertical-align: top; }
.sd-printtable td > .field-help { display: block; margin: .15rem 0 0; }
.sd-qty { width: 5.5rem; }
.sd-printstatus { margin: .5rem 0; }

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

@media (max-width: 1100px) {
  .sd-workspace { grid-template-columns: 11rem minmax(0, 1fr); }
  .sd-inspector { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 720px) {
  .sd-workspace { grid-template-columns: minmax(0, 1fr); }
  .sd-pieces { display: flex; overflow-x: auto; padding-bottom: .3rem; }
  .sd-pieces li { flex: 0 0 13rem; }
  .sd-stage { min-height: 240px; }
}
