/* =========================================================================
   templates/atomic/showcase/css/editorial.css

   Linked ONLY by gallery.html and article.html, after ../showcase.css.
   STRUCTURE ONLY: must pass `node tools/atomic-lint.mjs --kind=structure-paint`.
   No colour, border, background, radius, shadow or type metric lives here;
   the floor paints every surface and every style decides how it looks.

   Image cropping comes from core's .media-img hook (object-fit: cover) on the
   <img>; this file only sizes the box.

   The blockquote is deliberately left to the floor: it has no paint of its
   own yet, so here it only gets a measure and a margin.

   Sections:
     1. gallery — head, filter row, ratio-framed grid, captions, lightbox
     2. journal — head, two-column reading layout, prose flow, related row
   ========================================================================= */

/* ---- 1. gallery --------------------------------------------------------- */

.gallery-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
}
@media (min-width: 900px) {
  .gallery-head { grid-template-columns: 7fr 5fr; gap: var(--space-7); align-items: start; }
}
.gallery-head-lead {
  display: grid;
  gap: var(--space-4);
  max-inline-size: 34rem;
  min-width: 0;
}
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* THE GRID. No fixed row heights and no cropping maths: every picture sits in
   a frame whose ratio matches its own, so nothing is cut off, and the rows are
   grouped so that everything side by side shares one ratio. The wide photograph
   (5:3, two columns) and the tall one (4:5, one column) come out within a few
   pixels of each other in height, so they share the first row. */
.gallery-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-6) var(--space-5);
  }
  .gallery-item[data-shape="wide"] { grid-column: span 2; }
}
.gallery-item { min-width: 0; }

.gallery-figure {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
}
.gallery-open {
  display: block;
  min-width: 0;
}
.gallery-open .media-slot {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
}
.gallery-item[data-shape="land"] .media-slot,
.gallery-item[data-shape="wide"] .media-slot { aspect-ratio: 3 / 2; }
.gallery-item[data-shape="tall"] .media-slot { aspect-ratio: 4 / 5; }
@media (min-width: 640px) {
  .gallery-item[data-shape="wide"] .media-slot { aspect-ratio: 5 / 3; }
}
.gallery-open .media-slot > img {
  width: 100%;
  height: 100%;
}
.gallery-figure figcaption {
  display: grid;
  min-width: 0;
}
.gallery-figure figcaption > * {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.gallery-more { max-inline-size: 40rem; }

/* LIGHTBOX. The image frame has ONE fixed height and the picture is contained
   in it, the title is a single clipped line and the caption always has room for
   two, so Previous / Next never move when the photograph changes. */
dialog.dialog-panel.lightbox {
  inline-size: 100%;
  max-inline-size: min(52rem, calc(100vw - 2 * var(--space-4)));
}
.lightbox .dialog-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lightbox-figure {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}
/* core's .media supplies the box; the ratio is replaced by a fixed height */
.lightbox-slot {
  aspect-ratio: auto;
  width: 100%;
  height: min(60dvh, 34rem);
  margin: 0;
}
.lightbox-slot > img.media-img {
  width: 100%;
  height: 100%;
}
.lightbox-caption { min-height: 3em; }
.lightbox-foot { justify-content: space-between; }
.lightbox-nav {
  display: inline-flex;
  gap: var(--space-2);
}
/* on a phone the picture takes the full width of the screen: no side padding
   on the body, the caption keeps its own */
@media (max-width: 639px) {
  dialog.dialog-panel.lightbox { max-inline-size: calc(100vw - 2 * var(--space-2)); }
  .lightbox .dialog-body { padding-inline: 0; }
  .lightbox-caption { padding-inline: var(--space-4); }
  /* two lines, always: the title is the only name the picture has up here */
  .lightbox .dialog-title {
    white-space: normal;
    height: 2.6em;
  }
  .lightbox-slot { height: min(58dvh, 28rem); }
}

/* ---- 2. journal --------------------------------------------------------- */

.journal {
  display: grid;
  gap: var(--space-7);
  min-width: 0;
}
.journal-head {
  display: grid;
  gap: var(--space-4);
  max-inline-size: 52rem;
  min-width: 0;
}
.journal-standfirst { max-inline-size: 40rem; }

/* reading column + a rail. The column is the prose measure, not a share of the
   page, so the line length stays right and the rail takes what is left. */
.journal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-7);
  align-items: start;
}
@media (min-width: 900px) {
  .journal-grid {
    grid-template-columns: minmax(0, 42rem) minmax(13rem, 16rem);
    gap: var(--space-5);
    justify-content: space-between;
  }
  .journal-rail { position: sticky; inset-block-start: var(--space-8); }
}
.journal-main {
  display: grid;
  gap: var(--space-6);
  min-width: 0;
}
.journal-lead,
.journal-figure {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}
.journal-lead .media-slot > img,
.journal-figure .media-slot > img { display: block; width: 100%; height: auto; }
.journal-lead .media-slot,
.journal-figure .media-slot { display: block; width: 100%; margin: 0; }

/* .prose (core) caps the measure but resets every margin to zero, so the
   rhythm of the article is set here: space before a block, more before a head */
.journal-body.prose { max-width: none; }
.journal-body > * + * { margin-block-start: var(--space-4); }
.journal-body > h2 { margin-block-start: var(--space-7); }
.journal-body > h2 + * { margin-block-start: var(--space-3); }
.journal-body > h3,
.journal-body > h4 { margin-block-start: var(--space-6); }
.journal-body > h3 + *,
.journal-body > h4 + * { margin-block-start: var(--space-2); }
.journal-body ul,
.journal-body ol {
  padding-inline-start: var(--space-5);
  display: grid;
  gap: var(--space-2);
}
.journal-body > figure { margin-block: var(--space-6); }
.journal-body > .table-wrap { margin-block: var(--space-5); }
.journal-body .table { min-width: 0; }
@media (max-width: 639px) {
  /* three columns do not fit a phone: the table scrolls inside .table-wrap */
  .journal-body .table { min-width: 32rem; }
}
.journal-body .table caption {
  text-align: start;
  padding-block-start: var(--space-2);
}

/* semantic pull quote: no paint is faked; it only gets room and an indent */
.journal-body > blockquote {
  display: grid;
  gap: var(--space-3);
  margin-block: var(--space-6);
  margin-inline-start: var(--space-5);
  max-inline-size: 34rem;
}
.journal-body > blockquote footer { display: block; }

.journal-body > hr { margin-block: var(--space-6); }
.journal-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.journal-note { display: grid; gap: var(--space-4); justify-items: start; }
.journal-note .card-title { margin: 0; }
.journal-facts {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}
.journal-facts > div { display: grid; gap: var(--space-1); }
.journal-facts dd { margin: 0; }

.journal-related { display: grid; gap: var(--space-5); }
.journal-related-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}
@media (min-width: 640px) {
  .journal-related-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
}
.journal-related-item {
  display: grid;
  gap: var(--space-3);
  align-content: start;
  min-width: 0;
}
.journal-related-item .media-slot { display: block; width: 100%; aspect-ratio: 3 / 2; margin: 0; }
.journal-related-item .media-slot > img { width: 100%; height: 100%; }
.journal-related-item h3 { margin: 0; }
