/* The drawings of the paired chapters (js/pairs.js, figure) as they stand on the page, and the full-window viewer that
   opens a drawing to be read at any size (js/figure-view.js) — those drawings, and the Tabernacle's side view. The
   viewer is set like the blueprint's (css/blueprint.css): the page's ground, a bar with the drawing's name, and the
   zoom buttons in the corner. Loaded after css/manuscript.css, whose rules for .pr-fig it builds on. */

/* ---- the drawing on the page ----
   A drawing is drawn at 720 units wide and shown at no more than 720 pixels, so its words stay the size of the page's
   own; where a chapter gives one for a phone (svgNarrow, 360 wide), it takes the wide one's place on a narrow screen.
   The box is a container, so the button that opens the drawing can stand beside it where there is room, and over its
   corner where there is not. */
.pr-figs { position: relative; container-type: inline-size; margin: 0.9rem 0 0.15rem; }
.pr-figure .pr-figs .pr-fig { margin: 0; }
.pr-figs .pr-fig svg { max-width: 720px; margin-inline: auto; }
.pr-figs .pr-fig-n { display: none; }
.pr-figs .pr-fig-n svg { max-width: 440px; }
@media (max-width: 600px) {
  .pr-figs .pr-fig-w { display: none; }
  .pr-figs .pr-fig-n { display: block; }
}
.pr-figs .pr-fig { cursor: zoom-in; }
/* the caption under the drawing, as wide as the drawing */
.pr-figs + .pr-fig-cap { max-width: 720px; margin-inline: auto; }

/* The button that opens the drawing: beside its top-right corner where the page has room for it there; over the
   corner of a phone's drawing, which keeps that corner clear for it; and above the corner of a wide drawing that
   fills a narrower page, which does not. */
.pr-figs > .fv-enlarge {
  position: absolute;
  z-index: 1;
  top: 0;
  right: max(0px, (100cqw - 720px) / 2 - 52px);
  border: 1px solid var(--line);
  background: var(--panel);
}
@container (max-width: 823px) {
  .pr-figs > .pr-fig:not(.pr-fig-n) { padding-top: 52px; }
}
.fv-enlarge { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; color: var(--muted); cursor: pointer; }
.fv-enlarge svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.pr-figs > .fv-enlarge:hover { color: var(--rubric); border-color: var(--rubric); }
.fv-enlarge:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tb-zoom .fv-enlarge:focus-visible { outline-offset: -3px; }
@media print { .fv-enlarge { display: none; } .pr-figs > .pr-fig { padding-top: 0 !important; } }

/* ---- the viewer ---- */
html.fv-open { overflow: hidden; }
dialog.fv {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  line-height: 1.45;
}
dialog.fv[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
dialog.fv::backdrop { background: var(--overlay); }

.fv-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(20px, env(safe-area-inset-left));
  background: var(--panel);
  border-bottom: 3px double var(--press);
}
.fv-head { flex: 1; min-width: 0; }
.fv-kicker { margin: 0; font-family: var(--caps); font-size: 0.82rem; letter-spacing: 0.12em; line-height: 1.2; color: var(--rubric); }
.fv-kicker:empty { display: none; }
.fv-title { margin: 1px 0 0; font-family: var(--display); font-weight: 400; font-size: 1.4rem; line-height: 1.15; }
.fv-close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--rule);
  background: none;
  color: var(--ink);
  font-family: var(--sym);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.fv-close:hover { color: var(--rubric); border-color: var(--rubric); }

/* the drawing: its size is set in pixels (js/figure-view.js) inside a box that scrolls; one finger scrolls it, and two
   are the script's to pinch with */
.fv-stage { position: relative; min-width: 0; min-height: 0; }
.fv-canvas { position: absolute; inset: 0; overflow: auto; cursor: grab; overscroll-behavior: contain; touch-action: pan-x pan-y; }
.fv-canvas.dragging { cursor: grabbing; user-select: none; }
/* (room beneath the drawing for the zoom buttons, so that none of it need lie under them) */
.fv-sheet { display: grid; place-items: center; box-sizing: border-box; width: max-content; min-width: 100%; min-height: 100%; padding: 12px 12px 66px; }
.fv-art[hidden] { display: none; }
.fv-art svg { display: block; max-width: none; }

.fv-zoom {
  position: absolute;
  z-index: 2;
  right: max(14px, env(safe-area-inset-right));
  bottom: 14px;
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--rule);
  box-shadow: 0 4px 14px var(--shadow);
}
.fv.no-cap .fv-zoom { bottom: calc(14px + env(safe-area-inset-bottom)); }
.fv-zoom button {
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--caps);
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.fv-zoom button + button { border-left: 1px solid var(--rule); }
.fv-zoom button:hover { color: var(--rubric); }
.fv-close:focus-visible, .fv-zoom button:focus-visible, .fv-cap > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fv.keyed .fv-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
.fv:not(.keyed) .fv-canvas:focus-visible { outline: none; }

/* a wide drawing on a phone held upright: a word to turn it */
.fv-turn {
  display: none;
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 50%;
  translate: -50% 0;
  margin: 0;
  padding: 5px 12px;
  background: var(--panel);
  border: 1px solid var(--rule);
  box-shadow: 0 4px 14px var(--shadow);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}
@media (orientation: portrait) and (pointer: coarse) and (max-width: 600px) { .fv-turn:not([hidden]) { display: block; } }

/* the caption, folded under the drawing */
.fv-cap { background: var(--panel); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); }
.fv-cap[hidden] { display: none; }
.fv-cap > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 max(20px, env(safe-area-inset-left));
  font-family: var(--caps);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--rubric);
  cursor: pointer;
  list-style: none;
}
.fv-cap > summary::-webkit-details-marker { display: none; }
.fv-cap > summary::before { content: "›"; font-family: var(--sym); font-size: 1.2rem; line-height: 1; transition: rotate 160ms ease; }
.fv-cap[open] > summary::before { rotate: 90deg; }
.fv-cap-b { max-width: 46rem; max-height: 32vh; overflow: auto; margin: 0; padding: 0 max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left)); color: var(--muted); font-size: 0.92rem; font-style: italic; }

/* a phone held sideways: the bar as low as its buttons */
@media (max-height: 500px) {
  .fv-bar { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .fv-kicker { display: none; }
  .fv-title { font-size: 1.1rem; }
  .fv-cap > summary { min-height: 40px; }
}
@media (max-width: 780px) {
  .fv-bar { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); gap: 10px; }
  .fv-title { font-size: 1.15rem; }
  .fv-kicker { font-size: 0.74rem; }
  .fv-zoom { right: max(8px, env(safe-area-inset-right)); bottom: 8px; }
  .fv.no-cap .fv-zoom { bottom: calc(8px + env(safe-area-inset-bottom)); }
}
