/* ========================================================
   GanjehKala - Dynamic Product Grid
   v1.9.264 — theme header alignment
======================================================== */

.gk-product-grid {
    --gk-grid-card-lift: 3px;
    --gk-grid-image-hover-scale: 1.03;
    position: relative;
    width: 100%;
    min-width: 0;
    color: var(--gk-text, #24262b);
    background: transparent;
}

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

/* Header — same visual contract as the other Home widgets. */
.gk-product-grid__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-width: 0;
    margin-block-end: 20px;
}

.gk-product-grid__header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.gk-product-grid__header-main::before {
    content: "";
    display: block;
    flex: 0 0 6px;
    width: 6px;
    height: 24px;
    border-radius: 4px;
    background: var(--gk-grid-accent, var(--gk-primary, #3342fd));
}

.gk-product-grid__header-title {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--gk-text, #1f2937);
    font-family: var(--gk-font-heading, inherit);
    font-size: 22px;
    font-weight: 900;
    line-height: 1.4;
}

.gk-product-grid__header-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--gk-grid-accent, var(--gk-primary, #3342fd));
    border-radius: min(calc(var(--gk-radius, 8px) * 1.25), 24px);
    background: transparent;
    color: var(--gk-grid-accent, var(--gk-primary, #3342fd));
    font-size: 12px;
    font-weight: 800;
    line-height: 1.4;
    text-decoration: none;
    transition:
        background-color var(--gk-duration-fast, .2s) ease,
        color var(--gk-duration-fast, .2s) ease,
        border-color var(--gk-duration-fast, .2s) ease,
        transform var(--gk-duration-fast, .2s) ease;
}

.gk-product-grid__header-link-arrow {
    font-size: 15px;
    line-height: 1;
    transition: transform var(--gk-duration-fast, .2s) ease;
}

.gk-product-grid__header-link:hover,
.gk-product-grid__header-link:focus-visible {
    border-color: var(--gk-grid-accent, var(--gk-primary, #3342fd));
    background: var(--gk-grid-accent, var(--gk-primary, #3342fd));
    color: #fff;
}

/* Grid — column count is generated by Elementor responsive controls. */
.gk-product-grid__items {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: 15px;
    row-gap: 15px;
    align-items: stretch;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.gk-product-grid__items > .gk-product-card {
    min-width: 0;
    height: 100%;
    margin: 0;
    list-style: none;
}

.gk-product-grid__items > .gk-product-card > .gk-product-card__inner {
    height: 100%;
}

/* Legacy product card selectors kept for old cached Elementor CSS; new cards use Product Card Core. */
.gk-product-grid__item {
    position: relative;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    background: var(--gk-surface, #fff);
    border: 1px solid var(--gk-border-color, rgba(0, 0, 0, .06));
    border-radius: var(--gk-radius, 16px);
    box-shadow: var(--gk-shadow-sm, 0 2px 10px rgba(0, 0, 0, .035));
    transition:
        transform var(--gk-duration-fast, .22s) ease,
        box-shadow var(--gk-duration-fast, .22s) ease,
        border-color var(--gk-duration-fast, .22s) ease;
}

.gk-product-grid__item-inner {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

/* Image */
.gk-product-grid__image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--gk-surface-soft, #f7f7f8);
}

.gk-product-grid__image {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: transparent;
}

.gk-product-grid__image img,
.gk-product-grid__image .gk-main-img,
.gk-product-grid__image .gk-hover-img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center;
    transform: scale(1);
    transition:
        opacity var(--gk-duration, .35s) ease,
        transform var(--gk-duration, .35s) ease;
}

.gk-product-grid__image .gk-main-img {
    z-index: 1;
    opacity: 1;
}

.gk-product-grid__image .gk-hover-img {
    z-index: 2;
    opacity: 0;
    pointer-events: none;
}

.gk-product-grid__discount-badge {
    position: absolute;
    z-index: 7;
    inset-block-start: 10px;
    inset-inline-end: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--gk-accent, #ef4056);
    color: #fff;
    font-size: .76rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(239, 64, 86, .18);
}

/* Content */
.gk-product-grid__content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    padding: clamp(11px, 1.2vw, 14px);
}

.gk-product-grid__title {
    min-width: 0;
    margin: 0 0 12px;
    font-size: clamp(.82rem, 1vw, .92rem);
    font-weight: 700;
    line-height: 1.65;
}

.gk-product-grid__title a {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    color: var(--gk-text, #24262b);
    text-decoration: none;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    transition: color var(--gk-duration-fast, .2s) ease;
}

.gk-product-grid__title a:hover,
.gk-product-grid__title a:focus-visible {
    color: var(--gk-primary, #ef4056);
}

/* Compact price contract: same concept as native archive card. */
.gk-product-grid__price-block {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    margin-block-start: auto;
}

.gk-product-grid__price-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    min-height: 17px;
    color: var(--gk-muted, #8a8f98);
    font-size: .74rem;
    line-height: 1.35;
    white-space: nowrap;
}

.gk-product-grid__price-label {
    flex: 0 0 auto;
    color: var(--gk-muted, #8a8f98);
    font-weight: 700;
}

.gk-product-grid__price-regular {
    min-width: 0;
    overflow: hidden;
    color: var(--gk-muted, #9ca3af);
    font-size: .78rem;
    font-weight: 400;
    text-decoration-thickness: 1px;
    text-overflow: ellipsis;
}

.gk-product-grid__price-current {
    min-width: 0;
    overflow: hidden;
    color: var(--gk-text, #24262b);
    font-size: clamp(.88rem, 1vw, 1.05rem);
    font-weight: 800;
    line-height: 1.45;
    text-align: end;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gk-product-grid__price-current .woocommerce-Price-amount,
.gk-product-grid__price-regular .woocommerce-Price-amount,
.gk-product-grid__price-current bdi,
.gk-product-grid__price-regular bdi {
    color: inherit;
    white-space: nowrap;
}

.gk-product-grid__unavailable {
    margin-block-start: auto;
    color: var(--gk-muted, #8a8f98);
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.5;
    text-align: end;
}

.gk-product-grid__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 38px;
    margin-block-start: 12px;
    padding: 9px 12px;
    border: 0;
    border-radius: min(calc(var(--gk-radius, 8px) * 1.5), 24px);
    background: var(--gk-primary, #ef4056);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    transition:
        background var(--gk-duration-fast, .2s) ease,
        color var(--gk-duration-fast, .2s) ease,
        transform var(--gk-duration-fast, .2s) ease;
}

.gk-product-grid__button:hover,
.gk-product-grid__button:focus-visible {
    color: #fff;
    filter: brightness(.97);
}

/* Pagination */
.gk-product-grid__pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-block-start: 36px;
}

.gk-product-grid__pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding-inline: 10px;
    border: 1px solid var(--gk-border-color, rgba(0, 0, 0, .08));
    border-radius: var(--gk-radius-sm, 10px);
    background: var(--gk-surface, #fff);
    color: var(--gk-text, #333);
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition:
        background var(--gk-duration-fast, .2s) ease,
        color var(--gk-duration-fast, .2s) ease,
        border-color var(--gk-duration-fast, .2s) ease;
}

.gk-product-grid__pagination .page-numbers.current,
.gk-product-grid__pagination a.page-numbers:hover,
.gk-product-grid__pagination a.page-numbers:focus-visible {
    border-color: var(--gk-primary, #ef4056);
    background: var(--gk-primary, #ef4056);
    color: #fff;
}

/* Empty state */
.gk-product-grid__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 24px;
    border: 1px dashed var(--gk-border-color, rgba(0, 0, 0, .12));
    border-radius: var(--gk-radius, 16px);
    background: var(--gk-surface, #fff);
    color: var(--gk-muted, #6b7280);
    text-align: center;
}

.gk-product-grid__empty p {
    margin: 0;
}

/* Hover effects are deliberately disabled on touch/coarse pointers. */
@media (hover: hover) and (pointer: fine) {
    .gk-product-grid__item:hover {
        transform: translateY(calc(-1 * var(--gk-grid-card-lift, 3px)));
        box-shadow: var(--gk-shadow-lg, 0 12px 28px rgba(0, 0, 0, .08));
    }

    .gk-product-grid__header-link:hover .gk-product-grid__header-link-arrow {
        transform: translateX(-2px);
    }

    .gk-product-grid__item:hover .gk-main-img--has-hover,
    .gk-product-grid__item:focus-within .gk-main-img--has-hover {
        opacity: 0;
    }

    .gk-product-grid__item:hover .gk-main-img--has-hover + .gk-hover-img,
    .gk-product-grid__item:focus-within .gk-main-img--has-hover + .gk-hover-img {
        opacity: 1;
        transform: scale(var(--gk-grid-image-hover-scale, 1.03));
    }

    .gk-product-grid__item:hover .gk-main-img:not(.gk-main-img--has-hover) {
        transform: scale(var(--gk-grid-image-hover-scale, 1.03));
    }

    .gk-product-grid__button:hover {
        transform: translateY(-1px);
    }
}

@media (hover: none), (pointer: coarse) {
    .gk-product-grid__image .gk-main-img {
        opacity: 1;
        transform: none;
    }

    .gk-product-grid__image .gk-hover-img {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gk-product-grid *,
    .gk-product-grid *::before,
    .gk-product-grid *::after {
        scroll-behavior: auto !important;
        transition-duration: .001ms !important;
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
    }
}
