/* ----------------------------------------------------------
   PORTFOLIO PAGE + PORTFOLIO MODAL
---------------------------------------------------------- */

/* Portfolio grid (same as before) */
.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 720px) {
  .portfolio-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Portfolio card */
.portfolio-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  position: relative;
}

.portfolio-card h3 {
  margin: 10px 0 6px;
  font-size: 18px;
}

.portfolio-card p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 14px;
}

.portfolio-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.portfolio-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
}

/* ----------------------------------------------------------
   PORTFOLIO MODAL
---------------------------------------------------------- */

/* Overlay */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.25s ease-out;
  z-index: 9999;
}

/* Modal container */
.app-modal {
  position: relative;
  width: 90%;
  max-width: 1400px;
  height: 90%;
  background: #fff;
  border-radius: 12px;
  display: flex;
  overflow: hidden;
}

/* Left side (images) */
.modal-left {
  width: 30%;
  min-width: 320px;
  background: #f7f7f7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Image wrapper */
.image-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Screenshot */
.screenshot {
  max-width: 95%;
  max-height: 95%;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

/* Navigation arrows */
.nav_model {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.85);
  border: none;
  font-size: 32px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  z-index: 10;
}

.nav_model.prev { left: -10px; }
.nav_model.next { right: -10px; }

/* Right side (HTML details) */
.modal-right {
  width: 70%;
  height: 100%;
  overflow-y: auto;
  display: block;
}

/* Iframe */
.app-details-frame {
  width: 100%;
  height: calc(100% - 60px);
  border: none;
}

/* Buttons */
.more-details-btn,
.back-to-images-btn {
  display: none;
  padding: 10px 18px;
  background: #b8860b;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  margin: 12px auto;
}

.more-details-btn:hover,
.back-to-images-btn:hover {
  background: #a6760a;
}

/* ----------------------------------------------------------
   MOBILE BEHAVIOR (Option B)
---------------------------------------------------------- */
@media (max-width: 720px) {

  .app-modal {
    flex-direction: column;
    height: 90%;
  }

  .modal-left {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    padding: 20px 0;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .more-details-btn {
    display: block !important;
  }

  .modal-right {
    display: none !important;
    width: 100%;
    height: calc(100% - 60px);
  }

  .back-to-images-btn {
    display: block !important;
  }

  .app-details-frame {
    height: calc(100% - 60px);
  }
}


/* ---------------------------
   PORTFOLIO MODAL FIXES (paste last)
   --------------------------- */

/* Ensure overlay locks scroll and modal is centered */
.app-modal-overlay {
  display: none; /* controlled by JS */
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
}

/* Modal container: use a state class to control layout */
.app-modal {
  position: relative;
  width: 92%;
  max-width: 1400px;
  height: 90vh;
  max-height: 92vh;
  background: #fff;
  border-radius: 12px;
  display: flex;
  overflow: hidden;
  align-items: stretch;
}

/* Default two-column layout */
.app-modal .modal-left {
  width: 34%;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center; /* vertical center */
  align-items: center;
  background: #f7f7f7;
  padding: 18px;
  box-sizing: border-box;
}

/* Image wrapper fills left column and centers content */
.app-modal .image-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center; /* vertical center */
  justify-content: center; /* horizontal center */
  padding: 8px;
  box-sizing: border-box;
}

/* Screenshot: responsive, centered, no collapse */
.app-modal .screenshot {
  max-width: 100%;
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  display: block;
  margin: 0 auto;
}

/* Right column */
.app-modal .modal-right {
  width: 66%;
  min-width: 360px;
  height: 100%;
  overflow-y: auto;
  display: block;
  box-sizing: border-box;
  padding: 18px;
}

/* State: details mode (right panel visible, left may be hidden on mobile) */
.app-modal.details-mode .modal-left {
  /* keep left visible on desktop; on mobile JS will switch layout */
  display: flex;
}

.app-modal.details-mode .modal-right {
  display: block !important;
}

/* Mobile: stacked layout; JS will toggle .details-mode to show right panel */
@media (max-width: 720px) {
  .app-modal {
    flex-direction: column;
    height: 92vh;
  }

  .app-modal .modal-left {
    width: 100% !important;
    min-width: 0;
    height: auto;
    padding: 14px;
  }

  .app-modal .modal-right {
    width: 100%;
    height: calc(100% - 60px);
    display: none; /* default hidden on mobile until details-mode */
  }

  /* When details-mode is active on mobile, show right panel and hide left */
  .app-modal.details-mode .modal-left {
    display: none !important;
  }

  .app-modal.details-mode .modal-right {
    display: block !important;
  }

  /* Ensure screenshot remains centered when left is visible */
  .app-modal .image-wrapper { padding: 12px 0; }
}

/* Ensure close button sits above iframe and is consistent */
.modal-close,
.modal-close-app {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  border: 1px solid #e6e6e6;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10010;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Defensive: override any stray !important hiding rules */
.modal-right,
.app-details-frame,
.modal-left,
.image-wrapper,
.screenshot {
  -webkit-transform: translateZ(0); /* promote to its own layer to avoid repaint issues */
  transform: translateZ(0);
}

/* When overlay is active, lock body scroll (JS toggles class on body) */
body.modal-open {
  overflow: hidden;
  touch-action: none;
}
