/* Kadosh proprietary source.
 * SPDX-License-Identifier: LicenseRef-Kadosh-Proprietary
 *
 * Distribution is blocked until the legal owner and LICENSE-KADOSH are
 * approved. See LICENSING.md.
 */

/* The compare of two versions in the viewer: the section of the sidebar,
   the layer a compare puts into the page, the panes of side by side, and
   where the tools of the design system stand over the page. The tools
   themselves are styled by the design system. */

/* The section of the sidebar. The panel of the design system carries its
   own insets and scrolls by itself. */
.kadosh-native .kds-viewer-sidebar-shell[data-view="compare"] #viewsManager {
  width: 272px !important;
  min-width: 0;
}
.kadosh-native
  .kds-viewer-sidebar-shell[data-view="compare"]
  #viewsManagerContent {
  padding: 0;
  overflow: hidden;
}
.kadosh-native #compareView {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}
.kadosh-native #compareView.hidden {
  display: none;
}
.kadosh-native .kds-compare-hint {
  margin: 0;
  padding: 12px 14px;
  color: rgb(var(--kds-text-muted));
  font-size: var(--kds-viewer-text-xs, 0.75rem);
  line-height: 1.45;
}
.kadosh-native .kds-compare-elsewhere {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 8px 14px;
  color: rgb(var(--kds-text-muted));
  font-size: var(--kds-viewer-text-xs, 0.75rem);
}
.kadosh-native .kds-compare-close {
  margin-left: auto;
}
.kadosh-native .kds-compare-tabs {
  padding: 0 12px 8px;
}
.kadosh-native .kds-compare-inks {
  min-height: 0;
  overflow-y: auto;
}

/* The layer in the page. It takes no click: what is under it is read,
   selected and dragged as ever. Only what a reviewer acts on does. */
.kadoshCompareLayer {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.kadoshCompareLayer .kc-box {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
/* What is drawn lies on the page as it is unturned; the frame is turned
   with the page. */
.kc-frame {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}
.kc-frame > canvas,
.kc-tiles > canvas {
  position: absolute;
  display: block;
}

/* The reference: paper, then the whole of it coarse, then the part in sight
   as sharp as the screen. */
.kc-reference {
  display: none;
  background: rgb(var(--viewer-document-paper, 255 255 255));
}
.kc-whole {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* The differences: the cells of the page, and tiles over them where the
   page is seen closer. A block is a block, not a blur. */
.kc-evidence {
  display: none;
}
.kc-cells {
  top: 0;
  left: 0;
}
.kc-cells,
.kc-tile {
  image-rendering: pixelated;
}
.kc-tiles {
  position: absolute;
  inset: 0;
}

/* What veils the artwork so that the differences stand out. */
.kc-veil {
  position: absolute;
  inset: 0;
  display: none;
  background: rgb(var(--viewer-document-paper, 255 255 255));
}

.kc-over {
  pointer-events: none;
}
.kc-regions {
  position: absolute;
  inset: 0;
  display: none;
}

/* Where the inks were read. */
.kc-marker {
  position: absolute;
  width: 15px;
  height: 15px;
  margin: -8px 0 0 -8px;
  border: 1.5px solid rgb(var(--kds-primary));
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgb(var(--viewer-document-paper, 255 255 255) / 0.8),
    inset 0 0 0 1px rgb(var(--viewer-document-paper, 255 255 255) / 0.8);
}
.kc-marker::before,
.kc-marker::after {
  position: absolute;
  top: 50%;
  left: 50%;
  background: rgb(var(--kds-primary));
  content: "";
}
.kc-marker::before {
  width: 23px;
  height: 1px;
  margin: -0.5px 0 0 -11.5px;
}
.kc-marker::after {
  width: 1px;
  height: 23px;
  margin: -11.5px 0 0 -0.5px;
}

/* The modes: each shows parts of the layer. */
.kadoshCompareLayer:is(
    [data-mode="reference"],
    [data-mode="overlay"],
    [data-mode="curtain"],
    [data-mode="blink"][data-blink="reference"]
  )
  > .kc-reference {
  display: block;
}
.kadoshCompareLayer[data-mode="overlay"] > .kc-reference {
  opacity: var(--kc-overlay, 0.5);
}
.kadoshCompareLayer:is(
    [data-mode="differences"],
    [data-mode="highlight"],
    [data-mode="only-differences"]
  )
  > .kc-evidence {
  display: block;
}
.kadoshCompareLayer:is(
    [data-mode="differences"],
    [data-mode="highlight"],
    [data-mode="only-differences"],
    [data-mode="side-by-side"]
  )
  .kc-regions {
  display: block;
}
.kadoshCompareLayer:is(
    [data-mode="differences"],
    [data-mode="only-differences"]
  )
  > .kc-veil {
  display: block;
}
.kadoshCompareLayer[data-mode="differences"] > .kc-veil {
  opacity: 0.65;
}

/* Over the page: the bar of modes, the curtain, the reading of the inks and
   the alignment. The host covers what the viewer shows and takes no click
   but on what stands in it. */
.kadoshCompareChrome {
  position: absolute;
  z-index: 6;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.kadoshCompareChrome > * {
  pointer-events: auto;
}
.kadoshCompareChrome > .kds-viewer-compare-curtain,
.kadoshCompareChrome > .kds-compare-reading {
  pointer-events: none;
}
/* A dialog stands over everything the viewer has. */
.kadoshCompareDialog {
  position: absolute;
  z-index: 200;
  inset: 0;
  pointer-events: none;
}
.kadoshCompareDialog > * {
  pointer-events: auto;
}

/* Above the tools of the viewer, and in the middle of what is in sight as
   they are. */
.kadoshCompareChrome > .kds-viewer-compare-modebar {
  top: auto;
  bottom: 80px;
  left: calc(50% + var(--kadosh-toolbar-offset, 0px));
  max-width: calc(100% - var(--kadosh-artwork-offset, 0px) - 96px);
  transition: left 200ms ease-out;
}
/* The reading stands clear of the tools, at the corner the sidebar leaves. */
.kadoshCompareChrome > .kds-compare-reading {
  position: absolute;
  bottom: 16px;
  left: calc(var(--kadosh-artwork-offset, 0px) + 16px);
}
.kadoshCompareChrome > .kds-compare-alignment {
  position: absolute;
  top: 16px;
  left: calc(var(--kadosh-artwork-offset, 0px) + 16px);
}
@media (prefers-reduced-motion: reduce) {
  .kadoshCompareChrome > .kds-viewer-compare-modebar {
    transition: none;
  }
}

/* Side by side: the viewer keeps the current version and gives room to a
   pane for the reference before it, and to one for the differences after.
   The three share what the sidebar leaves of the window, which the viewer
   alone keeps clear of the sidebar otherwise. */
.kadosh-native .kds-viewer-canvas[data-compare-split] {
  --kc-left: var(--kadosh-artwork-offset, 0px);
  --kc-half: calc((100% - var(--kc-left)) / 2);
  --kc-third: calc((100% - var(--kc-left)) / 3);
}
.kadosh-native .kds-viewer-canvas[data-compare-split] .pdfViewer {
  padding-inline-start: 0;
}
.kadosh-native
  .kds-viewer-canvas[data-compare-split="2-horizontal"]
  #viewerContainer {
  inset: 0 0 0 calc(var(--kc-left) + var(--kc-half)) !important;
}
.kadosh-native
  .kds-viewer-canvas[data-compare-split="2-vertical"]
  #viewerContainer {
  inset: 50% 0 0 var(--kc-left) !important;
}
.kadosh-native
  .kds-viewer-canvas[data-compare-split="3-horizontal"]
  #viewerContainer {
  inset: 0 var(--kc-third) 0 calc(var(--kc-left) + var(--kc-third)) !important;
}
.kadosh-native
  .kds-viewer-canvas[data-compare-split="3-vertical"]
  #viewerContainer {
  inset: 33.333% 0 33.333% var(--kc-left) !important;
}
.kadoshComparePane {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  background: rgb(var(--kds-surface-muted));
}
[data-compare-split="2-horizontal"]
  > .kadoshComparePane[data-role="reference"] {
  inset: 0 var(--kc-half) 0 var(--kc-left);
  border-right: 1px solid rgb(var(--kds-border));
}
[data-compare-split="2-vertical"] > .kadoshComparePane[data-role="reference"] {
  inset: 0 0 50% var(--kc-left);
  border-bottom: 1px solid rgb(var(--kds-border));
}
[data-compare-split="3-horizontal"]
  > .kadoshComparePane[data-role="reference"] {
  inset: 0 calc(2 * var(--kc-third)) 0 var(--kc-left);
  border-right: 1px solid rgb(var(--kds-border));
}
[data-compare-split="3-horizontal"]
  > .kadoshComparePane[data-role="differences"] {
  inset: 0 0 0 calc(var(--kc-left) + 2 * var(--kc-third));
  border-left: 1px solid rgb(var(--kds-border));
}
[data-compare-split="3-vertical"] > .kadoshComparePane[data-role="reference"] {
  inset: 0 0 66.667% var(--kc-left);
  border-bottom: 1px solid rgb(var(--kds-border));
}
[data-compare-split="3-vertical"]
  > .kadoshComparePane[data-role="differences"] {
  inset: 66.667% 0 0 var(--kc-left);
  border-top: 1px solid rgb(var(--kds-border));
}
/* The page of a pane lies where the page of the viewer lies. */
.kc-pane-page {
  position: absolute;
  overflow: hidden;
  background: rgb(var(--viewer-document-paper, 255 255 255));
  box-shadow: var(--kds-shadow-md);
}
.kc-pane-page > .kc-box {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
}
.kc-pane-tag,
.kadoshComparePaneTag {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  pointer-events: none;
}
