/*
 * assets/css/single-project.css
 *
 * Layout for the automatic single-project detail page.
 *
 * Structure:
 *   .project-detail                  — two-column grid wrapper
 *   .project-detail__media           — left: hero + image grid + video
 *   .project-detail__figure--hero    — featured image, full width
 *   .project-detail__gallery         — 2-column grid of gallery images
 *   .project-detail__info            — right: sticky info panel
 *
 * Child theme overrides via CSS custom properties:
 *   --pd-cols         grid-template-columns  (default: 55fr 45fr)
 *   --pd-gap          column gap             (default: 0)
 *   --pd-info-top     sticky top offset      (default: 80px)
 *   --pd-padding      info column padding    (default: 3.5rem 2.5rem)
 *   --pd-gallery-gap  gap inside gallery     (default: 4px)
 */

/* ── Outer layout ─────────────────────────────────────────────────────────── */

.project-detail {
  --pd-cols:        55fr 45fr;
  --pd-gap:         0px;
  --pd-header-h:    98px;
  --pd-info-top:    var(--pd-header-h);
  --pd-padding:     3.5rem 2.5rem;
  --pd-gallery-gap: 8px;
  --pd-page-margin: 2rem;

  display: grid;
  grid-template-columns: var(--pd-cols);
  gap: var(--pd-gap);
  align-items: start;
}

/* Match header height at each breakpoint */
@media (max-width: 1200px) {
  .project-detail { --pd-header-h: 84px; }
}
@media (max-width: 1024px) {
  .project-detail { --pd-header-h: 72px; }
}

/* Side and bottom margins for two-column layout (>= 800px) */
@media (min-width: 800px) {
  .project-detail {
    padding-left:   var(--pd-page-margin);
    padding-right:  var(--pd-page-margin);
    padding-bottom: calc(var(--pd-page-margin) / 2);
    padding-top:    3rem;
  }
}

@media (min-width: 1280px) {
  .project-detail { --pd-page-margin: 4rem; }
}

/* Max-width on large screens — constrain both columns */
@media (min-width: 1500px) {
  .project-detail {
    max-width: 1600px;
    margin-inline: auto;
  }
}

/* ── Media column ─────────────────────────────────────────────────────────── */

.project-detail__media {
  display: flex;
  flex-direction: column;
  gap: var(--pd-gallery-gap);
}

/* ── Hero image — full width of the media column ─────────────────────────── */

.project-detail__figure {
  margin: 0;
  line-height: 0;
  display: block;
  overflow: hidden;
}

.project-detail__figure--hero {
  /* Hero always full width — no extra rules needed */
}

.project-detail__image {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.project-detail__gallery .project-detail__figure {
  cursor: pointer;
}

.project-detail__gallery .project-detail__figure:hover .project-detail__image {
  transform: scale(1.04);
}

/* ── Gallery grid — 2 columns, square cells ──────────────────────────────── */

.project-detail__gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--pd-gallery-gap);
}

/* Square crop for every gallery image */
.project-detail__gallery .project-detail__figure {
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.project-detail__gallery .project-detail__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Single gallery image → full width */
.project-detail__gallery .project-detail__figure:only-child {
  grid-column: 1 / -1;
}

/* ── Video ────────────────────────────────────────────────────────────────── */

.project-detail__video {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.project-detail__video iframe,
.project-detail__video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

.project-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.project-lightbox.is-open {
  display: flex;
}

.project-lightbox__inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.project-lightbox__img {
  display: block;
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}

.project-lightbox__close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

/* ── Info column — sticky ─────────────────────────────────────────────────── */

.project-detail__info {
  position: sticky;
  top: var(--pd-info-top);
  padding: var(--pd-padding);
  max-height: calc(100vh - var(--pd-info-top));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.12) transparent;
}

/* ── Back link ────────────────────────────────────────────────────────────── */

.project-detail__back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 1.5rem;
  font-family: var(--font-sans);
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted, #888);
  text-decoration: none;
  transition: color 0.2s ease;
}

.project-detail__back:hover,
.project-detail__back:focus-visible {
  color: var(--color-contrast, #171412);
}

/* ── Location (shown above title) ────────────────────────────────────────── */

.project-detail__location {
  margin: 0 0 0.2rem;
  font-family: "Helvetica Now Display", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--text-sm, 0.875rem);
  font-weight: 600;
  color: var(--color-text, #3a3530);
}

/* ── Category ─────────────────────────────────────────────────────────────── */

.project-detail__category {
  margin: 0 0 0.4rem;
  font-family: var(--font-sans);
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted, #888);
}

/* ── Title ────────────────────────────────────────────────────────────────── */

.project-detail__title {
  margin: 0 0 1rem;
  font-family: "Helvetica Now Display", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(3rem, 5vw, 5rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--color-contrast, #171412);
  text-wrap: balance;
}

/* ── Subtitle ─────────────────────────────────────────────────────────────── */

.project-detail__subtitle {
  margin: 0 0 1.25rem;
  font-family: var(--font-sans);
  font-size: var(--text-sm, 0.875rem);
  font-weight: 400;
  color: var(--color-text-muted, #888);
  line-height: 1.5;
}

/* ── Year ─────────────────────────────────────────────────────────────────── */

.project-detail__year {
  margin: 2rem 0 0;
  font-family: "Helvetica Now Display", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  color: var(--color-text, #3a3530);
}

/* ── Description ──────────────────────────────────────────────────────────── */

.project-detail__description {
  margin: 2rem 0 0;
  font-family: "Helvetica Now Display", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  line-height: var(--leading-relaxed, 1.65);
  color: var(--color-text, #3a3530);
}

.project-detail__description p {
  margin: 0 0 0.75em;
}

.project-detail__description p:last-child {
  margin-bottom: 0;
}

/* ── Meta list ────────────────────────────────────────────────────────────── */

.project-detail__meta-list {
  margin: 0 0 1.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}

.project-detail__meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.project-detail__meta-item dt {
  font-family: var(--font-sans);
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted, #888);
}

.project-detail__meta-item dd {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm, 0.875rem);
  font-weight: 400;
  color: var(--color-contrast, #171412);
}

/* Status dot */
.project-detail__status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.project-detail__status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.project-detail__status--completed   { color: #2d8a4e; }
.project-detail__status--in-progress { color: #b07d2a; }

/* ── Services ─────────────────────────────────────────────────────────────── */

.project-detail__services {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--color-text, #3a3530);
  line-height: var(--leading-relaxed, 1.65);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

/* Mobile (< 800px): single column, carousel, info centered below */
@media (max-width: 799px) {

  .project-detail {
    grid-template-columns: 1fr;
    padding-left: 0;
    padding-right: 0;
  }

  /* Info: centered and constrained — mirrors single-product mobile info */
  .project-detail__info {
    order: 0;
    position: static;
    max-height: none;
    overflow-y: visible;
    width: min(100% - 32px, 500px);
    max-width: 500px;
    padding: 2rem 1.5rem;
    margin-inline: auto;
  }

  .project-detail__meta-list {
    grid-template-columns: 1fr;
  }

  /* Carousel container */
  .pgm-active.project-detail__gallery {
    display: block !important;
    overflow: hidden;
    position: relative;
    background: #f0f0f0;
    aspect-ratio: 1 / 1;
    gap: 0 !important;
  }

  .pgm-strip {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    touch-action: pan-y;
  }

  /* Padding inside each slide — same as single-product */
  .pgm-active .project-detail__figure {
    flex: 0 0 100% !important;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: unset !important;
    padding: 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }

  .pgm-active .project-detail__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Controls row: dots left, arrows right */
  .pgm-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem 0;
  }

  .pgm-dots {
    display: flex;
    gap: 6px;
    align-items: center;
  }

  .pgm-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1.5px solid #0a0a0a;
    background: transparent;
    padding: 0;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
  }

  .pgm-dot.is-active {
    background: #0a0a0a;
  }

  .pgm-nav {
    display: flex;
    gap: 6px;
  }

  .pgm-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid #ccc;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: border-color 0.2s ease, background 0.2s ease;
  }

  .pgm-btn:hover {
    border-color: #888;
    background: #f5f5f5;
  }

  .pgm-btn svg {
    display: block;
    pointer-events: none;
  }

  .pgm-btn:disabled {
    opacity: 0.3;
    cursor: default;
  }

  .project-detail__title {
    font-size: clamp(2rem, 7vw, 2.75rem);
  }
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .project-detail__back { transition: none; }
}

/* ── Related projects ─────────────────────────────────────────────────────── */

.related-projects {
  padding-top: 6rem;
  padding-bottom: 8rem;
  margin-top: 4rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--color-bg, #fff);
}

/* Header row: heading left, nav buttons right */
.related-projects__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-left: clamp(1.5rem, 5vw, 4rem);
  padding-right: clamp(1.5rem, 5vw, 4rem);
}

.related-projects__heading {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-contrast, #171412);
}

.rp-nav {
  display: flex;
  gap: 1rem;
  flex-shrink: 0;
}

.rp-next-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  border: 1px solid #e2e2e2;
  background: #f5f5f5;
  color: #111;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  padding: 0;
}

.rp-next-btn:hover {
  background: #fff;
  border-color: #888;
}

.rp-next-btn.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Scrollable grid — always carousel like single-product */
.related-projects__grid {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 2rem;
  margin-top: 3rem;
  padding-left: clamp(1.5rem, 5vw, 4rem);
  padding-right: clamp(1.5rem, 5vw, 4rem);
}

.related-projects__grid::-webkit-scrollbar {
  display: none;
}

.related-card {
  flex: 0 0 calc(25% - 1.5rem);
  scroll-snap-align: start;
  min-width: 0;
  display: block;
  text-decoration: none;
  color: inherit;
}

.related-card__media {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--color-surface, #f0ede8);
  width: 100%;
}

.related-card__media--empty {
  background: var(--color-surface, #f0ede8);
}

.related-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.related-card:hover .related-card__img {
  transform: scale(1.04);
}

.related-card__body {
  padding: 0;
}

.related-card__title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--color-contrast, #171412);
  margin: 0;
  padding: 1rem 0 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, #000 70%, transparent 100%);
  mask-image: linear-gradient(to right, #000 70%, transparent 100%);
}

.related-card__services {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 400;
  color: #555;
  margin: 0;
  padding-bottom: 1rem;
}

/* Wide screens: constrain width */
@media (min-width: 1500px) {
  .related-projects {
    max-width: 1600px;
    margin-inline: auto;
  }
}

/* Mobile (< 800px) */
@media (max-width: 799px) {
  .related-projects {
    padding-top: 4rem;
    padding-bottom: 5rem;
    margin-top: 2rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .related-projects__header {
    padding-left: 0;
    padding-right: 0;
  }

  .related-projects__grid {
    padding-left: 0;
    padding-right: 0;
    gap: 1rem;
    margin-top: 1.5rem;
  }

  .related-card {
    flex: 0 0 calc(50% - 0.5rem);
  }
}

/* < 700px */
@media (max-width: 699px) {
  .related-projects__heading {
    font-size: 1.4rem;
  }

  .rp-next-btn {
    width: 1.75rem;
    height: 1.75rem;
  }
}
