/* ---------------- GRID ---------------- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    justify-items: stretch;
    padding: 0.5rem;
    margin-bottom: 48px;
}

/* ---------------- PRODUCT CARD ---------------- */
.product-card {
    width: 100%;
    background: #fff;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* ---------------- IMAGE ---------------- */
.product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f5f5f5;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-image img.loaded {
    transform: scale(1);
}

/* ---------------- PRODUCT INFO ---------------- */
.product-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 0.35rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    color: #222;

    /* не флекс, а блочный с обрезкой по 2 строкам */
    display: -webkit-box;
    -webkit-line-clamp: 2;         /* максимум 2 строки */
    -webkit-box-orient: vertical;

    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2rem;
    max-height: calc(1.2rem * 2);  /* фикс по высоте на 2 строки */
}

/* ---------------- FEATURE SELECT ---------------- */
.feature-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;

    /* толкает селект к низу блока product-info,
       чтобы он всегда был прямо над кнопкой */
    margin-top: auto;
}

.feature-select:hover {
    border-color: #2381cc; /* Telegram blue */
}

.feature-select:focus {
    outline: none;
    border-color: #2381cc; /* Telegram blue */
    box-shadow: 0 0 0 2px rgba(38, 165, 228, 0.8); /* Telegram blue @20% */
}

/* ---------------- BUY BUTTON ---------------- */
.buy-btn,
.buy-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 44px;
    background: #2381cc; /* Telegram blue */
    color: #fff;
    border: none;
    border-radius: 0 0 12px 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
}

.buy-btn-initial {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    background: #2381cc; /* Telegram blue */
    color: #fff;
    border: none;
    border-radius: 0 0 12px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

/* Counter buttons (- / +) */
.buy-btn button,
.buy-counter button {
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

/* Count number in middle */
.buy-btn span,
.buy-counter span {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
}

.buy-counter {
    padding: 0 4px;
}

/* ---------------- LINKS ---------------- */
a {
    color: inherit;
    text-decoration: none;
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 768px) {
    .product-grid {
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }

    .product-card {
        max-width: 180px;
    }

    .product-name {
        font-size: 0.95rem;
    }

    .product-info {
        padding: 0.3rem 0.4rem;
    }

    .feature-select {
        font-size: 0.8rem;
    }
}

@media (max-width: 400px) {
    .product-card {
        max-width: 170px;
    }

    .product-name {
        font-size: 0.9rem;
    }
}