/* ==========================================================================
   HEMFRY - Projekti (listing)
   Page-only styles. Everything else comes from hemfry.css.
   ========================================================================== */

/* 01 - HERO --------------------------------------------------------------- */
.pj-hero {
  padding-bottom: clamp(56px, 6vw, 104px);
}
.pj-hero__title {
  max-width: 11ch;
}
.pj-hero .page-hero__lead {
  max-width: 50ch;
}

.pj-hero__aside {
  display: grid;
  gap: clamp(28px, 3vw, 40px);
}
.pj-figs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.pj-figs .num {
  display: flex;
  align-items: flex-start;
  font-variant-numeric: tabular-nums;
}
.pj-figs .num sup {
  transform: translateY(0.1em);
}

.pj-refs > .mono {
  margin-bottom: 12px;
}
.pj-refs ul {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}
.pj-refs li {
  display: grid;
  place-items: center;
  height: 72px;
  padding: 0 12px;
}
.pj-refs li + li {
  border-left: 1px solid var(--line);
}
.pj-refs img {
  width: auto;
  max-width: 86%;
  max-height: 36px;
  filter: grayscale(1) contrast(1.15);
  mix-blend-mode: multiply;
  opacity: 0.72;
  transition:
    filter var(--t) var(--ease),
    opacity var(--t) var(--ease);
}
.pj-refs li:hover img {
  filter: none;
  opacity: 1;
}
/* desktop: the aside is only 4 columns wide - logos go 2 × 2 so they stay legible */
@media (min-width: 1100px) {
  .pj-refs ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-bottom: 0;
  }
  .pj-refs li {
    height: 76px;
    padding: 0 16px;
    border-bottom: 1px solid var(--line);
  }
  .pj-refs li + li {
    border-left: 0;
  }
  .pj-refs li:nth-child(odd) {
    border-right: 1px solid var(--line);
  }
  .pj-refs img {
    max-width: 78%;
    max-height: 38px;
  }
}
@media (max-width: 1099px) {
  .pj-hero__aside {
    margin-top: 16px;
  }
}
@media (max-width: 699px) {
  .pj-hero {
    padding-bottom: 40px;
  }
  .pj-hero__aside {
    gap: 24px;
  }
  .pj-refs li {
    height: 52px;
    padding: 0 4px;
  }
  .pj-refs img {
    max-width: 92%;
    max-height: 28px;
  }
}

/* 02 - FILTER + GRID ----------------------------------------------------- */
.pj-archive {
  padding-top: 0;
}
.pj-archive__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  margin-bottom: 20px;
}
.pj-archive__note {
  color: var(--fg-faint);
}
.pj-filter {
  margin-bottom: clamp(32px, 4vw, 64px);
}
/* the sticky bar needs its own surface once the page scrolls under it */
.pj-filter.filter-bar--sticky {
  background: var(--paper);
}
.pj-grid [hidden] {
  display: none !important;
}

/* Masonry. Base = CSS columns (before JS); projekti.js switches to balanced
   flex columns (.is-masonry) that keep a left-to-right reading order. */
.pj-grid {
  columns: 1;
  column-gap: var(--gap);
}
.pj-grid > .pj-card {
  break-inside: avoid;
  margin-bottom: clamp(44px, 4.4vw, 72px);
}
@media (min-width: 700px) {
  .pj-grid {
    columns: 2;
  }
}
@media (min-width: 1100px) {
  .pj-grid {
    columns: 3;
  }
}

.pj-grid.is-masonry {
  columns: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
}
.pj-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(44px, 4.4vw, 72px);
}
.pj-col:empty {
  display: block;
}
/* editorial stagger: middle column starts lower on desktop */
@media (min-width: 1100px) {
  .pj-grid.is-masonry > .pj-col:nth-child(2):not(:empty) {
    padding-top: clamp(72px, 6vw, 112px);
  }
}

/* Card tuning for a 3-column rhythm */
.pj-card .media {
  margin-bottom: 18px;
}
.pj-card .project-card__meta {
  margin-bottom: 8px;
}
.pj-card .project-card__title {
  font-size: clamp(1.25rem, 1.05rem + 0.55vw, 1.625rem);
  line-height: 1.12;
  text-wrap: balance;
}
.pj-card .project-card__row {
  align-items: flex-end;
}
.pj-card .project-card__loc {
  max-width: 34ch;
}
.pj-card__tag {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 1;
}
.pj-card--case .project-card__title {
  font-size: clamp(1.5rem, 1.2rem + 0.8vw, 2rem);
}

/* Filter change: short staggered settle (reduced-motion handled globally) */
.pj-card.is-enter {
  animation: pj-in 720ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
@keyframes pj-in {
  from {
    opacity: 0;
    transform: translate3d(0, 22px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Empty state */
.pj-empty {
  display: none;
  background: var(--surface);
  border-radius: var(--r-xs);
  overflow: hidden;
}
.pj-grid.is-empty {
  display: none;
}
.pj-grid.is-empty + .pj-empty {
  display: block;
}
.pj-empty__inner {
  display: grid;
  gap: 24px;
  padding: clamp(28px, 4vw, 64px);
}
.pj-empty__num {
  font-family: var(--font-display);
  font-stretch: 112%;
  font-weight: 700;
  font-size: clamp(4rem, 2.6rem + 5vw, 8rem);
  line-height: 0.85;
  letter-spacing: -0.05em;
  color: var(--line-strong);
  font-variant-numeric: tabular-nums;
}
.pj-empty .body {
  max-width: 52ch;
}
.pj-empty__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-top: 28px;
}
@media (min-width: 900px) {
  .pj-empty__inner {
    grid-template-columns: minmax(200px, 1fr) 2fr;
    gap: 48px;
    align-items: start;
  }
}

/* Closing strip under the grid */
.pj-strip {
  margin-top: clamp(24px, 3vw, 48px);
}
.pj-strip__title {
  line-height: 1.08;
}

@media (max-width: 699px) {
  .pj-archive__note {
    display: none;
  }
  .pj-filter {
    margin-bottom: 28px;
  }
  /* one card per row: square crops keep the list scannable (540 px photos are square anyway) */
  .pj-card .media.r-3x4,
  .pj-card .media.r-4x5 {
    aspect-ratio: 1;
  }
  .pj-card .media.pj-keep {
    aspect-ratio: 4 / 5;
  }
}
