/* ---------- Latest posts (infinite slider) ---------- */
.latest-posts {
  background: var(--surface-deep-alt);
  overflow: hidden;
}
.latest-posts .section-head {
  margin-bottom: 28px;
}

.lp-viewport {
  position: relative;
  overflow: hidden;
  /* room for the hover lift + shadow so cards are not clipped */
  padding: 14px 0 30px;
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0,
    #000 7%,
    #000 93%,
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    transparent 0,
    #000 7%,
    #000 93%,
    transparent 100%
  );
}

.lp-track {
  display: flex;
  align-items: stretch;
  width: max-content;
}

/* Endless loop: the track holds two identical halves; sliding it by 50%
   lands exactly on the start again (RTL: content moves to the right). */
.lp-track.is-running {
  animation: lp-scroll var(--lp-duration, 50s) linear infinite;
  will-change: transform;
}
.lp-viewport:hover .lp-track.is-running,
.lp-viewport:focus-within .lp-track.is-running {
  animation-play-state: paused;
}
@keyframes lp-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(50%);
  }
}

/* Few posts, or the visitor prefers reduced motion: plain scrollable row */
.lp-viewport.is-static {
  overflow-x: auto;
  -webkit-mask-image: none;
  mask-image: none;
  scroll-snap-type: x proximity;
}
.lp-track.is-static {
  min-width: 100%;
  padding: 0 28px;
}
.lp-track.is-static > .lp-card {
  scroll-snap-align: center;
}
/* auto margins center the row when it fits and never clip it when it overflows */
.lp-track.is-static > .lp-card:first-child {
  margin-inline-start: auto;
}
.lp-track.is-static > .lp-card:last-child {
  margin-inline-end: auto;
}

.lp-card {
  flex: 0 0 auto;
  width: 340px;
  margin-inline-end: 24px; /* margin (not gap) keeps both halves exactly equal */
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  color: inherit;
  transition:
    transform 0.35s var(--ease),
    box-shadow 0.35s var(--ease),
    border-color 0.35s var(--ease);
}
.lp-card:hover,
.lp-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--sky-500);
  box-shadow: 0 14px 26px -16px rgba(11, 22, 38, 0.35);
}
.lp-card:focus-visible {
  outline: 2px solid var(--sky-500);
  outline-offset: 3px;
}

.lp-media {
  aspect-ratio: 16 / 10;
  background: var(--chip-bg);
  overflow: hidden;
}
.lp-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.lp-card:hover .lp-media img {
  transform: scale(1.04);
}

.lp-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 22px 22px 20px;
}
.lp-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  min-height: 24px;
}
.lp-cat {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 2px 10px;
}
.lp-body h3 {
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lp-body p {
  font-size: 14.5px;
  line-height: 1.9;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lp-more {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-heading);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}
.lp-more svg {
  width: 16px;
  height: 16px;
}
.lp-card:hover .lp-more {
  color: var(--accent-text);
  border-color: var(--sky-500);
}

.lp-all {
  text-align: center;
  margin-top: 4px;
}

@media (max-width: 720px) {
  .lp-card {
    width: min(82vw, 320px);
    margin-inline-end: 16px;
  }
  .lp-body {
    padding: 18px 18px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lp-track.is-running {
    animation: none;
  }
}
