/* The client's page (js/recipient*.js): the producer's photos as a
   gallery on the paper, and the states around it (loading, a link that
   doesn't work, a load error). Loaded by index.html after uploads.css,
   whose tile classes it reuses: .wgrid.up-grid .up-cell .up-tile
   .up-thumb .up-generic .up-cap .up-name .up-check. The toolbar and chips
   are in recipient-toolbar.css, the download bar in recipient-bar.css, the
   list view in recipient-list.css, the download panel in
   recipient-download.css, the photo viewer in recipient-lightbox.css.

   The page, top to bottom (up to 1440 wide, no card):

     [S] Studio Lindgren  sent you files
     Wedding, 12 September                      205 files, 48.2 GB
     (serif, 56)                                Saving to Drive ... is coming.
     ----------------------------------------------------------------------
     [Select all|none|Invert]         (Search files) [Sort v] [Grid|List]
     [x Photos 180] [ Videos 12] [ RAW 10]  [x Ceremony 90] ...
     [photo][photo][photo][photo][photo]      12px gutters, no captions:
     [photo][photo][photo][photo][photo]      the name shows on hover
            [ (3 thumbs) 12 selected, 240 MB   Clear  Download 12 files ]
                        Sent with (mark) Theirway

   A tile:  .rc-media  [ (check)                     ]   chosen: the photo
                       [                             ]   steps in on an
                       [ name label        (download)]   accent matte */

:root {
  --rc-tile: 210px;         /* narrowest a tile may get on a wide screen */
  --rc-gap: 12px;
  --rc-cell-height: 164px;  /* measured at 1360px: a tile, no caption; held for tiles skipped off screen */
  --rc-row-height: 57px;    /* measured: one row of the list view */
  --rc-check-hit: var(--space-2);  /* padding round the check, which is its tap target */
  --rc-dl-reach: 6px;       /* how far the download button's tap reaches past its 32px square */
  --rc-list-thumb: 56px;
}

@media (max-width: 520px) {
  :root {
    --rc-gap: 6px;
    --rc-cell-height: 118px;  /* measured at 390px: two columns */
    --rc-list-thumb: 48px;
  }
}

@media (pointer: coarse) {
  :root { --rc-check-hit: var(--space-3); }
}

/* --- the page --------------------------------------------------------- */

.rv.rv-files { padding: var(--space-7) var(--space-6); }

.rcard.rc-files { max-width: 1440px; margin-top: 0; padding: 0; }

/* The title block: who sent it and what it is on the left, the size and
   the rails on the right, on one baseline; a hairline closes it. */
.rc-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-2) var(--space-6);
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
}
.rc-head .from { grid-column: 1 / -1; margin-bottom: var(--space-3); }
.rc-files .avatar { width: 32px; height: 32px; }
.rc-files .from b { font-weight: 500; }
.rc-files .from .s { display: block; }
.rc-files h1 { font-size: var(--text-display); line-height: 1.02; letter-spacing: -.024em; }
.rc-head-side { text-align: right; padding-bottom: 6px; }

.rc-meta {
  margin: 0;
  font: 400 var(--text-xl)/24px var(--font-display);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.rc-rails { margin: var(--space-1) 0 0; color: var(--mute); }

.rc-hint { margin: 0 0 var(--space-4); }

.rc-none { margin: var(--space-6) 0; text-align: center; color: var(--ink2); }

.rc-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- the tiles -------------------------------------------------------- */

.rc-grid.wgrid.up-grid {
  grid-template-columns: repeat(auto-fill, minmax(var(--rc-tile), 1fr));
  gap: var(--rc-gap);
}

/* A tile costs nothing to draw until it is near the screen. The bar's
   height is kept clear, so Tab never leaves a tile under it. */
.rc-cell {
  position: relative;
  contain-intrinsic-block-size: auto var(--rc-cell-height);
  scroll-margin-bottom: calc(var(--space-8) + var(--space-5));
}

/* No lift on hover: .up-cell's content-visibility contains paint, which
   would clip a shadow or a raised edge at the cell. Hover is told by what
   appears on the picture instead: the check, the name, the download. */
.rc-media { position: relative; border-radius: var(--radius-control); }

/* The picture is a button: a click opens it or chooses it. */
.rc-link {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rc-link .up-tile { display: block; }

/* Chosen: the photo steps in (scale .9, 180ms; its corner radius snaps,
   since the picture animates only its transform and opacity) onto an
   accent matte and the tile is ringed in the accent. Nothing covers or
   tints the picture. Focus adds its own ring outside the choice. */
.rc-cell .up-tile { transition: background-color var(--dur) var(--ease-out); }
.rc-cell .up-thumb,
.rc-cell .up-generic { transition: transform var(--dur) var(--ease-out), opacity var(--dur); }
.rc-cell.is-selected .up-tile { background: var(--accent-tint); }
.rc-cell.is-selected .up-thumb,
.rc-cell.is-selected .up-generic { transform: scale(.9); border-radius: var(--radius-s); }
.rc-cell .rc-link:focus-visible { outline: 0; }
.rc-cell .up-tile::after { z-index: 1; transition: box-shadow var(--dur) var(--ease-out); }
.rc-cell.is-selected .up-tile::after { box-shadow: inset 0 0 0 2px var(--accent); }
.rc-link:focus-visible .up-tile::after { box-shadow: inset 0 0 0 2px var(--focus), inset 0 0 0 4px var(--on-photo); }
.rc-cell.is-selected .rc-link:focus-visible .up-tile::after {
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 4px var(--on-photo), inset 0 0 0 6px var(--focus);
}

/* In the grid the caption is the name only, as a label over the foot of
   the picture that appears with the pointer or focus. The size is in the
   list view and the viewer. */
.rc-grid:not(.rc-list) .rc-cell .up-cap {
  position: absolute;
  left: var(--space-2);
  bottom: var(--space-2);
  z-index: 2;
  max-width: calc(100% - 56px);
  padding: 2px 6px;
  border-radius: var(--radius-s);
  background: var(--veil);
  color: var(--on-photo);
  font-size: var(--text-xs);
  line-height: 16px;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  pointer-events: none;
}
.rc-grid:not(.rc-list) .rc-cell:hover .up-cap,
.rc-grid:not(.rc-list) .rc-cell:focus-within .up-cap { opacity: 1; transform: none; }
.rc-grid:not(.rc-list) .up-cap .up-name { color: var(--on-photo); font-weight: 500; }
.rc-grid:not(.rc-list) .up-cap .s { display: none; }
.up-cap .up-name { min-width: 0; font-weight: 400; color: var(--ink); }
.up-cap .s { flex: none; }
.rc-where { display: none; }

.rc-cell .up-generic { align-content: center; justify-items: center; gap: var(--space-1); }
.rc-cell .up-generic svg { width: var(--icon-l); height: var(--icon-l); color: var(--mute); }

/* The real checkbox, at the picture's corner. The input is there for
   screen readers and labels; the rounded square is what is seen.
   upload-tiles.css hides it until hover while nothing is chosen, and never on
   touch. */
.rc-check {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: grid;
  padding: var(--rc-check-hit);
  cursor: pointer;
}
.rc-check .up-check { position: static; }
.rc-tick {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

/* The download button: a hint on hover, always there without a hover. */
.rc-dl {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  z-index: 3;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  background: var(--veil);
  color: var(--on-photo);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out), background-color var(--dur-fast);
}
.rc-dl:hover { background: var(--photo-ink); }
.rc-dl svg { width: 16px; height: 16px; }
.rc-cell:hover .rc-dl,
.rc-cell:focus-within .rc-dl { opacity: 1; }
.rc-dl:focus-visible { outline: 2px solid var(--on-photo); outline-offset: 2px; }
.rc-dl::after { content: ""; position: absolute; inset: calc(-1 * var(--rc-dl-reach)); }
@media (hover: none) { .rc-dl { opacity: 1; } }

/* --- show more, the footer ---------------------------------------------- */

.rc-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
}
.rc-more:empty { display: none; }
.rc-more p { margin: 0; }
.rc-more .s { color: var(--ink2); }

.rc-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1h);
  margin: var(--space-7) 0 0;
  font-size: var(--text-s);
  line-height: 16px;
  color: var(--mute);
}
.rc-foot .mark { width: 16px; height: 16px; }
.rc-foot a { color: inherit; }  /* keeps the footer quiet; the underline and the focus ring are the page's own */

/* --- loading, a link that doesn't work, a load error -------------- */

.rc-loading { margin: var(--space-4) 0; color: var(--ink2); }
.rc-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--rc-tile), 1fr));
  gap: var(--rc-gap);
}
.rc-skeleton i {
  display: block;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-control);
  background: var(--sunken);
}

.rc-dead-icon { display: block; margin-bottom: var(--space-4); color: var(--mute); }
.rc-dead-icon svg { width: 32px; height: 32px; }
.rc-dead p { margin: var(--space-3) 0 0; max-width: 34ch; font-size: var(--text-l); line-height: 24px; color: var(--ink2); }
.rc-dead .btn { margin-top: var(--space-5); }

/* The sender deleted the delivery (js/recipient-gone.js): who it was, one
   serif line, what happened and who to ask, on bare paper like the dead link
   above it, but wider for a sentence with an address in it. */
.rc-gone { max-width: 460px; }
/* a heading takes the focus so the swap is announced; it is not a control.
   .rc-dead (a link that does not work, no network) needs the rule too, or
   its heading shows a focus box on first load. */
.rc-dead h1:focus, .rc-gone h1:focus { outline: none; }
.rc-gone .from { margin-bottom: var(--space-6); }
.rc-gone .from b { font-weight: 500; overflow-wrap: anywhere; }
.rc-gone .from .s { display: block; }
.rc-gone p { margin: var(--space-3) 0 0; font-size: var(--text-l); line-height: 24px; color: var(--ink2); overflow-wrap: anywhere; }

/* --- narrow screens ---------------------------------------------------- */

@media (max-width: 820px) {
  .rv.rv-files { padding: var(--space-5) var(--space-4); }
  .rc-head { grid-template-columns: minmax(0, 1fr); padding-bottom: var(--space-4); margin-bottom: var(--space-4); }
  .rc-head-side { text-align: left; padding-bottom: 0; }
  .rc-files h1 { font-size: var(--text-display); line-height: 1.05; }
}

/* Two columns, edge to edge: the page's gutter is the only frame. */
@media (max-width: 520px) {
  .rv.rv-files { padding-inline: var(--space-3); }
  .rc-grid.wgrid.up-grid,
  .rc-skeleton {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--rc-gap);
  }
}
