/* sources.css - the source pane (UI overhaul R3, track B;
   docs/spec-ui-overhaul-r3-build.md §3, B1, B2): section#aw-source, its
   header, the viewer's frame, and where it sits by window size (covering
   the window under 700 px, docked at the bottom from 700 px, beside the
   answer from 1080 px), Expand and Shrink. Stacking: --z-source and
   --z-source-full (static/ui/app.css). Print rules: block "R3 B" of the
   page's print block.

   From the prototype's query.css (.src-*) and shell.css (.aw-source) with
   the aw-src- prefix. Colours are tokens only (static/ui/tokens.css;
   scripts/test_ui_tokens.py checks). Referenced as
   /static/ui/sources.css?v=<CACHE_VERSION number>. */

/* the sizes (R3 plan B2 item 1): the docked height (sources.js sets it on
   #app on each first open in a 700-1079 px window), the width beside the
   answer (60 % of the space the menu leaves, 600-1100 px) and the menu's
   share of that space: its width from 1360 px while it is shown, else 0 */
#app {
  --aw-sb-shown: 0px;
  --aw-source-h: 55vh;
  --aw-source-w: clamp(600px, calc((100vw - var(--aw-sb-shown)) * 0.6), 1100px);
}
@supports (height: 1dvh) {
  #app { --aw-source-h: 55dvh; }
}
@media (min-width: 1360px) {
  #app:not(.aw-menu-hidden) { --aw-sb-shown: var(--sidebar-w); }
}

/* the open pane covers the window under 700 px, and at any width while
   expanded (#app.aw-src-full): above the menu, padded by the four safe areas.
   #app[data-source="open"] is set by sources.js; [hidden] keeps it out of the
   page while closed. No transform, filter, contain or overflow lands on #app,
   #aw-col or #aw-main (the printed card and the reading position need them
   plain; app.css). */
.aw-source {
  position: fixed; inset: 0; z-index: var(--z-source-full);
  display: flex; flex-direction: column;
  padding: var(--top-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--surface); color: var(--text);
  font-family: var(--sans);
}
/* its scroll lock while it covers the window (the overlay stack owns aw-lock) */
html.aw-src-lock { overflow: hidden; }

/* the header: the document's title over its page; Expand and Close. (The
   left gap once kept for the installed iPad app's window buttons, --win-inset,
   was 0 from 2026-11-16 and went on 2026-11-19, design reference D11.) */
.aw-src-head {
  display: flex; align-items: center; gap: 12px;
  height: 60px; flex: none; padding: 0 8px 0 18px;
  border-bottom: 1px solid var(--border); color: var(--text-dim);
}
.aw-src-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.aw-src-name {
  overflow: hidden; font-size: 15px; line-height: 20px; font-weight: 600;
  color: var(--text-hi); text-overflow: ellipsis; white-space: nowrap;
}
.aw-src-page { font-size: 13px; line-height: 18px; color: var(--muted); }
.aw-src-expand { display: none; }

@media (min-width: 700px) {
  /* 700-1079 px: docked at the bottom, full width; the column makes room */
  #app:not(.aw-src-full) > .aw-source {
    inset: auto 0 0 0; z-index: var(--z-source);
    height: var(--aw-source-h);
    padding-top: 0;
    border-top: 1px solid var(--border-hi);
    box-shadow: var(--shadow-pop);
  }
  #app:not(.aw-src-full) > .aw-source .aw-src-head { padding-left: 18px; }
  #app[data-source="open"] > .aw-col { padding-bottom: var(--aw-source-h); }
  .aw-src-expand { display: inline-flex; }
}
@media (min-width: 1080px) {
  /* from 1080 px: beside the answer, the column keeps the rest */
  #app:not(.aw-src-full) > .aw-source {
    inset: 0 0 0 auto; width: var(--aw-source-w); height: auto;
    padding-top: var(--top-t); padding-left: 0;
    border-top: 0; border-left: 1px solid var(--border);
    box-shadow: none;
  }
  #app[data-source="open"] > .aw-col { margin-right: var(--aw-source-w); padding-bottom: 0; }
}

/* the body: the viewer's frame, or the spinner, or a message */
.aw-src-body { position: relative; flex: 1; min-height: 0; background: var(--viewer); }
/* the rule that keeps a pinch in the viewer from zooming the app page is set
   inside the frame, on the viewer's scroll containers (static/pdfjs-ios-pinch.js):
   WebKit does not apply an iframe element's touch-action to the frame's
   content, so the frame element carries none */
.aw-src-frame { display: block; width: 100%; height: 100%; border: 0; }
.aw-src-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.aw-src-msg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow-y: auto;
}
.aw-src-note { width: min(100%, 440px); }
.aw-src-note .aw-btn { margin-top: 8px; }
.aw-src-note .aw-note-text { margin: 0; color: var(--text); }

/* a print's progress in the header (run fx-print): a spinner beside Expand /
   Shrink (Close under 700 px), the words, Cancel; made by sources.js. The
   title gives way first; under reduced motion the spinner stands still
   (app.css) and the words carry the state. */
.aw-src-prog { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; }
.aw-src-prog[hidden] { display: none; }
.aw-src-prog-text {
  font-size: 13px; line-height: 18px; color: var(--text-dim);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.aw-src-prog-cancel { padding: 0 12px; }
