#gallery,
.gallery-lightbox {
    --gallery-cream: #ebe8e6;
    --gallery-mustard: #ed9d2d;
    --gallery-ink: #2b180c;
    --gallery-muted: #625a55;
    --gallery-border: #d8d0ca;
    font-family: 'Prompt', sans-serif;
}

#gallery {
    padding-block: 64px;
    background: var(--gallery-cream);
    color: var(--gallery-ink);
}

.gallery-section-header {
    max-width: 760px;
    margin-bottom: 28px;
}

#gallery-title {
    margin: 0 0 12px;
    font-size: clamp(28px, 3vw, 38px);
    font-weight: 600;
    line-height: 1.5;
}

.gallery-section-header p {
    margin: 0;
    color: var(--gallery-muted);
    font-size: 16px;
    line-height: 1.9;
}

#gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.gallery-filter {
    min-height: 44px;
    padding: 10px 19px;
    border: 1px solid #a99c92;
    border-radius: 999px;
    background: transparent;
    color: var(--gallery-ink);
    font: inherit;
    font-size: 14px;
    line-height: 1.6;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}

.gallery-filter:hover { background: #fff9; }
.gallery-filter[aria-pressed="true"] {
    border-color: var(--gallery-ink);
    background: var(--gallery-ink);
    color: #fff;
}

#gallery-status {
    margin: 0 0 22px;
    color: var(--gallery-muted);
    font-size: 14px;
    line-height: 1.8;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 22px;
}

.gallery-item {
    min-width: 0;
    margin: 0;
}

.gallery-thumbnail {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--gallery-border);
    border-radius: 12px;
    background: #fff;
    color: var(--gallery-ink);
    font: inherit;
    text-align: left;
    cursor: zoom-in;
    transition: border-color .18s ease;
}

.gallery-thumbnail:hover { border-color: #a18b7b; }

.gallery-thumbnail-media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #ded9d4;
}

.gallery-thumbnail-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-thumbnail-expand {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    color: var(--gallery-ink);
    pointer-events: none;
}

.gallery-thumbnail-expand svg { width: 18px; height: 18px; }

.gallery-thumbnail-caption {
    display: block;
    padding: 15px 16px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

.gallery-thumb-error {
    margin: 0;
    padding: 24px;
    color: var(--gallery-muted);
    font-size: 14px;
    line-height: 1.8;
    text-align: center;
}

#gallery-more {
    display: block;
    min-height: 48px;
    margin: 34px auto 0;
    padding: 12px 28px;
    border: 1px solid var(--gallery-mustard);
    border-radius: 999px;
    background: var(--gallery-mustard);
    color: var(--gallery-ink);
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background .18s ease;
}

#gallery-more:hover { background: #f3ad4a; }

#gallery [hidden],
.gallery-lightbox [hidden] { display: none !important; }

.gallery-filter:focus-visible,
.gallery-thumbnail:focus-visible,
#gallery-more:focus-visible,
.gallery-lightbox button:focus-visible,
#gallery-lightbox-title:focus-visible {
    outline: 3px solid #a25c00;
    outline-offset: 4px;
}

.gallery-lightbox {
    width: calc(100% - 40px);
    max-width: 1320px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 18px;
    background: #fff;
    color: var(--gallery-ink);
    box-shadow: 0 24px 100px #0006;
}

.gallery-lightbox::backdrop {
    background: rgb(26 21 17 / 80%);
    backdrop-filter: blur(4px);
}

.gallery-lightbox[open] { animation: gallery-open .18s ease-out; }

.gallery-lightbox-shell {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    min-height: 0;
}

.gallery-lightbox-header {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 24px;
}

#gallery-lightbox-title {
    min-width: 0;
    margin: 0;
    font-size: clamp(17px, 2vw, 22px);
    font-weight: 500;
    line-height: 1.6;
}

#gallery-close,
#gallery-prev,
#gallery-next {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--gallery-border);
    border-radius: 50%;
    background: #fff;
    color: var(--gallery-ink);
    cursor: pointer;
    transition: background .18s ease;
}

#gallery-close:hover,
#gallery-prev:not(:disabled):hover,
#gallery-next:not(:disabled):hover { background: #f7e8cf; }

.gallery-lightbox button svg { width: 22px; height: 22px; }

.gallery-image-area {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    height: min(72vh, 860px);
    height: min(72dvh, 860px);
    min-height: 0;
    max-height: calc(100vh - 206px);
    max-height: calc(100dvh - 206px);
    overflow: hidden;
    background: #1d1916;
}

#gallery-full-image {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#gallery-prev,
#gallery-next {
    position: absolute;
    z-index: 1;
    top: 50%;
    transform: translateY(-50%);
    border-color: #fff;
    background: #fffffff0;
    box-shadow: 0 2px 12px #0003;
}

#gallery-prev { left: 16px; }
#gallery-next { right: 16px; }
#gallery-prev:disabled,
#gallery-next:disabled {
    opacity: .3;
    cursor: default;
    box-shadow: none;
}

.gallery-image-message {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 24px 80px;
    color: #fff;
    font-size: 15px;
    line-height: 1.9;
    text-align: center;
    pointer-events: none;
}

.gallery-lightbox-footer {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 24px;
}

#gallery-caption,
#gallery-counter {
    margin: 0;
    color: var(--gallery-muted);
    font-size: 14px;
    line-height: 1.7;
}

#gallery-counter {
    flex: none;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

@keyframes gallery-open {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (hover: hover) and (pointer: fine) {
    .gallery-thumbnail-expand { opacity: 0; transition: opacity .18s ease; }
    .gallery-thumbnail:hover .gallery-thumbnail-expand,
    .gallery-thumbnail:focus-visible .gallery-thumbnail-expand { opacity: 1; }
}

@media (max-width: 1099px) {
    .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
}

@media (max-width: 719px) {
    #gallery { padding-block: 48px; }
    .gallery-section-header { margin-bottom: 24px; }
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .gallery-thumbnail-caption { padding: 12px; font-size: 13px; }
    .gallery-filter { padding: 10px 15px; font-size: 13px; }
    .gallery-lightbox { width: calc(100% - 20px); border-radius: 12px; }
    .gallery-lightbox-header { padding: 14px 16px; gap: 12px; }
    .gallery-lightbox-footer { padding: 14px 16px; gap: 12px; }
    .gallery-image-area {
        max-height: calc(100vh - 214px);
        max-height: calc(100dvh - 214px);
    }
    #gallery-close,
    #gallery-prev,
    #gallery-next { width: 44px; height: 44px; }
    #gallery-prev { left: 8px; }
    #gallery-next { right: 8px; }
    #gallery-caption,
    #gallery-counter { font-size: 13px; }
    .gallery-image-message { padding-inline: 62px; font-size: 14px; }
}

@media (max-width: 359px) {
    .gallery-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-lightbox[open] { animation: none; }
    .gallery-filter,
    .gallery-thumbnail,
    .gallery-thumbnail-expand,
    #gallery-more,
    .gallery-lightbox button { transition: none; }
}
