/* link_tile: a card in a tile collection (LinkTileHelper, blocks/link_tiles.js).
   It is the image grid's detail card (blocks/image_grid.css) with a cover well
   the cover fills, or a quiet placeholder when there is no cover. The title
   is the card's link, in the text colour. The list lines up with the page
   header, so its edges sit on the content's gutter instead of the gap. */
.link_tiles {
  --image-well-ratio: 3 / 2;
  --image-content-inset: var(--image-gap);
}

/* Website screenshots are 16:10. */
.link_tiles.link_tiles_screenshots {
  --image-well-ratio: 16 / 10;
}

/* Video posters are 16:9 (a video set and video search results). */
.link_tiles.video_tiles {
  --image-well-ratio: 16 / 9;
}

.images_detail_view.link_tiles .image_detail :is(img, .link_tile_placeholder) {
  object-fit: cover;
  aspect-ratio: var(--image-well-ratio);
}

.link_tile_cover {
  display: block;
}

/* A screenshot showing its page live fills the cover as its picture does
   (websites/live_screenshots). */
.link_tile_cover .website_screenshot_live {
  display: block;
}

/* An overlay (a video's play badge) shows over the cover and takes no
   clicks: they reach the cover's link beneath. */
.link_tile_overlay {
  display: contents;
  pointer-events: none;
}

/* No cover yet: the empty state's quiet glyph in a muted well. */
.link_tile_placeholder {
  --link-tile-glyph: var(--ui-icon-newspaper);

  display: grid;
  place-items: center;
  width: 100%;
  color: var(--color-text-muted);
  font: var(--ui-icon-weight) calc(var(--ui-icon-size) * 2) / 1 var(--ui-icon-font-family);
  background-color: var(--color-surface-muted);
}

.link_tile_placeholder[data-icon='comments'] {
  --link-tile-glyph: var(--ui-icon-comments);
}

.link_tile_placeholder[data-icon='globe'] {
  --link-tile-glyph: var(--ui-icon-globe);
}

.link_tile_placeholder[data-icon='images'] {
  --link-tile-glyph: var(--ui-icon-images);
}

.link_tile_placeholder[data-icon='film'] {
  --link-tile-glyph: var(--ui-icon-film);
}

.link_tile_placeholder::before {
  content: var(--link-tile-glyph) var(--ui-icon-alt,);
}

/* The title is the card's link. The card clips its content, so the focus
   ring sits inside the link. */
.images_detail_view.link_tiles .link_tile .line.title {
  color: var(--color-text);
}

.images_detail_view.link_tiles .link_tile .line.title:hover {
  text-decoration: underline;
}

.images_detail_view.link_tiles .link_tile .line.title:focus-visible {
  outline: 2px solid var(--color-input-focus-border);
  outline-offset: -2px;
}

/* The menu button is taller than the title's line, so both are centred on
   their row. */
.images_detail_view.link_tiles .link_tile :is(.line.title, .line.actions) {
  align-self: center;
}

/* A status (a video's missing thumbnail) reads at the size of the facts
   beside it. */
.images_detail_view.link_tiles .link_tile .row .block_status {
  font-size: inherit;
}

/* A collection (link_tile(stack:)): two cards show above the tile, each a
   little narrower, so it reads as a stack, within the row gap. */
.link_tiles .item:has(> .link_tile_prints) {
  --link-tile-stack-step: max(var(--ui-space-2), calc(var(--image-gap) * 0.4));

  position: relative;
  isolation: isolate;
}

.link_tile_prints {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.link_tile_print {
  position: absolute;
  inset: 0;
  background-color: var(--color-surface-muted);
  border: 1px solid var(--color-image-border);
  box-shadow: 0 1px 2px var(--color-shadow-muted);
  border-radius: var(--ui-radius-surface);
  transform-origin: 50% 0;
}

.link_tile_print[data-print='1'] {
  transform: translateY(calc(var(--link-tile-stack-step) * -1)) scaleX(0.96);
}

.link_tile_print[data-print='2'] {
  background-color: var(--color-surface-soft);
  transform: translateY(calc(var(--link-tile-stack-step) * -2)) scaleX(0.92);
}

/* A collection's name reads larger than one thing's. */
.images_detail_view.link_tiles .link_tile[data-stack] .line.title {
  font-size: var(--ui-font-size-lead);
}

/* A collection's cover with the next things' pictures, each in a cell,
   split by hairlines. A magazine: the cover takes two thirds, the next two
   share the last third. A film strip: the cover over a dark strip of four
   16:9 frames. While the tile is pointed at, a frame's next picture fades in
   over the last (blocks/link_tile_mosaic). */
.link_tile_mosaic {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: calc(var(--ui-space-unit) / 2);
  aspect-ratio: var(--image-well-ratio);
  background-color: var(--color-image-background);
}

.link_tile_mosaic[data-layout='magazine'] > .link_tile_cell:first-child,
.link_tile_mosaic[data-layout='magazine'][data-pictures='2'] > .link_tile_cell:last-of-type {
  grid-row: span 2;
}

.link_tile_mosaic[data-layout='film_strip'] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr) auto;
  padding-block-end: var(--ui-space-1);
  background-color: var(--color-video-embed-background);
}

.link_tile_mosaic[data-layout='film_strip'] > .link_tile_cell:first-child {
  grid-column: 1 / -1;
}

.link_tile_mosaic[data-layout='film_strip'] > .link_tile_cell:not(:first-child) {
  aspect-ratio: 16 / 9;
}

.link_tile_cell {
  position: relative;
  display: block;
  min-height: 0;
  overflow: hidden;
}

.images_detail_view.link_tiles .link_tile_mosaic .link_tile_cell img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: auto;
}

.link_tile_leaf {
  opacity: 0;
  transition: opacity calc(var(--ui-duration-reveal) * 3) var(--ui-ease-reveal);
}

.link_tile_leaf.link_tile_leaf_shown {
  opacity: 1;
}

/* The count rides on the cover over a scrim, in the colours that are the
   same in both themes for anything drawn over a photo. It takes no clicks. */
.link_tile_stack_count {
  position: absolute;
  inset-block-end: var(--ui-space-2);
  inset-inline-end: var(--ui-space-2);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-1);
  padding: var(--ui-space-1) var(--ui-space-2);
  color: var(--color-media-overlay-text);
  font-size: var(--ui-font-size-small);
  font-weight: var(--ui-weight-medium);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  background-color: var(--color-media-overlay-scrim-strong);
  border-radius: var(--ui-radius-control);
}

.link_tile_stack_count::before {
  font-family: var(--ui-icon-font-family);
  font-weight: var(--ui-icon-weight);
  content: var(--ui-icon-layer-group) var(--ui-icon-alt,);
}

/* On a film strip the count sits on the cover's top corner, clear of the
   frames. */
.image_detail:has(.link_tile_mosaic[data-layout='film_strip']) .link_tile_stack_count {
  inset-block: var(--ui-space-2) auto;
}

/* A word that sets the tile apart (link_tile(flag:), a featured post). It
   sits on the cover's top corner with a star, over the media scrim like the
   stack's count, and takes no clicks. */
.link_tile_flag {
  position: absolute;
  inset-block-start: var(--ui-space-2);
  inset-inline-start: var(--ui-space-2);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-1);
  padding: var(--ui-space-1) var(--ui-space-2);
  color: var(--color-media-overlay-text);
  font-size: var(--ui-font-size-small);
  font-weight: var(--ui-weight-medium);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  background-color: var(--color-media-overlay-scrim-strong);
  border-radius: var(--ui-radius-control);
}

.link_tile_flag::before {
  font-family: var(--ui-icon-font-family);
  font-weight: var(--ui-icon-weight);
  content: var(--ui-icon-star) var(--ui-icon-alt,);
}

