/* ==========================================================================
   Portfolio index cards + individual project pages
   ========================================================================== */

:root {
  --pj-ink: #1f1a18;
  --pj-paper: #e3dfd5;
  --pj-accent: #543d37;
  --pj-muted: rgba(227, 223, 213, 0.7);
  --pj-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* The theme's <main> is a scroll container (overflow: hidden auto), which stops
   position: sticky from working. Let the page scroll normally on project pages. */
main.project {
  overflow: visible;
  transform: none;
}

/* ---------- Portfolio index: project cards ---------- */

.portfolio-index {
  background: var(--pj-paper);
  padding: 96px 0 72px;
}

.portfolio-index__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 56px 40px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 768px) {
  .portfolio-index__grid {
    grid-template-columns: 1fr 1fr;
  }
}

.project-card {
  display: block;
  color: var(--pj-accent);
  text-decoration: none;
}

.project-card__media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--pj-ink);
}

.project-card__media img.project-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--pj-ease);
}

.project-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(31, 26, 24, 0.55), rgba(31, 26, 24, 0) 55%);
  transition: opacity 0.6s var(--pj-ease);
}

.project-card__title {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 1;
  pointer-events: none;
  color: #fff;
  font-size: clamp(32px, 4vw, 56px);
  line-height: 1;
  white-space: nowrap;
}

.project-card__caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 16px;
  font-family: var(--font-secondary);
  letter-spacing: 0.04em;
}

.project-card__location {
  font-size: 18px;
}

.project-card__cta {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}

.project-card:hover .project-card__image,
.project-card:focus-visible .project-card__image {
  transform: scale(1.04);
}

.project-card:hover .project-card__media::after,
.project-card:focus-visible .project-card__media::after {
  opacity: 0.85;
}

.project-card:focus-visible {
  outline: 2px solid var(--pj-accent);
  outline-offset: 6px;
}

/* Hover/focus text: the theme's link hover colour is light and disappears on the
   light background, so pin these to the dark accent colour. */
.project-card,
.project-card:hover,
.project-card:focus-visible,
.project-card:hover .project-card__location,
.project-card:hover .project-card__cta,
.project-nav__link,
.project-nav__link:hover,
.project-nav__link:focus-visible,
.project-nav__link:hover .project-nav__name,
.project-nav__link:hover .project-nav__label {
  color: var(--pj-accent) !important;
}

/* ---------- Project hero ---------- */

.project-hero {
  position: relative;
  height: 100vh;
  min-height: 480px;
  overflow: hidden;
  background: var(--pj-ink);
  color: #fff;
}

.project-hero__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.08);
  animation: project-hero-settle 2.4s var(--pj-ease) forwards;
}

@keyframes project-hero-settle {
  to { transform: scale(1); }
}

.project-hero__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(31, 26, 24, 0.2), rgba(31, 26, 24, 0.65));
}

.project-hero__content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24vh;
  text-align: center;
  padding: 0 16px;
}

.project-hero__title {
  display: block;
  margin: 0 auto;
  font-size: clamp(48px, 8vw, 120px);
  line-height: 1;
  color: #fff;
}

.project-hero__location {
  margin: 24px 0 0;
  font-family: var(--font-secondary);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--pj-paper);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}

/* ---------- Intro / description ---------- */

.project-intro {
  background: var(--pj-paper);
  color: var(--pj-accent);
  padding: 120px 0 96px;
}

.project-intro .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.project-intro__heading {
  font-family: var(--font-secondary);
  font-weight: 400;
  font-size: clamp(26px, 3.2vw, 40px);
  line-height: 1.25;
  margin: 0 0 56px;
}

/* Description copy uses the theme's <h4> styling, same as the other pages. */
.project-intro__body h4 {
  max-width: 62ch;
}

.project-publication {
  margin: 0 0 40px;
  font-family: var(--font-secondary);
  font-size: 17px;
  letter-spacing: 0.04em;
}

.project-publication a {
  color: var(--pj-accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- Gallery ---------- */

.project-gallery {
  position: relative;
  background: var(--color-accent-secondary-1, #543d37);
  color: var(--pj-paper);
}

.project-gallery__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.project-gallery__track {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4vw;
  height: 68vh;
  padding: 0 5vw;
  width: max-content;
  will-change: transform;
}

.project-gallery__item {
  position: relative;
  flex: 0 0 auto;
  height: 100%;
  margin: 0;
  transform-origin: center center;
  transition: transform 0.25s linear;
}

.project-gallery__button {
  display: block;
  position: relative;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.project-gallery__button img {
  display: block;
  height: 100%;
  width: auto;
  max-width: none;
  transition: filter 0.5s var(--pj-ease);
}

.project-gallery__button:hover img,
.project-gallery__button:focus-visible img {
  filter: brightness(1.06);
}

.project-gallery__button:focus-visible {
  outline: 2px solid var(--pj-paper);
  outline-offset: 6px;
}

.project-gallery__zoom {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  line-height: 32px;
  text-align: center;
  border-radius: 50%;
  background: rgba(31, 26, 24, 0.6);
  color: var(--pj-paper);
  font-size: 22px;
  opacity: 0;
  transition: opacity 0.4s var(--pj-ease);
}

.project-gallery__button:hover .project-gallery__zoom,
.project-gallery__button:focus-visible .project-gallery__zoom {
  opacity: 1;
}

.project-gallery__controls {
  display: flex;
  align-items: center;
  gap: 20px;
  width: min(560px, 86vw);
  margin: 40px auto 0;
  font-family: var(--font-secondary);
}

.project-gallery__arrow {
  background: none;
  border: 1px solid rgba(227, 223, 213, 0.4);
  color: var(--pj-paper);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.3s var(--pj-ease), border-color 0.3s var(--pj-ease);
}

.project-gallery__arrow:hover,
.project-gallery__arrow:focus-visible {
  background: var(--pj-paper);
  color: var(--pj-ink);
  border-color: var(--pj-paper);
}

.project-gallery__progress {
  flex: 1;
  height: 1px;
  background: rgba(227, 223, 213, 0.25);
  overflow: hidden;
}

.project-gallery__progress span {
  display: block;
  height: 100%;
  background: var(--pj-paper);
  transform-origin: left center;
  transform: scaleX(0);
}

.project-gallery__count {
  font-size: 17px;
  letter-spacing: 0.12em;
  min-width: 96px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--pj-paper);
}

/* Native swipe fallback: mobile and reduced-motion users */
.project-gallery.is-native .project-gallery__sticky {
  position: relative;
  height: auto;
  padding: 72px 0 64px;
}

.project-gallery.is-native .project-gallery__track {
  height: 62vh;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 16px;
  gap: 12px;
  transform: none !important;
  width: 100%;
  box-sizing: border-box;
}

.project-gallery.is-native .project-gallery__track::-webkit-scrollbar {
  display: none;
}

.project-gallery.is-native .project-gallery__item {
  scroll-snap-align: center;
  height: auto;
  transform: none !important;
  opacity: 1 !important;
}

/* Let the photo keep its own proportions: cap both dimensions instead of
   forcing a fixed height, which squashed images on narrow screens. */
.project-gallery.is-native .project-gallery__button {
  height: auto;
}

.project-gallery.is-native .project-gallery__button img {
  height: auto;
  width: auto;
  max-width: 86vw;
  max-height: 62vh;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 10, 9, 0.94);
  opacity: 0;
  transition: opacity 0.25s var(--pj-ease);
  padding: 56px 72px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  max-height: 100%;
}

.lightbox__image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  width: auto;
  height: auto;
  object-fit: contain;
  transform: scale(0.98);
  transition: transform 0.4s var(--pj-ease);
}

.lightbox.is-open .lightbox__image {
  transform: scale(1);
}

.lightbox__caption {
  margin-top: 16px;
  font-family: var(--font-secondary);
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--pj-paper);
  text-align: center;
}

.lightbox__close,
.lightbox__arrow {
  position: absolute;
  background: none;
  border: 0;
  color: var(--pj-paper);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  padding: 12px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.lightbox__close:hover,
.lightbox__arrow:hover,
.lightbox__close:focus-visible,
.lightbox__arrow:focus-visible {
  opacity: 1;
}

.lightbox__close {
  top: 12px;
  right: 16px;
  font-size: 40px;
}

.lightbox__arrow {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__arrow_prev {
  left: 12px;
}

.lightbox__arrow_next {
  right: 12px;
}

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

@media (max-width: 767px) {
  .lightbox {
    padding: 56px 8px 48px;
  }

  .lightbox__arrow {
    top: auto;
    bottom: 12px;
    transform: none;
  }
}

/* ---------- Previous / next project ---------- */

.project-nav {
  background: var(--pj-paper);
  color: var(--pj-accent);
  padding: 72px 0 48px;
  border-top: 1px solid rgba(84, 61, 55, 0.2);
}

.project-nav .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.project-nav__link {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  color: var(--pj-accent);
  text-decoration: none;
}

.project-nav__label {
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
}

.project-nav__name {
  font-family: var(--font-secondary);
  font-size: clamp(22px, 3vw, 34px);
}

.project-nav__link:hover .project-nav__name {
  text-decoration: underline;
  text-underline-offset: 6px;
}

.project-nav__back {
  margin-top: 56px;
}

@media (max-width: 767px) {
  .project-intro {
    padding: 80px 0 64px;
  }

  .project-gallery__controls {
    width: 88vw;
  }
}
