/* pdfview.css — the PDF viewer (app/pdfview.js, AI-917). One file for every Spaces front end that shows PDFs: the
   planner loads it from app/, the Samples app its copy from samples/ (tools/verify-pdf-viewer.js keeps them equal). */
/* ---------- AI-917: the PDF viewer (app/pdfview.js) ----------
   A tall dialog on a desktop (the browser's own viewer in a frame); the whole screen on a phone, clear of the notch and
   the home bar; on a dual-screen phone spread over both screens, a page per screen with the hinge between them. */
.pdfv.asp-modal { height: calc(100dvh - var(--cds-spacing-09)); max-height: calc(100dvh - var(--cds-spacing-09)); width: min(84vw, 1280px); }
.pdfv .pdfv__head { padding-bottom: var(--cds-spacing-03); }
.pdfv .pdfv__title { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pdfv__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--cds-spacing-03);
  padding: 0 var(--cds-spacing-06) var(--cds-spacing-03); flex: none; }
.pdfv__pick { flex: 1 1 14rem; min-width: 0; }
.pdfv__pick select { width: 100%; }
.pdfv__tools { display: flex; align-items: center; gap: var(--cds-spacing-04); margin-left: auto; }
.pdfv__pageno { font-size: var(--cds-label-01-font-size); color: var(--cds-text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pdfv__zoom { display: inline-flex; align-items: center; }
.pdfv__zoom [data-pdfv="fit"] { min-width: 4rem; justify-content: center; font-variant-numeric: tabular-nums; }
.pdfv .pdfv__body { padding: 0; display: flex; flex-direction: column; min-height: 0; background: var(--cds-layer-02); overflow: hidden; }
.pdfv__frame { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--cds-layer-02); }
.pdfv__msg { margin: auto; padding: var(--cds-spacing-07) var(--cds-spacing-06); max-width: 34rem; display: flex; flex-direction: column;
  align-items: center; gap: var(--cds-spacing-05); text-align: center; color: var(--cds-text-secondary); }
.pdfv__spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--cds-border-subtle-01); border-top-color: var(--cds-interactive);
  animation: pdfv-spin 0.9s linear infinite; }
@keyframes pdfv-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pdfv__spin { animation-duration: 3s; } }

/* the reader: pages down the screen (or one column per screen), each a sheet on the layer behind */
.pdfv__pages { --pdfv-cols: 1; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(var(--pdfv-cols), max-content); justify-content: center; align-content: start;
  gap: var(--cds-spacing-05); padding: var(--cds-spacing-05); outline: none; }
.pdfv__pages:focus-visible { box-shadow: inset 0 0 0 2px var(--cds-focus); }
.pdfv__page { background: #fff; box-shadow: 0 1px 3px var(--cds-shadow); position: relative; }
.pdfv__page canvas { display: block; width: 100%; height: 100%; }
.pdfv .pdfv__foot > .asp-btn { gap: var(--cds-spacing-03); }
.pdfv .pdfv__foot > .asp-btn .asp-icon { flex: none; }

/* a phone: the whole screen */
@media (max-width: 671.98px) {
  .pdfv.asp-modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0;
    padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .pdfv .pdfv__head { padding-left: var(--cds-spacing-05); }
  .pdfv .pdfv__title { font-size: var(--cds-heading-02-font-size); line-height: var(--cds-heading-02-line-height); -webkit-line-clamp: 1; }
  .pdfv__bar { padding: 0 var(--cds-spacing-05) var(--cds-spacing-03); }
  .pdfv__pages { padding: var(--cds-spacing-03); gap: var(--cds-spacing-03); }
  .pdfv .pdfv__foot { padding-bottom: env(safe-area-inset-bottom); background: var(--cds-layer-01); }
  .pdfv .pdfv__foot > .asp-btn { height: 56px; padding: 0 var(--cds-spacing-04); justify-content: center; border-radius: 0; }
  .pdfv .pdfv__close2 { display: none; }   /* the X in the corner closes it; the footer keeps the two actions */
}
/* a phone held sideways: every pixel of height for the page */
@media (max-height: 480px) and (pointer: coarse) {
  .pdfv.asp-modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0;
    padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .pdfv .pdfv__head { padding-top: var(--cds-spacing-03); }
  .pdfv .pdfv__head .asp-modal__label { display: none; }
  .pdfv .pdfv__foot > .asp-btn { height: 48px; }
}
/* a dual-screen phone spread over both screens: the dialog fills both, pages one per screen, the hinge as the gap */
@media (horizontal-viewport-segments: 2) {
  .pdfv.asp-modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .pdfv__pages { padding-left: 0; padding-right: 0; justify-content: start;
    column-gap: calc(env(viewport-segment-left 1 0, 50vw) - env(viewport-segment-right 0 0, 50vw)); }
}
/* folded flat like a laptop (one screen above the other): the pages on the top screen, the controls on the bottom */
@media (vertical-viewport-segments: 2) {
  .pdfv.asp-modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .pdfv .pdfv__body { flex: none; height: calc(env(viewport-segment-bottom 0 0, 50dvh) - env(viewport-segment-top 0 0, 0px) - 6.5rem); }
  .pdfv .pdfv__foot { margin-top: calc(env(viewport-segment-top 0 1, 50dvh) - env(viewport-segment-bottom 0 0, 50dvh)); }
}

/* AI-1275 - a file that is not a PDF: Word drawn as pages, an image as it is, text as text, all in the same body */
.pdfv__doc { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pdfv__doc:focus-visible { outline: 2px solid var(--cds-focus); outline-offset: -2px; }
.pdfv__doc--image { display: flex; align-items: flex-start; justify-content: center; padding: var(--cds-spacing-05); }
.pdfv__doc--image img { max-width: 100%; height: auto; background: var(--cds-layer-01); box-shadow: 0 1px 3px rgb(0 0 0 / 0.2); }
.pdfv__text { margin: 0; padding: var(--cds-spacing-05) var(--cds-spacing-06); background: var(--cds-layer-01); color: var(--cds-text-primary);
  font: 0.8125rem/1.5 var(--cds-font-mono, ui-monospace, Menlo, monospace); white-space: pre-wrap; word-break: break-word; min-height: 100%; }
.pdfv__cut { margin: 0; padding: var(--cds-spacing-03) var(--cds-spacing-06); font-size: 0.875rem; color: var(--cds-text-secondary); }
.pdfv__other { margin: 0; color: var(--cds-text-primary); }
/* docx-preview's pages: paper on the viewer's grey, like a PDF's; the text keeps the document's own colours */
/* blocks, not a centred flex column: a page wider than the screen then scrolls to its right edge instead of losing its left */
.pdfv__doc--word .pdfv-docx-wrapper { background: var(--cds-layer-02); padding: var(--cds-spacing-05); display: block; }
.pdfv__doc--word .pdfv-docx-wrapper > section.pdfv-docx { background: #fff; color: #000; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); margin: 0 auto var(--cds-spacing-05); }
@media (max-width: 671.98px) {
  .pdfv__doc--word .pdfv-docx-wrapper { padding: var(--cds-spacing-03); }
  .pdfv__doc--word .pdfv-docx-wrapper > section.pdfv-docx { padding: var(--cds-spacing-05) !important; width: auto !important; min-height: 0 !important; }
  /* a phone reads the text at its own width: a table drawn to the page's width is fitted to the screen */
  .pdfv__doc--word section.pdfv-docx table { width: 100% !important; max-width: 100%; }
  .pdfv__doc--word section.pdfv-docx td, .pdfv__doc--word section.pdfv-docx th { overflow-wrap: anywhere; }
  .pdfv__doc--word section.pdfv-docx img { max-width: 100%; height: auto; }
  .pdfv__text { padding: var(--cds-spacing-04); }
}

/* AI-1311 (studio AE-2) - a side panel the caller fills: an artwork's layers and file facts beside the pages */
.pdfv__split { flex: 1; min-height: 0; display: flex; }
.pdfv__split > .pdfv__body { flex: 1; min-width: 0; }
.pdfv__side { flex: none; width: 22rem; max-width: 42%; min-height: 0; overflow: auto; overscroll-behavior: contain;
  border-left: 1px solid var(--cds-border-subtle-01); background: var(--cds-layer-01); }
.pdfv__sidebtn[aria-pressed="true"] { border-color: var(--cds-border-strong-01); }
.pdfv__over { position: absolute; inset: 0; pointer-events: none; }
.pdfv__box { position: absolute; box-sizing: border-box; border: 1px dashed currentColor; }
.pdfv__box[data-box="trim"] { color: var(--cds-support-error); }
.pdfv__box[data-box="bleed"] { color: var(--cds-support-info); }
.pdfv__box[data-box="media"] { color: var(--cds-icon-secondary); }
.pdfv__box[data-box="art"] { color: var(--cds-support-success); }
.pdfv__sidein { min-height: 100%; }
.pdfv__boxlabel { position: absolute; left: 2px; top: 2px; font-size: 12px; line-height: 16px; font-weight: 600; background: var(--cds-layer-01); padding: 0 3px; }
@media (max-width: 671.98px) {
  .pdfv__split { flex-direction: column; }
  .pdfv__side { width: auto; max-width: none; max-height: 48%; border-left: 0; border-top: 1px solid var(--cds-border-subtle-01); }
}
