/**
 * Gallery CSS - Matches live site bizleyart.com
 * Extracted and adapted for JoomGallery 4 on Joomla 5
 */

/* Base gallery styling */
.gallery, .gallery-section {
    text-align: center;
    font-size: 0.9em;
    bottom: 0;
    width: 100%;
    height: auto;
}

/* Flexbox list container */
.gallery ul, .gallery-section ul {
    display: -webkit-box;
    display: -webkit-flex;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    background: #f8f8ff;
    padding-top: 18px;
    list-style: none;
    margin: 0;
    padding-left: 0;
}

/* Section headers */
.gallery h3, .gallery-section h3 {
    font-size: 18px;
    font-size: 1.6rem;
    text-transform: uppercase;
    line-height: 90px;
    letter-spacing: 0.3em;
    margin: 0.67em 0;
    width: 100%;
    text-align: center;
}

/* Nest2: For categories with subcategories (Prehistoric) */
.gallery .nest2 > li, .gallery-section .nest2 > li {
    width: 100%;
}

.gallery .nest2 > li > .imgtitle, .gallery-section .nest2 > li > .imgtitle {
    font-size: 1.3rem;
}

/* Category items - both nest levels */
.gallery .nest2 ul li,
.gallery .nest1 li,
.gallery-section .nest2 ul li,
.gallery-section .nest1 li {
    display: block;
    position: relative;
    background: #f8f8ff;
    color: #646464;
    float: left;
    margin-bottom: 36px;
    width: 100%;
}

/* Category link wrapper - makes entire card clickable */
.gallery .cat-link,
.gallery-section .cat-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.gallery .cat-link:hover,
.gallery-section .cat-link:hover {
    box-shadow: 0 0 9px 5px #b1b1b1;
    border-bottom: 3px solid #ff5722;
}

.gallery .cat-link img,
.gallery-section .cat-link img {
    display: block;
    width: 100%;
}

@media (min-width: 600px) {
    .gallery .nest2 ul li,
    .gallery .nest1 li,
    .gallery-section .nest2 ul li,
    .gallery-section .nest1 li {
        width: calc(50% - 18px);
    }
}

@media (min-width: 1022px) {
    .gallery .nest2 ul li,
    .gallery .nest1 li,
    .gallery-section .nest2 ul li,
    .gallery-section .nest1 li {
        width: calc(33.333333333333333333333% - 18px);
    }
}

/* Link overlay styles removed - using .cat-link wrapper instead */

.gallery .nest2 ul li a:before,
.gallery-section .nest2 ul li a:before {
    display: none;
}

/* Thumbnail images */
.gallery .nest2 ul li img,
.gallery .nest1 li img,
.gallery-section .nest2 ul li img,
.gallery-section .nest1 li img {
    object-fit: cover;
    width: 100%;
    height: 160px;
    margin-bottom: 9px;
    background: #eee;
}

/* Image replacement (for categories without thumbnails) */
.gallery .nest2 ul li .imgreplacement,
.gallery .nest1 li .imgreplacement,
.gallery-section .nest2 ul li .imgreplacement,
.gallery-section .nest1 li .imgreplacement {
    display: block;
    width: 100%;
    height: 160px;
    line-height: 160px;
    font-size: 1.6rem;
    background: #eee;
}

/* Title styling */
.imgtitle {
    display: block;
    width: 100%;
    text-align: center;
    line-height: 1em;
    margin-bottom: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

/* Responsive adjustments for 2 items */
@media (min-width: 600px) {
    .nest1 li:nth-last-child(-n+2):first-child,
    .nest1 li:nth-last-child(-n+2):first-child ~ li {
        width: calc(50% - 18px);
    }
}

/* Hide default JoomGallery styling when using custom gallery */
.jg-gallery.custom-gallery-active {
    display: none;
}

/* Typography */
.gallery-section li {
    line-height: 1.6em;
}

/* Base link styling from live site */
.gallery a, .gallery-section a {
    text-decoration: none;
    color: inherit;
}

/* ========================================
   IMAGE GALLERY STYLES (for category pages with images)
   Matches live site's simple grid layout
   ======================================== */

/* JG Photo - thumbnail images in image list */
.gallery .jg_photo {
    object-fit: cover;
    width: 100%;
    height: 160px;
    margin-bottom: 9px;
    background: #eee;
    display: block;
}

/* Image list item styling adjustments */
.gallery .nest1 li {
    padding-bottom: 40px; /* Space for more details button */
    position: relative;
}

/* Container div inside li */
.gallery .nest1 li > div:first-child {
    position: relative;
}

/* Lightbox link overlay - covers the image */
.gallery .nest1 li .lightbox {
    position: absolute;
    top: 5px;
    left: 10px;
    right: 10px;
    height: 160px;
    z-index: 10;
    cursor: pointer;
    border: none;
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    transition: all 0.2s ease;
}

.gallery .nest1 li .lightbox:hover {
    box-shadow: 0 0 9px 5px #b1b1b1;
}

.gallery .nest1 li .lightbox:before {
    display: none;
}

/* More Details button */
.more_details_btn {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: #ff5722;
    color: #fff !important;
    text-transform: uppercase;
    text-decoration: none !important;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-align: center;
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    transition: all 0.2s ease;
    z-index: 5;
    border: none !important;
}

.more_details_btn:hover {
    background: #e64a19;
    color: #fff !important;
    text-decoration: none !important;
}

/* ========================================
   CSS-ONLY LIGHTBOX
   Pure CSS lightbox implementation
   ======================================== */

/* Lightbox target container (hidden by default) */
.lightbox-target {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-bottom: 80px; /* Space for caption */
}

/* Show lightbox when targeted */
.lightbox-target:target {
    display: flex;
}

/* Lightbox image */
.lightbox-target img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    background: transparent;
    margin: auto;
    height: auto !important;
}

/* Close button link */
.lightbox-close {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #fff;
    font-size: 50px;
    text-decoration: none;
    cursor: pointer;
    z-index: 10001;
    line-height: 1;
    padding: 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 5px;
}

.lightbox-close:hover {
    color: #ff5722;
    background: rgba(0,0,0,0.8);
}

/* Background close overlay - click anywhere to close */
.lightbox-overlay-close {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
}

/* Gallery navigation back button styling */
.gallery-nav {
    text-align: center;
    padding: 20px 0;
}

.gallery-nav a {
    display: inline-block;
    padding: 10px 20px;
    background: #333;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 3px;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    border: none !important;
}

.gallery-nav a:hover {
    background: #ff5722;
}

/* ========================================
   IMAGE DETAIL PAGE STYLES
   Matches live site artwork detail view
   ======================================== */

.component.detail {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

.artworkdetail {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 20px;
}

.artworkdetail .artwork {
    flex: 1;
    min-width: 300px;
    max-width: 600px;
    position: relative;
}

.artworkdetail .artwork img.jg_photo {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.artworkdetail .artwork:hover img.jg_photo {
    opacity: 0.9;
}

.artworkdetail .artwork .lightbox {
    display: block;
    position: relative;
}

.artworkdetail .artwork .lightbox .imgtitle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 10px 20px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.artworkdetail .artwork .lightbox:hover .imgtitle {
    opacity: 1;
}

.artworkdetail .artworkdescription {
    flex: 1;
    min-width: 300px;
}

.artworkdetail .artworkdescription h3 {
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 20px;
    color: #333;
}

.artworkdetail .artworkdescription p {
    line-height: 1.8;
    color: #555;
    margin-bottom: 20px;
}

.artworkdetail .pathway {
    margin-top: 20px;
}

.artworkdetail .details h4,
.artworkdetail .category h4 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 10px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.artworkdetail .details table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.artworkdetail .details table td {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.artworkdetail .details table td:first-child {
    font-weight: bold;
    width: 100px;
    color: #666;
}

.artworkdetail .category {
    margin-top: 15px;
}

.artworkdetail .category a {
    color: #ff5722;
    text-decoration: none;
}

.artworkdetail .category a:hover {
    text-decoration: underline;
}

/* Navigation Arrows */
.leftarrow, .rightarrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.9);
    padding: 15px;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    z-index: 100;
}

.leftarrow {
    left: 20px;
}

.rightarrow {
    right: 20px;
}

.leftarrow:hover, .rightarrow:hover {
    background: #ff5722;
}

.leftarrow:hover svg, .rightarrow:hover svg {
    fill: #fff;
}

.leftarrow svg, .rightarrow svg {
    display: block;
    transition: fill 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .artworkdetail {
        flex-direction: column;
    }
    
    .artworkdetail .artwork,
    .artworkdetail .artworkdescription {
        max-width: 100%;
    }
    
    .leftarrow, .rightarrow {
        top: auto;
        bottom: 100px;
        transform: none;
    }
    
    .leftarrow {
        left: 20px;
    }
    
    .rightarrow {
        right: 20px;
    }
}

/* ========================================
   FANCYBOX CAPTION INSIDE LIGHTBOX
   ======================================== */

/* Container for image in lightbox - flex layout */
.lightbox-target .lightbox-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-height: calc(100vh - 100px);
}

.lightbox-target .lightbox-image-container img {
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
}

/* Caption wrap at bottom of lightbox */
.lightbox-target .fancybox-caption-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 20px;
    z-index: 999996;
}

.lightbox-target .fancybox-caption {
    text-align: center;
}

.lightbox-target .fancybox-image-caption {
    color: #fff;
    font-size: 16px;
    line-height: 1.6;
}

.lightbox-target .fancybox-image-caption .button {
    display: inline-block;
    margin-top: 8px;
    padding: 10px 24px;
    background: #ff5722;
    color: #fff !important;
    text-decoration: none;
    border-radius: 3px;
    font-weight: bold;
    transition: background 0.2s ease;
}

.lightbox-target .fancybox-image-caption .button:hover {
    background: #e64a19;
    text-decoration: none;
}
