/* =========================================================
   PROJECT DETAILS POPUP
   Opens when a portfolio image is clicked. Shows the project
   title, description, a swipeable photo gallery, and (when
   real before/after pairs are supplied in js/portfolio-data.js)
   a before/after comparison slider.
   ========================================================= */

.pm-open {
  overflow: hidden;
}

.project-modal {
  position: fixed;
  inset: 0;
  z-index: 10500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.project-modal.active {
  display: flex;
}

.project-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(3px);
}

.project-modal-dialog {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 980px;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(160deg, var(--black-medium), var(--black-light));
  border: 1px solid rgba(255, 193, 7, 0.25);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  padding: 30px 30px 35px;
  animation: pmPopIn 0.25s ease;
}

@keyframes pmPopIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.project-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--gold-primary);
  background: rgba(0, 0, 0, 0.5);
  color: var(--gold-primary);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  z-index: 3;
}

.project-modal-close:hover {
  background: var(--gold-primary);
  color: var(--black-primary);
  transform: rotate(90deg);
}

.project-modal-share {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--gold-primary);
  background: rgba(0, 0, 0, 0.5);
  color: var(--gold-primary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  z-index: 4;
}

.project-modal-share:hover,
.project-modal-share[aria-expanded="true"] {
  background: var(--gold-primary);
  color: var(--black-primary);
}

.pm-share-panel {
  position: absolute;
  top: 64px;
  left: 16px;
  z-index: 5;
  background: var(--black-medium);
  border: 1px solid rgba(255, 193, 7, 0.35);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

.pm-share-panel[hidden] {
  display: none;
}

.pm-share-title {
  color: #d8d8d8;
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.pm-share-panel a {
  color: var(--gold-primary);
  font-size: 1.2rem;
  transition: all 0.2s ease;
}

.pm-share-panel a:hover {
  color: var(--gold-light);
  transform: scale(1.15);
}

.project-modal-header {
  padding-right: 50px;
  padding-left: 50px;
  margin-bottom: 20px;
}

.pm-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gold-primary);
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.project-modal-header h3 {
  font-family: 'Playfair Display', serif;
  color: var(--white);
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0 0 10px;
}

.project-modal-header p {
  color: #d8d8d8;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  margin: 0;
  max-width: 720px;
}

/* Tabs */
.project-modal-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(255, 193, 7, 0.15);
}

.pm-tab-btn {
  background: none;
  border: none;
  color: #b8b8b8;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 10px 4px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}

.pm-tab-btn:hover {
  color: var(--gold-light);
}

.pm-tab-btn.active {
  color: var(--gold-primary);
  border-bottom-color: var(--gold-primary);
}

.pm-tab-btn[hidden] {
  display: none;
}

/* Main image stage */
.project-modal-stage {
  position: relative;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pm-image-wrap {
  width: 100%;
  height: 100%;
  position: relative;
}

.pm-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.pm-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 193, 7, 0.85);
  color: var(--black-primary);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: all 0.2s ease;
}

.pm-nav:hover {
  background: var(--gold-primary);
  transform: translateY(-50%) scale(1.1);
}

.pm-prev { left: 14px; }
.pm-next { right: 14px; }

.pm-counter {
  text-align: center;
  color: var(--gold-primary);
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 12px;
}

/* Thumbnail strip */
.pm-thumbs {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.pm-thumbs::-webkit-scrollbar {
  height: 6px;
}

.pm-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 193, 7, 0.4);
  border-radius: 3px;
}

.pm-thumb {
  flex: 0 0 auto;
  width: 74px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.2s ease;
  padding: 0;
  background: #111;
}

.pm-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pm-thumb:hover {
  opacity: 0.9;
}

.pm-thumb.active {
  border-color: var(--gold-primary);
  opacity: 1;
}

/* Before / After comparison slider */
.pm-beforeafter {
  margin-top: 6px;
}

.pm-ba-item {
  margin-bottom: 22px;
}

.pm-ba-item:last-child {
  margin-bottom: 0;
}

.pm-ba-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  user-select: none;
  touch-action: pan-y;
}

.pm-ba-slider img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.pm-ba-before-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.pm-ba-before-wrap img {
  width: 100%;
  height: 100%;
}

.pm-ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--gold-primary);
  transform: translateX(-50%);
  cursor: ew-resize;
  z-index: 4;
}

.pm-ba-handle::after {
  content: '\f337';
  font-family: 'FontAwesome';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold-primary);
  color: var(--black-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.pm-ba-label {
  position: absolute;
  top: 14px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.65);
  color: var(--white);
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 193, 7, 0.5);
}

.pm-ba-label-before { left: 14px; }
.pm-ba-label-after { right: 14px; }

.pm-ba-sample-flag {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: var(--gold-primary);
  color: var(--black-primary);
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
}

.pm-ba-caption {
  text-align: center;
  color: #cfcfcf;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  margin-top: 10px;
}

.pm-empty-state {
  text-align: center;
  padding: 50px 20px;
  color: #b8b8b8;
  font-family: 'Inter', sans-serif;
}

.pm-empty-state i {
  font-size: 2.2rem;
  color: var(--gold-primary);
  margin-bottom: 14px;
  display: block;
}

/* Loading skeleton for lazily-loaded grid/thumb images */
.pm-loading .pm-image-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,193,7,0.06) 25%, rgba(255,193,7,0.18) 50%, rgba(255,193,7,0.06) 75%);
  background-size: 200% 100%;
  animation: pmLoading 1.4s infinite;
}

@keyframes pmLoading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 768px) {
  .project-modal {
    padding: 0;
  }

  .project-modal-dialog {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: 16px 14px 24px;
    display: flex;
    flex-direction: column;
  }

  .project-modal-header {
    padding-left: 46px;
    padding-right: 46px;
  }

  .project-modal-header h3 {
    font-size: 1.15rem;
  }

  .project-modal-header p {
    font-size: 0.88rem;
  }

  .project-modal-close,
  .project-modal-share {
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
    top: 10px;
  }

  .project-modal-close { right: 10px; }
  .project-modal-share { left: 10px; }

  .pm-share-panel {
    top: 52px;
    left: 10px;
    right: 10px;
    flex-wrap: wrap;
  }

  .project-modal-tabs {
    gap: 18px;
    margin-bottom: 12px;
  }

  .pm-tab-btn {
    font-size: 0.78rem;
    padding: 8px 2px;
  }

  .project-modal-stage {
    aspect-ratio: 4 / 3;
    flex: 0 0 auto;
  }

  .pm-nav {
    width: 38px;
    height: 38px;
    font-size: 1.05rem;
  }

  .pm-prev { left: 8px; }
  .pm-next { right: 8px; }

  .pm-thumbs {
    margin-top: 12px;
  }

  .pm-thumb {
    width: 56px;
    height: 42px;
  }

  .pm-ba-slider {
    aspect-ratio: 4 / 3;
  }

  .pm-ba-handle::after {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }

  .pm-ba-label,
  .pm-ba-sample-flag {
    font-size: 0.65rem;
    padding: 4px 10px;
  }
}

@media (max-width: 420px) {
  .project-modal-tabs {
    gap: 12px;
  }

  .pm-tab-btn {
    font-size: 0.72rem;
  }
}

/* Short / landscape phones: keep the stage from pushing controls off-screen */
@media (max-height: 480px) and (orientation: landscape) {
  .project-modal-dialog {
    padding-top: 10px;
  }

  .project-modal-header {
    margin-bottom: 10px;
  }

  .project-modal-header p {
    display: none;
  }

  .project-modal-stage {
    aspect-ratio: 16 / 7;
  }
}
