/* The blog index's posts: compact rows, one of them open with its post's art.
   The newest row carries .is-expanded in the HTML; blog-list.js moves it to
   the row a mouse rests on or keyboard focus is in, and back to the first row
   shown when the reader leaves.

   No jank: how open a row is, is one number, --open (0 to 1), and every
   size an open row adds is that number times a fixed length. Nothing else in
   a row changes size. blog-list-motion.js moves --open on every row from one
   shared progress, so the rows' numbers always add up to one and the list
   keeps its height at every frame: nothing below it moves, and the row under
   the pointer only grows toward it. Do not give these sizes their own CSS
   transitions; two rows' transitions drift apart when one is reversed. Each
   post styles its own art, under .post-art, in assets/posts/<slug>.css.
   Without the script, .is-expanded sets --open to 1. */

.post-list .post-card {
  --open: 0;
}

.post-list .post-card.is-expanded {
  --open: 1;
}

.post-list {
  --post-pad: 22px;
  --post-read-h: 34px; /* the read link, below the copy */
  --post-art-h: 220px; /* the art, below the read link, on a phone */
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.post-list .post-card a {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "copy" "read" "art";
  padding: var(--post-pad) 24px 0;
  overflow: hidden;
  border-radius: var(--r-group);
  background: var(--surface);
  box-shadow: var(--highlight);
  color: inherit;
  text-decoration: none;
  transition: background var(--fast) var(--ease-out-soft);
}

/* The open row's glow, faded by --open: a gradient cannot be blended. */
.post-list .post-card a::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 90% at 85% 100%, var(--tint-fill), transparent 60%);
  opacity: var(--open);
}

@media (hover: hover) {
  .post-list .post-card a:hover {
    background: var(--elevated);
  }
}

.post-list .post-card a:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--tint), 0 0 0 4px var(--tint-fill);
}

/* ------------------------------------------------------------- the copy --- */

/* The same in both states, so opening a row never rewraps its words. */
.post-card-copy {
  grid-area: copy;
  display: block;
  min-width: 0;
  padding-bottom: var(--post-pad);
}

.post-card-copy > span {
  display: block;
}

.post-card h2 {
  margin: 10px 0 0;
  font-size: var(--title-3);
  letter-spacing: var(--track-title-3);
}

.post-card p {
  display: -webkit-box;
  max-width: var(--measure);
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--label-body);
  font-size: var(--callout);
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.post-tags {
  margin-top: 10px;
}

.post-tags span {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--fill-2);
  color: var(--label-2);
  font-size: var(--caption);
  font-weight: 510;
}

/* -------------------------------------------- what an open row adds --- */

/* The read link and the art grow from nothing to a fixed height, by --open. */
.post-read {
  grid-area: read;
  display: flex;
  align-items: flex-start;
  height: calc(var(--post-read-h) * var(--open));
  overflow: hidden;
  opacity: var(--open);
  color: var(--tint);
  font-size: var(--callout);
  font-weight: 600;
}

/* The card clips the art, not this box, so a drawing's shadow is not cut
   square at its edge. */
.post-art {
  grid-area: art;
  position: relative;
  height: calc(var(--post-art-h) * var(--open));
  opacity: var(--open);
}

/* A post's art is placed, never sized by the row: centred, from the top, and
   rising a little as it shows. Its post's stylesheet gives it a width. */
.post-list .post-art > * {
  position: absolute;
  top: var(--post-art-top, 0);
  right: 0;
  left: 0;
  margin: 0 auto;
  transform: translateY(calc((1 - var(--open)) * 14px));
}

/* Beside the copy, the art runs to the card's right and bottom edges, and the
   read link carries the whole extra height, at its foot. */
@media (min-width: 760px) {
  .post-list {
    --post-pad: 26px;
    --post-grow: 176px;
    --post-art-w: 300px;
  }

  .post-list .post-card a {
    grid-template-columns: minmax(0, 1fr) var(--post-art-w);
    grid-template-areas: "copy art" "read art";
    column-gap: 32px;
    padding: var(--post-pad) 0 0 32px;
  }

  .post-card p {
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  /* The padding grows with the height and stays inside it (border-box), so
     it never holds a closing row open. */
  .post-read {
    align-items: flex-end;
    height: calc(var(--post-grow) * var(--open));
    padding-bottom: calc(30px * var(--open));
  }

  .post-art {
    height: auto;
  }
}

/* ---------------------------------------------------------- more posts --- */

.blog-more {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}
