/*
 * TAG Legal Desk v2.1: the file viewer (js/v21_viewer.js, 30 Sep 2026). The panel fills its height: the file's name
 * wraps under Close, the tools sit in one row, and the file takes the rest. Light, dark, every theme, high contrast and
 * forced colours; the spinner stops for reduced motion, the Motion setting and Calm. No style attributes: sizes come
 * through custom properties set by the page.
 */

/* Any panel: a long title wraps, so Close is never pushed off the screen (it was, at 400 px, 30 Sep 2026). */
.sheet-h h2 { min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- the panel */

.vw-sheet .sheet-h { flex-wrap: wrap; row-gap: 2px; align-items: flex-start; padding: 14px 14px 8px 22px; }
.vw-sheet .sheet-h h2 { order: 0; flex: 1 1 0%; font-size: 1.125rem; line-height: 1.35; padding-top: 10px; }
.vw-sheet .sheet-h > .btn { order: 1; flex: none; }
.vw-meta { order: 2; flex: 1 0 100%; margin: 0; color: var(--ink-2); font-size: .8125rem; font-weight: 600; line-height: 1.4; }
.vw-sheet .sheet-b { display: flex; flex-direction: column; overflow: hidden; padding: 4px 22px 16px; gap: 0; }
.vw { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; min-height: 0; }
.vw-back-row[hidden], .vw-notes:empty { display: none; }
.vw-back { max-width: 100%; }
.vw-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.vw-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vw-bar [hidden] { display: none; }
.vw-tools { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.vw-tools:empty { display: none; }
.vw-tool { width: 36px; padding: 0; }
.vw-zoom { min-width: 88px; text-align: center; font-size: .8125rem; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.vw-pagebox { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 700; color: var(--ink-2); }
.vw-pagebox .ico { color: var(--ink-3); }
.vw-page { width: 64px; min-height: 36px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--edge-strong); background: var(--solid); color: var(--ink); font: inherit; font-weight: 700; }
.vw-go { min-width: 44px; }

.vw-notes { display: grid; gap: 6px; }
.vw-note { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--ink-2); font-size: .875rem; line-height: 1.45; }
.vw-note .ico { flex: none; margin-top: 2px; color: var(--info); }
.vw-note-row { margin: 0; }

/* ---------------------------------------------------------------- the file itself */

.vw-stage { position: relative; flex: 1 1 auto; min-height: 140px; overflow: auto; border-radius: 12px; outline-offset: 2px; }
.vw-stage:focus-visible { outline: 2px solid var(--focus); }

/* Waiting: a calm spinner and one line (announced from the panel's status line) */
.vw-loading { display: flex; align-items: center; gap: 12px; margin: 0; padding: 22px 6px; color: var(--ink-2); font-weight: 600; }
.vw-spin { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand-text); animation: vw-spin 900ms linear infinite; }
@keyframes vw-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { :root:not([data-motion="full"]) .vw-spin { animation: none; } }
:root[data-motion="reduced"] .vw-spin, :root[data-calm="on"] .vw-spin { animation: none; }

/* A PDF fills the panel: width and height */
.vw-stage.vw-pdf { overflow: hidden; background: var(--paper); box-shadow: 0 0 0 1px rgba(0,0,0,.10); }
.vw-stage.vw-pdf .vw-loading { color: #333; }
.vw-frame { display: block; width: 100%; height: 100%; min-height: 320px; border: 0; background: var(--paper); }
/* The calm line over a PDF while the browser's reader opens it (a big scan takes a few seconds to draw). It never
   takes a press, so the PDF can be used the moment it shows. */
.vw-opening { position: absolute; left: 0; right: 0; top: 50%; z-index: 1; transform: translateY(-50%); display: flex; align-items: center; gap: 10px; box-sizing: border-box; width: max-content; max-width: calc(100% - 32px); margin: 0 auto; padding: 10px 18px 10px 12px; border-radius: 22px; background: var(--solid); color: var(--ink); border: 1px solid var(--edge-strong); box-shadow: 0 6px 22px rgba(0,0,0,.22); font-size: .875rem; font-weight: 600; line-height: 1.35; pointer-events: none; }
.vw-opening .vw-spin { width: 18px; height: 18px; border-width: 3px; }
.vw-hint { font-size: .8125rem; font-weight: 600; color: var(--ink-2); }

/* A picture: fitted, zoomed, moved, turned (sizes from --vw-bw, --vw-bh, --vw-iw, --vw-ih and --vw-rot) */
.vw-stage.vw-pic { display: flex; background: rgba(0,0,0,.06); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); touch-action: pan-x pan-y; }
:root[data-theme="dark"] .vw-stage.vw-pic, :root[data-theme="night_shift"] .vw-stage.vw-pic { background: rgba(255,255,255,.05); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.vw-stage.vw-pic .vw-loading { position: absolute; left: 12px; top: 8px; }
.vw-stage.vw-can-move { cursor: grab; }
.vw-stage.vw-dragging { cursor: grabbing; }
.vw-imgbox { position: relative; flex: none; margin: auto; width: var(--vw-bw, 0px); height: var(--vw-bh, 0px); }
.vw-img { position: absolute; left: 50%; top: 50%; display: block; width: var(--vw-iw, auto); height: var(--vw-ih, auto); max-width: none; max-height: none; transform: translate(-50%, -50%) rotate(var(--vw-rot, 0deg)); image-orientation: from-image; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); }

/* A sound recording or a film clip: the player always on screen */
.vw-stage.vw-media { display: flex; align-items: center; justify-content: center; }
.vw-stage.vw-snd { flex: 0 0 auto; min-height: 0; padding: 18px 16px; background: var(--glass-1); box-shadow: inset 0 0 0 1px var(--glass-edge); }
.vw-audio { display: block; width: 100%; }
.vw-stage.vw-clip { flex: 0 1 auto; background: #000; }
.vw-video { display: block; width: 100%; height: auto; max-height: calc(100vh - 210px); object-fit: contain; background: #000; }
.vw-stage.vw-clip .vw-loading { color: #F2F2F2; }

/* Words: the paper, scrolled inside the panel */
.vw-stage.vw-read { padding: 1px; }
.vw-paper { min-height: 100%; box-sizing: border-box; }

/* When a file cannot show: one plain line, and what to do */
.vw-stage.vw-failed { flex: 0 0 auto; min-height: 0; overflow: visible; }
.vw-fail { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 18px; border-radius: 14px; background: var(--solid); border: 1px solid var(--edge-strong); color: var(--ink); }
.vw-fail > .ico { color: var(--warn); margin-top: 1px; }
.vw-fail-h { margin: 0; font-weight: 700; font-size: 1rem; line-height: 1.45; }
.vw-fail-said { margin: 6px 0 0; color: var(--ink-2); font-size: .875rem; line-height: 1.45; overflow-wrap: anywhere; }
.vw-fail-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------------------------------------------------------------- words on the paper, in every theme */

/* The paper is white in every theme, so the links and buttons on it take paper colours (in dark they were pale green
   on white, 1.71 to 1). */
.preview-text { --brand-text: #1F4A26; --ink: #000000; --ink-2: #333333; --ink-3: #555555; --glass-1: #FFFFFF; --glass-2: #EEF1EC; --glass-edge: rgba(0,0,0,.28); --glass-rim: rgba(0,0,0,.06); --glass-hi: rgba(255,255,255,.6); --brand-soft: rgba(31,74,38,.10); --focus: #1F5FD1; }
.preview-text .part-line { margin: 2px 0; }
.preview-text .link { color: var(--brand-text); }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 600px) {
  /* The panel is already the whole width: Expand has nothing to do. */
  .vw-expand, .dl-expand { display: none; }
  .vw-sheet .sheet-h { padding: 10px 10px 6px 16px; }
  .vw-sheet .sheet-b { padding: 2px 12px 12px; }
  .vw-zoom { min-width: 0; }
  .vw-frame { min-height: 240px; }
}

/* The Ask Fred orb waits under the viewer (it sat over the PDF's scroll bar). */
:root.vw-open .v21ao-layer { visibility: hidden; }

/* ---------------------------------------------------------------- high contrast and forced colours */

:root[data-theme="high_contrast"] .vw-meta, :root[data-theme="high_contrast"] .vw-note, :root[data-theme="high_contrast"] .vw-zoom, :root[data-theme="high_contrast"] .vw-pagebox, :root[data-theme="high_contrast"] .vw-hint { color: #000; }
:root[data-theme="high_contrast"] .vw-opening { border: 2px solid #000; background: #fff; color: #000; box-shadow: none; }
:root[data-theme="high_contrast"] .vw-stage.vw-pic, :root[data-theme="high_contrast"] .vw-stage.vw-pdf, :root[data-theme="high_contrast"] .vw-stage.vw-snd { border: 2px solid #000; background: #fff; box-shadow: none; }
:root[data-theme="high_contrast"] .vw-fail { border: 2px solid #000; background: #fff; }
:root[data-theme="high_contrast"] .vw-page { border: 2px solid #000; background: #fff; color: #000; }
:root[data-theme="high_contrast"] .preview-text { --brand-text: #000000; }
:root[data-theme="high_contrast"] .vw-spin { border-color: #BBBBBB; border-top-color: #000; }
@media (forced-colors: active) {
  .vw-spin { border-color: GrayText; border-top-color: Highlight; }
  .vw-stage.vw-pic, .vw-stage.vw-pdf, .vw-stage.vw-snd, .vw-fail { border: 1px solid CanvasText; }
  .vw-opening { border: 1px solid CanvasText; background: Canvas; color: CanvasText; box-shadow: none; }
  .vw-page { border: 1px solid ButtonText; }
  .preview-text .link { color: LinkText; }
  .preview-text .dl-btn { border: 1px solid ButtonText; }
  .vw-img { box-shadow: none; }
}

/* ---------- claims manager task files (desk.cmTask.viewer, 30 Sep 2026) ----------
   On a cm_task job the files on its tasks sit with the job's attachments. One with no copy on the desk is a name only:
   quieter, with nothing to press. */
.vw-task { margin-top: 12px; gap: 6px; }
.vw-task-h { margin: 0; font-weight: 600; color: var(--ink-2); }
.vw-task-name { color: var(--ink-2); font-weight: 500; }
.vw-task-ico { display: inline-flex; flex: none; color: var(--ink-3); }
:root[data-theme="high_contrast"] .vw-task-name, :root[data-theme="high_contrast"] .vw-task-h { color: #000; }
@media (forced-colors: active) { .vw-task-name { border: 1px dashed CanvasText; } }
