/**
 * News lists: only what Elementor's Posts widget can't express.
 *
 * Layout (image position/size, borders, fonts) is set in the widgets themselves,
 * by scripts/elementor/001-novice-lists.php. The widgets carry the class
 * `sm-news-list` (+ `--latest` / `--list`), so any list that gets the class
 * inherits this, e.g. press releases, podcasts, interviews.
 */

:root {
  --sm-news-title-lines: 2;
  --sm-news-excerpt-lines: 3;
}

/* Phones: the text column is narrow, so give titles one more line */
@media (max-width: 767px) {
  :root {
    --sm-news-title-lines: 3;
  }
}

/* Long titles/excerpts: clamp so cards stay a similar height */
body .sm-news-list .elementor-post__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--sm-news-title-lines);
  line-clamp: var(--sm-news-title-lines);
  overflow: hidden;
}

body .sm-news-list .elementor-post__excerpt p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--sm-news-excerpt-lines);
  line-clamp: var(--sm-news-excerpt-lines);
  overflow: hidden;
}

/* A short card (e.g. a post without an image) must not stretch to its row mate */
body .sm-news-list .elementor-posts-container {
  align-items: start;
}

/* Thumbnails: always fill the square, crop from the top (keeps faces) */
body .sm-news-list.elementor-widget-posts .elementor-posts-container.elementor-has-item-ratio .elementor-post__thumbnail img {
  position: absolute;
  inset: 0;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center top;
  transform: none;
}

/*
 * Posts without a featured image: a placeholder tile takes the image slot, so the text
 * column and the "preberi več" buttons line up with the posts that have an image.
 * Sizes mirror the widgets' image width/spacing (set in scripts/elementor/_lib.php).
 */
.sm-news-list--latest {
  --sm-news-thumb: 150px;
  --sm-news-thumb-gap: 20px;
}

.sm-news-list--list {
  --sm-news-thumb: 220px;
  --sm-news-thumb-gap: 30px;
}

@media (max-width: 1024px) {
  .sm-news-list--list {
    --sm-news-thumb: 160px;
  }
}

@media (max-width: 767px) {
  .sm-news-list--latest,
  .sm-news-list--list {
    --sm-news-thumb: 100px;
  }
}

body .sm-news-list .elementor-post:not(.has-post-thumbnail)::before {
  content: "";
  flex: 0 0 var(--sm-news-thumb);
  align-self: flex-start; /* stay square, don't stretch to the text height */
  width: var(--sm-news-thumb);
  aspect-ratio: 1;
  margin-right: var(--sm-news-thumb-gap);
  background: url("../img/sm-monogram.png") center / 52% no-repeat, #f5efe3;
}
