/* Dedicated gallery templates. Shared masthead and article styles keep their owners. */
.itp-gallery-page {
    box-sizing: border-box;
    width: 100%;
    max-width: 1160px;
    margin: 32px auto 80px;
    padding: 0 32px;
}
.itp-gallery-page > h1 {
    margin: 0 0 26px;
    font: 400 clamp(26px, 2.8vw, 36px)/1.16 Georgia, 'Times New Roman', serif;
    letter-spacing: -.035em;
    color: var(--itp-ink);
    text-align: left;
}
.itp-gallery-images .wp-block-gallery.has-nested-images {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
    margin: 0;
    padding: 0;
}
.itp-gallery-images .wp-block-gallery.itp-rows-ready {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.itp-justified-row {
    display: grid;
    gap: 16px;
    max-width: 100%;
    align-items: start;
}
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0;
    flex: none;
    position: relative;
}
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image > a {
    display: block;
    width: 100%;
    aspect-ratio: var(--itp-photo-ratio, auto);
    text-decoration: none;
}
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: none;
    aspect-ratio: var(--itp-photo-ratio, auto);
    object-fit: contain;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image figcaption {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 100%;
    overflow: auto;
    margin: 0;
    padding: 64px 14px 12px;
    background: linear-gradient(to bottom,
        rgba(12, 14, 10, 0) 0,
        rgba(12, 14, 10, .04) 12px,
        rgba(12, 14, 10, .18) 26px,
        rgba(12, 14, 10, .48) 42px,
        rgba(12, 14, 10, .8) 56px,
        rgba(12, 14, 10, .92) 100%);
    color: #fff;
    font: 400 13px/1.6 var(--itp-service-font);
    letter-spacing: .01em;
    text-align: left;
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease;
}
/* Captions remain in the native figure and accessible tree; no extra row height. */
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image:hover figcaption,
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image:focus-within figcaption {
    opacity: 1;
}
.itp-gallery-images figure.wp-block-image figcaption a { color: inherit; pointer-events: none; }
/* Plain caption pixels remain part of the image's click target; authored links stay usable. */
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image:hover figcaption a,
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image:focus-within figcaption a {
    pointer-events: auto;
}
/* Replace the native blur overlay with the dedicated caption treatment. */
.itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image:has(figcaption)::before {
    content: none;
}
@media (max-width: 767.98px) {
    .itp-gallery-page { margin-top: 24px; }
    .itp-gallery-page > h1 { margin-bottom: 22px; }
}
@media (max-width: 575.98px) {
    .itp-gallery-page { padding: 0 24px; }
}
@media (max-width: 599.98px) {
    .itp-gallery-page { margin-bottom: 56px; }
    .itp-gallery-images .wp-block-gallery.has-nested-images { grid-template-columns: 1fr; }
    .itp-gallery-images .wp-block-gallery.itp-rows-ready { gap: 16px; }
}
@media (hover: none) {
    .itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image figcaption {
        opacity: 1;
    }
    .itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image figcaption a { pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .itp-gallery-images .wp-block-gallery.has-nested-images figure.wp-block-image figcaption { transition: none; }
}

.itp-gallery-selection { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 32px; }
.itp-gallery-selection a { display: block; text-decoration: none; }
.itp-gallery-selection img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; }
.itp-gallery-selection h2 { margin: 14px 0 0; font: 400 clamp(24px, 2.5vw, 32px)/1.2 Georgia, serif; }
.itp-gallery-page .navigation { margin-top: 48px; }
.itp-gallery-page a:focus-visible, .pswp button:focus-visible { outline: 3px solid #ad7959; outline-offset: 4px; }
html.viewer-open { overflow: hidden; }
.pswp__counter { color: #fff; }
@media (max-width: 599.98px) { .itp-gallery-selection { grid-template-columns: 1fr; } }
