/* PRODUCT GRID (DESKTOP) */
.app-grid {
    display: grid; gap: 20px; margin-bottom: 60px; grid-template-columns: repeat(2, 1fr);
}

/* Only #secondaryGrid (not the whole .app-grid class) fades between
   "Новинки"/"Знижки" — see switchTab() in js/app.js, which toggles this
   element's opacity directly. Scoped to the id so catalog/account grids
   (which never get their opacity touched) aren't affected. */
#secondaryGrid { transition: opacity 0.25s ease; }

@media (min-width: 768px) { .app-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .app-grid { grid-template-columns: repeat(4, 1fr); } }
/* NOTE: no 5-column breakpoint here on purpose — that only applies to the
   home page's full-width grid (no sidebar eating into the row). See
   css/hero-categories.css for that page-specific addition. The catalog
   page's grid sits next to a 280px sidebar and stays at 4 columns max,
   matching the original catalog design. */

/* BLOG GRID (DESKTOP) */
.blog-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; margin-top: 30px; }

/* APP CARD (reusable product card component) */
.app-card {
    background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 4px;
    position: relative; display: flex; flex-direction: column; transition: all 0.2s ease-in-out;
    height: 100%; z-index: 1;
}
/* hover:hover + pointer:fine — real mouse only. Without this guard,
   touch devices simulate :hover on tap and it can stay "stuck" (no
   mouseleave to clear it), firing this transition mid touch-scroll —
   confirmed cause of the cart recommendations jank (Апдейт 82 audit). */
@media (hover: hover) and (pointer: fine) {
    .app-card:hover { border-color: var(--accent-gold); box-shadow: 0 10px 30px rgba(15, 30, 51, 0.1); z-index: 10; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
}

.card-image-box { width: 100%; aspect-ratio: 1 / 1; background: var(--bg-soft); position: relative; overflow: hidden; border-radius: 4px 4px 0 0; }
.card-bg-image { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
@media (hover: hover) and (pointer: fine) {
    .app-card:hover .card-bg-image { transform: scale(1.05); }
}

.card-wishlist-btn {
    will-change: transform; /* above the zooming photo in Safari, as .card-badges */
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 5;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.3s ease;
}
@media (hover: hover) and (pointer: fine) {
    .card-wishlist-btn:hover {
        background: #fff;
        color: var(--accent-gold);
        border-color: var(--accent-gold);
    }
}
.card-wishlist-btn:active { transform: scale(0.88); }
.card-wishlist-btn.w-active {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
}
@keyframes heartJump {
    0% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.2) translateY(-2px); }
    100% { transform: scale(1) translateY(0); }
}
.card-wishlist-btn.w-active i {
    animation: heartJump 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@media (hover: hover) and (pointer: fine) {
    .app-card:hover .card-wishlist-btn {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

/* Shows every badge that applies (a product can be new AND on sale at
   once) instead of showing just one, stacked in a column — see
   product-card.js's computeBadges(), driven by the product's real
   is_new/is_top/is_sale flags rather than a single caller-picked label.
   Ordering and the Новинка badge's color depend on which rail the card
   is rendered in (badgeContext — 'top'/'new'/'sale'), also decided in
   computeBadges(). */
.card-badges {
    position: absolute; top: 10px; left: 10px; z-index: 5;
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    /* its own layer: in Safari the photo's hover zoom (a layer of its own while
       it runs) was drawn over the badges, so they blinked as cards slid under
       the cursor, e.g. scrolling the cart's recommendations */
    will-change: transform;
}
.card-badge {
    background: var(--accent-gold); color: #fff;
    font-size: 10px; font-weight: 600; text-transform: uppercase; padding: 4px 8px; border-radius: 4px;
}
.card-badge--new { background: var(--success); color: #fff; }
.card-badge--top { background: var(--navy); color: #fff; }
.card-badge--sale { background: var(--danger); color: #fff; }
/* «Покупка частинами monobank»: a black sticker with a small flag tail at the lower left,
   the white paw (icon/mono-paw-white.png) and the number of payments, as Horoshop shows it */
.card-badge.card-badge--parts {
    position: relative; display: none; align-items: center; gap: 5px;
    background: #111; color: #fff; padding: 4px 7px; border-radius: 4px 4px 4px 0; /* beats the phone padding in responsive.css */
    font-size: 12px; font-weight: 700; line-height: 1;
}
.card-badge--parts::after {
    content: ''; position: absolute; left: 0; top: 100%;
    border-left: 4px solid #111; border-bottom: 4px solid transparent;
}
.card-badge--parts .card-badge-paw { height: 12px; width: auto; display: block; }
html[data-parts] .card-badge.card-badge--parts { display: inline-flex; }

.card-info { position: relative; padding: 15px; flex-grow: 1; display: flex; flex-direction: column; background: var(--bg-card); border-radius: 0 0 4px 4px; }
.app-name { font-size: 14px; font-weight: 500; color: var(--text-main); margin-bottom: 8px; line-height: 1.4; min-height: 38px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stock-status { font-size: 11px; font-weight: 500; margin-bottom: 10px; display: flex; align-items: center; gap: 5px; }
.stock-status.available { color: var(--success); }
.stock-status.unavailable { color: var(--danger); }
.card-price { font-size: 18px; font-weight: 600; color: var(--navy); margin-top: auto; }
.card-price span { font-size: 12px; color: var(--text-secondary); margin-left: 5px; font-weight: normal;}
.card-price .card-old-price { margin-left: 8px; font-size: 13px; font-weight: 400; color: var(--text-secondary); text-decoration: line-through; }
/* where the round cart button sits in the card's bottom-right corner (phones, tablets, touch screens,
   the cart's recommendations) the old price would slide under it: it goes on its own line above the price */
@media (max-width: 1024px), (hover: none) {
    .card-price { display: flex; flex-wrap: wrap; align-items: baseline; }
    .card-price .card-old-price { order: -1; flex-basis: 100%; margin: 0 0 2px; font-size: 12px; line-height: 1.2; }
}
.reco-track .card-price { display: flex; flex-wrap: wrap; align-items: baseline; }
.reco-track .card-price .card-old-price { order: -1; flex-basis: 100%; margin: 0 0 2px; font-size: 12px; line-height: 1.2; }

/* HOVER DROPDOWN */
.hover-dropdown {
    position: absolute; top: 100%; left: -1px; right: -1px; background: var(--bg-card);
    border: 1px solid var(--accent-gold); border-top: none; border-radius: 0 0 4px 4px; padding: 0 15px 15px;
    opacity: 0; visibility: hidden; transform: translateY(-5px); transition: all 0.2s ease-in-out;
    box-shadow: 0 15px 30px rgba(15, 30, 51, 0.1); display: flex; flex-direction: column; gap: 12px;
}
@media (hover: hover) and (pointer: fine) {
    .app-card:hover .hover-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
}

.weight-selector { display: flex; gap: 5px; width: 100%; }
.weight-btn {
    flex: 1; font-size: 11px; color: var(--text-secondary); background: var(--bg-soft); padding: 8px 0; border: 1px solid var(--border-strong);
    border-radius: 4px; transition: 0.3s; font-weight: 500; text-align: center; cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
    .weight-btn:hover { color: var(--text-main); border-color: var(--border-strong); }
}
.weight-btn:active { border-color: var(--border-strong); }
.weight-btn.active { background: transparent; color: var(--accent-gold); border-color: var(--accent-gold); }

.btn-action-cart {
    width: 100%; background: var(--accent-gold); color: #fff; padding: 12px; border-radius: 4px;
    font-weight: 500; font-size: 13px; text-transform: uppercase; cursor: pointer; border: none;
    transition: 0.3s; display: flex; align-items: center; justify-content: center; gap: 8px;
}
@media (hover: hover) and (pointer: fine) {
    .btn-action-cart:hover { background: var(--accent-hover); }
    .btn-action-cart:disabled:hover { background: var(--border-light); }
}
.btn-action-cart:active:not(:disabled) { transform: scale(0.96); }
.btn-action-cart:disabled { background: var(--border-light); color: var(--text-secondary); cursor: not-allowed; }

.mobile-cart-btn {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    width: 44px;
    height: 44px;
    background: var(--accent-gold);
    color: #fff;
    border-radius: 4px 0 4px 0;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: 0.3s;
    border: none;
}
@media (hover: hover) and (pointer: fine) {
    .mobile-cart-btn:hover { background: var(--accent-hover); }
    .mobile-cart-btn:disabled:hover { background: var(--border-light); }
}
.mobile-cart-btn:active:not(:disabled) { transform: scale(0.92); }
.mobile-cart-btn:disabled { background: var(--border-light); color: var(--text-secondary); cursor: not-allowed; }

/* List-view markup (used by the catalog page's grid/list toggle) is part
   of the shared card component but hidden by default — only the catalog
   page's .app-grid.list-view rules (css/catalog.css) turn it on. */
.list-middle-col, .card-divider, .list-right-col, .list-wishlist { display: none !important; }


/* «Порівняти»: the scales button under the heart; shown on hover like the heart, and always
   once the product is in the list */
.card-compare-btn {
    will-change: transform;
    position: absolute; top: 50px; right: 10px; width: 32px; height: 32px;
    background: rgba(255, 255, 255, 0.92); border: 1px solid var(--border-light); border-radius: 50%;
    color: var(--navy); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 5;
    opacity: 0; visibility: hidden; transform: translateY(-5px); transition: all 0.3s ease;
}
.card-compare-btn svg { width: 16px; height: 16px; display: block; }
.card-compare-btn.w-active { opacity: 1; visibility: visible; transform: translateY(0); color: var(--accent-gold); border-color: var(--accent-gold); }
@media (hover: hover) and (pointer: fine) {
    .app-card:hover .card-compare-btn { opacity: 1; visibility: visible; transform: translateY(0); }
    .card-compare-btn:hover { background: #fff; color: var(--accent-gold); border-color: var(--accent-gold); }
}
.card-compare-btn:active { transform: scale(0.88); }
