/*
Theme Name: kh-portfolio
Author: Your Name (optional)
Description: A minimalistic greyscale portfolio theme for photographers.
Version: 1.0
Text Domain: kh-portfolio
*/
/* Removed: Console log for style.css version */


/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------
1.0 - Reset & General Styles
2.0 - Typography
3.0 - Header & Navigation
4.0 - Portfolio Page
5.0 - Contact Page
6.0 - Footer
7.0 - Mobile Styles
8.0 - Fullscreen Gallery Overlay
9.0 - About Page Columns
10.0 - Utility Classes
--------------------------------------------------------------*/

/*--------------------------------------------------------------
1.0 - Reset & General Styles
--------------------------------------------------------------*/
html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    background-color: #FFFFFF; /* Changed to solid white */
    color: #333; /* Dark grey text */
    font-family: sans-serif; /* Fallback font */
    line-height: 1.6;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    max-width: 100%; /* User's change */
    margin: 0 auto;
    padding: 0 20px;
}

.site-content {
    /* Adjusted to directly compensate for header height */
    padding-top: 80px; /* Assuming header height is around 80px (20px top/bottom padding + content) */
    padding-bottom: 40px;
}

/*--------------------------------------------------------------
2.0 - Typography
--------------------------------------------------------------*/
body {
    font-family: 'Manrope', sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    color: #111; /* Very dark grey headings */
    font-weight: bold;
    line-height: 1.2;
    margin-bottom: 1em;
}

p {
    margin-bottom: 1.5em;
}

a {
    color: #555;
    text-decoration: none;
}

a:hover {
    color: #111;
}

/*--------------------------------------------------------------
3.0 - Header & Navigation
--------------------------------------------------------------*/
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #FFFFFF; /* Changed to solid white, removed rgba for consistency */
    padding: 20px 0; /* Adjust this padding to control header height */
    z-index: 1000; /* Ensure header is on top */
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-branding {
    flex-grow: 0;
    flex-shrink: 0;
}

.site-logo img { /* Targets the actual logo image */
    max-height: 70px; /* User's change: set max height for the logo */
    width: auto; /* Maintain aspect ratio */
}

.main-navigation {
    flex-grow: 1; /* Allow navigation to take up remaining space */
    text-align: right; /* Align menu to the right */
}

.main-navigation ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    justify-content: flex-end; /* Align menu items to the right */
}

.main-navigation li {
    margin-left: 20px;
}

.main-navigation li:first-child {
    margin-left: 0;
}

.main-navigation a {
    display: block;
    padding: 10px 15px;
}

.hamburger-menu {
    display: none; /* Hidden by default on desktop, will be shown in mobile media query */
    cursor: pointer;
    padding: 0; /* Removed padding to make it truly square based on width/height */
    background: none; /* Ensure no default button background */
    border: none; /* Ensure no default button border */
    position: relative; /* Needed for z-index to work reliably on Safari */
    z-index: 1001; /* Ensure it's above the navigation for clicking */
    -webkit-appearance: none; /* Remove default button styling for Safari */
    appearance: none;
    line-height: 0; /* Remove extra space below bars */
    width: 40px; /* Example: set a fixed width for the square */
    height: 40px; /* Example: set a fixed height for the square (adjust based on mobile logo height) */
    display: flex; /* Use flex to center bars */
    flex-direction: column;
    justify-content: center; /* Center bars vertically */
    align-items: center; /* Center bars horizontally */
}

.bar {
    width: 25px; /* Width of the individual bars */
    height: 3px;
    background-color: #000000; /* Changed to black */
    margin-bottom: 5px; /* Spacing between bars */
    transition: 0.3s;
}

.hamburger-menu .bar:last-child {
    margin-bottom: 0; /* No margin after the last bar */
}


/* Desktop Logo Width Constraint (20% of navigation) */
@media (min-width: 769px) { /* Apply on desktop and larger */
    .site-header .container {
        display: flex; /* Ensure flexbox is active */
        align-items: center;
        justify-content: space-between;
    }

    .site-branding {
        /* On desktop, explicitly give site-branding a width */
        width: 20%; /* Logo takes 20% of the header width */
        max-width: 200px; /* Or a max pixel width if the logo gets too big */
    }

    .site-logo img {
        width: 100%; /* Make the image fill its container */
        height: auto;
    }

    .main-navigation {
        width: 80%; /* Navigation takes 80% of the header width */
        text-align: right; /* Ensure menu items align right */
    }

    /* Hide hamburger on desktop */
    .hamburger-menu {
        display: none;
    }
}

/*--------------------------------------------------------------
4.0 - Portfolio Page
--------------------------------------------------------------*/
/* Crucial styles for the Masonry container, applied to figure.wp-block-gallery by functions.php filter */
figure.wp-block-gallery.portfolio-grid { /* This is now applied to figure.wp-block-gallery */
    display: block !important; /* Force block display for Masonry container */
    margin: 0 auto !important; /* Center the grid and override WP default margins */
    padding: 0 10px !important; /* Apply padding consistently and override WP default */
    width: 100% !important; /* Take full available width */
    max-width: none !important; /* Ensure it doesn't get constrained by parent defaults */
    box-sizing: border-box !important;
    margin-bottom: 40px !important; /* FIX: Footer gap - set to 40px and !important to override any other margin */
    clear: both !important; /* Ensure no floats interfere with it */
    overflow: hidden !important; /* Prevent margin collapsing and ensure floats are contained */
    position: relative !important; /* Essential for Custom JS Masonry's absolute positioning of items */
    min-height: 1px; /* Ensure it always has some height */


    /* Explicitly remove ALL layout properties that could conflict from global-styles-inline-css */
    flex: none !important;
    flex-wrap: unset !important;
    flex-direction: unset !important;
    justify-content: unset !important;
    align-items: unset !important;
    grid-template-columns: unset !important;
    grid-gap: unset !important;
    gap: unset !important;
    -ms-grid-columns: unset !important; /* For IE11 Grid */
}

/* Styles for individual items within the Masonry grid (applied to figure.wp-block-image by functions.php filter) */
figure.wp-block-image.portfolio-item { /* This is now applied to figure.wp-block-image */
    overflow: hidden;
    margin: 2.5px !important; /* Half of the desired 5px spacing */
    float: left !important; /* Crucial for Custom JS Masonry's positioning */
    box-sizing: border-box !important; /* Corrected typo: should be border-box */
    display: block !important; /* Ensure the item is a block-level element */
    
    /* **CRITICAL**: FORCE absolute positioning AND ADD TRANSITIONS */
    position: absolute !important; /* Force absolute position */
    left: auto !important; /* Reset any default positioning */
    top: auto !important; /* Reset any default positioning */
    right: auto !important;
    bottom: auto !important;
    transform: none !important; /* Reset any default transforms */
    max-width: 100% !important; /* Images should respect container width */
    height: auto !important; /* Images should respect original aspect ratio */
    
    /* Explicitly remove flex properties that might interfere with absolute positioning */
    flex: none !important;
    align-self: unset !important;
    justify-self: unset !important;

    /* Smooth Transitions for Custom JS Masonry */
    transition: top 0.4s ease-out, left 0.4s ease-out, width 0.4s ease-out; /* Add transitions */
}

.portfolio-item img {
    width: 100%;
    height: auto; /* Allow image height to be dynamic */
    display: block;
    object-fit: contain;
    cursor: pointer;
}

/* Desktop columns (3 columns) */
@media (min-width: 769px) {
    .portfolio-item {
        width: calc(33.333333% - 5px) !important; /* Three columns: 100% / 3 = 33.333333%, then subtract for 5px total margin */
    }
}


/*--------------------------------------------------------------
5.0 - Contact Page
--------------------------------------------------------------*/
.contact-content {
    padding: 40px 20px;
}

/*--------------------------------------------------------------
6.0 - Footer
--------------------------------------------------------------*/
.site-footer {
    color: #111; /* User's change */
    padding: 20px 0;
    text-align: center;
    font-size: 0.8em;
    background-color: #FFFFFF; /* Changed to solid white */
}

.site-footer a {
    color: #111; /* User's change */
}

.site-footer a:hover {
    color: #ccc;
}

/*--------------------------------------------------------------
7.0 - Mobile Styles
--------------------------------------------------------------*/
@media (max-width: 768px) {
    .site-header .container {
        flex-wrap: nowrap; /* Prevent wrapping so logo and hamburger stay on one line */
        justify-content: space-between; /* Space between logo and hamburger */
        align-items: center;
    }

    .site-branding {
        flex-grow: 1; /* Allow logo area to grow */
        max-width: calc(100% - 60px); /* Adjust based on hamburger width to keep it inline */
    }

    .site-logo img {
        max-height: 40px; /* Smaller max height for mobile logo */
        width: auto; /* Maintain aspect ratio */
    }

    .main-navigation {
        display: none; /* Hidden when closed */
        position: absolute;
        top: 100%; /* Position below the header */
        left: 0;
        width: 100%;
        background-color: #FFFFFF; /* Solid white */
        padding: 20px;
        text-align: center;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Optional: add a subtle shadow */
        z-index: 990; /* Ensure it's below the header (1000) but above content */
    }

    .main-navigation.open {
        display: block; /* Show mobile menu when 'open' class is present */
    }

    .main-navigation ul {
        flex-direction: column;
        align-items: center;
    }

    .main-navigation li {
        margin: 10px 0;
    }

    .portfolio-grid { /* This is the wrapper for masonry on mobile */
        padding: 0 10px;
    }

    .portfolio-item {
        margin: 2.5px !important; /* Smaller margin on mobile */
        width: calc(100% - 5px) !important; /* Changed to 1 column on mobile (100% - total margin) */
    }

    /* Adjust overlay close button and image for mobile header height */
    #close-overlay {
        font-size: 2em;
        top: 15px; /* Adjust as needed for mobile header */
        right: 15px;
    }

    #overlay-current-image {
        margin-top: 80px; /* Roughly header height + padding for mobile */
        max-height: calc(100vh - 80px - 30px); /* Adjust for mobile header and bottom space */
        margin-bottom: 30px;
    }

    /* General Gutenberg Heading Scaling for Mobile - using clamp for fluid typography */
    h1.wp-block-heading,
    .entry-header h1.entry-title {
        /* Original: clamp(1.6rem, 5vw, 2.0rem); */
        /* 15% reduction: 1.6*0.85=1.36rem, 5*0.85=4.25vw, 2.0*0.85=1.7rem */
        font-size: clamp(1.36rem, 4.25vw, 1.7rem);
    }

    h2.wp-block-heading {
        /* Original: clamp(1.3rem, 4vw, 1.6rem); */
        /* 15% reduction: 1.3*0.85=1.105rem, 4*0.85=3.4vw, 1.6*0.85=1.36rem */
        font-size: clamp(1.105rem, 3.4vw, 1.36rem);
    }

    h3.wp-block-heading {
        /* Original: clamp(1.1rem, 3.5vw, 1.3rem); */
        /* 15% reduction: 1.1*0.85=0.935rem, 3.5*0.85=2.975vw, 1.3*0.85=1.105rem */
        font-size: clamp(0.935rem, 2.975vw, 1.105rem);
    }

    h4.wp-block-heading {
        /* Default from original theme or browser, let's apply a general scaling */
        /* Assuming a base of ~1.0em/rem for desktop h4 if not explicitly set */
        font-size: clamp(0.85rem, 2.5vw, 1.0rem); /* Example scaling, adjust as needed */
        font-size: calc(1em * 0.85); /* 15% reduction from default h4 size */
    }

    h5.wp-block-heading {
        /* Assuming a base of ~0.8em/rem for desktop h5 if not explicitly set */
        font-size: clamp(0.75rem, 2vw, 0.85rem); /* Example scaling, adjust as needed */
        font-size: calc(0.8em * 0.85); /* 15% reduction from default h5 size */
    }

    h6.wp-block-heading {
        /* Assuming a base of ~0.7em/rem for desktop h6 if not explicitly set */
        font-size: clamp(0.65rem, 1.8vw, 0.75rem); /* Example scaling, adjust as needed */
        font-size: calc(0.7em * 0.85); /* 15% reduction from default h6 size */
    }
}

/*--------------------------------------------------------------
8.0 - Fullscreen Gallery Overlay
--------------------------------------------------------------*/
#fullscreen-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #FFFFFF; /* Solid white background */
    z-index: 999; /* Below header (1000), but above page content */

    /* Flexbox for centering content - applied by JS when opened */
    justify-content: center;
    align-items: center;
    flex-direction: row;
}

#overlay-current-image {
    max-width: 90%;
    /* Calculate max height to fit below header and above bottom edge */
    max-height: calc(100vh - 100px - 40px); /* 100px for header, 40px for bottom space */
    object-fit: contain;
    cursor: pointer; /* Indicate clickability for next image */
    display: block;
    margin-top: 100px; /* Pushes image down below the fixed header */
    margin-bottom: 40px; /* Space from bottom edge */
    transition: opacity 0.3s ease-in-out; /* Smooth transition for image visibility */
}

#close-overlay {
    position: fixed;
    top: 120px; /* Adjusted to be below the assumed 100px header height + 20px padding */
    right: 30px;
    font-size: 3em; /* Scalable font size */
    color: #333;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    z-index: 995; /* Set below header (1000) and mobile menu (990) for clickability */
}

/* Hide body scrollbar when overlay is open */
body.overlay-open {
    overflow: hidden;
}

/* Spinner Styles */
#fullscreen-overlay.loading::before {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3; /* Light grey */
    border-top: 4px solid #3498db; /* Blue */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute; /* Position relative to the overlay */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10; /* Ensure it's above the image, but below close button */
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/*--------------------------------------------------------------
9.0 - About Page Columns
--------------------------------------------------------------*/
/* Ensure base column styles for flex/grid are correct */
.wp-block-columns.is-layout-flex,
.wp-block-columns.is-layout-grid {
    /* These properties might already be handled by Gutenberg, but ensuring consistency */
    display: flex; /* Or grid, depending on the class */
    flex-wrap: wrap; /* Allow wrapping by default, handled by media query for desktop */
    gap: 20px; /* Add some gap between columns for spacing */
}

/* Styling for the image figure inside a column */
.wp-block-columns .wp-block-column figure.wp-block-image {
    margin: 0 !important; /* Remove all margins around the image figure */
    padding: 0 !important; /* Remove all padding around the image figure */
}


/* Desktop Styles for About Page Columns (Image 1/3 Left, Text 2/3 Right) */
@media (min-width: 769px) {
    /* Ensure the main columns container is a flex row */
    .wp-block-columns.is-layout-flex,
    .wp-block-columns.is-layout-grid {
        flex-direction: row !important; /* Ensure horizontal layout on desktop */
        flex-wrap: nowrap !important; /* Prevent wrapping on desktop */
        align-items: flex-start !important; /* Aligns content to the top */
    }

    /* First column (Image) */
    .wp-block-columns.is-layout-flex > .wp-block-column:nth-child(1),
    .wp-block-columns.is-layout-grid > .wp-block-column:nth-child(1) {
        flex: 0 0 calc(33.3333% - 10px) !important; /* flex-grow, flex-shrink, flex-basis */
        max-width: calc(33.3333% - 10px) !important; /* Max-width to constrain */
        width: calc(33.3333% - 10px) !important; /* Specific width */
    }

    /* Second column (Text) */
    .wp-block-columns.is-layout-flex > .wp-block-column:nth-child(2),
    .wp-block-columns.is-layout-grid > .wp-block-column:nth-child(2) {
        flex: 0 0 calc(66.6666% - 10px) !important; /* flex-grow, flex-shrink, flex-basis */
        max-width: calc(66.6666% - 10px) !important; /* Max-width to constrain */
        width: calc(66.6666% - 10px) !important; /* Specific width */
    }
}

/* Mobile Styles (Stacking: Image first, then Text) */
@media (max-width: 768px) {
    .wp-block-columns.is-layout-flex,
    .wp-block-columns.is-layout-grid {
        flex-direction: column !important; /* Force stacking vertically on mobile */
        align-items: stretch !important; /* Ensure items stretch to full width */
    }

    .wp-block-columns > .wp-block-column {
        /* Reset widths and flex-basis for mobile to ensure full width stacking */
        flex: 0 0 100% !important; /* Force full width on mobile */
        max-width: 100% !important; /* Ensure it doesn't get constrained */
        width: 100% !important; /* Explicitly set width to 100% */
        order: unset !important; /* Reset order to default document flow (Image will be first as it's first in HTML) */
    }
}

/*--------------------------------------------------------------
10.0 - Utility Classes
--------------------------------------------------------------*/
.has-no-wrap-text a {
    white-space: nowrap; /* Prevents text from wrapping within the link */
}