/* ─── 26 Sep 2026 — PACKAGING: the PDF viewer (src/PackagingViewer.jsx) + PDF tiles ─────────────────
   Hugo: booklets, sleeves, labels for CD and vinyl are PDFs; they live in the Packaging asset category and
   open page by page here. ONE fixed size for the viewer (invariant #20): the pages scale inside the stage,
   every control keeps its width whatever it reads. Tokens only; each level sits a step LIGHTER than the
   one it sits on (panel → strip / stage → thumbnail), text 4.5:1 on its own fill; no tooltips. */

.pkv-host { position: relative; z-index: 10050; }
.pkv-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blur-scrim, color-mix(in srgb, var(--black) 55%, transparent));
  backdrop-filter: blur(6px);
}

.pkv {
  --pkv-head-h: 56px;
  --pkv-strip-w: 150px;
  display: grid;
  grid-template-rows: var(--pkv-head-h) minmax(0, 1fr);
  width: min(1280px, 94vw);
  height: min(860px, 90vh);
  box-sizing: border-box;
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  background: var(--sep-panel);
  color: var(--ink);
  --ink-muted: var(--sep-panel-ink-muted);
  box-shadow: 0 24px 64px color-mix(in srgb, var(--black) 40%, transparent);
  overflow: hidden;
}
.pkv--embedded {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border-radius: var(--r-md);
  box-shadow: none;
}

/* ── header ── */
.pkv-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--card-border) 70%, transparent);
}
.pkv-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
.pkv-title-main {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-14);
  font-weight: var(--fw-bold);
}
.pkv-title-sub {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-12);
  color: var(--ink-muted);
}
.pkv-files { display: flex; gap: 4px; min-width: 0; overflow: hidden; }
.pkv-file {
  flex: 0 0 auto;
  max-width: 180px;
  min-width: 60px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--card-border) 80%, transparent);
  border-radius: var(--r-pill);
  background: var(--sep-card-fill);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-11-5);
  font-weight: var(--fw-semi);
  cursor: pointer;
}
.pkv-file span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pkv-file.is-on { background: var(--check-on-fill); color: var(--check-on-ink); border-color: transparent; }

.pkv-tools { flex: none; display: flex; align-items: center; gap: 6px; }
.pkv-sep { width: 1px; height: 22px; margin: 0 4px; background: color-mix(in srgb, var(--card-border) 80%, transparent); }
.pkv-btn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--card-border) 80%, transparent);
  border-radius: var(--r-pill);
  background: var(--sep-card-fill);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-12);
  font-weight: var(--fw-semi);
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-2, 120ms) ease;
}
.pkv-btn:hover:not(:disabled) { background: var(--sep-row-fill-hover); }
.pkv-btn:disabled { background: var(--disabled-fill); color: var(--disabled-ink); border-color: var(--disabled-line); cursor: default; }
.pkv-btn:focus-visible, .pkv-seg-btn:focus-visible, .pkv-thumb:focus-visible, .pkv-file:focus-visible { outline: 2px solid var(--leaf); outline-offset: 1px; }
.pkv-btn--icon { width: 30px; padding: 0; font-size: var(--fs-16); }
.pkv-zoom { width: 58px; padding: 0; font-variant-numeric: tabular-nums; }
.pkv-dl { width: 92px; padding: 0; }
.pkv-pages {
  width: 132px;
  text-align: center;
  font-size: var(--fs-12);
  font-weight: var(--fw-semi);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pkv-seg {
  display: inline-flex;
  height: 30px;
  padding: 2px;
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--card-border) 80%, transparent);
  border-radius: var(--r-pill);
  background: var(--sep-card-fill);
}
.pkv-seg-btn {
  width: 64px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-12);
  font-weight: var(--fw-semi);
  cursor: pointer;
}
.pkv-seg-btn.is-on { background: var(--check-on-fill); color: var(--check-on-ink); }

/* ── body: strip | stage ── */
.pkv-body {
  display: grid;
  grid-template-columns: var(--pkv-strip-w) minmax(0, 1fr);
  min-height: 0;
}
.pkv-strip {
  min-height: 0;
  overflow-y: auto;
  padding: 10px 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--sep-card-fill);
  border-right: 1px solid color-mix(in srgb, var(--card-border) 70%, transparent);
}
.pkv-thumb {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 6px 4px 4px;
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  background: var(--sep-row-fill);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.pkv-thumb:hover { background: var(--sep-row-fill-hover); }
.pkv-thumb.is-on { border-color: var(--check-on-fill); }
/* a fixed square per thumbnail: a page loading (or a wide spread) never moves the strip */
.pkv-thumb .pdf-thumb { width: 112px; height: 112px; background: transparent; }
.pkv-thumb-no { font-size: var(--fs-11); font-weight: var(--fw-semi); font-variant-numeric: tabular-nums; }

.pkv-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--sep-card-fill);
}
.pkv-stage.is-zoomed { overflow: auto; }
.pkv-pages-row {
  box-sizing: border-box;
  min-width: 100%;
  min-height: 100%;
  width: max-content;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 8 Nov 2026 — a page = its canvas + a layer of the PDF's own links over it (clickable; a soft tint on hover) */
.pkv-page { position: relative; flex: none; line-height: 0; }
.pkv-links { position: absolute; inset: 0; pointer-events: none; }
.pkv-link {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}
.pkv-link:hover,
.pkv-link:focus-visible {
  background: color-mix(in srgb, var(--leaf) 16%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--leaf) 55%, transparent);
  outline: none;
}
.pkv-canvas {
  display: block;
  flex: none;
  background: var(--paper, var(--cream));
  box-shadow: 0 2px 14px color-mix(in srgb, var(--black) 28%, transparent);
}
.pkv-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: var(--fs-13);
  color: var(--ink);
}
/* the "finding the song" line is always there (empty = invisible), so nothing moves when it shows */
.pkv-note {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--sep-row-fill-hover);
  color: var(--ink);
  font-size: var(--fs-12);
  font-weight: var(--fw-semi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  visibility: hidden;
  pointer-events: none;
}
.pkv-note.is-on { visibility: visible; }

/* ── a PDF as a picture (cards, strip tiles) ── */
.pdf-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--sep-row-fill);
}
.pdf-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pdf-thumb-badge {
  padding: 3px 8px;
  border-radius: var(--r-xs);
  background: var(--sep-row-fill-hover);
  color: var(--ink);
  font-size: var(--fs-11);
  font-weight: var(--fw-bold);
  letter-spacing: var(--track-12, 0.12em);
}

/* ── embedded in the asset window: the same viewer, a compact header, a narrower strip ── */
.pkv--embedded { --pkv-head-h: 48px; --pkv-strip-w: 116px; }
.pkv--embedded .pkv-head { gap: 8px; padding: 0 8px 0 12px; }
.pkv--embedded .pkv-title-main { font-size: var(--fs-12-5); }
.pkv--embedded .pkv-tools { gap: 4px; }
.pkv--embedded .pkv-pages { width: 84px; }
.pkv--embedded .pkv-sep { margin: 0 2px; }
.pkv--embedded .pkv-seg-btn { width: 56px; }
.pkv--embedded .pkv-dl { width: 84px; }
.pkv--embedded .pkv-thumb .pdf-thumb { width: 84px; height: 84px; }
.pkv-expand { width: 92px; padding: 0; }

/* ── the asset window's big box for a Packaging piece: one fixed size for pictures and PDFs ── */
.char-modal-grid .char-main-img.char-main-img--pkg {
  aspect-ratio: auto !important;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 420px;
  display: flex;
  overflow: hidden;
  background-color: var(--sep-card-fill);
  background-size: contain !important;
}
.char-main-img--pkg > .pkv { flex: 1 1 auto; }

/* ── the strip: a PDF tile shows its first page; the + ADD FILES tile; a file dragged over ── */
.char-gallery-thumb .char-gallery-thumb-pdfpage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}
.char-gallery-strip.is-file-over {
  outline: 2px dashed var(--leaf);
  outline-offset: -2px;
  border-radius: var(--r-sm);
}
.char-gallery-strip .char-gallery-thumb.pkg-add-files {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1.5px dashed var(--tile-add-border);
  background: var(--cream-27);
  color: var(--ink);
  cursor: pointer;
}
.char-gallery-strip .char-gallery-thumb.pkg-add-files:disabled { cursor: default; }
.pkg-add-files-plus { font-size: var(--fs-22); line-height: 1; font-weight: 300; }
.pkg-add-files-label { font-size: var(--fs-8-5); letter-spacing: var(--track-06); font-weight: var(--fw-semi); text-align: center; line-height: 1.15; }

/* ── the Assets page: Packaging per album ── */
.pkg-albums { display: flex; flex-direction: column; gap: 22px; }
.pkg-album-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 2px 10px;
  color: var(--ink);
}
.pkg-album-title { font-size: var(--fs-16); font-weight: var(--fw-bold); }
.pkg-album-count { font-size: var(--fs-12); color: var(--ink-muted); }
.prop-frame.pkg-card-pdf { background: var(--sep-row-fill); }
.prop-frame .pkg-card-pdf-page { position: absolute; inset: 8px; width: auto; height: auto; background: transparent; }
.pkg-add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 100%;
  border: 1.5px dashed var(--tile-add-border);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.pkg-add-card:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }
.pkg-add-plus { font-size: var(--fs-30); line-height: 1; font-weight: 300; }
.pkg-add-label { font-size: var(--fs-13); font-weight: var(--fw-bold); }
.pkg-add-sub { font-size: var(--fs-11-5); color: var(--ink-muted); }

@media (max-width: 720px) {
  .pkv { --pkv-head-h: 96px; --pkv-strip-w: 0px; width: 100vw; height: 100dvh; border-radius: 0; }
  .pkv-head { flex-wrap: wrap; align-content: center; row-gap: 6px; padding: 6px 10px; }
  .pkv-strip { display: none; }
  .pkv-tools { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
}

/* (8 Nov 2026) the Briefs page opens a PDF nearly full screen (PdfViewer large) */
.pkv.pkv--large { width: 96vw; height: 94vh; }
