/* Gallery grid and lightbox captions.
 *
 * The grid is CSS columns rather than a JavaScript masonry: the tiles vary in
 * height, and letting the browser flow them costs nothing and cannot get out of
 * step with the images the way a measured layout can.
 */

:root {
    /* The theme's primary, used for the navigation bar and borders. Global
     * links are #d4cd05, which is why an unstyled heading link reads yellow. */
    --gmt-primary: #663b7d;
    --gmt-primary-light: #b378d3;
}

.gmt-gallery {
    columns: 4 240px;
    column-gap: 18px;
    margin-bottom: 8px;
}

@media (max-width: 991px) {
    .gmt-gallery { columns: 3 200px; column-gap: 14px; }
}

@media (max-width: 600px) {
    .gmt-gallery { columns: 1; }
}

.gmt-tile {
    break-inside: avoid;
    page-break-inside: avoid;   /* older engines */
    margin: 0 0 18px;
    display: inline-block;
    width: 100%;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 3px;
    overflow: hidden;
}

.gmt-tile a {
    display: block;
    line-height: 0;            /* no gap under the image */
    position: relative;
}

.gmt-tile img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform .35s ease, opacity .35s ease;
}

.gmt-tile:hover img {
    transform: scale(1.03);
    opacity: .9;
}

/* Captions under a tile are a preview: two lines, then ellipsis. The whole
 * caption is shown in the lightbox, which has room for it. */
.gmt-tile figcaption {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gmt-gallery-group {
    margin-bottom: 34px;
}

.gmt-gallery-group h3,
.gmt-gallery-group h3 a {
    margin: 0 0 4px;
    color: var(--gmt-primary, #663b7d);
}

.gmt-gallery-group h3 a:hover,
.gmt-gallery-group h3 a:focus {
    color: var(--gmt-primary-light, #b378d3);
}

/* The year sits beside the heading without competing with it. */
.gmt-gallery-group .gmt-group-year {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 10px;
    border: 1px solid var(--gmt-primary-light, #b378d3);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--gmt-primary, #663b7d);
    vertical-align: middle;
    white-space: nowrap;
    /* .module-title > span in the theme sets 62px, bold, block and uppercase. */
    text-transform: none;
    letter-spacing: 0;
}

.gmt-gallery-group .gmt-group-count {
    color: #888;
    font-size: 13px;
    margin-bottom: 14px;
}

/* --- Lightbox captions ---------------------------------------------------
 *
 * GLightbox sizes its side panel for a line or two. Some of these captions run
 * to several hundred words, so the panel is widened and allowed to scroll on
 * its own rather than pushing the image out of view.
 */

.glightbox-container .gslide-description.description-left,
.glightbox-container .gslide-description.description-right {
    max-width: 380px;
    background: #16181c;
}

.glightbox-container .gslide-description {
    background: #16181c;
}

.glightbox-container .gdesc-inner {
    padding: 22px 24px;
    max-height: 90vh;
    overflow-y: auto;
}

.glightbox-container .gslide-desc {
    color: #e8eaed;
    font-size: 15px;
    line-height: 1.65;
}

/* The way back to the article the picture came from.
 *
 * Styled as a button rather than a link: inside the lightbox there is no
 * surrounding text to make a plain link read as clickable, and the theme's
 * global link colour is a yellow that does not belong here. */
.glightbox-container .gmt-desc-source {
    margin: 20px 0 0;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, .18);
}

.glightbox-container .gmt-desc-source-label {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.5;
    color: #a9adb5;
}

.glightbox-container a.gmt-desc-link {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 4px;
    background: var(--gmt-primary, #663b7d);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.4;
    transition: background .2s ease;
}

.glightbox-container a.gmt-desc-link:hover,
.glightbox-container a.gmt-desc-link:focus {
    background: var(--gmt-primary-light, #b378d3);
    color: #fff;
    text-decoration: none;
}

/* Below the breakpoint where GLightbox stacks the panel under the image, cap
 * its height so a long caption cannot swallow the picture. */
@media (max-width: 768px) {
    .glightbox-container .gdesc-inner {
        max-height: 38vh;
        padding: 16px 18px;
    }

    .glightbox-container .gslide-desc {
        font-size: 14px;
    }
}

/* --- Loading more, and getting back --------------------------------------- */

.gmt-gallery-intro {
    margin: 0 0 22px;
    color: #6b6b6b;
    font-size: 15px;
}

.gmt-load-more-wrap {
    text-align: center;
    margin: 10px 0 40px;
}

a.gmt-load-more {
    display: inline-block;
    padding: 13px 32px;
    border: 2px solid var(--gmt-primary, #663b7d);
    border-radius: 4px;
    background: transparent;
    color: var(--gmt-primary, #663b7d);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
}

a.gmt-load-more:hover,
a.gmt-load-more:focus {
    background: var(--gmt-primary, #663b7d);
    color: #fff;
    text-decoration: none;
}

a.gmt-load-more.is-loading {
    opacity: .6;
    pointer-events: none;
}

.gmt-to-top {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--gmt-primary, #663b7d);
    color: #fff;
    font-size: 20px;
    line-height: 46px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .28);
    z-index: 1000;
    transition: background .2s ease;
}

.gmt-to-top:hover,
.gmt-to-top:focus {
    background: var(--gmt-primary-light, #b378d3);
}

@media (max-width: 600px) {
    .gmt-to-top { right: 14px; bottom: 14px; }
}
