.album-archive {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.75rem;
}

.album-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.album-card:only-child {
    justify-self: start;
    width: 100%;
    max-width: calc((1200px - 1.75rem) / 2);
}

.album-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

.album-card__thumb img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: cover;
}

.album-card__body {
    padding: 1.25rem 1.25rem 1.5rem;
    color: #111827;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.album-card__title {
    color: #111827;
    font-size: 1.25rem;
    margin: 0;
}

.album-card__excerpt {
    color: #4a4a4a;
    margin: 0;
}

.album-card__meta {
    color: #7a7a7a;
    font-size: 0.95rem;
    margin: 0;
}

.album-card__link {
	text-decoration: none;
	color: #111827;
	display: flex;
	flex-direction: column;
	height: 100%;
}

.album-card__link:visited {
    color: #111827;
}

:root[data-theme="dark"] .album-card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border-neutral);
    box-shadow: var(--shadow-card);
}

:root[data-theme="dark"] .album-card:hover {
    box-shadow: var(--shadow-card-hover);
}

:root[data-theme="dark"] .album-card__body {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

:root[data-theme="dark"] .album-card__link,
:root[data-theme="dark"] .album-card__link:visited,
:root[data-theme="dark"] .album-card__title {
    color: var(--color-text);
}

:root[data-theme="dark"] .album-card__excerpt {
    color: var(--color-text);
    opacity: 0.86;
}

:root[data-theme="dark"] .album-card__meta {
    color: var(--color-text);
    opacity: 0.68;
}

.album {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.album-hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: clamp(420px, 62vh, 760px);
    color: #fff;
    background: linear-gradient(135deg, #10294b 0%, #1f4677 100%);
    overflow: hidden;
}

.album-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(8, 20, 40, 0.14) 0%, rgba(8, 20, 40, 0.3) 34%, rgba(8, 20, 40, 0.82) 100%),
        linear-gradient(90deg, rgba(8, 20, 40, 0.38) 0%, rgba(8, 20, 40, 0.08) 42%, rgba(8, 20, 40, 0.18) 100%);
    z-index: 1;
}

.album-hero--no-image {
    min-height: clamp(280px, 42vh, 420px);
}

.album-hero__media {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.album-hero__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.album-hero__content {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: clamp(5rem, 10vw, 7.5rem) 0 clamp(2rem, 5vw, 4rem);
}

.album-hero__copy {
    max-width: min(46rem, 100%);
    padding-right: clamp(1rem, 4vw, 2rem);
}

.album-hero__meta {
    margin: 0 0 0.75rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.album-hero__title {
    margin: 0;
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    line-height: 1.05;
    color: #fff;
    text-wrap: balance;
}

.album-hero__lead {
    margin-top: 1.15rem;
    max-width: 40rem;
    font-size: clamp(1rem, 2vw, 1.2rem);
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.92);
}

.album-hero__lead p {
    margin: 0;
}

.album-hero__lead p + p {
    margin-top: 0.75rem;
}

.album__section {
    padding-top: clamp(2.25rem, 6vw, 4rem);
}

.album__body {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.album__content {
    font-size: 1.05rem;
    line-height: 1.7;
    width: 100%;
}

.album__content > :where(p, h2, h3, h4, h5, h6, ul, ol, blockquote) {
    max-width: 72ch;
}

.album__content > .wp-block-heading,
.album__content > .wp-block-paragraph,
.album__content > .wp-block-list,
.album__content > .wp-block-quote {
    max-width: 72ch;
}

.album__content > .wp-block-gallery,
.album__content > .wp-block-image,
.album__content > .wp-block-embed,
.album__content > .wp-block-video {
    width: 100%;
    max-width: none;
}

.album__section-title {
    font-size: 1.25rem;
    margin: 0 0 0.5rem 0;
}

.album__videos {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.album__video {
    display: grid;
    gap: 0.5rem;
    width: 100%;
    max-width: none;
}

.album__video-embed {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}

.album__video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.album__video-embed > :where(div, figure) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none !important;
    margin: 0 !important;
    display: block;
}

.album__video-embed :where(iframe, embed, object) {
    width: 100%;
    height: 100%;
    border: 0;
}

.album__video-embed .wp-block-embed__wrapper {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100%;
    max-width: none !important;
    margin: 0 !important;
}

.album__video-embed .wp-block-embed__wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

.gallery-grid {
    --masonry-gap: 1rem;
    --thumb-height: 200px;
    --masonry-last-row-max-scale: 2.1;
    --masonry-last-row-min-scale: 0.9;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: var(--masonry-gap);
    align-items: flex-start;
    justify-content: flex-start;
}

.gallery-grid__item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #f5f5f5;
    display: block;
    flex: 0 0 auto;
    text-decoration: none;
    color: inherit;
}

.gallery-grid__image {
    height: var(--thumb-height);
    width: auto;
    display: block;
    object-fit: contain !important;
    object-position: center;
    transition: transform 250ms ease;
}

.gallery-grid__item:hover .gallery-grid__image {
    transform: scale(1.03);
}

.gallery-grid__caption,
.album .wp-block-gallery.has-nested-images figure.wp-block-image figcaption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 0.75rem 0.85rem 0.7rem;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.4) 48%, rgba(0, 0, 0, 0) 100%);
    color: #fff;
    text-align: left;
    pointer-events: none;
}

.pswp__dynamic-caption--hidden {
    opacity: 0;
    pointer-events: none;
}

.pswp__button--copy-link.is-copied {
    color: #8ff0a4;
}

.pswp__copy-toast {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 1rem);
    left: 50%;
    z-index: 30;
    padding: 0.65rem 0.95rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.01em;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate3d(-50%, -10px, 0);
    transition: opacity 160ms ease, transform 180ms ease;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.26);
}

.pswp__copy-toast.is-visible {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
}

.gallery-grid__caption .pswp-caption-content__caption,
.album .wp-block-gallery.has-nested-images figure.wp-block-image figcaption .pswp-caption-content__caption,
.pswp__dynamic-caption .pswp-caption-content__caption,
.pswp__dynamic-caption .pswp-caption-content__description,
.pswp__dynamic-caption .pswp-caption-content__description p {
    margin: 0;
}

.gallery-grid__caption .pswp-caption-content__caption,
.album .wp-block-gallery.has-nested-images figure.wp-block-image figcaption .pswp-caption-content__caption {
    display: -webkit-box;
    overflow: hidden;
    max-width: min(100%, 24ch);
    font-size: clamp(0.78rem, 0.72rem + 0.22vw, 0.92rem);
    font-weight: 620;
    line-height: 1.22;
    letter-spacing: 0;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pswp__dynamic-caption .pswp-caption-content__caption {
    font-size: 1.05rem;
    font-weight: 650;
    line-height: 1.35;
    letter-spacing: 0.01em;
    color: #fff;
}

.pswp__dynamic-caption .pswp-caption-content__description {
    margin-top: 0.5rem;
    font-size: 0.94rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.82);
}

.pswp__dynamic-caption .pswp-caption-content__description p + p {
    margin-top: 0.5rem;
}

@media (min-width: 640px) {
    .album-hero__content {
        padding-bottom: clamp(2.5rem, 5vw, 4.5rem);
    }

    .gallery-grid {
        --thumb-height: 210px;
    }
}

@media (min-width: 960px) {
    .album-hero__copy {
        max-width: min(54rem, 100%);
    }

    .gallery-grid {
        --thumb-height: 230px;
        --masonry-gap: 1.25rem;
    }

}

@media (max-width: 639px) {
    .gallery-grid {
        flex-direction: column;
        align-items: stretch;
    }

    .gallery-grid__item {
        width: 100%;
    }

    .gallery-grid__image {
        width: 100%;
        height: auto;
    }

    .pswp__copy-toast {
        top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
        max-width: calc(100vw - 2rem);
        white-space: normal;
        text-align: center;
    }
}

@media (min-width: 1280px) {
    .album-hero {
        min-height: clamp(520px, 70vh, 860px);
    }

    .gallery-grid {
        --thumb-height: 240px;
    }
}

/* Album gallery: server-side justified flex layout.
 *
 * Each row is a flex container whose CSS aspect-ratio equals the sum of its
 * items' aspect ratios (set inline via --row-ar). The row's height therefore
 * scales with the container width while preserving the natural proportions of
 * its images. Items use flex-grow proportional to their aspect ratio (--ar),
 * so widths distribute exactly to fill the row. No JS layout is required and
 * lazy image loading cannot cause layout shifts.
 */
.album-gallery-flex {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.album-gallery-flex__row {
    display: flex;
    gap: 1rem;
    width: 100%;
    aspect-ratio: var(--row-ar, auto);
}

.album-gallery-flex__row--natural {
    aspect-ratio: auto;
    height: 230px;
    justify-content: flex-start;
}

.album-gallery-flex__item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #f5f5f5;
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
    min-width: 0;
    flex: var(--ar, 1) 0 0;
}

.album-gallery-flex__item--natural {
    flex: 0 0 calc(var(--ar, 1) * 230px);
}

.album-gallery-flex__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 250ms ease;
}

.album-gallery-flex__item:hover img {
    transform: scale(1.03);
}

.album-gallery-flex__caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 0.75rem 0.85rem 0.7rem;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.4) 48%, rgba(0, 0, 0, 0) 100%);
    color: #fff;
    text-align: left;
    pointer-events: none;
}

.album-gallery-flex__caption .pswp-caption-content__caption {
    display: -webkit-box;
    overflow: hidden;
    max-width: min(100%, 24ch);
    margin: 0;
    font-size: clamp(0.78rem, 0.72rem + 0.22vw, 0.92rem);
    font-weight: 620;
    line-height: 1.22;
    letter-spacing: 0;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

@media (max-width: 639px) {
    .album-gallery-flex__row,
    .album-gallery-flex__row--natural {
        flex-direction: column;
        aspect-ratio: auto;
        height: auto;
    }

    .album-gallery-flex__item,
    .album-gallery-flex__item--natural {
        flex: 0 0 auto;
        width: 100%;
        aspect-ratio: var(--ar, 1);
        height: auto;
    }
}
