/*
 * Magazine sections of the academy home (The Good Life, Money Moves). Loaded on that page only, after academy.css,
 * whose tokens it uses. See docs/design-system.md.
 */

/* Stories are signed like posts in a feed: a small round picture of the author before the name. */
.academy-magazine .cs-meta-author .cs-photo {
  width: 1.75rem;
  height: 1.75rem;
}

.academy-magazine__stories {
  display: grid;
  gap: 1.5rem;
}

/* Strip: stories side by side, each built like a post in a feed. A phone swipes through them. */
.academy-magazine--strip .academy-magazine__stories {
  grid-auto-flow: column;
  grid-auto-columns: min(78%, 20rem);
  margin-inline: -1.5rem;
  padding: 0.25rem 1.5rem 1.25rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 1.5rem;
  scrollbar-width: none;
}
/* The post: the author on top, the picture from edge to edge, the caption under it. */
.academy-card--photo {
  --cs-thumbnail-border-radius: 0;
  position: relative;
  overflow: hidden;
  border-radius: var(--academy-radius-lg);
  background: var(--cs-color-widgets-background);
  box-shadow: var(--academy-shadow-soft);
  scroll-snap-align: start;
  transition: translate 0.3s var(--academy-ease-snap);
}
.academy-card--photo > .cs-entry__post-meta {
  margin: 0;
  padding: 0.875rem 1rem;
}
/* The ring of a story around the author, in the brand colour. */
.academy-card--photo .cs-meta-author .cs-photo {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  outline: 2px solid var(--academy-brand);
  outline-offset: 2px;
}
.academy-card--photo .cs-meta-author .cs-photo:not(:last-child) {
  margin-inline-end: 0.75rem;
}
.academy-card--photo .academy-card__body {
  gap: 0.375rem;
  padding: 0.875rem 1rem 1rem;
}
/* The caption is cut short like a post in a feed: three lines of how the text begins (two in a row of the list). */
.academy-card--photo .cs-entry__excerpt,
.academy-card--feature .cs-entry__excerpt {
  -webkit-line-clamp: 3;
}
.academy-hashtags {
  margin: 0;
  font-size: var(--cs-font-post-meta-size);
}
.academy-hashtags a {
  margin-inline-end: 0.375rem;
  color: var(--cs-color-post-meta-link);
}
/* A label beside the author of the newest post. */
.academy-sticker {
  position: absolute;
  z-index: 2;
  top: 1.125rem;
  inset-inline-end: 1rem;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  background: var(--academy-brand);
  color: #141614;
  font-family: var(--cs-font-primary-family), sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

/* List: a panel lit by the brand from a corner. The newest story is large, the older ones are rows beside it. */
.academy-magazine--list {
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border-radius: var(--academy-radius-xl);
  background: radial-gradient(circle at 0 0, color-mix(in srgb, var(--academy-brand) 24%, var(--cs-color-widgets-background)), var(--cs-color-widgets-background) 55%);
}
.academy-card--feature .cs-entry__title {
  font-size: clamp(1.375rem, 2.2vw, 1.75rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.academy-card--row {
  display: grid;
  grid-template-columns: clamp(6.5rem, 38%, 15rem) 1fr;
  align-items: center;
  gap: 1rem;
  transition: translate 0.3s var(--academy-ease-snap);
}
.academy-card--row .academy-card__body {
  padding: 0;
}
.academy-magazine__rows {
  display: grid;
  gap: 1.5rem;
}
/* The signature of a story in the list takes two lines: the author, then the date and the reading time. */
.academy-magazine--list .cs-entry__post-meta {
  flex-wrap: wrap;
  row-gap: 0.375rem;
}
.academy-magazine--list .cs-meta-author {
  flex-basis: 100%;
}
.academy-magazine--list .cs-meta-author + ::before {
  display: none;
}
/* In a narrow post or row the reading time wraps under the date: space instead of a dot, so no line starts with one. */
@media (max-width: 1019px) {
  .academy-card--photo .academy-card__body .cs-entry__post-meta,
  .academy-card--row .cs-entry__post-meta {
    flex-wrap: wrap;
    gap: 0.125rem 0.75rem;
  }
  .academy-card--photo .academy-card__body .cs-entry__post-meta > *::before,
  .academy-card--row .cs-entry__post-meta > *::before {
    display: none;
  }
}

@media (hover: hover) {
  .academy-card--photo:hover {
    translate: 0 -0.25rem;
  }
  .academy-card--row:hover {
    translate: 0.25rem 0;
  }
}

@media (min-width: 1020px) {
  /* Wide screens show the whole strip. */
  .academy-magazine--strip .academy-magazine__stories {
    grid-auto-columns: 1fr;
    margin-inline: 0;
    padding: 0.25rem 0 0;
    overflow: visible;
  }
  /* In the panel the large story stands on the left; the rows share its height on the right. */
  .academy-magazine--list .academy-magazine__stories {
    grid-template-columns: 5fr 6fr;
    gap: 2.5rem;
  }
  .academy-magazine__rows {
    gap: 0;
  }
}

/* The sticker shakes once when the pointer comes to its post. */
@keyframes academy-wiggle {
  50% {
    rotate: -6deg;
  }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  .academy-card--photo:hover .academy-sticker {
    animation: academy-wiggle 0.5s var(--academy-ease);
  }
}
