/* Media, organised. The one stylesheet for the one script, /site/media-grid.js.
   These rules used to be copied into five pages, which is how a page ended up
   with the script and none of the styles. A page that loads the script loads
   this. */

/* ---- the grid ---- */
.media-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;
  border-radius:var(--m3-r-m);overflow:hidden}
.media-cell{position:relative;aspect-ratio:1;padding:0;border:0;background:var(--m3-surface-3);
  cursor:pointer;overflow:hidden;width:100%}
.media-cell img{width:100%;height:100%;object-fit:cover;display:block;transition:transform .12s ease}
/* A picture in a card is shown whole, not cropped to a square. These are
   photographs and screenshots of every shape, and a square crop of a wide
   screenshot is a slice of nothing. Asked for on 11 September 2026. */
/* A picture that has been talked about is shown whole rather than cropped, but
   it is still one thing on a page of things: half the screen each, four of them
   in a row, made the request read as a photo album with a note under it.
   16 September 2026. */
.media-card .media-cell{aspect-ratio:auto;min-height:120px;max-height:34svh;
  display:flex;align-items:center;justify-content:center;
  background:var(--m3-surface-3);padding:6px}
.media-card .media-cell img{width:auto;height:auto;max-width:100%;max-height:34svh;object-fit:contain}
.media-cell:active img{transform:scale(.97)}
.media-cell.answered::after{content:"";position:absolute;inset:auto 6px 6px auto;width:11px;height:11px;
  border-radius:50%;background:var(--m3-good);box-shadow:0 0 0 2px #fff}

/* A picture with its own footer is a card, and cards need room to breathe and
   to hold what was said under them. Rows, not columns: the number on a card is
   how a person names that picture, so 1, 2, 3 must read left to right even if
   a card that grew a long answer leaves a space beside a short one. */
.media-grid.with-feet{grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:12px;
  align-items:start;overflow:visible}
.media-card{margin:0;display:flex;flex-direction:column;min-width:0;
  border-radius:var(--m3-r-m);background:var(--m3-surface-2);overflow:hidden}
.media-card .media-cell{border-radius:0}
.media-foot{display:flex;align-items:center;gap:8px;padding:8px 10px;
  border-top:1px solid var(--m3-outline-variant)}
.media-reply{flex:1;display:inline-flex;align-items:center;justify-content:center;gap:6px;
  min-height:var(--m3-tap-small);padding:0 12px;border:1px solid var(--m3-outline);
  border-radius:var(--m3-r-full);background:transparent;color:var(--m3-on-surface-variant);
  font:600 13px/1 var(--m3-sans);cursor:pointer}
.media-reply svg{width:16px;height:16px;flex:0 0 auto;fill:none;stroke:currentColor;stroke-width:1.8;
  stroke-linecap:round;stroke-linejoin:round}
.media-reply.answered{background:var(--m3-good-container);color:var(--m3-good);border-color:transparent}
.media-card .media-note{margin:0;border-radius:0;border-left:0;
  border-top:1px solid var(--m3-outline-variant);background:var(--m3-surface-1)}

/* What is being talked about comes first, full width, with everything said
   about it underneath. The rest stay in the grid. */
.media-spoken{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px;margin:0 0 14px}
.media-card.wide{width:100%}
.media-card.wide .media-cell{max-height:60svh;padding:8px}
.media-card.wide .media-cell img{max-height:60svh}

/* How many things have been said about it, at the end of the button where a
   count belongs -- not the picture's number at the front, which told nobody
   anything. */
.media-count{margin-left:2px;min-width:20px;height:20px;display:inline-flex;align-items:center;
  justify-content:center;padding:0 6px;border-radius:var(--m3-r-full);
  background:var(--m3-good);color:#fff;font:600 11px/1 var(--m3-sans)}
.media-reply.answered .media-count{background:var(--m3-good);color:#fff}

/* ---- what is not a photograph ---- */
.media-block{margin:8px 0 0;padding:10px;border-radius:var(--m3-r-m);background:var(--m3-surface-2)}
.media-head{display:flex;align-items:center;gap:8px}
.media-head span{flex:1;min-width:0;font-size:13px;overflow-wrap:anywhere}
.media-tools{display:flex;gap:2px;margin-left:auto;flex:0 0 auto!important}
.media-block audio,.media-block video{display:block;width:100%;margin:8px 0 0}
.media-block video{max-height:40svh;border-radius:var(--m3-r-s);background:#000}

/* Pictures sent with an answer are small, and open full screen when tapped. */
.answer-media .media-grid{grid-template-columns:repeat(auto-fill,minmax(84px,1fr));gap:6px}
.answer-media .media-cell{border-radius:var(--m3-r-s)}

/* ---- the full screen viewer ---- */
.viewer{border:0;padding:0;margin:0;max-width:100vw;max-height:100dvh;background:#000;
  /* The dialog must not pan: a browser that decides a swipe down is a scroll
     cancels the gesture, and the swipe that closes the picture never lands. */
  touch-action:none;overscroll-behavior:contain}
.viewer[open]{display:block;position:fixed;inset:0;width:100vw;height:100dvh}
.viewer::backdrop{background:#000}
.viewer figure{position:absolute;inset:0;margin:0;padding:0;display:block;height:100%;touch-action:none}
.viewer img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;
  will-change:transform;touch-action:none;-webkit-user-select:none;user-select:none;
  -webkit-user-drag:none}
.viewer .viewer-next{z-index:2}
.viewer-caption{position:absolute;left:0;right:0;bottom:0;z-index:3;
  padding:16px 18px calc(18px + env(safe-area-inset-bottom));color:#fff;font-size:13px;
  background:linear-gradient(180deg,#0000,#000000b0);pointer-events:none}
.viewer-close{position:absolute;top:calc(8px + env(safe-area-inset-top));right:8px;z-index:5;
  background:#ffffff1f!important;color:#fff!important}
/* Arrows for a desktop, which has no swipe. */
.viewer-arrow{position:absolute;top:50%;transform:translateY(-50%);z-index:5;
  background:#ffffff1f!important;color:#fff!important}
.viewer-arrow.back{left:8px}
.viewer-arrow.on{right:8px}
.viewer-arrow[hidden]{display:none}
@media(hover:none)and(pointer:coarse){.viewer-arrow{display:none}}
