/* ============================================================
   GREENPI SERVICES — 18 categories as one wireframe table.
   No card frames: every rectangle is made by the crossing of
   1px horizontal and vertical rules. Lines in site gray.
   هر سلول دو تصویر دارد: پیش‌فرض + هاور (cross-fade).
   ============================================================ */

.wilo-categories-section {
    --wc-line: var(--line-strong);
    --wc-ink: var(--text-muted);
    padding: 60px 0;
    position: relative;
    z-index: 1;
}

.wilo-categories-section,
.wilo-categories-section .container,
.wilo-categories-section .inner {
    overflow: visible !important;
}

/* خطوط و نقطه‌های سکشن، هم‌رنگ بقیه سایت */
.wilo-categories-section::before,
.wilo-categories-section::after,
.wilo-categories-section .inner::before,
.wilo-categories-section .inner::after {
    background: var(--line-px) !important;
}

.wilo-categories-section .dot {
    background: var(--dot-empty) !important;
    border-color: var(--wc-line) !important;
    box-shadow: none !important;
}

/* ============================================================
   HEADER — کادر خط‌کشی جدا برای تایتل
   ============================================================ */
#wilo-categories .wc-header {
    width: 100% !important;
    max-width: none !important;
    margin: 0 0 34px !important;
    padding: 22px 32px !important;
    position: relative !important;
    text-align: center !important;
    overflow: visible !important;
}

#wilo-categories .wc-header::before {
    content: '' !important;
    position: absolute !important;
    left: calc(-1 * var(--line-ext)) !important;
    right: calc(-1 * var(--line-ext)) !important;
    top: 0 !important;
    bottom: 0 !important;
    height: auto !important;
    border: 0 !important;
    border-top: 1px solid var(--wc-line) !important;
    border-bottom: 1px solid var(--wc-line) !important;
    background: none !important;
    pointer-events: none;
}

#wilo-categories .wc-header::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    border: 0 !important;
    border-left: 1px solid var(--wc-line) !important;
    border-right: 1px solid var(--wc-line) !important;
    background: none !important;
    box-shadow: none !important;
    pointer-events: none;
}

#wilo-categories .wc-header h2 {
    margin: 0 0 6px !important;
    font-family: 'Vazirmatn', 'Inter', sans-serif;
    font-size: 2rem !important;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.2;
}

#wilo-categories .wc-header p {
    max-width: 560px;
    margin: 0 auto !important;
    font-family: 'Vazirmatn', 'Inter', sans-serif;
    font-size: 0.82rem !important;
    opacity: 0.45;
}

/* ============================================================
   BOARD — فقط یک قاب بیرونی؛ داخل آن فقط خطوط
   ============================================================ */
.wc-board {
    position: relative;
    border: 1px solid var(--wc-line);
    z-index: 2;
}

.wc-board::before,
.wc-board::after {
    content: '';
    position: absolute;
    top: -1px;
    height: 1px;
    background: var(--wc-line);
    pointer-events: none;
    z-index: 3;
}

.wc-board::before { left: 100%; right: calc(-1 * var(--line-ext)); }
.wc-board::after { right: 100%; left: calc(-1 * var(--line-ext)); }

/* ============================================================
   GRID — بدون فاصله؛ خانه‌ها از تقاطع خطوط ساخته می‌شوند
   ============================================================ */
.wilo-cat-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
}

.wilo-cat-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 210px;
    padding: 18px 18px 16px;
    border-right: 1px solid var(--wc-line);
    border-bottom: 1px solid var(--wc-line);
    text-decoration: none;
    color: inherit;
    background: transparent;
    transition: background 0.3s ease;
}

.wilo-cat-cell:nth-child(6n) {
    border-right: 0;
}

/* خط افقی هر ردیف تا لبه‌های صفحه — فقط از خانه‌های ابتدا/انتها
   تا خط‌ها روی هم نیفتند و پررنگ نشوند */
.wilo-cat-cell:nth-child(6n+1)::after,
.wilo-cat-cell:nth-child(6n)::after {
    content: '';
    position: absolute;
    bottom: -1px;
    height: 1px;
    background: var(--wc-line);
    pointer-events: none;
    z-index: 3;
}

.wilo-cat-cell:nth-child(6n+1)::after { right: 100%; left: calc(-1 * var(--line-ext)); }
.wilo-cat-cell:nth-child(6n)::after { left: 100%; right: calc(-1 * var(--line-ext)); }

.wilo-cat-cell:hover,
.wilo-cat-cell:focus-visible {
    background: rgba(255, 255, 255, 0.016);
    outline: none;
}

[data-theme="light"] .wilo-cat-cell:hover,
[data-theme="light"] .wilo-cat-cell:focus-visible {
    background: rgba(0, 0, 0, 0.018);
}

/* ============================================================
   CELL CONTENT
   ============================================================ */
.wilo-cat-num {
    font-family: 'Vazirmatn', 'Inter', sans-serif;
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    line-height: 1;
    color: var(--wc-ink);
    opacity: 0.55;
    font-variant-numeric: tabular-nums;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.wilo-cat-cell:hover .wilo-cat-num {
    opacity: 1;
    color: var(--text);
}

/* ——— محفظه‌ی هنری: stack برای cross-fade ——— */
.wilo-cat-art {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 88px;
    padding: 6px 0 14px;
}

.wilo-cat-img {
    display: block;
    width: auto;
    max-width: 84%;
    max-height: 88px;
    object-fit: contain;
    /* تک‌رنگ خاکستری — هم‌دست با خطوط و متن سایت */
    filter: grayscale(1) brightness(1.35) contrast(0.95);
    opacity: 0.72;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                filter 0.3s ease;
}

.wilo-cat-img.is-default {
    position: relative;
    opacity: 0.72;
    transform: none;
}

.wilo-cat-img.is-hover {
    position: absolute;
    inset: 0;
    margin: auto;
    opacity: 0;
    transform: translateY(-3px) scale(0.97);
    pointer-events: none;
}

/* ——— hover: عکس پیش‌فرض محو، عکس دوم ظاهر ——— */
.wilo-cat-cell.has-hover:hover .wilo-cat-img.is-default,
.wilo-cat-cell.has-hover:focus-visible .wilo-cat-img.is-default {
    opacity: 0;
    transform: translateY(-3px) scale(1.02);
    filter: grayscale(0) brightness(1.05) contrast(1);
}

.wilo-cat-cell.has-hover:hover .wilo-cat-img.is-hover,
.wilo-cat-cell.has-hover:focus-visible .wilo-cat-img.is-hover {
    opacity: 1;
    transform: translateY(-3px) scale(1);
    filter: grayscale(0) brightness(1.05) contrast(1);
}

/* در موبایل/تاچ، hover مزاحمه؛ غیرفعالش می‌کنیم */
@media (hover: none) {
    .wilo-cat-cell.has-hover:hover .wilo-cat-img.is-default,
    .wilo-cat-cell.has-hover:focus-visible .wilo-cat-img.is-default {
        opacity: 0.72;
        transform: none;
        filter: grayscale(1) brightness(1.35) contrast(0.95);
    }

    .wilo-cat-cell.has-hover:hover .wilo-cat-img.is-hover,
    .wilo-cat-cell.has-hover:focus-visible .wilo-cat-img.is-hover {
        opacity: 0;
        transform: translateY(-3px) scale(0.97);
        filter: grayscale(1) brightness(1.35) contrast(0.95);
    }
}

.wilo-cat-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.wilo-cat-name {
    font-family: 'Vazirmatn', 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.2px;
    color: var(--text);
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

.wilo-cat-cell:hover .wilo-cat-name {
    opacity: 1;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .wilo-cat-cell {
        min-height: 190px;
        padding: 16px;
    }

    .wilo-cat-name { font-size: 0.78rem; }
    .wilo-cat-img { max-height: 76px; }
}

@media (max-width: 1000px) {
    .wilo-cat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .wilo-cat-cell:nth-child(6n) {
        border-right: 1px solid var(--wc-line);
    }

    .wilo-cat-cell:nth-child(3n) {
        border-right: 0;
    }

    .wilo-cat-cell:nth-child(6n+1)::after,
    .wilo-cat-cell:nth-child(6n)::after {
        content: none;
    }

    .wilo-cat-cell:nth-child(3n+1)::after,
    .wilo-cat-cell:nth-child(3n)::after {
        content: '';
        position: absolute;
        bottom: -1px;
        height: 1px;
        background: var(--wc-line);
        pointer-events: none;
        z-index: 3;
    }

    .wilo-cat-cell:nth-child(3n+1)::after { right: 100%; left: calc(-1 * var(--line-ext)); }
    .wilo-cat-cell:nth-child(3n)::after { left: 100%; right: calc(-1 * var(--line-ext)); }

    .wilo-cat-cell { min-height: 200px; }
}

@media (max-width: 600px) {
    .wilo-categories-section { padding: 40px 0; }

    #wilo-categories .wc-header {
        padding: 18px 16px !important;
        margin-bottom: 24px !important;
    }

    #wilo-categories .wc-header::before {
        left: -1200px !important;
        right: -1200px !important;
    }

    #wilo-categories .wc-header h2 { font-size: 1.2rem !important; }

    .wilo-cat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .wilo-cat-cell:nth-child(3n) {
        border-right: 1px solid var(--wc-line);
    }

    .wilo-cat-cell:nth-child(2n) {
        border-right: 0;
    }

    .wilo-cat-cell:nth-child(3n+1)::after,
    .wilo-cat-cell:nth-child(3n)::after {
        content: none;
    }

    .wilo-cat-cell:nth-child(2n+1)::after,
    .wilo-cat-cell:nth-child(2n)::after {
        content: '';
        position: absolute;
        bottom: -1px;
        height: 1px;
        background: var(--wc-line);
        pointer-events: none;
        z-index: 3;
    }

    .wilo-cat-cell:nth-child(2n+1)::after { right: 100%; left: calc(-1 * var(--line-ext)); }
    .wilo-cat-cell:nth-child(2n)::after { left: 100%; right: calc(-1 * var(--line-ext)); }

    .wilo-cat-cell {
        min-height: 165px;
        padding: 14px 12px 12px;
    }

    .wilo-cat-num { font-size: 0.6rem; }
    .wilo-cat-img { max-height: 64px; }
    .wilo-cat-name { font-size: 0.76rem; }
}