/* =================================================================== */
/*    PARTIAL: OVERLAYS & MODALS                                       */
/*    Contains: Base containers, Testimonials, Product Split-Layout,   */
/*    Macro Zoom Overlay, and Modal Entrance Animations.               */
/* =================================================================== */

/* --- BASE MODAL STRUCTURE --- */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* High z-index to sit above Navbar and regular content */
    z-index: 10000;
    pointer-events: none;
    visibility: hidden;
}

.modal-container::-webkit-scrollbar {
  display: none;
}

.modal-container.active {
    pointer-events: all;
    visibility: visible;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: hsl(0, 0%, 5%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* Dims everything including navbar */
    z-index: 9500;
    transition: var(--transition1);
}

.overlay.active {
    opacity: .8;
    visibility: visible;
    pointer-events: all;
}

/* --- COMMON MODAL UI COMPONENTS --- */
.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--onyx);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--white2);
    font-size: 18px;
    opacity: .7;
    z-index: 10;
}

.modal-close-btn:hover, .modal-close-btn:focus {
  opacity: 1;
}

.modal-close-btn ion-icon {
  --ionicon-stroke-width: 50px;
}

/* --- TESTIMONIALS MODAL --- */
.testimonials-modal {
    background: var(--eerie-black2);
    position: relative;
    padding: 15px;
    margin: 15px 12px;
    border: 1px solid var(--jet);
    border-radius: 14px;
    box-shadow: var(--shadow5);
    transform: scale(1.2);
    opacity: 0;
    transition: var(--transition1);
    z-index: 2;
}

.modal-container.active .testimonials-modal {
    transform: scale(1);
    opacity: 1;
}

.modal-avatar-box {
    background: var(--bg-gradient-onyx);
    width: max-content;
    border-radius: 14px;
    margin-bottom: 15px;
    box-shadow: var(--shadow2);
}

.modal-img-wrapper > img {
  display: none;
}

.modal-title {
  margin-bottom: 4px;
}

.modal-content time {
    font-size: var(--fs6);
    color: var(--light-gray70);
    font-weight: var(--fw500);
    margin-bottom: 10px;
}

.modal-content p {
    color: var(--light-gray);
    font-size: var(--fs6);
    font-weight: var(--fw300);
    line-height: 1.6;
}

/* --- PRODUCT / CATALOG MODAL (SPLIT LAYOUT) --- */
.project-modal {
  background: var(--eerie-black2);
  position: relative;
  padding: 30px;
  border: 1px solid var(--jet);
  border-radius: 20px;
  box-shadow: var(--shadow5);
  transform: scale(1.2);
  opacity: 0;
  transition: var(--transition1);
  z-index: 2;
  width: 95%;
  max-width: 1000px; 
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin; 
  scrollbar-color: var(--jet) transparent;
}

.modal-container.active .project-modal {
  transform: scale(1);
  opacity: 1;
}

.project-modal::-webkit-scrollbar { width: 6px; }
.project-modal::-webkit-scrollbar-track { background: transparent; }
.project-modal::-webkit-scrollbar-thumb { background-color: transparent; border-radius: 20px; }
.project-modal:hover::-webkit-scrollbar-thumb { background-color: var(--jet); }
.project-modal::-webkit-scrollbar-thumb:hover { background-color: var(--orange-yellow-crayola); }

.project-modal-columns {
    display: grid;
    grid-template-columns: 1fr; /* Stacked on mobile */
    gap: 30px;
}

@media (min-width: 768px) {
    .project-modal-columns {
        grid-template-columns: 1.1fr 0.9fr; /* Image left, content right */
        align-items: start;
    }
}

/* Left Column: Media & Thumbnails */
.project-modal-media {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.project-modal-img-wrapper {
    width: 100%;
    background-color: var(--eerie-black1);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--jet);
    position: relative;
}

.project-modal-img-wrapper img {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
}

.project-modal-img-wrapper img[data-catalog-detail-img] {
    cursor: zoom-in !important;
}

.project-modal-img-wrapper img[data-catalog-detail-img]:hover {
    transform: scale(1.02);
}

/* Gallery Navigation Arrows (Overlay) */
.gallery-nav-btn {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    border: 1px solid rgba(255,255,255,0.2);
    cursor: pointer;
    backdrop-filter: blur(2px);
}
.gallery-nav-btn:hover {
    background: var(--orange-yellow-crayola);
    color: black;
    border-color: var(--orange-yellow-crayola);
}
.gallery-nav-btn.prev { left: 10px; }
.gallery-nav-btn.next { right: 10px; }

/* Thumbnails Strip */
.modal-thumbnails-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none; 
    -ms-overflow-style: none; 
}
.modal-thumbnails-row::-webkit-scrollbar { display: none; }

.modal-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: 0.6;
    transition: var(--transition1);
    background: var(--eerie-black1);
    object-fit: cover;
    flex-shrink: 0;
}

.modal-thumbnail:hover { opacity: 1; }
.modal-thumbnail.active {
    opacity: 1;
    border-color: var(--orange-yellow-crayola);
    box-shadow: 0 0 10px rgba(255, 172, 51, 0.2);
}

/* --- 4X MACRO ZOOM OVERLAY --- */
#image-zoom-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.98); 
    cursor: zoom-out;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
    touch-action: none;
}

#image-zoom-overlay.active {
    display: flex !important;
    opacity: 1 !important;
}

#image-zoom-overlay img {
    width: 70vw; 
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    transition: transform 0.2s ease-out, transform-origin 0.1s ease-out; 
    box-shadow: 0 0 50px rgba(0,0,0,0.9);
    pointer-events: none;
    transform: scale(1);
    will-change: transform;
}

#image-zoom-overlay .modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.5); 
    cursor: pointer;
    pointer-events: auto; 
}

@media (min-width: 1024px) {
    #image-zoom-overlay.active img {
        transform: scale(2); 
    }
}

@media (max-width: 1023px) {
    #image-zoom-overlay.active img {
        width: 90vw;
        transform: scale(2.5);
    }
}

/* --- MODAL CONTENT & BUILD STATS --- */
.project-modal-content {
    display: flex;
    flex-direction: column;
    padding-right: 10px; 
}

.build-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 25px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--jet);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--light-gray70);
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-value {
    font-size: 13px;
    color: var(--white2);
    font-weight: 500;
}

.project-modal-cta {
    margin-top: auto; 
    padding-top: 25px;
    border-top: 1px solid var(--jet);
    text-align: center;
}

.cta-subtext {
    font-size: 12px;
    color: var(--light-gray70);
    margin-bottom: 15px;
    font-style: italic;
}

/* --- ENTRANCE ANIMATIONS (WOW FACTOR) --- */
@keyframes modalContentSlideUp {
    from { 
        opacity: 0; 
        transform: translateY(15px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.modal-container.active .project-modal-title {
    opacity: 0;
    animation: modalContentSlideUp 0.5s ease-out forwards;
    animation-delay: 0.2s; 
}

.modal-container.active .price-stock-row {
    opacity: 0;
    animation: modalContentSlideUp 0.5s ease-out forwards;
    animation-delay: 0.3s;
}

.modal-container.active .variant-selector-wrapper {
    opacity: 0;
    animation: modalContentSlideUp 0.5s ease-out forwards;
    animation-delay: 0.35s;
}

.modal-container.active .catalog-actions-row {
    opacity: 0;
    animation: modalContentSlideUp 0.5s ease-out forwards;
    animation-delay: 0.4s;
}

.modal-container.active .project-modal-description {
    opacity: 0;
    animation: modalContentSlideUp 0.6s ease-out forwards;
    animation-delay: 0.5s;
}

@keyframes scaleUp {
    0% { transform: scale(0.5); }
    100% { transform: scale(1); }
}

.modal-container.active .project-modal-img-wrapper img {
    animation: scaleUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* --- MOBILE MODAL OPTIMIZATIONS --- */
@media (max-width: 768px) {
    .project-modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
        /* Padding to clear the sticky checkout bar */
        padding-bottom: 220px !important; 
        background: var(--smoky-black);
        transform: none !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .project-modal-img-wrapper {
        aspect-ratio: 4/3;
    }
}