/* Project page (projects/*.html, built from tools/projects.json): title, cover photograph, details and
   description, a gallery that opens in a full-screen photo viewer, and links to the neighbouring projects.
   Loaded after css/site.css, which holds the header, reveals and footer. */

:root { --plaster-line: #dcd6ce; }

/* ---------- Title ---------- */
.pd-hero { padding: calc(var(--header-h) + clamp(40px, 6vw, 88px)) 0 clamp(28px, 3.4vw, 48px); }
.pd-crumbs { margin-bottom: clamp(18px, 2.4vw, 32px); }

.pd-hero-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 32px;
  row-gap: 20px;
  align-items: end;
}
.pd-title {
  grid-column: 1 / 9;
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3rem, 5.6vw + 1rem, 7rem);
  line-height: .95;
  letter-spacing: -0.025em;
}
.pd-title-line {
  display: block;
  overflow: hidden;
  margin-top: -.08em;
  padding: .08em 0;
}
.pd-title-line > span { display: inline-block; }

.pd-hero-meta {
  grid-column: 9 / 13;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 0;
  margin: 0 0 .6rem;
  font: 500 0.75rem/1.4 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--stone);
}
.pd-hero-meta span + span::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 1px;
  margin: 0 12px;
  vertical-align: middle;
  background: #cfc8c0;
}

/* ---------- Cover ---------- */
.pd-cover {
  position: relative;
  margin: 0 var(--gutter);
  aspect-ratio: var(--band, 21 / 9);
  min-height: 320px;
  overflow: hidden;
  background: var(--plaster);
}
.pd-cover-link {
  position: absolute;
  inset: 0;
  display: block;
  cursor: zoom-in;
}
.pd-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* A tall (portrait) cover: the whole photograph in the middle, a blurred copy of it filling the band */
.pd-cover--tall { --band: 16 / 9; }
.pd-cover--tall .pd-cover-img {
  position: relative;
  object-fit: contain;
}
.pd-cover-fill {
  position: absolute;
  inset: -96px;
  width: calc(100% + 192px);
  height: calc(100% + 192px);
  object-fit: cover;
  filter: blur(32px) saturate(.9) brightness(.82);
}
.pd-cover-badge {
  position: absolute;
  right: clamp(14px, 2vw, 28px);
  bottom: clamp(14px, 2vw, 28px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .94);
  font: 500 0.8125rem/1 var(--sans);
  color: var(--ink);
  transition: background-color .3s ease, color .3s ease;
}
.pd-cover-badge svg { width: 13px; height: 13px; }
.pd-cover-link:hover .pd-cover-badge,
.pd-cover-link:focus-visible .pd-cover-badge { background: var(--olive); color: #fff; }
.pd-cover-link:focus-visible { outline: 2px solid #fff; outline-offset: -8px; }

/* Page load: the title rises, the cover opens out and settles from a zoom (as the page banners do) */
.js .pd-title-line > span {
  transform: translateY(110%);
  transition: transform 1.1s var(--ease-out) .25s;
}
.js .pd-crumbs,
.js .pd-hero-meta {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .9s var(--ease-out) .5s, transform .9s var(--ease-out) .5s;
}
.js .pd-cover {
  clip-path: inset(6% 4% 6% 4%);
  transition: clip-path 1.4s var(--ease-out) .3s;
}
.js .pd-cover-img {
  transform: scale(1.12);
  transition: transform 2s var(--ease-out) .3s;
}
.is-loaded .pd-title-line > span,
.is-loaded .pd-cover-img { transform: none; }
.is-loaded .pd-crumbs,
.is-loaded .pd-hero-meta { opacity: 1; transform: none; }
.is-loaded .pd-cover { clip-path: inset(0); }

/* ---------- Details and description ---------- */
.pd-overview-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 32px;
  row-gap: 48px;
  align-items: start;
}
.pd-facts {
  grid-column: 1 / 5;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 961px) {
  .pd-facts { position: sticky; top: calc(var(--header-h) + 32px); }
}
.pd-facts > div {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  column-gap: 16px;
  padding: 15px 0;
}
.pd-facts dt {
  padding-top: 3px;
  font: 500 0.6875rem/1.4 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--stone);
}
.pd-facts dd {
  margin: 0;
  font-size: 0.96875rem;
  line-height: 1.5;
  color: var(--ink);
}

.pd-story { grid-column: 6 / 13; }
.pd-lead {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 1.3vw + 1rem, 2.375rem);
  line-height: 1.28;
  letter-spacing: -0.012em;
  color: var(--ink);
  text-wrap: pretty;
}
.pd-body {
  max-width: 40rem;
  margin: 22px 0 0;
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--ink-soft);
  text-wrap: pretty;
}
.pd-lead + .pd-body { margin-top: clamp(28px, 3vw, 40px); }

/* ---------- Gallery ---------- */
.pd-gallery { padding: 0 0 clamp(80px, 9vw, 140px); }

.pd-gallery-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 24px;
  margin-bottom: clamp(28px, 3vw, 44px);
  padding-top: 24px;
}
.pd-gallery-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.75rem, 1.2vw + 1rem, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.pd-gallery-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--stone);
}

/* Rows of two photographs at their own shape, nothing cropped: content.php gives each its shape (--r, width
   / height) and its share of the row (--w), worked out so both photographs in a row are the same height.
   A row is never taller than --gal-max: a pair of tall photographs is shown smaller, centred. An odd one
   out at the end has the row to itself. */
.pd-gal {
  --gal-gap: clamp(12px, 1.6vw, 24px);
  --gal-max: min(520px, 62svh);
}
.pd-gal-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: var(--gal-gap);
}
.pd-gal-item {
  flex: none;
  width: min(calc((100% - var(--gal-gap)) * var(--w, .5) - .5px), calc(var(--gal-max) * var(--r, 1.5)));
  min-width: 0;
  margin: 0;
}
.pd-gal-row--single .pd-gal-item { width: min(100%, calc(var(--gal-max) * var(--r, 1.5))); }

.pd-gal-link {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: var(--r, 1.5);
  background: var(--plaster);
  cursor: zoom-in;
}
.pd-gal-link img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--ease-out);
}
/* Keeps the reveal from site.css alongside the hover zoom */
.js .pd-gal-link.reveal-media img {
  transition: clip-path 1.4s var(--ease-out) var(--d, 0s), scale 1.9s var(--ease-out) var(--d, 0s), transform 1.2s var(--ease-out);
}
.pd-gal-zoom {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: #fff;
  color: var(--ink);
  opacity: 0;
  transform: scale(.6);
  transition: opacity .4s ease, transform .6s var(--ease-out);
}
.pd-gal-zoom svg { width: 14px; height: 14px; }
@media (hover: hover) {
  .pd-gal-link:hover img { transform: scale(1.04); }
  .pd-gal-link:hover .pd-gal-zoom { opacity: 1; transform: none; }
}
.pd-gal-link:focus-visible { outline-offset: 4px; }
.pd-gal-link:focus-visible .pd-gal-zoom { opacity: 1; transform: none; }

.pd-gal-cap {
  display: flex;
  gap: 14px;
  margin: 0;
  padding: 12px 0 clamp(28px, 3.4vw, 48px);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--stone);
}
.pd-gal-cap span {
  color: var(--olive);
  font-variant-numeric: tabular-nums;
}

/* ---------- Previous and next project ---------- */
.pd-more {
  display: flex;
  margin: 0 var(--gutter);
  height: clamp(280px, 30vw, 440px);
  overflow: hidden;
  background: var(--night);
}
.pd-more-link {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  transition: flex-grow .9s var(--ease-out);
}
.pd-more-media { position: absolute; inset: 0; }
.pd-more-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.4s var(--ease-out);
}
.pd-more-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(24, 19, 16, .2), rgba(24, 19, 16, .62));
  transition: opacity .6s ease;
}
.pd-more-text {
  position: absolute;
  left: clamp(20px, 3vw, 44px);
  right: clamp(20px, 3vw, 44px);
  bottom: clamp(20px, 3vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pd-more-link--next .pd-more-text { align-items: flex-end; text-align: right; }
.pd-more-label {
  font: 500 0.6875rem/1.4 var(--sans);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .8);
}
.pd-more-name {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 2vw + 1rem, 3.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
}
.pd-more-meta {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, .78);
}
.pd-more-arrow {
  position: absolute;
  top: clamp(20px, 3vw, 36px);
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 50%;
  transition: background-color .4s ease, color .4s ease, border-color .4s ease;
}
.pd-more-arrow svg { width: 22px; height: 10px; }
.pd-more-link--prev .pd-more-arrow { left: clamp(20px, 3vw, 44px); transform: scaleX(-1); }
.pd-more-link--next .pd-more-arrow { right: clamp(20px, 3vw, 44px); }
.pd-more-link:focus-visible { outline: 2px solid #fff; outline-offset: -8px; }
@media (hover: hover) and (min-width: 761px) {
  .pd-more-link:hover { flex-grow: 1.3; }
  .pd-more-link:hover .pd-more-media img { transform: scale(1.05); }
  .pd-more-link:hover .pd-more-tint { opacity: .7; }
  .pd-more-link:hover .pd-more-arrow { background: #fff; border-color: #fff; color: var(--ink); }
}

.pd-all {
  display: flex;
  justify-content: center;
  padding: clamp(28px, 3vw, 40px) 0 clamp(72px, 8vw, 120px);
}
.pd-all-link {
  font: 500 0.75rem/1 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  padding-bottom: 8px;
  transition: color .3s ease;
}
.pd-all-link:hover { color: var(--olive); }

/* ---------- Photo viewer (built by site.js) ---------- */
html.lb-lock { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #171512;
  color: #f1efe6;
  opacity: 0;
  transition: opacity .35s ease;
}
.lightbox.is-open { opacity: 1; }
.lightbox[hidden] { display: none; }

.lb-figure {
  position: absolute;
  inset: 72px 96px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
}
.lb-img {
  display: block;
  max-width: 100%;
  max-height: calc(100% - 44px);
  object-fit: contain;
  transition: opacity .35s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.lb-img.is-loading { opacity: 0; }
.lb-caption {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: rgba(241, 239, 230, .82);
}
.lb-count { color: #b7c09a; font-variant-numeric: tabular-nums; }

.lb-close {
  position: absolute;
  top: 18px;
  right: 22px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border: 0;
  background: none;
  font: 500 0.875rem/1 var(--sans);
  color: #f1efe6;
  cursor: pointer;
}
.lb-close svg { width: 14px; height: 14px; }
.lb-prev,
.lb-next {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(241, 239, 230, .3);
  border-radius: 50%;
  background: transparent;
  color: #f1efe6;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}
.lb-prev { left: 22px; }
.lb-next { right: 22px; }
.lb-prev svg,
.lb-next svg { width: 22px; height: 10px; }
.lb-prev svg { transform: scaleX(-1); }
.lb-prev:hover,
.lb-next:hover { background: #f1efe6; border-color: #f1efe6; color: var(--ink); }
.lightbox :focus-visible { outline: 2px solid #f1efe6; outline-offset: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .pd-title,
  .pd-hero-meta { grid-column: 1 / -1; justify-self: start; justify-content: flex-start; }
  .pd-cover { aspect-ratio: 16 / 10; }
  .pd-facts,
  .pd-story { grid-column: 1 / -1; }
  .pd-facts { order: 2; }
}

@media (max-width: 760px) {
  .pd-gal-row { flex-direction: column; align-items: center; gap: 0; }
  .pd-gal-item:nth-child(n) { width: min(100%, calc(80svh * var(--r, 1.5))); }

  .pd-more { flex-direction: column; height: auto; }
  .pd-more-link { height: 240px; flex: none; }
}

@media (max-width: 640px) {
  .pd-cover { aspect-ratio: 4 / 5; min-height: 0; }
  .pd-cover-badge { padding: 9px 12px; font-size: 0.75rem; }
  .pd-gal-zoom { opacity: 1; transform: none; width: 36px; height: 36px; top: 12px; right: 12px; }
  .lb-figure { inset: 64px 12px 92px; }
  .lb-prev,
  .lb-next { top: auto; bottom: 20px; transform: none; }
  .lb-prev { left: calc(50% - 66px); }
  .lb-next { right: calc(50% - 66px); }
}

@media (prefers-reduced-motion: reduce) {
  .js .pd-title-line > span,
  .js .pd-cover-img { transform: none; transition: none; }
  .js .pd-crumbs,
  .js .pd-hero-meta { opacity: 1; transform: none; transition: none; }
  .js .pd-cover { clip-path: none; transition: none; }
  .pd-gal-link img,
  .pd-more-link,
  .pd-more-media img,
  .lightbox,
  .lb-img { transition: none; }
}
