/* The markup is emitted by Post::Renderer#still_html, not a template, and driven by
   image_modal_controller.js; the frame follows the landing page's screencast carousel so a still
   and a clip read as the same kind of beat in a body. */
.c-postfigure {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  /* No margin: the air around a still is the article's to set, and 08-pages/_article.css sets the
     same for a screencast. */
}

.c-postfigure__frame {
  display: block;
  width: 100%;
  /* Air between the border and the image, so the frame reads as a mount rather than as a crop of
     the screenshot's own edge. */
  padding: var(--space-2xs);
  border: 2px solid var(--rule);
  border-radius: 4px;
  background: var(--field);
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
  transition: border-color 0.2s ease;
}
.c-postfigure__frame:hover { border-color: var(--accent); }
.c-postfigure__frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.c-postfigure__image {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface-sunken);
}

/* The carousel puts this affordance in its titlebar; a still has none, so it sits over the
   image's own corner. */
.c-postfigure__expand {
  position: absolute;
  inset-block-start: var(--space-2xs);
  inset-inline-end: var(--space-2xs);
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  background: var(--panel);
  color: var(--gray-muted);
  font-size: var(--text-sm);
  line-height: 1;
  transition: color 0.2s ease;
}
.c-postfigure__frame:hover .c-postfigure__expand,
.c-postfigure__frame:focus-visible .c-postfigure__expand { color: var(--gray-bright); }

.c-postfigure__caption {
  min-width: 0;
  margin: 0;
  color: var(--text-dim);
  font-size: var(--text-sm);
  line-height: var(--lh-copy);
  text-align: left;
}

.c-postfigure__dialog {
  width: min(92vw, 1400px);
  max-width: 92vw;
  max-height: 90vh;
  margin: auto; /* the reset's `* { margin: 0 }` reaches a dialog and would pin it to the corner */
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
}
.c-postfigure__dialog::backdrop { background: rgba(0, 0, 0, 0.8); }

.c-postfigure__dialog-window {
  position: relative;
  padding: var(--space-2xs);
  border: 2px solid var(--rule);
  border-radius: 4px;
  background: var(--field);
  overflow: hidden;
}
.c-postfigure__dialog-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(90vh - 5rem);
  object-fit: contain;
  background: var(--surface-sunken);
}
.c-postfigure__dialog-caption {
  padding-block-start: var(--space-xs);
  color: var(--text-dim);
  font-size: var(--text-xs);
  line-height: var(--lh-copy);
}
.c-postfigure__close {
  position: absolute;
  inset-block-start: var(--space-xs);
  inset-inline-end: var(--space-xs);
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border: none;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--gray-muted);
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.c-postfigure__close:hover {
  background: rgba(0, 0, 0, 0.85);
  color: var(--gray-bright);
}
.c-postfigure__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  color: var(--gray-bright);
}

@media (prefers-reduced-motion: reduce) {
  .c-postfigure__frame,
  .c-postfigure__expand,
  .c-postfigure__close { transition: none; }
}
