/*
 * KingSoft / Osapa 2.2.4 migration — Phase 2
 * Homepage product and category cards only.
 * Scoped selectors intentionally avoid changing shop archives or product pages.
 */
.ivn-home-bestseller-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 34px 24px;
    padding-top: 50px;
}

.ivn-home-product-card {
    min-width: 0;
    margin: 0;
    padding: 0;
    text-align: left;
}

.ivn-home-product-card-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 14px;
    border: 1px solid #e0e0e0;
    background: #fff;
    overflow: hidden;
}

.ivn-home-product-card-image:hover,
.ivn-home-product-card-image:focus {
    border-color: #ea0028;
    text-decoration: none;
}

.ivn-home-product-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    margin: 0;
}

.ivn-home-product-card-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding-top: 14px;
}

.ivn-home-product-card-title {
    margin: 0;
    padding: 0;
    font-family: "Hanken Sans", "Open Sans", sans-serif;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 500;
    text-transform: none;
}

.ivn-home-product-card-title a {
    color: #222;
}

.ivn-home-product-card-title a:hover,
.ivn-home-product-card-title a:focus {
    color: #ea0028;
    text-decoration: none;
}

.ivn-home-product-card-price {
    white-space: nowrap;
    color: #222;
    font-family: "Montserrat", "Open Sans", sans-serif;
    font-size: 15px;
    line-height: 1.35;
    font-weight: 700;
    text-align: right;
}

.ivn-home-product-card-price del {
    display: block;
    color: #888;
    font-size: 12px;
    font-weight: 400;
}

.ivn-home-product-card-price ins {
    display: block;
    background: transparent;
    color: #222;
    text-decoration: none;
}

.ivn-home-category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 24px;
    margin-top: 50px;
}

.ivn-home-category-card {
    display: flex;
    align-items: center;
    min-height: 82px;
    padding: 14px 16px;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #000;
    text-decoration: none;
}

.ivn-home-category-card:hover,
.ivn-home-category-card:focus {
    padding: 12px 14px;
    border: 3px solid #ea0028;
    color: #000;
    text-decoration: none;
}

.ivn-home-category-card-image {
    display: flex;
    flex: 0 0 58px;
    width: 58px;
    height: 52px;
    align-items: center;
    justify-content: center;
}

.ivn-home-category-card-image img {
    display: block;
    width: auto;
    height: auto;
    max-width: 50px;
    max-height: 50px;
    margin: 0;
    object-fit: contain;
}

.ivn-home-category-card-title {
    min-width: 0;
    padding-left: 22px;
    font-family: "Montserrat", "Open Sans", sans-serif;
    font-size: 15px;
    line-height: 1.25;
    font-weight: 600;
}

@media (max-width: 991px) {
    .ivn-home-bestseller-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding-top: 30px;
    }

    .ivn-home-category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 30px;
    }
}

@media (max-width: 767px) {
    .ivn-home-bestseller-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 28px 14px;
    }

    .ivn-home-product-card-body {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .ivn-home-product-card-price {
        text-align: left;
    }
}

@media (max-width: 639px) {
    .ivn-home-category-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Phase 3: restore the original KingSoft desktop content width.
 * Osapa 2.2.4 uses a narrower container in this layout, which compressed
 * the bestseller and category grids compared with the March reference.
 */
@media (min-width: 1200px) {
    .ivn-home-bestsellers > .container,
    .ivn-home-products > .container {
        width: 1170px;
        max-width: calc(100% - 30px);
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .ivn-home-bestsellers > .container,
    .ivn-home-products > .container {
        width: 970px;
        max-width: calc(100% - 30px);
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .ivn-home-bestsellers > .container,
    .ivn-home-products > .container {
        width: 750px;
        max-width: calc(100% - 30px);
    }
}
