/* ===========================
   MODAL / CAROUSEL
   =========================== */

/* Configurable carousel gap — adjust this value to change all image gaps */
:root {
  --modal-carousel-gap: 28px;
}

.project-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  background: rgba(13, 11, 8, 0.7);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.project-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.project-modal {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 0;
  padding: 0 0 40px 0;  /* REMOVED horizontal padding (was 0 24px 40px) */
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.06);
  transform: translateY(12px) scale(0.997);
  transition: opacity 0.22s ease, transform 0.22s ease;
  font-family: var(--font-body);
  opacity: 0;
}
.project-modal-overlay.open .project-modal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.project-modal-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px 0;  
  position: sticky;
  top: 0;
  background: linear-gradient(
    180deg,
    rgba(45, 37, 26, 0.98) 0%,
    rgba(45, 37, 26, 0.92) 100%
  );
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2;
  padding: 16px 24px; 
}

.project-modal-title {
  font-family: var(--font-retro);
  font-size: 1.6rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0;
  text-align: center;
}

.project-modal-close {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font-retro);
  font-weight: 600;
  letter-spacing: 1px;
  transition: color 0.15s ease;
}

.project-modal-right {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.project-modal-left {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

.project-modal-next-project,
.project-modal-prev-project {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  width: 64px;
  height: 64px;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-retro);
  font-size: 54px;
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.project-modal-next-project:hover,
.project-modal-prev-project:hover {
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.25);
}
.project-modal-close:hover {
  color: var(--text-primary);
}

.project-modal-media,
.project-modal-meta,
.project-modal-meta-rows,
.project-modal-description,
.project-modal-tags {
  max-width: 1500px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 24px;
  width: calc(100% - 48px);
}

.project-modal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.project-modal-year {
  font-family: var(--font-retro);
  font-size: 24px;
  letter-spacing: 1px;
  color: var(--warm-brown);
  text-transform: uppercase;
  font-weight: 600;
}

.project-modal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.project-modal-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-retro);
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 4px 10px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.project-modal-links a:hover {
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.3);
}

.project-modal-video {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(255,255,255,0.03);
  border-radius: 4px;
  max-width: 1500px;
  margin-left: auto;
  margin-right: auto;
  width: calc(100% - 48px);
}

.project-modal-video a,
.project-modal-video button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-retro);
  font-size: 13px;
  padding: 10px 16px;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  text-decoration: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  white-space: nowrap;
  flex: 1;
  min-width: 140px;
}

.project-modal-video a:hover,
.project-modal-video button:hover {
  background-color: rgba(255,255,255,0.08);
  border-color: var(--text-secondary);
  transform: translateY(-1px);
}

.project-modal-media {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-flow: dense;
  gap: var(--modal-carousel-gap);
  margin-bottom: 16px;
}

.project-modal-media .project-modal-image:first-child:not(.is-portrait) {
  grid-column: 1 / -1;
}

.project-modal-media .project-modal-image.is-portrait {
  grid-column: auto;
  grid-row: span 2;
  aspect-ratio: auto;
  height: 100%;
}

.project-modal-media .project-modal-image.is-lone-last {
  grid-column: 1 / -1;
  grid-row: auto;
  aspect-ratio: 4 / 3;
}

.project-modal-image {
  border: none;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
  overflow: hidden;
  background-color: var(--bg-secondary);
  position: relative;
}

.project-modal-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.project-modal-description {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.8;
  white-space: pre-wrap;
}

.project-modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  row-gap: 12px;
  margin-top: 8px;
  margin-bottom: 16px;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(13, 11, 8, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10000;
}

.image-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.image-lightbox-inner {
  max-width: 94vw;
  max-height: 92vh;
}

.image-lightbox-img {
  max-width: 100%;
  max-height: 92vh;
  border-radius: 6px;
  display: block;
}

/* Modal meta rows - for Produced for and Collaborators */
.project-modal-meta-rows .project-info-row {
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr);
  column-gap: 10px;
  align-items: start;
  margin-top: 2px;
  font-size: 22px;
  font-family: var(--font-retro);
  font-weight: 400;
  line-height: 1.1;
  text-rendering: geometricPrecision;
}

.project-modal-meta-rows .project-info-row .info-label {
  font-weight: 400;
  color: var(--text-primary);
  text-transform: uppercase;
}

.project-modal-meta-rows .project-info-row .info-value {
  font-family: var(--font-retro);
  font-weight: 400;
  color: var(--text-secondary);
  min-width: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Link styles - matching about page exactly */
.project-modal-meta-rows .info-value a {
  display: inline;
  position: relative;
  font-weight: 400;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: none;
  transition: color 0.2s ease;
  padding: 0 2px;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

.project-modal-meta-rows .info-value a:hover {
  color: var(--bg-secondary);
}

.project-modal-meta-rows .info-value .bio-link.bio-muted {
  color: var(--text-secondary);
}

/* Color variations - same as about page */
.project-modal-meta-rows .info-value a.bio-red {
  --bio-accent: rgba(255, 71, 86, 1);
  color: var(--rgb-red);
}

.project-modal-meta-rows .info-value a.bio-green {
  --bio-accent: rgba(46, 213, 115, 1);
  color: var(--rgb-green);
}

.project-modal-meta-rows .info-value a.bio-blue {
  --bio-accent: rgba(83, 82, 237, 1);
  color: var(--rgb-blue);
}

.project-modal-meta-rows .info-value a.bio-highlight {
  --bio-accent: var(--color-highlight);
  color: var(--color-highlight);
}

.project-modal-meta-rows .info-value a.bio-red:hover,
.project-modal-meta-rows .info-value a.bio-green:hover,
.project-modal-meta-rows .info-value a.bio-blue:hover,
.project-modal-meta-rows .info-value a.bio-highlight:hover,
.project-modal-meta-rows .info-value a:hover {
  color: var(--bg-secondary);
}

/* Underline animation - same as about page */
.project-modal-meta-rows .info-value a::after {
  content: '';
  position: absolute;
  width: calc(100% + 4px);
  height: 1.2em;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bio-accent);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.project-modal-meta-rows .info-value a:hover::after {
  opacity: 1;
}

/* ===========================
   MODAL MOBILE RESPONSIVE
   =========================== */

@media (max-width: 768px) {
  .project-modal-media {
    grid-template-columns: 1fr !important;
    gap: var(--modal-carousel-gap);
  }

  /* Force a consistent height for stacked images on mobile so gaps look even */
  .project-modal-media .project-modal-image:first-child:not(.is-portrait),
  .project-modal-media .project-modal-image.is-portrait,
  .project-modal-media .project-modal-image.is-lone-last {
    grid-column: 1 / -1;
    grid-row: auto;
    height: auto;
  }

  /* Give all modal images a shared aspect ratio on small screens */
  .project-modal-image {
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    display: block;
  }

  .project-modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
  }

  .project-modal-media,
  .project-modal-meta,
  .project-modal-meta-rows,
  .project-modal-description,
  .project-modal-tags,
  .project-modal-video {
    width: calc(100% - 32px);  /* Smaller padding on mobile */
  }

  .project-modal-meta-rows .project-info-row {
    grid-template-columns: 1fr;
    row-gap: 4px;
    margin-top: 4px;
    font-size: 22px;
    line-height: 1.1;
  }

  .project-modal-meta-rows .project-info-row .info-label {
    white-space: normal;
  }

  .project-modal-meta-rows .project-info-row .info-value {
    padding-left: 0;
  }
}

@media (max-width: 600px) {
  .project-modal {
    padding: 0 0 28px 0;
  }
  
  .project-modal-header {
    margin: 0 0 14px 0;
    padding: 14px 16px;
    grid-template-columns: 88px 1fr 88px;
    gap: 6px;
  }

  .project-modal-title {
    font-size: 1.3rem;
  }
  
  .project-modal-left,
  .project-modal-right {
    width: 88px;
  }
  
  .project-modal-next-project,
  .project-modal-prev-project {
    width: 30px;
    height: 30px;
    font-size: 34px;
  }
  
  .project-modal-close {
    width: 30px;
    height: 30px;
    font-size: 28px;
    transform: translateY(4px);
  }
  
  .project-modal-media {
    gap: var(--modal-carousel-gap);
  }

  .project-modal-media,
  .project-modal-meta,
  .project-modal-meta-rows,
  .project-modal-description,
  .project-modal-tags,
  .project-modal-video {
    width: calc(100% - 32px);
  }
}