/* The viewer (js/recipient-lightbox.js): a full-screen dark frame with
   the picture, or the video, fit to it. Loaded after recipient.css. A
   near-black grey in both themes (--viewer), taken from the tokens app.css
   keeps identical in light and dark. The picture has no radius: here it
   is the page. Controls are rounded squares on a lighter grey
   (--viewer-surface). The viewer fades in (180ms); each new picture fades
   in over the last.

     12 of 205                                              [x]
     [<]              [ the picture, fit to the screen ]     [>]
     IMG_0412.jpg  4 MB          [ ] Select  [Download this file]

   While the larger preview is made, the grid's thumbnail stands in under a
   quiet line (.rc-lb-note).

   The producer's words sit under the picture, over the footer: the note
   as a caption, the tags as small labels (.rc-lb-about). Nothing there is
   pressed; a long note scrolls inside its own box so the footer and its
   buttons never leave the screen.

   The carets are there at every width whenever the viewer holds more than
   one file: beside the picture on a wide window, over its edges, on the
   --veil, on a narrow one (a swipe works too). At an end the caret is
   disabled and dim, not removed. The footer stacks on a phone.

   Where to look next: the tokens used here are app.css's :root, plus the
   few numbers only the viewer has, in the block below. */

:root {
  --viewer-layer: 60;                /* over sheets (50), under the toast (90) */
  --viewer-press-scale: .96;         /* a pressed control sinks a little */
  --viewer-hover-mix: 22%;           /* how much white a hovered control gets */
  --viewer-primary-hover-mix: 86%;   /* the white Download button, hovered */
  --viewer-ring: 2px;                /* the focus ring, on the dark grey */
  --viewer-placeholder-opacity: .7;  /* the blurred thumbnail is "not final" */
  --viewer-disabled-opacity: .4;     /* a caret with no neighbour left */
  --viewer-card-width: 28rem;        /* the file card's text never runs wider */
  --viewer-card-tile: 12rem;         /* the extension tile on the card */
}

html.rc-modal-open { overflow: hidden; }

.rc-lb {
  position: fixed;
  inset: 0;
  z-index: var(--viewer-layer);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--viewer);
  color: var(--on-photo);
  animation: fade var(--dur) var(--ease-out);
  /* The buttons here (button.css) on the viewer's grey: ink is dark in the
     light theme, and on the viewer the primary is white; the bite of its
     fold shows the grey; the keyboard ring is white, as the carets'. */
  --btn-ground: var(--viewer);
  --btn-action: var(--on-photo);
  --btn-on-action: var(--photo-ink);
  --btn-action-hover: color-mix(in srgb, var(--on-photo) var(--viewer-primary-hover-mix), var(--viewer));
  --btn-ring: var(--on-photo);
}

.rc-lb-top,
.rc-lb-foot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.rc-lb-top { justify-content: space-between; }
.rc-lb-count { font-size: var(--text-ui); color: var(--viewer-mute); }

.rc-lb-button {
  display: grid;
  place-items: center;
  width: var(--control-l);
  height: var(--control-l);
  border: 0;
  border-radius: var(--radius-l);
  background: var(--viewer-surface);
  color: var(--on-photo);
  cursor: pointer;
  /* The press is a button's 100ms (button.css), written out because no
     duration token is that short. */
  transition: background-color var(--dur-fast) var(--ease-out), transform 100ms var(--ease-out);
}
.rc-lb-button:hover:not(:disabled) { background: color-mix(in srgb, var(--on-photo) var(--viewer-hover-mix), var(--viewer-surface)); }
.rc-lb-button:active:not(:disabled) { transform: scale(var(--viewer-press-scale)); }
.rc-lb-button:disabled { opacity: var(--viewer-disabled-opacity); cursor: default; }
.rc-lb-button:focus-visible,
.rc-lb-choose:focus-within {
  outline: var(--viewer-ring) solid var(--on-photo);
  outline-offset: var(--viewer-ring);
}
.rc-lb-button svg { width: var(--icon-l); height: var(--icon-l); }

/* --- the stage ---------------------------------------------------------- */

.rc-lb-stage {
  display: grid;
  grid-template-columns: var(--control-l) minmax(0, 1fr) var(--control-l);
  align-items: center;
  grid-template-rows: minmax(0, 1fr);
  gap: var(--space-3);
  min-height: 0;
  padding: 0 var(--space-4);
}
.rc-lb-prev { grid-column: 1; }
.rc-lb-next { grid-column: 3; }

/* Explicit columns: a hidden arrow (first or last photo) must not slide the
   frame into its narrow column. */
.rc-lb-frame {
  grid-column: 2;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
}
/* Filling the frame with object-fit keeps any picture inside it: a
   max-height in percent resolves against content here, and the footer
   would go under it. */
.rc-lb-image,
.rc-lb-video,
.rc-lb-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* The thumbnail stands in, enlarged: blurred so its few pixels read as
   "not final" rather than as a poor picture. */
.rc-lb-placeholder {
  filter: blur(var(--space-2));
  opacity: var(--viewer-placeholder-opacity);
  animation: fade var(--dur) var(--ease-out);
}
/* The preview fades in over it (keyframes in components.css; with reduced
   motion app.css switches the animation off and the swap is instant). */
.rc-lb-image { animation: fade var(--dur-slow) ease-out; }

/* One quiet line over the foot of the picture: "Preparing a larger
   preview..." and, after three minutes, that it is still being prepared. */
.rc-lb-note {
  position: absolute;
  inset-inline: 0;
  bottom: var(--space-3);
  width: fit-content;
  max-width: calc(100% - var(--space-4) * 2);
  margin: 0 auto;
  padding: var(--space-1h) var(--space-3);
  border-radius: var(--radius-control);
  background: var(--veil);
  color: var(--on-photo);
  font-size: var(--text-ui);
  text-align: center;
}

/* The size, and for a PDF that its picture is page 1 only, on one line. */
.rc-lb-sub { display: flex; flex-wrap: wrap; column-gap: var(--space-2); }
/* The dot is for the eye: the second declaration gives it an empty spoken
   text, and a browser that does not know that syntax keeps the first. */
.rc-lb-page-note::before {
  content: "\00b7";
  content: "\00b7" / "";
  margin-inline-end: var(--space-2);
}
/* On a phone a longer note ("Too large to preview, download to watch")
   wraps under the size and its dot would start the line. There the note
   takes a line of its own and the dot goes. */
@media (max-width: 520px) {
  .rc-lb-sub { flex-direction: column; }
  .rc-lb-page-note::before { content: none; }
}

/* A file with no picture: the extension tile, its name, a line of help. */
.rc-lb-card {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  max-width: var(--viewer-card-width);
  text-align: center;
}
.rc-lb-card .tile { width: var(--viewer-card-tile); background: var(--viewer-surface); }
.rc-lb-card .up-generic { background: none; }
.rc-lb-card .up-generic svg,
.rc-lb-card .up-generic b { color: var(--on-photo); }
.rc-lb-card-title { margin: var(--space-2) 0 0; max-width: 100%; font-weight: 500; overflow-wrap: anywhere; }
.rc-lb-card .s { margin: 0; color: var(--viewer-mute); }

/* --- the producer's words ------------------------------------------------- */

.rc-lb-about {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-4) 0;
}
.rc-lb-caption {
  margin: 0;
  max-height: 20vh;
  overflow: auto;
  max-width: 72ch;
  font: 400 var(--text-ui)/20px var(--font-sans);
  white-space: pre-line;
  overflow-wrap: anywhere;
  unicode-bidi: isolate; /* the producer's note: see .tag in app.css */
}
/* The base focus ring is the accent; the viewer's controls use white. */
.rc-lb-caption:focus-visible { outline: 2px solid var(--on-photo); outline-offset: 2px; }
.rc-lb-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.rc-lb-tags:empty { display: none; }
.rc-lb-tag {
  max-width: 100%;
  height: 24px;
  padding: 0 var(--space-2);
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--viewer-surface);
  color: var(--on-photo);
  font: 500 var(--text-m)/24px var(--font-sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- the footer ----------------------------------------------------------- */

.rc-lb-foot { flex-wrap: wrap; }
.rc-lb-meta { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.rc-lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.rc-lb-meta .s { color: var(--viewer-mute); }

/* Select is a button-sized control on the viewer's grey; chosen, it fills
   with the accent, the same signal as the tile's check. */
.rc-lb-choose {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control);
  padding: 0 var(--space-4) 0 var(--space-3);
  border-radius: var(--radius-control);
  background: var(--viewer-surface);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur-fast);
}
.rc-lb-choose:has(input:checked) { background: var(--accent); color: var(--on-accent); }
.rc-lb-choose input { border-color: var(--on-photo); background-color: transparent; }
.rc-lb-choose input:checked { border-color: var(--on-photo); }

@media (max-width: 820px) {
  .rc-lb-stage { position: relative; grid-template-columns: minmax(0, 1fr); padding: 0; }
  .rc-lb-frame { grid-column: 1; }
  /* Two 44 px columns would take a third of a phone's width from the
     picture, so the carets sit over its edges, on the veil. */
  .rc-lb-prev,
  .rc-lb-next {
    position: absolute;
    grid-column: 1;
    inset-block: 0;
    z-index: 1;               /* the frame is positioned too, and comes after the Previous caret */
    margin-block: auto;
    background: var(--veil);
  }
  .rc-lb-prev { left: var(--space-2); }
  .rc-lb-next { right: var(--space-2); }
  .rc-lb-foot .btn { flex: 1 1 100%; }
}
