/* --- RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { 
    scrollbar-gutter: stable; 
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: "monotype-grotesque", sans-serif;
    background-color: #f7f7f5;
    color: #111;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    justify-content: flex-start; 
    padding-left: 30px; 
    overflow-x: hidden;
    width: 100%;
}


header {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    margin-bottom: 5px;
    gap: 40px;
    padding-top: 30px;
    padding-right: 0;
}

header h1.logo {
    flex-shrink: 0;
    font-size: 16px; 
    font-weight: 400; 
    text-transform: uppercase; 
}

header h1.logo a {
    text-decoration: none;
    color: inherit;
}

#page-content {
    opacity: 0;
    visibility: hidden;
    /* This transition handles BOTH the fade-in and the fade-out */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* When this class is added, everything shows at once */
#page-content.is-visible {
    opacity: 1;
    visibility: visible;
}

/* This is for the "Close" effect when clicking a link */
.content-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
}

.container {
    width: 100%;
    max-width: 900px;
    margin: 0; /* Keeps everything aligned to the left padding of the body */
}


nav { 
    display: flex;
    justify-content: flex-end; /* Keeps links pushed to the right edge */
}
nav ul { display: flex; list-style: none; gap: 30px; }
nav a { text-decoration: none; color: #111; font-size: 15px; }
nav a:hover,
header h1.logo a:hover { color: #a9a9a9; }

nav a.active-grey {
    color: #a9a9a9 !important;
    transition: none !important;
    opacity: 1 !important;
}

/* --- SECTION LABELS --- */
h2.section-label { 
    font-size: 15px; 
    margin-bottom: 30px; 
    font-style: italic; 
    text-transform: capitalize;
    font-weight: normal;
}

h2.section-label span { 
    font-size: 15px;
    font-style: normal;
    text-transform: capitalize;
    font-weight: normal;
}

/* --- GRID SYSTEMS --- */

/* 1. Standard 2-Column (Description/Info) */
.description-grid {
    display: grid;
    /* Use 'repeat' with 'minmax' to prevent Chrome from collapsing columns */
    grid-template-columns: repeat(2, minmax(0, 1fr)); 
    gap: 30px;
    
    /* Ensure it fills the available space */
    width: 100%;
    max-width: 969px;
    
    /* Chrome fix: prevent flex-parent from squishing the grid */
    flex-shrink: 0; 
    align-items: start;
}

.text-block {
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    margin-bottom: 10px;
    
    /* Chrome fix: ensure long words don't push the column width */
    overflow-wrap: break-word;
    word-break: break-word;
}

/* 2. Standard 3-Column (Series/Books) */
.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 60px;
    max-width: 840px;
}

.image-grid img {
    aspect-ratio: auto;
    background-color: #f8f8f8;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* 3. 12-Column Variable (Fragments/Commercials) */
.variable-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 120px 40px;
    max-width: 90%;
}

.variable-grid img {
    aspect-ratio: auto;
    background-color: #f8f8f8;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* Grid Item & Image Logic */
.grid-item { display: flex; flex-direction: column; }

img {
    -webkit-user-drag: none;
    pointer-events: none;
    object-fit: contain;
    opacity: 1;
}

img[loading="lazy"] {
    transition: opacity 0.3s ease-in-out;
}

.grid-item img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    cursor: pointer;
    pointer-events: auto; /* ALLOWS CLICKING FOR LIGHTBOX */
    display: block;
    object-fit: contain;
}

.caption {
    font-size: 13px;
    margin-top: 5px;
    font-style: italic;
}

/* --- BOOK SPECIFIC GRID ITEMS --- */
.grid-item-book {
    display: flex;
    flex-direction: column;
}

.grid-item-book img {
    width: 100%;
    aspect-ratio: 3 / 2; 
    object-fit: cover; 
    display: block;
    cursor: pointer;
    transition: opacity 0.3s ease;
    pointer-events: auto !important; 
}

/* --- FOOTER --- */
footer {
    position: fixed;
    bottom: 30px;
    left: 30px;
    font-size: 14px;
    pointer-events: none;
}

/* --- LIGHTBOX (With Caption) --- */
#lightbox {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(247, 247, 245, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000 !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#lightbox.active { opacity: 1; visibility: visible; pointer-events: auto; }

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 90vw;
    pointer-events: none;
}

.grid-item, 
.lightbox-trigger {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 5;
}

#lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
}

#lightbox-caption {
    margin-top: 5px;
    font-size: 13px;
    font-style: italic;
}

#lightbox-close {
    position: absolute;
    top: 45px;
    right: 25px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    z-index: 1000;
}

#lightbox-close::before,
#lightbox-close::after {
    content: '';
    position: absolute;
    top: 15px;
    left: 5px;
    width: 20px;
    height: 1px;
    background-color: #111;
}

#lightbox-close::before {
    transform: rotate(45deg);
}

#lightbox-close::after {
    transform: rotate(-45deg);
}

#lightbox-img {

    pointer-events: none; /* Prevents the image from "stealing" the click */
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    /* This ensures the 0.3s transition matches your overlay */
    transition: opacity 0.3s ease; 
    opacity: 1;
}

.info-image img {
    display: block;
    width: 80%;          /* Smaller width */
    max-width: 200px;    /* Lowered max-width */
    height: auto;
    margin-left: auto;   /* This aligns it to the right of the column */
}

.image-grid-flexible {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Keep the 3-column layout */
    gap: 60px;
    max-width: 969px;
    width: 100%;
    align-items: center;
}

.image-grid-flexible img {
    pointer-events: auto !important;
    cursor: pointer;
    aspect-ratio: auto;
    background-color: #f8f8f8;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

.grid-cell {
    display: flex;
    justify-content: center; /* Centers horizontally */
    align-items: center;     /* Centers vertically */
    width: 100%;
}

.grid-cell img {
    width: 100%;            /* Fills the column width */
    height: auto;           /* Respects original aspect ratio */
    display: block;
    cursor: pointer;
    transition: opacity 0.3s ease;
    pointer-events: auto !important;
    
    /* Remove any forced aspect-ratios or object-fit from previous classes */
    aspect-ratio: auto !important;
    object-fit: contain !important;
}

/* --- FRAGMENTS 12-COLUMN SYSTEM --- */
.fragments-page .col-center-small { grid-column: 5 / 9; } 
.fragments-page .col-left-mid     { grid-column: 1 / 6; }  
.fragments-page .col-right-small  { grid-column: 8 / 12; } 
.fragments-page .col-wide         { grid-column: 6 / 11; }

/* --- FRAGMENTS PAGE ONLY --- */
.fragments-page {
    width: calc(100vw - 30px); /* full width minus the body's left padding */
    padding-bottom: 70px;
}

.fragments-page .variable-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 90px 30px;
    width: 100%;
    max-width: none;
    align-items: center;
}

#landing-image {
    max-width: 85vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    pointer-events: auto;
    transition: opacity 0.6s ease;
}

#landing-image.is-changing {
    opacity: 0;
}

#landing-image.is-reappearing {
    transition: opacity 0.2s ease;
}

#landing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(247, 247, 245, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    cursor: pointer;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* When the class is added, fade to 0 */
.landing-closed #landing-overlay {
    opacity: 0;
    visibility: hidden;
}

.text-block, .caption, .section-label, .logo {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    pointer-events: auto;
}

.image-grid img, 
.variable-grid img, 
.grid-item img,
.grid-cell img {
    -webkit-touch-callout: none; /* Prevents "Save Image" on iOS */
    -webkit-user-select: none;   /* Prevents selection of the image */
    user-select: none;
}

@media (max-width: 768px) {

    .fragments-page { width: 100%; }

    /* 1. Layout & Base */
    body {
        padding-left: 20px;
        padding-right: 20px;
        display: block; /* Standard vertical stacking */
        overflow-x: hidden;
    }

    /* 2. Header & Navigation */
    header {
        flex-direction: column;
        gap: 5px;
        padding-top: 20px;
    }

    nav {
        width: 100%;
        justify-content: flex-start;
    }

    nav ul, .nav-menu {
        flex-wrap: wrap;
        gap: 15px 20px;
        display: flex;
        list-style: none;
    }

    /* 3. Grid Systems Reset */
    /* Forces all grid types to act as a single vertical column */
    .image-grid-flexible,
    .description-grid,
    .variable-grid,
    .image-grid {
        display: flex;
        flex-direction: column;
        gap: 30px; /* Consistent vertical spacing between items */
        width: 100%;
        pointer-events: auto; /* Ensure items remain clickable */
    }

    /* Reset all grid children (spans) to full width */
    .grid-item, 
    [class*="col-"] { 
        grid-column: 1 / -1 !important; 
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .fragments-page .grid-item,
    .fragments-page [class*="col-"] {
        grid-column: 1 / -1 !important; 
        width: 86% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .fragments-page .variable-grid {
        gap: 30px ;
    }

    .grid-item img {
        max-width: 100%;
    }

    /* 4. Content Adjustments */
    .section-label {
        margin-top: 20px;
    }

    .info-image img {
        max-width: 100%;
        margin-top: 20px;
        height: auto;
    }

    #landing-image {
        max-width: 90%; /* Better fit for mobile screens */
    }

    #lightbox {
        left: 5px;
    }

    #lightbox-close {
        right: 10px;
    }

    /* 5. Footer */
    footer {
        position: fixed;
        bottom: 15px;
        left: 20px;
        font-size: 14px;
        pointer-events: none;
}
}