/* =============================================================
   Section: Recent Work
   Maps to: template-parts/sections/section-work.php
   On WP migration: cards become a WP_Query loop over the Projects
   plugin CPT, ordered by most recent.
   ============================================================= */

.work {
  background: var(--ink);
  color: var(--bone);
  position: relative;
  overflow: hidden;
}

.work::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../../img/textures/grain.svg");
  background-size: 320px 320px;
  opacity: 0.05;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.work__head {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
  margin-bottom: var(--s-8);
  align-items: end;
}

@media (min-width: 980px) {
  .work__head {
    grid-template-columns: 1.4fr 1fr;
    gap: var(--s-9);
  }
}

.work__title {
  font-family: var(--font-display);
  font-size: var(--fs-mega);
  line-height: 0.9;
  letter-spacing: -0.025em;
  text-transform: uppercase;
}

.work__title .accent { color: var(--safety); }

/* Replaces the old year-filter chip row. Plain editorial lede so
   nothing in the UI hints at sortable date — supports the
   "every project is current" stance for the future plugin. */
.work__lede {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: clamp(1rem, 1.3vw, 1.2rem);
  line-height: 1.5;
  color: var(--muted-dark);
  max-width: 44ch;
  align-self: end;
}

/* ---- Asymmetric staggered grid ---- */
.work__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
}

@media (min-width: 720px) {
  .work__grid {
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(160px, auto);
    gap: var(--s-5);
  }
  /* Editorial staggered placement -- only applied to the home page
     "Recent Work" feature grid (4 cards). The Projects page grid
     uses .work__grid--full below to opt out of the stagger and
     render a uniform tile layout. */
  .work__grid:not(.work__grid--full) .work-card:nth-child(1) { grid-column: 1 / span 7; grid-row: span 3; }
  .work__grid:not(.work__grid--full) .work-card:nth-child(2) { grid-column: 8 / span 5; grid-row: span 2; margin-top: var(--s-7); }
  .work__grid:not(.work__grid--full) .work-card:nth-child(3) { grid-column: 1 / span 5; grid-row: span 2; }
  .work__grid:not(.work__grid--full) .work-card:nth-child(4) { grid-column: 6 / span 7; grid-row: span 3; }
}

/* ---- Full grid (Projects page) ----
   Uniform auto-fill tiles. Every Nth card spans two rows so the
   page keeps the editorial rhythm of the home stagger without
   needing per-card class wiring. */
.work__grid--full {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  grid-auto-rows: 280px;
  align-items: stretch;
}
.work__grid--full .work-card {
  grid-column: auto;
  grid-row: span 1;
  margin-top: 0;
}
.work__grid--full .work-card:nth-child(7n+1) {
  grid-row: span 2;
}
.work__grid--full .work-card__inner,
.work__grid--full .work-card:nth-child(1) .work-card__inner,
.work__grid--full .work-card:nth-child(4) .work-card__inner {
  min-height: 0;
  height: 100%;
}

.work-card {
  position: relative;
  display: block;
  color: var(--bone);
  background: var(--ink-2);
  overflow: hidden;
  isolation: isolate;
  /* Torn-dirt edge mask along bottom */
  -webkit-mask-image:
    linear-gradient(180deg, #000 0, #000 calc(100% - 22px), transparent 100%),
    url("../../img/shapes/divider-torn.svg");
  -webkit-mask-size: 100% 100%, 100% 30px;
  -webkit-mask-position: top, bottom;
  -webkit-mask-repeat: no-repeat, no-repeat;
  -webkit-mask-composite: source-over;
          mask-image:
    linear-gradient(180deg, #000 0, #000 calc(100% - 22px), transparent 100%);
}

.work-card__media {
  position: absolute;
  inset: 0;
  z-index: -2;
}
.work-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.2) contrast(1.05);
  transition: transform var(--dur-slow) var(--ease-out), filter var(--dur-base) var(--ease-out);
}
.work-card:hover .work-card__media img {
  transform: scale(1.06);
  filter: grayscale(0) contrast(1.08);
}

/* Placeholder treatment for projects without a featured image. The
   plugin renders the work-card with a `work-card--no-image` modifier
   when no thumbnail exists; the .work-card__media div is empty, so we
   paint a textured dirt-on-ink gradient inside it. Reads as an
   intentional brand surface rather than an empty card. The texture
   reuses the existing grain.svg overlay so no extra asset is needed. */
.work-card--no-image .work-card__media {
  background:
    radial-gradient(120% 80% at 30% 0%, rgba(107,74,44,0.55) 0%, rgba(107,74,44,0) 60%),
    linear-gradient(160deg, var(--ink-3) 0%, var(--ink) 70%, var(--dirt-deep) 100%);
}
.work-card--no-image .work-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../../img/textures/grain.svg");
  background-size: 320px 320px;
  opacity: 0.18;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.work-card__overlay {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(11,11,12,0.05) 0%, rgba(11,11,12,0.85) 100%);
}

.work-card__inner {
  position: relative;
  height: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--s-5) var(--s-5) var(--s-7);
}

.work-card:nth-child(1) .work-card__inner,
.work-card:nth-child(4) .work-card__inner { min-height: 460px; }

.work-card__top {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.work-card__sector {
  color: var(--bone);
  background: rgba(11,11,12,0.55);
  border: 1px solid var(--rule-dark);
  padding: 6px 12px;
}

.work-card__bottom { display: grid; gap: var(--s-3); }

.work-card__name {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.4vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.work-card__meta {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-dark);
}

.work-card__meta strong { color: var(--bone); font-weight: 500; }

/* Optional one-line description (only present when projects.json carries
   a structured description block from the live Squarespace page). */
.work-card__desc {
  margin: 0;
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.45;
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Sectors pill row ---- */
.work__sectors {
  margin-top: var(--s-8);
  padding-top: var(--s-6);
  border-top: 1px solid var(--rule-dark);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
}

.work__sectors-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--safety);
  margin-right: var(--s-3);
}

.work__sectors .pill {
  color: var(--bone);
  border-color: var(--rule-dark);
}
