/* Project detail layout — reference-based two-column presentation */

.page--project {
  height: min(var(--project-height), calc(100svh - 120px));
  padding: 0;
  overflow: hidden;
}

.project-detail {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
  gap: 38px;
  align-items: stretch;
  padding: 28px 6px 8px 0;
}

.project-gallery-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto;
  gap: 5px;
  align-content: start;
}

.project-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  background: #fff;
  overflow: hidden;
  contain: layout paint;
  outline: none;
  touch-action: pan-y pinch-zoom;
}

.project-stage.is-clickable {
  cursor: zoom-in;
}

.project-stage.is-clickable:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: -1px;
}

/* Media is locked to the stage bounds. The whole source remains visible,
   keeps its original aspect ratio, and can never extend outside the square. */
.project-stage > img,
.project-stage > video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  object-fit: contain;
  object-position: center;
  background: #fff;
  opacity: 1;
  transition: opacity 180ms ease;
  will-change: opacity;
}

.project-stage.is-media-faded > img,
.project-stage.is-media-faded > video {
  opacity: 0;
}

.project-gallery-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 16px;
  margin-top: 10px;
  white-space: nowrap;
}

.project-gallery-controls button,
.project-lightbox button {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.project-gallery-controls button:hover,
.project-gallery-controls button:focus-visible,
.project-lightbox button:hover,
.project-lightbox button:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
  outline: none;
}

.project-copy-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 24px;
}

.project-copy-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 20px;
  row-gap: 4px;
  align-items: baseline;
}

.project-copy-header h1,
.project-copy-header p {
  margin: 0;
  font-size: inherit;
  line-height: inherit;
  font-weight: 400;
}

.project-title-main,
.project-title-brand {
  font-weight: 700;
}

.project-title-prefix,
.project-title-year,
.project-format {
  font-weight: 400;
}

.project-format {
  grid-column: 1 / -1;
}

.project-copy-scroll {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}

.project-copy-scroll::-webkit-scrollbar {
  width: 7px;
}

.project-copy-scroll::-webkit-scrollbar-track {
  background: transparent;
  border: 1px solid var(--muted);
}

.project-copy-scroll::-webkit-scrollbar-thumb {
  background: var(--muted);
}

.project-copy-body {
  display: grid;
  gap: 18px;
  padding-bottom: 18px;
}

.project-copy-body p {
  margin: 0;
  white-space: pre-line;
}

.project-copy-meta {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.project-copy-meta p {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
}

.project-copy-meta span:first-child {
  color: var(--muted);
}

/* Full-screen gallery */
.project-lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 3000;
  overflow: hidden;
  background: #fff;
  color: var(--text);
}

.project-lightbox[hidden] {
  display: none;
}

.project-lightbox__inner {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

/* Center against the viewport itself, not the portfolio layout. */
.project-lightbox__stage {
  position: fixed;
  z-index: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(68vw, 990px);
  height: min(68dvh, 730px);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  contain: layout paint;
  touch-action: pan-y pinch-zoom;
}

.project-lightbox__stage > img,
.project-lightbox__stage > video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  object-fit: contain;
  object-position: center;
  background: #fff;
  opacity: 1;
  transition: opacity 180ms ease;
  will-change: opacity;
}

.project-lightbox__stage.is-media-faded > img,
.project-lightbox__stage.is-media-faded > video {
  opacity: 0;
}

.project-lightbox__close,
.project-lightbox__prev,
.project-lightbox__next,
.project-lightbox__counter {
  z-index: 4;
}

.project-lightbox__close {
  position: fixed;
  top: 18px;
  right: 22px;
}

.project-lightbox__prev,
.project-lightbox__next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  padding: 18px !important;
}

.project-lightbox__prev { left: 8px; }
.project-lightbox__next { right: 8px; }

.project-lightbox__counter {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

body.is-lightbox-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .project-stage > img,
  .project-stage > video,
  .project-lightbox__stage > img,
  .project-lightbox__stage > video {
    transition: none;
  }
}

@media (max-width: 700px) {
  .page--project {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .project-detail {
    height: auto;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 0;
  }

  .project-gallery-pane {
    grid-template-rows: auto auto;
  }

  .project-stage {
    width: min(88vw, 460px);
    justify-self: center;
    aspect-ratio: 1 / 1;
  }

  .project-gallery-controls button {
    min-width: 28px;
    min-height: 28px;
  }

  .project-copy-pane {
    display: grid;
    grid-template-rows: auto auto;
    gap: 18px;
  }

  .project-copy-scroll {
    overflow: visible;
    padding-right: 0;
  }

  /* Mobile lightbox uses nearly the complete viewport while preserving
     enough edge space for large, tappable previous/next controls. */
  .project-lightbox__stage {
    top: 50dvh;
    width: calc(100vw - 28px);
    height: calc(100dvh - 104px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-width: none;
    max-height: none;
  }

  .project-lightbox__close {
    top: calc(8px + env(safe-area-inset-top));
    right: 8px;
    min-width: 52px;
    min-height: 44px;
    padding: 10px !important;
  }

  .project-lightbox__prev,
  .project-lightbox__next {
    top: 50dvh;
    width: 48px;
    height: 72px;
    display: grid;
    place-items: center;
    padding: 0 !important;
  }

  .project-lightbox__prev { left: 0; }
  .project-lightbox__next { right: 0; }

  .project-lightbox__counter {
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
}
