/*
 * Ganjeh Kala — Digikala-inspired two-row category Swiper
 * Independent visual skin for GridCategoryCarousel::two_row_swiper.
 * Swiper owns only the two-row carousel behavior; this file owns all presentation.
 */
.gk-dkcat {
    --gk-dkcat-accent: var(--gk-primary, #ef4056);
    --gk-dkcat-text: #3f4064;
    --gk-dkcat-muted: #a1a3a8;
    --gk-dkcat-border: #e0e0e2;
    --gk-dkcat-media-bg: #f4f4f5;
    --gk-dkcat-gap: 18px;
    --gk-dkcat-cell-height: 154px;
    --gk-dkcat-media-size: 88px;
    --gk-dkcat-item-accent: var(--gk-dkcat-accent);
    position: relative;
    width: 100%;
    direction: rtl;
    background: transparent;
    box-sizing: border-box;
}

.gk-dkcat *,
.gk-dkcat *::before,
.gk-dkcat *::after { box-sizing: border-box; }

.gk-dkcat__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.gk-dkcat__heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gk-dkcat__title {
    position: relative;
    margin: 0;
    padding-bottom: 8px;
    color: #23254b;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.55;
    letter-spacing: -.012em;
}

.gk-dkcat__title::after {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    bottom: 0;
    width: 34px;
    height: 3px;
    border-radius: 99px;
    background: var(--gk-dkcat-accent);
}

.gk-dkcat__subtitle {
    margin: 0;
    color: var(--gk-dkcat-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.8;
}

.gk-dkcat__all {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0;
    color: var(--gk-dkcat-accent);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity .18s ease;
}
.gk-dkcat__all:hover { opacity: .72; }

.gk-dkcat__all-icon {
    display: block;
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 18l6-6-6-6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 18l6-6-6-6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transform: scaleX(-1);
    transition: transform .18s ease;
}
.gk-dkcat__all:hover .gk-dkcat__all-icon { transform: translateX(-2px) scaleX(-1); }

.gk-dkcat__stage {
    position: relative;
    width: 100%;
    min-width: 0;
    padding-inline: 22px;
}

.gk-dkcat__swiper {
    width: 100%;
    height: calc((var(--gk-dkcat-cell-height) * 2) + var(--gk-dkcat-gap));
    overflow: hidden;
}

.gk-dkcat__swiper .swiper-wrapper { align-items: stretch; }
.gk-dkcat__slide { height: auto; }

.gk-dkcat__item {
    --gk-dkcat-item-accent: var(--gk-dkcat-accent);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: var(--gk-dkcat-cell-height);
    padding: 4px 6px 6px;
    color: inherit;
    text-align: center;
    text-decoration: none;
    user-select: none;
    -webkit-user-drag: none;
}

.gk-dkcat__visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--gk-dkcat-media-size);
    height: var(--gk-dkcat-media-size);
    flex: 0 0 var(--gk-dkcat-media-size);
    margin-bottom: 10px;
}

.gk-dkcat__media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 50%;
    background: var(--gk-dkcat-media-bg);
    color: var(--gk-dkcat-item-accent);
    transform: translateZ(0);
    transition: transform .24s cubic-bezier(.2,.8,.2,1), background-color .2s ease, border-color .2s ease, box-shadow .24s ease;
}

.gk-dkcat__media::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
    pointer-events: none;
}

.gk-dkcat__image-empty {
    display: block;
    width: 42%;
    height: 42%;
    border-radius: 50%;
    background: #e5e7eb;
    opacity: .65;
}

.gk-dkcat__image--placeholder {
    opacity: .72;
    filter: saturate(.75);
}

.gk-dkcat__image,
.gk-dkcat__media img {
    display: block;
    width: 100%;
    height: 100%;
    padding: 8px;
    object-fit: contain;
    transform: translateZ(0);
    transition: transform .24s cubic-bezier(.2,.8,.2,1);
}


.gk-dkcat__name {
    display: -webkit-box;
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    color: var(--gk-dkcat-text);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.65;
    text-align: center;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    transition: color .18s ease;
}

.gk-dkcat__count {
    display: block;
    max-width: 100%;
    margin-top: 3px;
    overflow: hidden;
    color: var(--gk-dkcat-muted);
    font-size: 10.5px;
    font-weight: 400;
    line-height: 1.55;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
    .gk-dkcat__item:hover .gk-dkcat__media {
        border-color: color-mix(in srgb, var(--gk-dkcat-item-accent) 16%, transparent);
        background: color-mix(in srgb, var(--gk-dkcat-item-accent) 6%, #f4f4f5);
        box-shadow: 0 8px 24px rgba(0,0,0,.055);
        transform: translateY(-3px);
    }
    .gk-dkcat__item:hover .gk-dkcat__image,
    .gk-dkcat__item:hover .gk-dkcat__media img { transform: scale(1.045); }
    .gk-dkcat__item:hover .gk-dkcat__name { color: var(--gk-dkcat-item-accent); }
}

.gk-dkcat__nav {
    position: absolute !important;
    top: 50% !important;
    z-index: 5;
    display: inline-flex !important;
    transform: translateY(-50%);
}

/* Canonical RTL/LTR placement. The icon direction itself is owned by
   swiper-unified.css, exactly like the other Swiper widgets. */
.gk-dkcat__nav--prev {
    inset-inline-start: var(--gk-dkcat-nav-offset, 0) !important;
    inset-inline-end: auto !important;
}
.gk-dkcat__nav--next {
    inset-inline-end: var(--gk-dkcat-nav-offset, 0) !important;
    inset-inline-start: auto !important;
}
.gk-dkcat__nav.swiper-button-lock { display: none !important; }

.gk-dkcat__pagination {
    position: static !important;
    width: 100%;
    min-height: 10px;
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Stable no-JS / editor fallback: same two-row geometry, no old-skin dependency. */
.gk-dkcat__swiper:not(.swiper-initialized) .swiper-wrapper,
.gk-dkcat__swiper.gk-swiper-pending .swiper-wrapper {
    display: grid !important;
    grid-template-rows: repeat(2, var(--gk-dkcat-cell-height));
    grid-auto-flow: column;
    grid-auto-columns: minmax(130px, 1fr);
    gap: var(--gk-dkcat-gap);
    transform: none !important;
}
.gk-dkcat__swiper:not(.swiper-initialized) .swiper-slide,
.gk-dkcat__swiper.gk-swiper-pending .swiper-slide {
    width: auto !important;
    height: var(--gk-dkcat-cell-height) !important;
    margin: 0 !important;
}

@media (max-width: 1024px) {
    .gk-dkcat__stage { padding-inline: 18px; }
    .gk-dkcat__swiper:not(.swiper-initialized) .swiper-wrapper,
    .gk-dkcat__swiper.gk-swiper-pending .swiper-wrapper { grid-auto-columns: minmax(120px, 1fr); }
}

@media (max-width: 767px) {
    .gk-dkcat {
        --gk-dkcat-cell-height: 128px;
        --gk-dkcat-media-size: 70px;
        --gk-dkcat-gap: 10px;
    }
    .gk-dkcat__head { align-items: center; gap: 12px; margin-bottom: 16px; }
    .gk-dkcat__title { padding-bottom: 6px; font-size: 16px; }
    .gk-dkcat__title::after { width: 26px; height: 2px; }
    .gk-dkcat__subtitle { display: none; }
    .gk-dkcat__all { font-size: 11px; }
    .gk-dkcat__stage { padding-inline: 4px; }
    .gk-dkcat__item { padding-inline: 4px; }
    .gk-dkcat__visual { margin-bottom: 7px; }
    .gk-dkcat__name { font-size: 11.5px; line-height: 1.55; }
    .gk-dkcat__count { margin-top: 2px; font-size: 9.5px; }
    .gk-dkcat__nav { display: none; }
    .gk-dkcat__swiper:not(.swiper-initialized) .swiper-wrapper,
    .gk-dkcat__swiper.gk-swiper-pending .swiper-wrapper { grid-auto-columns: minmax(92px, 32vw); }
    .gk-dkcat--hide-all-mobile .gk-dkcat__all { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .gk-dkcat__all,
    .gk-dkcat__all-icon,
    .gk-dkcat__media,
    .gk-dkcat__image,
    .gk-dkcat__media img,
    .gk-dkcat__name,
    .gk-dkcat__pagination .swiper-pagination-bullet { transition: none !important; }
}


/* Mobile compositor guard: the Swiper wrapper is the moving layer; individual
 * category media/images do not need their own translateZ GPU layers. */
@media (max-width: 1024px), (pointer: coarse) {
    .gk-dkcat__media,
    .gk-dkcat__image,
    .gk-dkcat__media img {
        transform: none !important;
        will-change: auto !important;
    }
}
