/* assets/ec-media.css — media figures, credit lines and the zoom viewer.
 *
 * WHY CSS-ONLY. Person, text and event pages are served under `script-src 'none'`
 * (see CLAUDE.md, Bunny edge). A JavaScript lightbox is not merely discouraged there,
 * it cannot run. So the zoom viewer is built on `:target`: the thumbnail is an anchor,
 * the overlay is a sibling that is invisible until the URL fragment names it. Same
 * technique the timeline already uses for its portrait preview panel.
 *
 * Three consequences worth keeping:
 *   - it works with no script, so it works on every page of the archive;
 *   - it survives print and PDF export, because there is no runtime state to lose;
 *   - the open image has a real URL, so a reader can link to a specific photograph.
 *
 * The overlay loads a wider file than the tile. Both are local — the archive serves
 * its own media from /media/ and no longer hotlinks upload.wikimedia.org.
 */

/* ---------- the figure grid ---------- */
.figs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 18px;
  margin: 18px 0 22px;
}
.figs figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ---------- the tile ---------- */
.figs a.tile {
  display: block;
  position: relative;
  border: 1px solid #c9c0ae;
  background: #efe9dd;
  line-height: 0;
  cursor: zoom-in;
  text-decoration: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.figs a.tile:hover,
.figs a.tile:focus-visible {
  border-color: #7d2b1f;
  box-shadow: 0 2px 10px rgba(33, 32, 28, .16);
  outline: none;
}
.figs a.tile img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: center 42%;
}

/* The magnifier is a typographic glyph, not an icon file: one character, no request,
   and it inherits the serif the rest of the page is set in.

   Written as a literal "+", not as the escape "\002B;". A CSS escape terminates at the
   first non-hex character, so the semicolon is not a delimiter — it survives as a
   second glyph and the badge reads "+;" on every tile. */
.figs a.tile::after {
  content: "+";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-family: Cinzel, Georgia, serif;
  font-size: 14px;
  line-height: 1;
  color: #f2ece0;
  background: rgba(125, 43, 31, .88);
  opacity: 0;
  transition: opacity .18s ease;
}
.figs a.tile:hover::after,
.figs a.tile:focus-visible::after { opacity: 1; }

/* ---------- the credit line ----------
   Small, quiet, and never omitted. Most photographs of ancient sites are CC-BY-SA:
   rehosting them is permitted, publishing them without author and licence is not. */
.figs figcaption {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 13.5px;
  line-height: 1.4;
  color: #6b665c;
  padding: 6px 1px 0;
  text-wrap: pretty;
}
.figs figcaption .cap { color: #4a463d; }
/* 12.5px #6b665c on the #e8e1d3 page measured 4.39:1 — under AA. It carries the author
   name, which is the part CC-BY actually requires, so it is the last text on the page
   that should be hard to read. #5f5a51 clears 5:1 at the same size. */
.figs figcaption .cred { display: block; margin-top: 2px; font-size: 12.5px; color: #5f5a51; }
.figs figcaption a {
  color: #7d2b1f;
  text-decoration: none;
  border-bottom: 1px solid rgba(125, 43, 31, .3);
}
.figs figcaption a:hover { color: #4a1810; border-bottom-color: #4a1810; }

/* ---------- the zoom viewer ---------- */
.lb {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  /* Solid, not translucent: the overlay must seal the page behind it. An rgba backdrop
     let body text read through at some zoom levels and in print preview. */
  background: #141310;
  padding: 3vh 3vw;
  overflow: hidden;
}
/* Flex, not grid: the caption is auto-height and the frame takes the rest. A grid with
   minmax(0,1fr) should do the same and did not — the track grew to its content. */
.lb:target {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

/* The backdrop is itself a close link, so clicking anywhere outside the image exits.
   The image sits above it and does not inherit the click. */
.lb-dismiss {
  position: absolute;
  inset: 0;
  display: block;
  cursor: zoom-out;
}
.lb-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  flex: 0 1 auto;
  pointer-events: none;
}
.lb-frame img {
  /* Sized against the VIEWPORT, not against a grid area. Percentage heights resolved
     against a grid track measured wrong in three different ways here (571px inside a
     394px track, then 100% of a track that grew to fit its own content). vh is
     unambiguous: 100vh less the room the caption, gap and padding need. */
  max-width: 100%;
  max-height: calc(100vh - 210px);
  width: auto;
  height: auto;
  pointer-events: auto;
  cursor: default;
}
.lb-meta {
  position: relative;
  font-family: 'EB Garamond', Georgia, serif;
  color: #d9d2c4;
  font-size: 15.5px;
  line-height: 1.5;
  max-width: 74ch;
  margin: 0 auto;
  padding-bottom: 4px;
  text-align: center;
  text-wrap: pretty;
}
.lb-meta .cred { display: block; margin-top: 4px; font-size: 13.5px; color: #a9a294; }
.lb-meta a { color: #e0b9a6; text-decoration: none; border-bottom: 1px solid rgba(224, 185, 166, .35); }
.lb-meta a:hover { color: #fff; border-bottom-color: #fff; }
.lb-close {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 2;
  font-family: Cinzel, Georgia, serif;
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #d9d2c4;
  text-decoration: none;
  border: 1px solid rgba(217, 210, 196, .4);
  padding: 6px 11px;
  background: rgba(20, 19, 16, .6);
}
.lb-close:hover { color: #fff; border-color: #fff; }

/* Printing: the overlay never prints, and every tile prints with its credit. */
@media print {
  .lb { display: none !important; }
  .figs a.tile::after { display: none; }
  .figs { grid-template-columns: repeat(2, 1fr); }
  .figs figcaption { color: #333; }
}

@media (max-width: 620px) {
  .figs { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 13px; }
  .figs a.tile img { height: 140px; }
  .lb { padding: 2vh 2vw; }
}

@media (prefers-reduced-motion: reduce) {
  .figs a.tile { transition: none; }
  .figs a.tile::after { transition: none; }
}
