/* PDF files (js/pdf.js): the card in a chat, and the viewer that opens over the whole window. */

/* The card: the top of the first page, and under it the name, the size and a way to download. Its height is
   fixed, so the chat does not jump when the page's picture arrives. */
.att-pdf { width: min(100%, 420px); background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pc-view { display: block; width: 100%; height: 180px; background: var(--bg-0); border-bottom: 1px solid var(--line); cursor: zoom-in; overflow: hidden; }
.pc-view:focus-visible { outline-offset: -2px; }
.pc-view img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.pc-wait { display: grid; place-items: center; place-content: center; gap: 8px; height: 100%; color: var(--muted); font-size: 13px; }
.pc-foot { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.pc-icon { display: grid; color: var(--accent); flex-shrink: 0; }
.pc-text { flex: 1; min-width: 0; }
.pc-name { display: block; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-size { font-size: 12px; color: var(--muted); }

/* The viewer. It is dark in both themes, like the picture preview it is built on (.lightbox in app.css), so
   the buttons and boxes inside it always use the dark colours. */
.pv {
  --bg-0: #060606; --bg-1: #0a0a0a; --bg-3: #141414; --bg-4: #1b1b1b;
  --line: rgba(255, 255, 255, 0.05); --line-strong: rgba(255, 255, 255, 0.08);
  --text: #cdcdcd; --text-2: #8c8c8c; --muted: #5c5c5c;
  --accent: #c8c8c8; --accent-hover: #a8a8a8; --on-accent: #0a0a0a;
  color-scheme: dark; user-select: none; -webkit-user-select: none;
}
.pv-scroll {
  flex: 1; min-height: 0; min-width: 0; position: relative; overflow: auto; outline: none;
  overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #2a2a2a transparent;
  scrollbar-gutter: stable both-edges; /* the room for the scroll bar is always there, so a page fitted to the width stays fitted */
}
.pv-pages {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: max-content; min-width: 100%; padding: 4px 24px 88px;
}
.pv-page { position: relative; flex-shrink: 0; background: #fff; overflow: hidden; border-radius: 2px; }
.pv-page canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.pv-page.broken::after {
  content: "This page can't be shown"; position: absolute; inset: 0; display: grid; place-items: center;
  color: #666; font-size: 14px;
}

/* The words of a page, laid invisibly over its picture: what the cursor selects and copies. These rules are
   PDF.js's own (web/pdf_viewer.css of 6.5.438), without the parts for editing, which Chat-Monki does not use. */
.pv-page { --user-unit: 1; --total-scale-factor: calc(var(--scale-factor) * var(--user-unit)); --scale-round-x: 1px; --scale-round-y: 1px; }
.pv .textLayer {
  position: absolute; inset: 0; z-index: 1; overflow: clip; line-height: 1; text-align: initial; opacity: 1;
  letter-spacing: normal; word-spacing: normal; color-scheme: only light;
  -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0;
  --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size));
}
.pv .textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; -webkit-user-select: text; }
.pv .textLayer > :not(.markedContent), .pv .textLayer .markedContent span:not(.markedContent) {
  z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.pv .textLayer .markedContent { display: contents; }
.pv .textLayer span[role="img"] { user-select: none; -webkit-user-select: none; cursor: default; }
.pv .textLayer ::selection { background: rgba(128, 128, 128, 0.42); color: transparent; }
.pv .textLayer br::selection { background: transparent; }
.pv .textLayer .endOfContent {
  display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default;
  user-select: none; -webkit-user-select: none;
}
.pv .textLayer.selecting .endOfContent { top: 0; }

/* The links of a page: nothing to see until the pointer is on one. */
.pv-links { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.pv-link { position: absolute; pointer-events: auto; cursor: pointer; border-radius: 2px; }
.pv-link:hover, .pv-link:focus-visible { background: rgba(128, 128, 128, 0.25); outline: 1px solid rgba(96, 96, 96, 0.7); outline-offset: 0; }

/* Pages and zoom: a small bar that floats at the bottom, the same on a phone and on a large screen. */
.pv-bar {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 2px; max-width: calc(100% - 16px); padding: 4px;
  background: #121212; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; color: #ccc;
}
.pv-btn { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 6px; color: #ccc; font-size: 13px; }
.pv-btn:hover:not(:disabled) { color: #fff; background: rgba(255, 255, 255, 0.12); }
.pv-btn:disabled { opacity: 0.35; cursor: default; }
.pv-glyph { font-size: 18px; line-height: 1; }
.pv-zoom { min-width: 54px; font-variant-numeric: tabular-nums; }
.pv-num {
  height: 26px; min-width: 3ch; padding: 0 4px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums;
  color: #eee; background: #1e1e1e; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 5px; outline: none;
  user-select: text; -webkit-user-select: text;
}
.pv-num:focus { border-color: #888; }
.pv-count { padding: 0 6px 0 5px; font-size: 13px; color: #999; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pv-sep { width: 1px; height: 18px; margin: 0 4px; background: rgba(255, 255, 255, 0.12); }

/* What is said in the middle: opening, a password to type, why the file cannot be shown. */
.pv-note { position: absolute; inset: calc(44px + env(safe-area-inset-top, 0px)) 0 0; z-index: 4; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.pv-note > * { pointer-events: auto; }
.pv-box {
  display: grid; justify-items: center; gap: 10px; width: min(100%, 320px); padding: 20px; text-align: center;
  color: #999; background: #101010; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 8px;
}
.pv-why { font-size: 14px; color: #ddd; }
.pv-file { max-width: 100%; font-size: 12px; color: #777; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-box .input { background: #1b1b1b; user-select: text; -webkit-user-select: text; }
.pv-row { display: flex; justify-content: flex-end; gap: 8px; }

/* A link in the PDF was clicked: where it really goes, and the question whether to open it. */
.pv-ask {
  position: absolute; left: 50%; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 6;
  display: grid; gap: 10px; width: min(calc(100% - 16px), 520px); padding: 12px 14px;
  background: #121212; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.pv-ask-what { font-size: 13px; color: #999; }
.pv-ask-url { max-height: 4.4em; margin-top: 2px; overflow: auto; font-size: 14px; color: #eee; word-break: break-all; user-select: text; -webkit-user-select: text; }

@media (max-width: 760px) {
  .pv-pages { gap: 6px; padding: 0 0 88px; }
  .pv-page { border-radius: 0; }
}
