/* Blog index, archive and category pages: posts as cards, 3 per row (4 rows = 12 per page) */
.pf-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

@media screen and (max-width: 59.9844em) {
  .pf-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 37.4844em) {
  .pf-cards { grid-template-columns: minmax(0, 1fr); }
}

.pf-card.md-post {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0.05rem solid var(--md-default-fg-color--lightest);
  border-radius: 0.4rem;
  background: var(--md-default-bg-color);
  transition: box-shadow 125ms, border-color 125ms;
}

.pf-card.md-post:hover {
  border-color: transparent;
  box-shadow: var(--md-shadow-z2);
}

.pf-card__image img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.pf-card .md-post__header,
.pf-card .md-post__content,
.pf-card .md-post__action {
  padding: 0 0.8rem;
}

.pf-card .md-post__header { margin-top: 0.6rem; }

/* title */
.pf-card .md-post__content h2 {
  margin: 0.3rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

/* excerpt: text only, at most 5 lines; images and embeds belong to the post page */
.pf-card .md-post__content {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 9;
  line-clamp: 9;
  font-size: 0.7rem;
}

.pf-card .md-post__content img,
.pf-card .md-post__content figure,
.pf-card .md-post__content iframe,
.pf-card .md-post__content .glightbox,
.pf-card .md-post__content .headerlink {
  display: none;
}

.pf-card .md-post__content > :first-child { margin-top: 0; }

.pf-card .md-post__action {
  margin-top: auto;
  padding-top: 0.4rem;
  padding-bottom: 0.7rem;
  font-size: 0.7rem;
}

/* card pages have no table of contents or section navigation: give the grid the full width */
@media screen and (min-width: 76.25em) {
  .md-main__inner:has(.pf-cards) > .md-sidebar { display: none; }
  .md-main__inner:has(.pf-cards) > .md-content { max-width: none; }
}

/* top navigation: a tab that is a section opens a dropdown with its children (overrides/partials/tabs-item.html) */
.md-tabs,
.md-tabs__list {
  overflow: visible;
}
.md-tabs__list { contain: none; }
.pf-menu { position: relative; }
.pf-menu > .md-tabs__link::after {
  content: "";
  align-self: center;
  margin-left: 0.3rem;
  border: 0.2rem solid transparent;
  border-top-color: currentcolor;
  border-bottom-width: 0;
}
.pf-menu__list {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 5;
  min-width: 9rem;
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  font-weight: 400;
  background: var(--md-default-bg-color);
  border: 0.05rem solid var(--md-default-fg-color--lightest);
  border-radius: 0 0 0.3rem 0.3rem;
  box-shadow: var(--md-shadow-z2);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s, visibility 0.15s;
}
.pf-menu:hover > .pf-menu__list,
.pf-menu:focus-within > .pf-menu__list {
  visibility: visible;
  opacity: 1;
}
.md-tabs[hidden] .pf-menu__list { visibility: hidden; }
.pf-menu__link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.7rem;
  color: var(--md-default-fg-color);
}
.pf-menu__link:hover,
.pf-menu__link:focus,
.pf-menu__item--active > .pf-menu__link {
  color: var(--md-typeset-a-color);
}
.pf-menu__icon {
  display: inline-flex;
  flex: none;
  opacity: 0.7;
}
.pf-menu__icon svg {
  width: 0.9rem;
  height: 0.9rem;
}

/* one-row header on wide screens: logo, site name, menu, light/dark switch, search
   (the tabs sit inside the header row, see overrides/partials/header.html) */
@media screen and (min-width: 76.25em) {
  .md-header__title {
    flex-grow: 0;
    flex-shrink: 0;
  }
  /* the site name stays; it is no longer swapped for the page title while scrolling */
  .md-header__title .md-header__topic:first-child {
    position: static;
    z-index: 0;
    pointer-events: auto;
    opacity: 1;
    transform: none;
  }
  .md-header__title .md-header__topic + .md-header__topic { display: none; }
  .md-header__inner > .md-tabs {
    flex: 1 1 auto;
    width: auto;
    margin: 0 0 0 0.8rem;
    box-shadow: none;
  }
  .md-header__inner > .md-tabs > .md-grid {
    max-width: none;
    margin: 0;
  }
  /* the header is one row high now, not two */
  .md-header--lifted ~ .md-container .md-sidebar { top: 2.4rem; }
  .md-header--lifted ~ .md-container .md-typeset :target { --md-scroll-margin: 3.6rem; }
}

/* home page: site title, and next to it the tagline in a speech bubble whose tail points at the title
   (docs/index.md marks the tagline with .pf-tagline) */
.md-content header.md-typeset:has(.pf-tagline) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.1rem;
  margin: 0.4rem 0 1.4rem;
}
.md-content header.md-typeset:has(.pf-tagline) h1,
.md-content header.md-typeset:has(.pf-tagline) p {
  margin: 0;
}
/* the theme's empty "skip to content" anchor must not take a slot (and a gap) in the row */
.md-content header.md-typeset:has(.pf-tagline) > #__skip { position: absolute; }
.md-typeset .pf-tagline {
  position: relative;
  display: inline-block;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--md-primary-bg-color, #fff);
  background: var(--md-typeset-a-color);
  border-radius: 1rem;
}
.md-typeset .pf-tagline::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -0.45rem;
  border: 0.35rem solid transparent;
  border-right-color: var(--md-typeset-a-color);
  border-left-width: 0;
  transform: translateY(-50%);
}
/* narrow screens: the bubble sits under the title, tail pointing up */
@media screen and (max-width: 44.9375em) {
  .md-typeset .pf-tagline::before {
    top: -0.4rem;
    left: 1.2rem;
    border: 0.35rem solid transparent;
    border-bottom-color: var(--md-typeset-a-color);
    border-top-width: 0;
    transform: none;
  }
}
