/*
 * Custom styles for the GS Gallery plugin.
 * This handles the grid layout of thumbnails for both default and directory galleries.
 * gsgallery/css_gsgallery.css
 * version 1.0.1
 */

/* =======================================
   Gallery Container Styles
   ======================================= */

/* Styles for individual member galleries (e.g., ?member=username)
   and also for the main directory listing. They will look the same for now. */
.gsgallery-container,
.gsgallery-directory-container {
    display: grid;
    /* Use the smaller thumbnail size for both for now */
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px; /* Slightly more space */
    margin: 20px auto;
    padding: 10px;
    max-width: 1200px;
}


/* =======================================
   Gallery Item Styles (Shared for Default and Directory)
   ======================================= */

.gsgallery-item,
.gsgallery-directory-item {
    /* Ensure figure elements don't have default margins */
    margin: 0;
    padding: 0;
    text-align: center;
    background-color: #f8f8f8; /* Light background for items */
    border: 1px solid #eee;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 5px;
    overflow: hidden; /* Ensures image corners are rounded if figure has border-radius */
    display: flex; /* Use flexbox for vertical alignment */
    flex-direction: column;
    justify-content: space-between; /* Pushes caption to bottom if image is smaller */
    align-items: center; /* Center items horizontally within their cell */
    height: 100%; /* Ensure all items take full height in their grid cell */
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out; /* Smooth hover effect */
 /* --- Add these lines to limit the container size --- */
    max-width: 300px; 
    max-height: 300px; 

}

.gsgallery-item:hover,
.gsgallery-directory-item:hover {
    transform: translateY(-3px); /* Slight lift on hover */
    box-shadow: 0 5px 10px rgba(0,0,0,0.2); /* More prominent shadow on hover */
}


/* =======================================
   Thumbnail & Link Styles (Shared)
   ======================================= */

.gsgallery-link,
.gsgallery-directory-link { /* Apply to both gallery links */
    display: flex; /* Changed to flex to help center images */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
    width: 100%;
    /* The height/overflow properties will be handled by the image itself */
    overflow: hidden; /* Ensure image corners are rounded if the link has border-radius */
    box-sizing: border-box; /* Include padding/border in total dimensions */
}

/* Updated selector to target the img directly within the item for consistent styling */
.gsgallery-item img,
.gsgallery-directory-item img {
    display: block; /* Remove extra space below image */
    width: 100%; /* Take full width of its flex parent */
    height: 100%; /* Take full height of its flex parent */
    object-fit: cover; /* Cover the area, cropping if necessary (e.g., if you set a fixed height) */
    aspect-ratio: 1 / 1; /* Force square aspect ratio for thumbnails */
    border-bottom: 1px solid #eee; /* Separator between image and caption */
    transition: transform 0.2s ease-in-out; /* Smooth hover effect */
}

.gsgallery-item img:hover,
.gsgallery-directory-item img:hover {
    transform: scale(1.05); /* Slightly enlarge on hover */
}

/* =======================================
   Caption Styles (Shared & Specific for Directory)
   ======================================= */

.gsgallery-caption,
.gsgallery-directory-caption {
    font-size: 0.9em;
    text-transform: uppercase;
    color: #555;
    padding: 10px 5px;
    word-break: break-word; /* Break long words */
    width: 100%; /* Ensure caption takes full width */
    flex-grow: 1; /* Allow caption to take up remaining space if item has a height */
    display: flex; /* Use flexbox for caption to align text */
    align-items: flex-end; /* Align caption text to the bottom if there's extra space */
    justify-content: center; /* Center caption text horizontally */
}

/* Specific styling for the link *inside* directory captions */
.gsgallery-directory-caption a {
    text-decoration: none;
    color: #333; /* Default text color for the link */
    font-weight: bold;
    display: block; /* Make the entire caption text clickable */
}

.gsgallery-directory-caption a:hover {
    color: #0073aa; /* WordPress blue on hover */
    text-decoration: underline;
}

/* =======================================
   Placeholder for empty directory folders
   ======================================= */

.gsgallery-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1; /* Match thumbnail aspect ratio */
    background-color: #e9e9e9;
    color: #666;
    font-size: 1.1em;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    height: auto; /* Allow height to adjust based on aspect-ratio */
}

/* =======================================
   Empty Gallery Message Styles
   ======================================= */
.gsgallery-empty-message {
    text-align: center;
    margin: 40px auto; /* More vertical space */
    padding: 30px;
    background-color: #f9f9f9;
    border: 1px dashed #ccc; /* Dashed border for a softer look */
    border-radius: 8px;
    max-width: 600px; /* Constrain width */
    color: #666;
    font-size: 1.1em;
    line-height: 1.6;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); /* Subtle shadow */
}

.gsgallery-empty-message p {
    margin: 0; /* Remove default paragraph margin */
    font-weight: bold; /* Make the message stand out */
}

.gsgallery-empty-message strong {
    color: #333; /* Make the member name slightly darker */
}


/* ---
   Pagination Styles (Designed for Flexbox with consistent HTML)
   --- */

.gsgallery-pagination { /* Apply these styles to both paginations */
    display: flex; /* Use flexbox for horizontal layout */
    justify-content: space-between; /* Pushes items to the ends with space between */
    align-items: center; /* Vertically centers content within the row */
    gap: 15px; /* Space between flex items */
    margin: 20px auto; /* Center the pagination div itself and add vertical spacing */
    padding: 5px;
    clear: both; /* Clear floats above it, important if previous elements are floated */
    max-width: 1200px; /* Constrain width */
    position: relative; /* Needed for absolute positioning of the middle element */
}

/* Style for the button links. WordPress's wp-block-button__link is often `display: inline-flex`
   or similar, but we want to ensure it behaves well within our flex items. */
.gsgallery-pagination .wp-block-button__link {
    width: auto; /* Allows button to take its content width */
    display: inline-block; /* Ensures it respects padding/margins and doesn't take full cell width by default */
    white-space: nowrap; /* Prevent button text from wrapping onto multiple lines */
}

/* Position and align the "Previous Set" button wrapper */
.gsgallery-pagination-prev-wrapper {
    /* Flexbox handles positioning, no need for grid-column or justify-self */
    flex-shrink: 0; /* Prevent shrinking */
}
/* Style for the pagination info text (e.g., "Set X of N") in the middle.
   Use absolute positioning for precise centering. */
.gsgallery-pagination-info {
    position: absolute; /* Position relative to .gsgallery-pagination */
    left: 50%; /* Start at the horizontal center of the parent */
    transform: translateX(-50%); /* Move back by half its own width to truly center */
    
    display: flex; /* Use flex for internal content alignment */
    align-items: center; /* Vertically align content */
    justify-content: center; /* Horizontally align content */

    font-size: 1.1em;
    font-weight: bold;
    color: #555;
    white-space: nowrap; /* Prevent "Directory" from wrapping */
    padding: 0; /* No need for padding, flex gap handles spacing */
    box-sizing: border-box; /* Ensure padding is included in width calculation */
    width: auto; /* Allow it to shrink to content width */
    max-width: 240px; /* Keep a max-width to prevent excessive growth */
    z-index: 1; /* Ensure it's above other elements if they overlap slightly */

    /* New Amazon-style properties */
    border: 1px solid #ddd; /* Add a light gray border */
    border-radius: 4px; /* Add slightly rounded corners */
    background-color: #fff; /* Ensure a white background */
}

/* Position and align the 'Next' button wrapper */
.gsgallery-pagination-next-wrapper{
    /* Flexbox handles positioning, no need for grid-column or justify-self */
    flex-shrink: 0; /* Prevent shrinking */
}
/* =======================================
   PhotoSwipe Base Styles (Minimal - for visibility control)
   ======================================= */

/* Basic styling for the PhotoSwipe UI, which is primarily handled by css_photoswipe.css */
/* Ensure the PhotoSwipe root element is hidden until active */
.pswp {
    display: none;
}

/* When PhotoSwipe is open, ensure it's visible */
.pswp--open {
    display: block;
}
/* =======================================
   Artist Pagination Specific Styles
   ======================================= */
.gsgallery-pagination-info .gsgallery-base-link {
    color: inherit; /* Use inherited color from parent, or set a specific color */
    display: inline-flex; /* Allows icon and text to sit nicely side-by-side */
    align-items: center; /* Vertically aligns icon and text */
    padding: 5px 8px; /* Add some padding for better click area */
    border-radius: 4px; /* Slightly rounded corners */
    text-decoration: none; /* Remove default underline */
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition for hover effects */
}

.gsgallery-pagination-info .gsgallery-base-link .dashicons {
    margin-right: 5px; /* Space between icon and text */
    font-size: 18px; /* Adjust icon size if needed */
    line-height: 1; /* Ensure icon aligns well with text */
}

.gsgallery-pagination-info .gsgallery-base-link:hover {
    background-color: rgba(0, 0, 0, 0.05); /* Subtle background on hover */
    color: #202020; /* Standard WordPress blue on hover, or your theme's link color */
    cursor: pointer; /* Indicate it's clickable */
}

/* Add a focus style for accessibility */
.gsgallery-pagination-info .gsgallery-base-link:focus {
    outline: 2px solid #e3e3e3; /* Outline for keyboard navigation */
    outline-offset: 2px;
}
/* ---
   Basic Responsiveness (Adjustments for smaller screens)
   --- */

/* Keep 768px breakpoint to desktop behavior (single row) */
@media (max-width: 768px) {
    .gsgallery-pagination {
        flex-direction: row; /* Keep items in a row */
        align-items: center; /* Vertically center items */
        position: relative; /* Maintain relative positioning for absolute child */
        gap: 15px; /* Maintain desktop gap */
    }

    .gsgallery-pagination-prev-wrapper,
    .gsgallery-pagination-next-wrapper {
        width: auto; /* Allow width to be determined by content */
        white-space: nowrap; /* Prevent text wrapping */
        flex-shrink: 0; /* Prevent shrinking */
    }

    .gsgallery-pagination-info {
        position: absolute; /* Maintain absolute positioning for centering */
        left: 50%; /* Maintain horizontal centering */
        transform: translateX(-50%); /* Maintain horizontal centering */
        display: flex; /* Maintain flex for internal content alignment */
        align-items: center; /* Maintain vertical alignment */
        justify-content: center; /* Maintain horizontal alignment */
        width: auto; /* Allow width to shrink-wrap content */
        white-space: nowrap; /* Prevent text wrapping */
        max-width: 200px; /* Maintain max-width */
        margin-top: 0; /* Ensure no top margin */
        order: unset; /* Remove explicit order for desktop-like behavior */
    }

    /* Ensure buttons within wrappers also take full width if desired,
       or at least center themselves. */
    .gsgallery-pagination .wp-block-button {
        width: auto; /* Allow button block to size to content */
        text-align: center; /* Center the button content */
    }

    .gsgallery-pagination .wp-block-button__link {
        width: 150px; /* Fixed width for the button link */
        min-width: 120px; /* Ensure a minimum width */
        max-width: 180px; /* Ensure a maximum width */
        display: inline-block; /* Keep it inline-block to respect width */
        padding: 10px 15px; /* Adjust padding for stacked buttons */
        box-sizing: border-box; /* Include padding in width */
        white-space: nowrap; /* Prevent text from wrapping */
        overflow: hidden; /* Hide overflow if text is too long */
        text-overflow: ellipsis; /* Add ellipsis for overflowing text */
    }
}


@media (max-width: 480px) {
    .gsgallery-pagination {
        flex-direction: column; /* Stack items vertically for smaller screens */
        align-items: center; /* Center items horizontally when stacked */
        gap: 10px; /* Adjust gap for stacking */
        position: static; /* Reset position for mobile stacking */
    }

    .gsgallery-pagination-prev-wrapper,
    .gsgallery-pagination-next-wrapper {
        justify-self: center; /* Center the grid item itself within its column */
        width: 100%; /* Make them full width */
        white-space: normal; /* Allow text to wrap */
        /* Remove fixed width properties from here */
    }

    .gsgallery-pagination-info {
        position: static; /* Reset absolute positioning for mobile stacking */
        transform: none; /* Reset transform for mobile stacking */
        display: block; /* Make it a block element for stacking */
        margin: 0 auto; /* Center the block element horizontally */
        text-align: center; /* Center text content within the block */
        width: 100%; /* Make it full width */
        white-space: normal; /* Allow text to wrap */
        margin-top: 0; /* Reset margin-top for stacked view */
        max-width: none; /* Remove max-width for mobile stacking */
    }

    /* Order the elements for phone view */
    .gsgallery-pagination-info {
        order: 1; /* Make the info span appear first */
    }

    .gsgallery-pagination-prev-wrapper {
        order: 2; /* Make the previous button appear second */
    }

    .gsgallery-pagination-next-wrapper {
        order: 3; /* Make the next button appear third */
    }

    /* Adjust button width for very small screens if needed */
    .gsgallery-pagination .wp-block-button__link {
        width: 100%; /* Make the link itself full width */
        min-width: unset; /* Remove min-width constraint */
        max-width: unset; /* Remove max-width constraint */
        display: block; /* Ensure it behaves as a block for full width */
        padding: 10px 15px; /* Adjust padding for stacked buttons */
        box-sizing: border-box; /* Include padding in width */
        white-space: normal; /* Allow text to wrap within the button link */
        overflow: visible; /* Allow overflow to be visible if needed */
        text-overflow: clip; /* Clip text instead of ellipsis for full width */
    }
}
/* --- Amazon-style Pagination for Center Numbers Only --- */

/* Style the container for the numbers, adding the main box look */
.gsgallery-pagination-numbers-container {
    display: flex; /* Use flexbox to align numbers horizontally */
    align-items: center; /* Vertically center the numbers */
    list-style: none; /* Remove list bullets */
    margin: 0;
    padding: 0;
    gap: 0;
    border: 1px solid #ddd; /* Add the border around the entire block of numbers */
    border-radius: 4px; /* Add subtle rounded corners */
    font-family: inherit; /* Inherit font from the body */
    background-color: #fff;
}

/* Style each individual number link or ellipsis */
.gsgallery-pagination-numbers-container .page-numbers {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 8px 12px;
    text-decoration: none;
    color: #555;
    background-color: #fff;
    border-right: 1px solid #ddd; /* Add a vertical separator between links */
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Style for the current (active) page */
.gsgallery-pagination-numbers-container .page-numbers.current {
    background-color: #f0f0f0; /* Light gray background for the active page */
    color: #000;
    font-weight: bold;
    cursor: default; /* Indicate this is not a clickable link */
}

/* Style for the ellipsis (...) */
.gsgallery-pagination-numbers-container .dots {
    color: #888;
    padding: 8px 12px;
    border-right: 1px solid #ddd;
}

/* Remove the border from the last item to avoid an extra line at the end */
.gsgallery-pagination-numbers-container .page-numbers:last-child {
    border-right: none;
}

.gsgallery-pagination-numbers-container .dots:last-child {
    border-right: none;
}

.gsgallery-custom-overlay-text {
    /* Basic Layout & Positioning */
    position: fixed; /* Stays in place relative to the viewport */
    z-index: 2147483647; /* Ensure it's on top of PhotoSwipe and everything else */
    
    /* Positioning */
    top: 38px;   /* Distance from the top of the screen (adjust as needed) */
    left: 10px;   
    
    /* Appearance */
    color: #ffffff; /* White text */
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent black background */
    padding-right: 8px;
    padding-left: 8px;
     /* border-radius: 0px;Slightly rounded corners */
    font-size: 14px; /* Text size */
    text-align: left; /* Center the text inside the div */
    /* pointer-events: none; Allows clicks to pass through to the PhotoSwipe UI behind it */
    text-transform: uppercase;

    /* Optional: for animation */
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* Optional: If you want it to fade in/out or animate */
/* You might need to add/remove a class via JS for more complex animations */
.gsgallery-copy-link-button {
    cursor: pointer;
}