/* --- Gallery Page: General Section Styling --- */
.gallery-section {
    padding: 0;
    background-color: #ccc;
}

.gallery-section h1 {
    text-align: center;
    font-size: 3.5rem;
    color: #5061C4;
    font-weight: 700;
    margin-bottom: 3rem;
    line-height: 1.8;
    letter-spacing: 2px;
    font-family: 'Tangerine', cursive;
    font-style: italic;
}

.gallery-section h2 {
    text-align: center;
    font-size: 2.8rem;
    margin-bottom: 1rem;
}

.gallery-intro {
    text-align: center;
    max-width: 700px;
    margin: 0 auto 4rem auto;
    color: #555;
    font-size: 1.1rem;
}

.section-subtitle {
    font-size: 2.2rem;
    margin-bottom: 2rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e0e0e0;
}


/* --- Publication List Styling --- */
.publication-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.publication-item {
    background-color: #f9f9f9;
    border-left: 5px solid #5061C4;
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.publication-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.publication-item h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #333;
    font-size: 1.2rem;
    padding-right: 90px; /* Space for the tag */
}

.publication-item p {
    margin: 0;
    color: #555;
}

.publication-tag {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    text-transform: uppercase;
}
.publication-tag.scopus {
    background-color: #E6F4EA;
    color: #34A853;
}
.publication-tag.peer-reviewed {
    background-color: #E8F0FE;
    color: #4285F4;
}


/* --- Authored Books Section Styling --- */
.books-section {
    margin-top: 5rem;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.book-card {
    text-align: center;
}

.book-cover {
    background: linear-gradient(45deg, #5061C4, #6a7ee8);
    color: white;
    padding: 3rem 1.5rem;
    border-radius: 8px 3px 3px 8px;
    margin-bottom: 1rem;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.book-card:hover .book-cover {
    transform: perspective(1000px) rotateY(-10deg) scale(1.02);
}

.book-cover h4 {
    margin: 0;
    font-size: 1.5rem;
}

.book-cover span {
    display: block;
    margin-top: 0.5rem;
    opacity: 0.8;
}


/* --- Media Gallery Sections Styling --- */
.media-category {
    margin-top: 5rem;
}

.media-grid {
    display: grid;
    gap: 1.5rem;
    /* NEW: Force all rows to be exactly 230px tall so the math works */
    grid-auto-rows: 230px; 
}
.photo-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.video-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.cuttings-grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.media-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    cursor: pointer;
    /* REMOVED: aspect-ratio: 16 / 10; (This conflicts with fixed row height) */
    height: 100%; /* Fill the 230px row */
    width: 100%;
    opacity: 0; 
    transform: translateY(20px); 
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.media-item.is-visible { /* State when item is visible (triggered by JS) */
    opacity: 1;
    transform: translateY(0);
}

a.media-item { /* Ensure video link behaves like a grid item */
    display: block;
    text-decoration: none;
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.media-item:hover img {
    transform: scale(1.1);
}

.media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 2rem 1rem 1rem;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.media-item:hover .media-overlay {
    opacity: 1;
    transform: translateY(0);
}

.media-overlay span {
    font-weight: 500;
}

.video-item .play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease, background-color 0.3s ease;
    pointer-events: none;
}

.media-item:hover .play-button {
    transform: translate(-50%, -50%) scale(1.1);
    background-color: rgba(80, 97, 196, 0.8);
}

.book-image {
    width: 100%;           /* Fills the card width */
    max-width: 250px;      /* Limits size so it doesn't get too huge */
    height: auto;          /* Keeps original shape */
    border-radius: 8px;    /* Rounded corners */
    box-shadow: 0 10px 20px rgba(0,0,0,0.15); /* Nice 3D shadow */
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Hover Effect: Book pops up slightly */
.book-card:hover .book-image {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 25px rgba(0,0,0,0.25);
}

/* Typography for Book Titles */
.book-card h4 {
    color: #5061C4;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.book-card .year {
    color: #777;
    font-size: 0.9rem;
    font-weight: normal;
}

/* Collapsible Gallery Rows */
.collapsible-grid {
    --row-height: 230px;
    --gap-size: 1.5rem;
    
    /* NEW FORMULA: (Rows * Height) + (Gaps) */
    /* This ensures the bottom of the images isn't chopped off */
    max-height: calc( 
        (var(--visible-rows, 2) * var(--row-height)) + 
        ((var(--visible-rows, 2) - 1) * var(--gap-size)) 
    );
    
    overflow: hidden;
    transition: max-height 0.4s ease;
}


/* View More Button */
.view-more-btn {
    margin: 2rem auto 0;
    display: block;
    background: #5061C4;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.3s ease;
}

.view-more-btn:hover {
    background: #3646b5;
}


/* --- Lightbox (Enlarge Photo) Styles --- */

/* Add pointer cursor so users know it's clickable */
.media-item {
    cursor: pointer;
}

/* The Modal Background */
.lightbox {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 3000; /* High z-index to sit on top of everything */
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.95); /* Deep black background */
}

/* The Image inside the Modal */
.lightbox-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 1000px;
    max-height: 85vh; /* Prevents image from being taller than screen */
    object-fit: contain;
    border-radius: 4px;
    animation: zoom 0.4s;
}

/* Caption Text */
#lightboxCaption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    height: 150px;
}

/* The Close Button */
.close-lightbox {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.close-lightbox:hover,
.close-lightbox:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* Zoom Animation */
@keyframes zoom {
    from {transform:scale(0.8); opacity: 0;} 
    to {transform:scale(1); opacity: 1;}
}

/* Responsive: Full width on mobile */
@media only screen and (max-width: 700px){
    .lightbox-content {
        width: 100%;
    }
}