/* ==========================================================================
   Gallery — the pictures on a task, side by side
   ========================================================================== */
/* The column is stated as minmax(0,1fr) rather than left implicit: an implicit
   column takes the width of its widest child, so on a phone the header's chips
   made the whole grid wider than the window and everything under it — picture,
   document, strip — hung off the right edge. */
.gallery {
  position: fixed; inset: 0; z-index: 200; background: rgba(12,12,14,.92);
  display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr);
  gap: 10px; padding: 14px;
}
body.gal-open { overflow: hidden; }

.gal-top { display: flex; align-items: center; gap: 12px; color: #fff; min-width: 0; }
/* a floor, not zero: with everything else in the row allowed to claim its width
   first, the file name was squeezed out of existence on a narrow screen */
.gal-meta { min-width: 104px; flex: 1 1 104px; display: flex; flex-direction: column; }
.gal-name {
  font-size: 14.5px; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.gal-sub { font-size: 12.5px; color: rgba(255,255,255,.6); }
.gal-btn {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff;
  cursor: pointer; font-size: 16px; text-decoration: none;
}
.gal-btn:hover { background: rgba(255,255,255,.22); }

/* The picture is positioned rather than laid out: as a plain grid item its
   max-height:100% resolved against an auto height, so a portrait image kept its
   full size and ran over the thumbnail strip. Absolute inside a sized box
   resolves the percentage against something real. */
.gal-stage { position: relative; min-height: 0; grid-column: 1 / -1; }
.gal-stage img {
  position: absolute; inset: 0; margin: auto;
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; display: block;
  border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}

/* A document gets the whole stage rather than being centred at its own size —
   and keeps clear of the arrows, which would otherwise sit on the page and on
   the reader's own scrollbar. */
/* The width is stated rather than left to left+right: an iframe is a replaced
   element, and a replaced box with width:auto takes its intrinsic 300px and
   drops the right edge on the floor. */
.gal-pdf {
  position: absolute; top: 0; bottom: 0; left: 62px;
  width: calc(100% - 124px); height: 100%;
  border: 0; border-radius: 8px; background: #fff;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
/* nothing to step through, no arrows to avoid */
.gal-stage.solo .gal-pdf { left: 0; width: 100%; }
@media (max-width: 640px) {
  .gal-pdf { left: 42px; width: calc(100% - 84px); }
  .gal-stage.solo .gal-pdf { left: 0; width: 100%; }
}

.gal-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 64px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.10); color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer;
}
.gal-nav:hover { background: rgba(255,255,255,.2); }
.gal-nav.prev { left: 14px; }
.gal-nav.next { right: 14px; }

.gal-strip {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px;
  scrollbar-width: thin; justify-content: safe center;
}
.gal-thumb {
  flex: none; width: 72px; height: 54px; padding: 0; border: 2px solid transparent;
  border-radius: 8px; overflow: hidden; background: rgba(255,255,255,.08);
  cursor: pointer; line-height: 0;
}
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: .65; }
.gal-thumb:hover img { opacity: .9; }
.gal-thumb.on { border-color: var(--accent); }
.gal-thumb.on img { opacity: 1; }

/* a document has no picture of itself — the mark and the name do the telling */
.gal-doc {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; width: 100%; height: 100%; padding: 4px 3px;
  color: rgba(255,255,255,.7); line-height: 1.1;
}
.gal-thumb:hover .gal-doc, .gal-thumb.on .gal-doc { color: #fff; }
.gal-doc-name {
  font-size: 8.5px; font-weight: 600; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 640px) {
  .gal-nav { width: 36px; height: 52px; font-size: 22px; }
  .gal-thumb { width: 58px; height: 44px; }
}

/* where the file came from, and a link straight to it — it gives way before the
   buttons do, since those are the way out */
.gal-task {
  flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; max-width: 40%;
  border: 0; background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  border-radius: 10px; padding: 7px 12px; font: inherit; font-size: 13px;
}
.gal-task:hover { background: rgba(255,255,255,.22); }
.gal-task-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-task-ws { flex: none; font-size: 11.5px; color: rgba(255,255,255,.6); }
@media (max-width: 640px) { .gal-task { max-width: 45%; } .gal-task-ws { display: none; } }

/* who uploaded it, in the large view */
.gal-by {
  flex: none; display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.85);
  font-size: 13px; background: rgba(255,255,255,.10); border-radius: 10px; padding: 6px 12px 6px 6px;
}
.gal-av {
  flex: none; width: 24px; height: 24px; border-radius: 50%; overflow: hidden;
  background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center;
}
.gal-av img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 700px) { .gal-by span:last-child { display: none; } .gal-by { padding: 6px; } }
/* On a phone the row runs out of space. What goes is the information — who
   uploaded it, which the card you came from already said — and what stays is
   the thing you can act on: the way back to the task. */
@media (max-width: 560px) { .gal-by { display: none; } .gal-task { min-width: 84px; } }
