/* Modale galleria per Portfolio 2
   Prefisso classi: p2-modal-
*/

.p2-modal-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  /* Su desktop teniamo la modale agganciata in alto, con un piccolo margine */
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
  padding-top: 40px;
  padding-bottom: 24px;
}

.p2-modal-root[hidden] {
  display: none;
}

.p2-modal-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.98));
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.p2-modal-shell {
  position: relative;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  max-height: calc(100vh - 64px);
  max-height: calc(100svh - 64px);
  max-height: calc(100dvh - 64px);
  margin: 0 16px;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .p2-modal-shell {
    margin: 0 32px;
  }
}

.p2-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(248, 250, 252, 0.6);
  background: rgba(15, 23, 42, 0.75);
  color: #f9fafb;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.p2-modal-close:hover {
  background: rgba(15, 23, 42, 0.95);
}

.p2-modal-brand {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.p2-modal-logo-image {
  max-width: 180px;
  width: 50%;
  height: auto;
  display: block;
}

.p2-modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px 14px;
  color: #e5e7eb;
}

.p2-modal-title {
  text-align: center;
  font-size: 1rem;
  color: #cbd5f5;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.p2-modal-title-main {
  font-weight: 600;
}

.p2-modal-title-desc {
  font-size: 0.85rem;
  color: #9ca3af;
}

/* Barre progress in alto (stile social) */
.p2-modal-progress {
  margin: 8px 24px 0;
  display: flex;
  gap: 6px;
  pointer-events: none;
}

.p2-modal-progress-bar {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: transparent;
  overflow: hidden;
}

.p2-modal-progress-bar-fill {
  width: 100%;
  height: 100%;
  background: #4b5669;
  border-radius: inherit;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.p2-modal-gallery {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  padding-top: 8px;
}

.p2-modal-rail {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.p2-modal-slide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 90vw;
  height: calc(100vh - 200px);
  height: calc(100svh - 200px);
  height: calc(100dvh - 200px);
  max-height: calc(100vh - 140px);
  max-height: calc(100svh - 140px);
  max-height: calc(100dvh - 140px);
  z-index: 1;
}

.p2-modal-slide img {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.p2-modal-slide iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.p2-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.2s ease;
}

.p2-modal-nav svg {
  width: 28px;
  height: 28px;
}

.p2-modal-nav--prev {
  left: 16px;
}

.p2-modal-nav--next {
  right: 16px;
}

.p2-modal-nav:hover {
  background: rgba(0, 0, 0, 0.75);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-50%) scale(1.1);
}

/* Su mobile le frecce RESTANO visibili: navigazione principale tramite frecce */

.p2-modal-footer {
  padding: 12px 8px 8px;
  text-align: center;
  font-size: 0.8rem;
  color: #9ca3af;
}

.p2-modal-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.7);
}

/* Quando la modale è aperta nascondiamo il footer/navigation in basso
   (classe p2-modal-footer) per avere un'esperienza full-immersion */
body.p2-modal-open .p2-modal-footer {
  display: none;
}


