/* AP02. Outer section spacing and typography remain shared. */
.CommunityGallery .CommunityGallery__viewport {
    margin-top: 2rem;
    width: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 12px;
    overscroll-behavior-x: contain;
    padding: 6px 12px 20px;
}

.CommunityGallery .CommunityGallery__belt,
.CommunityGallery .CommunityGallery__sequence {
    display: flex;
    gap: 16px;
    width: max-content;
    align-items: stretch;
}

.CommunityGallery .CommunityGallery__panel {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.CommunityGallery .CommunityGallery__card {
    flex: none;
    width: min(520px, calc(100vw - 24px));
    margin: 0;
    border-radius: 10px;
    background: #243c4b;
    color: #fff;
    scroll-snap-align: start;
}

.CommunityGallery .CommunityGallery__image {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1.65;
    object-fit: cover;
    object-position: center 35%;
    border-radius: 10px 10px 0 0;
}

.CommunityGallery .CommunityGallery__text {
    padding: 1.5rem;
    overflow-wrap: anywhere;
}

.CommunityGallery .CommunityGallery__overlay-copy {
    font-family: Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 1rem;
}

.CommunityGallery .CommunityGallery__overlay-title {
    font-family: "Poppins", sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.3;
    margin: 0;
    color: inherit;
}

.CommunityGallery .CommunityGallery__mosaic {
    display: grid;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 16px;
    width: 312px;
}

.CommunityGallery .CommunityGallery__mosaic--two {
    grid-template-rows: repeat(2, minmax(0, 1fr));
}

.CommunityGallery .CommunityGallery__mosaic img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: cover;
    border-radius: 10px;
}

.CommunityGallery .CommunityGallery__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 1rem;
}

.CommunityGallery .CommunityGallery__controls[hidden],
.CommunityGallery .CommunityGallery__motion-button[hidden],
.CommunityGallery .CommunityGallery__sequence--visual {
    display: none;
}

.CommunityGallery .CommunityGallery__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid #243c4b;
    border-radius: 6px;
    background: #fff;
    color: #243c4b;
    font: inherit;
    line-height: 1.4;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

.CommunityGallery .CommunityGallery__button ion-icon {
    flex: none;
    font-size: 20px;
}

.CommunityGallery .CommunityGallery__button:active {
    background: #e7f3fb;
}

.CommunityGallery .CommunityGallery__button:disabled {
    opacity: .5;
    cursor: default;
}

.CommunityGallery .CommunityGallery__button:focus-visible,
.CommunityGallery .CommunityGallery__viewport:focus-visible,
.CommunityGallery .CommunityGallery__card:focus-visible {
    outline: 3px solid #0072ce;
    outline-offset: 3px;
}

.CommunityGallery .CommunityGallery__status {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
    .CommunityGallery .CommunityGallery__button:not(:disabled):hover {
        background: #e7f3fb;
    }
}

/* Desktop refinement: spare shared mosaic height belongs to the photograph,
   while the text keeps its natural height, including enlarged type. */
@media (min-width: 768px) {
    .CommunityGallery .CommunityGallery__card {
        display: flex;
        flex-direction: column;
    }

    .CommunityGallery .CommunityGallery__image {
        flex: 1 0 auto;
    }

    .CommunityGallery .CommunityGallery__text {
        flex: none;
    }
}

@media (max-width: 767.98px) {
    .CommunityGallery .CommunityGallery__card {
        width: calc(100vw - 40px);
    }

    .CommunityGallery .CommunityGallery__text {
        padding: 1rem;
    }

    .CommunityGallery .CommunityGallery__mosaic {
        display: none;
    }
}

/* No script / failed enhancement / Reduce stays native and static. Focus removes
   the entire transform, not just its motion: offscreen originals must be reachable. */
@media (min-width: 768px) and (prefers-reduced-motion: no-preference) {
    .CommunityGallery[data-gallery-loop="true"] .CommunityGallery__viewport {
        overflow-x: hidden;
        scroll-snap-type: none;
    }

    .CommunityGallery[data-gallery-loop="true"] .CommunityGallery__sequence--visual {
        display: flex;
    }

    .CommunityGallery[data-gallery-loop="true"] .CommunityGallery__belt {
        animation: communityGalleryLoop 63.3s linear infinite;
    }

    .CommunityGallery[data-gallery-paused="true"] .CommunityGallery__belt {
        animation-play-state: paused;
    }

    .CommunityGallery .CommunityGallery__viewport:focus-within {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
    }

    .CommunityGallery .CommunityGallery__viewport:focus-within .CommunityGallery__belt {
        animation: none;
        transform: none;
    }

    .CommunityGallery .CommunityGallery__viewport:focus-within .CommunityGallery__sequence--visual {
        display: none;
    }
}

@keyframes communityGalleryLoop {
    to { transform: translateX(calc(-50% - 8px)); }
}
