/* components/post-info.css — layout for partials/post-info.hbs. */

.post-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block: var(--space-6);
  padding-block: var(--space-3);
  border-block: var(--border-width) solid var(--color-border-soft);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}

/* .container's max-width includes the gutters, so widen it by two gutters to
   line the content up with the article body at --measure while keeping the
   gutter on narrow screens. */
.post-info.container {
  --container: calc(var(--container-content) + var(--gutter) * 2);
}

/* Author line over dates, centred by default. */
.post-info__meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

/* Single-author posts render .post-info__meta as one link (avatar, name and
   date); it drops the base underline and dims on hover like a card. */
a.post-info__meta {
  text-decoration: none;
  transition: opacity var(--transition);
}

@media (hover: hover) {
  a.post-info__meta:hover {
    opacity: var(--card-hover-opacity);
  }
}

/* Avatars: only on STANDARD, COLOR BANNER and left-aligned LARGE IMAGE — the
   layouts with the merged byline row (opt-in list, so new layouts start
   without) — and only when an author has an image. */
/* isolation keeps the active co-author's raised z-index (below) local. */
.post-info__avatars {
  display: none;
  align-items: center;
  isolation: isolate;
}

.post[data-layout="standard"] .post-info__avatars:not(:empty),
.post[data-layout="color-banner"] .post-info__avatars:not(:empty),
.post[data-layout="large-image"][data-align="left"] .post-info__avatars:not(:empty) {
  display: flex;
}

/* Fixed circle; --avatar-size and --avatar-radius are design-layer hooks. */
.post-info__avatar {
  width: var(--avatar-size, 3rem);
  height: var(--avatar-size, 3rem);
  border-radius: var(--avatar-radius, 50%);
  object-fit: cover;
  filter: var(--avatar-filter);
}

/* Co-authors: the avatars overlap, each ringed in the surface behind it (the
   band when there is one, else the page). Hover lifts one out of the stack
   (below) rather than spreading them. Spacing is margin, not gap, because
   gap can't go negative. The ring is on the link, not the img, so
   --avatar-filter can't grey it against a coloured band. isolation keeps
   ring and img painting as one: a filtered img otherwise paints above every
   link's ring, hiding it. */
.post-info__avatar-link {
  isolation: isolate;
  border-radius: var(--avatar-radius, 50%);
  box-shadow: 0 0 0 var(--avatar-ring-width) var(--post-top-bg, var(--color-bg));
  transition: opacity var(--transition);
}

.post-info__avatar-link + .post-info__avatar-link {
  margin-inline-start: calc(var(--avatar-stack-overlap) * -1);
}

/* Names over dates as one block, so the avatar centres against both. */
.post-info__byline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

/* Long author lists wrap like a line of text: no row gap. */
.post-info__authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 var(--space-2);
}

/* The name leads the byline. */
.post-info__author {
  font-size: var(--byline-author-size, var(--text-base));
  font-weight: var(--byline-author-weight, var(--weight-medium));
  text-decoration: none;
}

/* Several authors: hovering one (avatar or name) dims the rest. The index
   pairs each avatar with its name, since avatars skip authors without an
   image; avatars only render for up to three authors (post-info.hbs). The
   avatar links' transition is set with the stack above. */
.post-info__author {
  transition: opacity var(--transition);
}

@media (hover: hover) {
  .post-info__authors:has(.post-info__author:hover) .post-info__author:not(:hover),
  .post-info__meta:has([data-author-index="0"]:hover) [data-author-index]:not([data-author-index="0"]),
  .post-info__meta:has([data-author-index="1"]:hover) [data-author-index]:not([data-author-index="1"]),
  .post-info__meta:has([data-author-index="2"]:hover) [data-author-index]:not([data-author-index="2"]) {
    opacity: var(--card-hover-opacity);
  }

  /* The active author's avatar lifts above the stack, so hovering a name or
     an avatar shows that face whole. Flex items take z-index without
     position. */
  .post-info__meta:has([data-author-index="0"]:hover) .post-info__avatar-link[data-author-index="0"],
  .post-info__meta:has([data-author-index="1"]:hover) .post-info__avatar-link[data-author-index="1"],
  .post-info__meta:has([data-author-index="2"]:hover) .post-info__avatar-link[data-author-index="2"] {
    z-index: 1;
  }
}

/* Comma between multiple authors (kept out of the link text). */
.post-info__author:not(:last-child)::after {
  content: ",";
}

.post-info__dates {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-fg-tone);
}

/* Actions: comment count and share. --icon-size: 1em because these icons
   are drawn edge to edge. */
.post-info__actions {
  --icon-size: 1em;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-inline-start: auto;
}

.post-info__comment-count,
.post-info__share {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  white-space: nowrap;
}

/* [data-part]: each part alone drops the combined bar's border and padding.
   A lone "meta" is centred; a lone "actions" stays at the start. */
.post-info[data-part="meta"],
.post-info[data-part="actions"] {
  border-block: none;
  padding-block: 0;
}

.post-info[data-part="meta"] {
  justify-content: center;
}

.post-info[data-part="actions"] .post-info__actions {
  margin-inline-start: 0;
}

/* MERGED ROW — STANDARD, COLOR BANNER and left-aligned LARGE IMAGE, at
   every width: byline left, actions right, in one row (inside the colour
   band on COLOR BANNER). Centred LARGE IMAGE (#header-center) and every other
   layout hide this copy and show .post__actions below the image instead.
   Avatars stay STANDARD/COLOR BANNER only. header-scroll.js watches
   whichever copy is visible. */
.post-info[data-part="meta"] .post-info__actions {
  display: none;
}

.post[data-layout="standard"] .post-info[data-part="meta"] .post-info__actions,
.post[data-layout="color-banner"] .post-info[data-part="meta"] .post-info__actions,
.post[data-layout="large-image"][data-align="left"] .post-info[data-part="meta"] .post-info__actions {
  display: flex;
  flex-shrink: 0;
}

/* Two children again: space-between. No wrap, so a long author list wraps
   inside the byline instead of pushing the actions to a new line. */
.post[data-layout="standard"] .post-info[data-part="meta"],
.post[data-layout="color-banner"] .post-info[data-part="meta"],
.post[data-layout="large-image"][data-align="left"] .post-info[data-part="meta"] {
  flex-wrap: nowrap;
  justify-content: space-between;
}

/* Avatar beside the byline, left-aligned. When the row is tight the byline
   wraps; the avatars keep their size rather than squash into ovals. */
.post[data-layout="standard"] .post-info[data-part="meta"] .post-info__meta,
.post[data-layout="color-banner"] .post-info[data-part="meta"] .post-info__meta,
.post[data-layout="large-image"][data-align="left"] .post-info[data-part="meta"] .post-info__meta {
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.post[data-layout="standard"] .post-info[data-part="meta"] .post-info__avatars,
.post[data-layout="color-banner"] .post-info[data-part="meta"] .post-info__avatars,
.post[data-layout="large-image"][data-align="left"] .post-info[data-part="meta"] .post-info__avatars {
  flex-shrink: 0;
}

.post[data-layout="standard"] .post-info[data-part="meta"] .post-info__byline,
.post[data-layout="color-banner"] .post-info[data-part="meta"] .post-info__byline,
.post[data-layout="large-image"][data-align="left"] .post-info[data-part="meta"] .post-info__byline {
  align-items: flex-start;
  min-width: 0;
}

.post[data-layout="standard"] .post-info[data-part="meta"] .post-info__authors,
.post[data-layout="color-banner"] .post-info[data-part="meta"] .post-info__authors,
.post[data-layout="large-image"][data-align="left"] .post-info[data-part="meta"] .post-info__authors {
  justify-content: flex-start;
}

/* Below --bp-md two or more authors leave no room beside the actions, so
   the actions drop to their own line, at the start under the byline. */
@media (width < 48rem) {
  .post[data-layout="standard"] .post-info--co-authored[data-part="meta"],
  .post[data-layout="color-banner"] .post-info--co-authored[data-part="meta"],
  .post[data-layout="large-image"][data-align="left"] .post-info--co-authored[data-part="meta"] {
    flex-wrap: wrap;
  }

  .post[data-layout="standard"] .post-info--co-authored[data-part="meta"] .post-info__actions,
  .post[data-layout="color-banner"] .post-info--co-authored[data-part="meta"] .post-info__actions,
  .post[data-layout="large-image"][data-align="left"] .post-info--co-authored[data-part="meta"] .post-info__actions {
    flex-basis: 100%;
    margin-inline-start: 0;
  }
}

/* Wrapped names: actions line up with the first line of names. */
@media (width >= 48rem) {
  .post[data-layout="standard"] .post-info--many-authors[data-part="meta"],
  .post[data-layout="color-banner"] .post-info--many-authors[data-part="meta"],
  .post[data-layout="large-image"][data-align="left"] .post-info--many-authors[data-part="meta"] {
    align-items: baseline;
  }
}
