.komplex-gallery {
    width: 100%;
    box-sizing: border-box;
    color: var(--wp--preset--color--contrast, inherit);
}

.komplex-gallery * {
    box-sizing: border-box;
}

.komplex-gallery__controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.komplex-gallery__search {
    display: flex;
    flex: 1 1 420px;
    gap: .5rem;
}

.komplex-gallery__search input {
    min-width: 0;
    flex: 1;
    padding: .7rem .85rem;
    border: 1px solid color-mix(in srgb, var(--wp--preset--color--contrast, #1e1e1e) 30%, transparent);
    border-radius: .45rem;
    background: var(--wp--preset--color--secondary-bg, #fff);
    color: var(--wp--preset--color--primary, #1e1e1e);
    font: inherit;
}

.komplex-gallery__search input::placeholder {
    color: color-mix(in srgb, var(--wp--preset--color--contrast, #1e1e1e) 60%, transparent);
}

.komplex-gallery__search button {
    padding: .7rem 1rem;
    border-radius: .45rem;
    cursor: pointer;
    font: inherit;
    border-width: 0px;
    background: var(--wp--preset--color--secondary-bg, #fff);
    color: var(--wp--preset--color--secondary, #1e1e1e);
}

.komplex-gallery__search button:hover {
    background: var(--wp--preset--color--btn-hover-bg, #fff);
    color: var(--wp--preset--color--btn-hover-text, #1e1e1e);
}

.komplex-gallery__per-page {
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
    color: var(--wp--preset--color--contrast, inherit);
}

.komplex-gallery__per-page select {
    height: 2.25rem;
    min-height: 2.25rem;
    padding: 0 .7rem;
    border: 1px solid color-mix(in srgb, var(--wp--preset--color--contrast, #1e1e1e) 30%, transparent);
    border-radius: .45rem;
    background: var(--wp--preset--color--base, #fff);
    color: var(--wp--preset--color--contrast, #1e1e1e);
    font: inherit;
}

.komplex-gallery__count {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: .95rem;
    opacity: .8;
}

.komplex-gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, clamp(245px, 23vw, 320px));
    justify-content: center;
    gap: 1.25rem;
}

.komplex-gallery__card-link {
    display: block;
    min-width: 0;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.komplex-gallery__card-link:focus-visible {
    outline: 2px solid var(--wp--preset--color--primary, #16ddff);
    outline-offset: 3px;
    border-radius: 1rem;
}

.komplex-gallery__card-link--entering {
    opacity: 0;
    transform: translateY(18px);
    animation: komplex-gallery-card-in .42s cubic-bezier(.2, .75, .25, 1) forwards;
    animation-delay: calc(var(--komplex-gallery-card-index, 0) * 85ms);
}

.komplex-gallery__card-link--leaving {
    animation: komplex-gallery-card-out 160ms ease-in both;
    pointer-events: none;
}

@keyframes komplex-gallery-card-in {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes komplex-gallery-card-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-8px) scale(.985);
    }
}

@media (prefers-reduced-motion: reduce) {
    .komplex-gallery__card-link--entering {
        opacity: 1;
        transform: none;
        animation: none;
    }

    .komplex-gallery__card-link--leaving {
        animation: none;
    }
}

.komplex-gallery__card {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100%;
    height: 100%;
    overflow: hidden;
    border: 1px solid color-mix(
        in srgb,
        var(--wp--preset--color--primary, #16ddff) 28%,
        transparent
    );
    border-radius: 1rem;
    background:
        radial-gradient(
            circle at 100% 0%,
            color-mix(in srgb, var(--wp--preset--color--accent, #9d63ff) 14%, transparent),
            transparent 34%
        ),
        linear-gradient(
            155deg,
            color-mix(in srgb, var(--wp--preset--color--secondary-bg, #101d33) 96%, #000),
            color-mix(in srgb, var(--wp--preset--color--base, #07101e) 96%, #000)
        );
    color: var(--wp--preset--color--contrast, #f4f7ff);
    cursor: pointer;
    font-family: var(
        --wp--preset--font-family--system,
        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif
    );
    box-shadow:
        0 14px 38px rgba(0, 0, 0, .22),
        inset 0 1px 0 rgba(255, 255, 255, .025);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.komplex-gallery__card::before {
    content: "";
    position: absolute;
    z-index: 2;
    inset: 0 0 auto;
    height: 2px;
    background: linear-gradient(
        90deg,
        var(--wp--preset--color--primary, #16ddff),
        var(--wp--preset--color--accent, #9d63ff) 50%,
        var(--wp--preset--color--secondary, #ff42df)
    );
    box-shadow: 0 0 16px color-mix(
        in srgb,
        var(--wp--preset--color--primary, #16ddff) 32%,
        transparent
    );
    pointer-events: none;
}

.komplex-gallery__card::after {
    content: "";
    position: absolute;
    z-index: -1;
    width: 150px;
    height: 150px;
    right: -60px;
    bottom: -80px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        color-mix(in srgb, var(--wp--preset--color--accent-5, #39ff14) 8%, transparent),
        transparent 68%
    );
    pointer-events: none;
}

.komplex-gallery__card:hover {
    transform: translateY(-2px);
    border-color: color-mix(
        in srgb,
        var(--wp--preset--color--primary, #16ddff) 55%,
        transparent
    );
    box-shadow:
        0 18px 44px rgba(0, 0, 0, .30),
        0 0 24px color-mix(in srgb, var(--wp--preset--color--primary, #16ddff) 12%, transparent),
        0 0 30px color-mix(in srgb, var(--wp--preset--color--accent, #39ff14) 8%, transparent);
}

.komplex-gallery__thumbnail-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    flex: 0 0 auto;
    background: var(--wp--preset--color--base, #07101e);
    border-bottom: 1px solid color-mix(
        in srgb,
        var(--wp--preset--color--primary, #16ddff) 18%,
        transparent
    );
}

.komplex-gallery__thumbnail {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.komplex-gallery__featured-star {
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: 32px;
    height: 32px;
    fill: var(--wp--preset--color--accent);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
    pointer-events: none;
}

.komplex-gallery__thumbnail--empty {
    background: linear-gradient(
        135deg,
        var(--wp--preset--color--secondary-bg, #101d33),
        var(--wp--preset--color--base, #07101e)
    );
}

.komplex-gallery__card-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    padding: .95rem 1rem 1rem;
}

.komplex-gallery__title {
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--wp--preset--color--primary, #f4f7ff);
    font-family: var(
        --wp--preset--font-family--display,
        "Arial Black", Impact, Inter, ui-sans-serif, system-ui, sans-serif
    );
    font-size: 1.05rem;
    line-height: 1.3;
    letter-spacing: .01em;
}

.komplex-gallery__author {
    margin: 0 0 6px;
    padding: 0;
    color: var(--wp--preset--color--accent-4, #94a8c1);
    font-size: .85rem;
}

.komplex-gallery__description {
    margin: 0;
    color: var(--wp--preset--color--contrast, #f4f7ff);
    font-size: .9rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: .88;
}

.komplex-gallery__initial,
.komplex-gallery__loading,
.komplex-gallery__empty,
.komplex-gallery__no-results,
.komplex-gallery__error,
.komplex-gallery__warning {
    padding: 2rem 1rem;
    text-align: center;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 512px;
    display: flex;
    flex-direction: column;
}

.komplex-gallery__initial img,
.komplex-gallery__loading img,
.komplex-gallery__empty img,
.komplex-gallery__no-results img,
.komplex-gallery__error img,
.komplex-gallery__warning img {
    display: block;
    width: min(512px, 100%);
    height: auto;
    max-height: 512px;
    object-fit: contain;
    margin: 0 auto;
}

.komplex-gallery__no-results p,
.komplex-gallery__error p,
.komplex-gallery__warning p {
    margin: 1rem 0 0;
}

.komplex-gallery [hidden] {
    display: none !important;
}

.komplex-gallery__error {
    color: var(--wp--preset--color--vivid-red, #b32d2e);
}

.komplex-gallery__pagination-block {
    width: 100%;
    margin-top: 1.75rem;
}

.komplex-gallery__pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .35rem;
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
}

.komplex-gallery__pagination--compact {
    justify-content: flex-start;
}

.komplex-gallery__pagination-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    width: 100%;
    margin-top: .75rem;
    flex-wrap: wrap;
}

.komplex-gallery__pagination-meta .komplex-gallery__per-page,
.komplex-gallery__pagination-meta .komplex-gallery__count {
    flex: 0 0 auto;
}

.komplex-gallery__pagination button {
    flex: 0 0 auto;
    border-radius: .4rem;
    cursor: pointer;
    border-width: 0px;
    background: var(--wp--preset--color--secondary-bg, #fff);
    color: var(--wp--preset--color--primary, #1e1e1e);
    opacity: .8;
}

.komplex-gallery__pagination button[aria-current="page"] {
    font-weight: 700;
    box-shadow: inset 0 0 0 2px currentColor;
    background: var(--wp--preset--color--btn-hover-bg, #fff);
    color: var(--wp--preset--color--btn-hover-text, #1e1e1e);
}

.komplex-gallery__pagination button:hover {
    background: var(--wp--preset--color--btn-hover-bg, #fff);
    color: var(--wp--preset--color--btn-hover-text, #1e1e1e);
}

.komplex-gallery__pagination button:disabled {
    opacity: .4;
    cursor: default;
}

.komplex-gallery__ellipsis {
    flex: 0 0 auto;
    padding: 0 .2rem;
    color: var(--wp--preset--color--contrast, inherit);
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 782px) {
    .komplex-gallery__grid {
        grid-template-columns: repeat(auto-fill, min(78vw, 300px));
    }
}

@media (max-width: 520px) {
    .komplex-gallery__search {
        flex-basis: 100%;
    }
}

@media (max-width: 640px) {
    .komplex-gallery__pagination-meta {
        gap: .75rem;
    }
}

/* Loading/default cards and thumbnail states */
.komplex-gallery__thumbnail-wrap {
    display: grid;
    place-items: center;
    background: #090a0d;
}

.komplex-gallery__thumbnail-loader {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-items: center;
    opacity: 1;
    transition: opacity .15s ease;
}

.komplex-gallery__spinner {
    display: block;
    width: 24px;
    height: 24px;
    border: 3px solid color-mix(in srgb, var(--wp--preset--color--contrast, #f4f7ff) 22%, transparent);
    border-top-color: var(--wp--preset--color--primary, #16ddff);
    border-radius: 50%;
    animation: komplex-gallery-spin .7s linear infinite;
}

.komplex-gallery__thumbnail {
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity .18s ease;
}

.komplex-gallery__thumbnail-wrap.is-image-loaded .komplex-gallery__thumbnail {
    opacity: 1;
}

.komplex-gallery__thumbnail-wrap.is-image-loaded .komplex-gallery__thumbnail-loader {
    opacity: 0;
    pointer-events: none;
}

.komplex-gallery__thumbnail-placeholder {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    width: 100%;
    height: 100%;
    color: color-mix(in srgb, currentColor 72%, transparent);
    font-size: 10px;
}

.komplex-gallery__thumbnail-placeholder i {
    font-size: 24px;
}

.komplex-gallery__card-link--loading {
    pointer-events: none;
}

.komplex-gallery__skeleton-line {
    display: block;
    width: 100%;
    height: 10px;
    margin: 0 0 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--wp--preset--color--contrast, #f4f7ff) 9%, transparent);
}

.komplex-gallery__skeleton-line.is-title {
    width: 68%;
    height: 16px;
}

.komplex-gallery__skeleton-line.is-author {
    width: 42%;
    margin-bottom: 18px;
}

.komplex-gallery__skeleton-line.is-short {
    width: 76%;
}

@keyframes komplex-gallery-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .komplex-gallery__spinner {
        animation-duration: 1.5s;
    }
}
