/* DeepSire's product gallery. Layout and gesture transforms use separate layers. */
.ecosystem .circular-gallery {
    --gallery-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --gallery-card-width: clamp(240px, 22vw, 336px);
    --gallery-gap: 48px;
    height: auto;
    max-width: 1600px;
    overflow: visible;
    border-radius: 0;
    background: transparent;
    direction: ltr;
}

.ecosystem .section-title {
    margin-bottom: 1rem;
}

.ecosystem-motion .section-title {
    transition: transform 400ms cubic-bezier(0.23, 1, 0.32, 1), opacity 400ms ease;
}

.ecosystem-motion:not(.is-in-view) .section-title {
    opacity: 0;
    transform: translateY(16px);
}

.gallery-viewport {
    position: relative;
    height: clamp(464px, 38vw, 560px);
    overflow: hidden;
    isolation: isolate;
    touch-action: pan-y pinch-zoom;
    cursor: grab;
    /* Fade the scene itself: painted dark edge strips cannot match the page's radial background. */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent),
        linear-gradient(180deg, transparent, #000 7%, #000 90%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent),
        linear-gradient(180deg, transparent, #000 7%, #000 90%, transparent);
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
}

.gallery-viewport::before,
.gallery-viewport::after {
    content: none;
}

.gallery-ground {
    position: absolute;
    inset: 40% 8% 0;
    background: radial-gradient(ellipse at 50% 58%, rgba(144, 147, 255, 0.1), transparent 65%);
    pointer-events: none;
}

.gallery-scene {
    position: relative;
    height: 100%;
    perspective: 1200px;
    perspective-origin: 50% 50%;
}

.gallery-track {
    display: flex;
    align-items: center;
    gap: var(--gallery-gap);
    height: 100%;
    margin: 0;
    padding: 1rem 2rem;
    list-style: none;
    overflow-x: auto;
}

.gallery-item {
    flex: 0 0 var(--gallery-card-width);
    width: var(--gallery-card-width);
}

.is-enhanced .gallery-track {
    display: block;
    position: absolute;
    inset: 0;
    padding: 0;
    overflow: visible;
    transform-style: preserve-3d;
}

.is-enhanced .gallery-item {
    position: absolute;
    top: 50%;
    left: 50%;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.gallery-card-reveal {
    transition: transform 600ms var(--gallery-ease-out), opacity 600ms ease;
}

.is-enhanced:not(.has-entered) .gallery-card-reveal {
    transform: translateY(24px) scale(0.96);
    opacity: 0;
}

.gallery-card {
    display: block;
    width: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 20px;
    color: var(--on-surface);
    cursor: inherit;
    font: inherit;
    text-align: start;
    -webkit-tap-highlight-color: transparent;
}

.gallery-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 8px;
}

.gallery-card-tilt {
    display: block;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: inherit;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.025));
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    transition: transform 160ms var(--gallery-ease-out), border-color 160ms ease;
}

.is-current .gallery-card-tilt {
    border-color: rgba(212, 165, 165, 0.7);
}

.gallery-card-image {
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 12px;
    background: #bababa;
    transition: transform 160ms var(--gallery-ease-out);
}

.gallery-card picture,
.gallery-card img {
    display: block;
    width: 100%;
    height: 100%;
}

.gallery-card img {
    object-fit: contain;
    user-select: none;
    pointer-events: none;
}

.gallery-card-name {
    display: block;
    padding: 16px 8px 8px;
    color: rgba(250, 249, 246, 0.72);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
}

.gallery-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 32px;
}

.gallery-description {
    min-width: 0;
}

.gallery-current {
    color: var(--warm-white);
    font-family: 'Lexend', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
}

.gallery-count {
    display: inline-block;
    margin-inline-end: 16px;
    color: var(--primary);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.gallery-hint {
    margin-top: 8px;
    color: var(--on-surface-variant);
    font-size: 0.75rem;
    line-height: 1.6;
}

.gallery-controls {
    display: none;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
}

.is-enhanced .gallery-controls {
    display: flex;
}

.gallery-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--warm-white);
    cursor: pointer;
    font: inherit;
    font-size: 0.75rem;
    white-space: nowrap;
    transition: transform 160ms var(--gallery-ease-out), background-color 160ms ease, border-color 160ms ease;
}

.gallery-control svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.gallery-control:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
}

.gallery-control:active {
    transform: scale(0.97);
}

.gallery-play-icon,
.is-paused .gallery-pause-icon {
    display: none;
}

.is-paused .gallery-play-icon {
    display: block;
}

.gallery-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.is-dragging .gallery-viewport {
    cursor: grabbing;
}

.is-keyboard .gallery-control,
.is-keyboard .gallery-card-image,
.is-keyboard .gallery-card-tilt {
    transition: none;
}

.is-reduced .gallery-toggle {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .gallery-control:hover {
        border-color: rgba(212, 165, 165, 0.65);
        background-color: rgba(212, 165, 165, 0.1);
    }

    .gallery-card:active .gallery-card-image {
        transform: scale(0.97);
    }
}

@media (max-width: 768px) {
    .ecosystem .circular-gallery {
        --gallery-card-width: clamp(208px, 62vw, 260px);
        --gallery-gap: 24px;
    }

    .gallery-viewport {
        height: 408px;
    }

    .gallery-footer {
        padding-inline: 24px;
    }

    .gallery-hint {
        max-width: 20rem;
    }
}

@media (max-width: 480px) {
    .gallery-footer {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding-inline: 16px;
    }

    .gallery-current {
        font-size: 0.8125rem;
    }

    .gallery-count {
        margin-inline-end: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ecosystem-motion .section-title,
    .gallery-card-reveal,
    .gallery-card-image,
    .gallery-card-tilt,
    .gallery-control {
        transition: none;
    }

    .gallery-card-tilt {
        transition: border-color 160ms ease;
    }

    .gallery-control {
        transition: background-color 160ms ease, border-color 160ms ease;
    }

    .ecosystem-motion:not(.is-in-view) .section-title,
    .is-enhanced:not(.has-entered) .gallery-card-reveal {
        transform: none;
        opacity: 1;
    }
}
