/* =========================================
   HERO (page-specific: home page)
   ========================================= */
.hero {
    position: relative; aspect-ratio: 2880 / 1152; width: 100%;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}

.hero::after {
    content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 15%;
    background: linear-gradient(to bottom, transparent 0%, var(--bg-body) 90%);
    z-index: 5; pointer-events: none;
}

.hero-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: url('../Baner/baner/baner1.webp') no-repeat center/cover; z-index: 1;
}

.hero-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(180deg, rgba(5,5,5,0.4) 0%, rgba(5,5,5,0.6) 50%, rgba(5,5,5,0.9) 100%); z-index: 2;
}

.hero-content {
    position: relative; z-index: 3; text-align: center; max-width: 800px;
    padding: 0 20px; animation: fadeInUp 1s ease-out;
}

.hero-label {
    color: var(--accent-gold); letter-spacing: 4px; font-size: 14px;
    text-transform: uppercase; margin-bottom: 20px; display: block; font-weight: 500;
}

.hero-title { font-size: 58px; line-height: 1.1; font-weight: 700; margin-bottom: 30px; text-shadow: 0 10px 30px rgba(0,0,0,0.5); }

.hero-btn {
    display: inline-block; padding: 18px 50px; background: var(--accent-gold); color: #000;
    font-weight: 500; font-size: 14px; text-transform: uppercase; letter-spacing: 1px;
    border-radius: 50px; transition: all 0.4s ease; box-shadow: 0 10px 30px rgba(194, 160, 93, 0.3);
}
.hero-btn:hover { transform: translateY(-5px); box-shadow: 0 20px 40px rgba(194, 160, 93, 0.5); background: #fff; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   CATEGORIES GRID (Desktop)
   ========================================= */
.categories-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
    margin-top: -5%; position: relative; z-index: 10; margin-bottom: 100px;
}

.cat-card {
    background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 4px;
    overflow: hidden; position: relative; aspect-ratio: 1/1.2; cursor: pointer; transition: 0.4s;
}
.cat-card img { width: 100%; height: 100%; object-fit: cover; transition: 0.6s; opacity: 0.7; }
.cat-info {
    position: absolute; bottom: 0; left: 0; width: 100%; padding: 30px;
    background: linear-gradient(0deg, #000 0%, transparent 100%);
}
.cat-title { font-size: 19px; font-weight: 500; color: #fff; margin-bottom: 5px; }
.cat-link {
    color: var(--accent-gold); font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
    opacity: 0; transform: translateY(10px); transition: 0.4s;
}

.cat-card:hover { transform: translateY(-10px); border-color: var(--accent-gold); }
.cat-card:hover img { transform: scale(1.1); opacity: 1; }
.cat-card:hover .cat-link { opacity: 1; transform: translateY(0); }

/* Home page's product grid is full-width (no sidebar), so it gets an extra
   column at wide viewports. Catalog page intentionally caps at 4 columns
   (see css/product-card.css) since its grid sits next to a filter sidebar. */
@media (min-width: 1400px) { .app-grid { grid-template-columns: repeat(5, 1fr); } }

/* Home page's product rails (.app-grid) — and the blog teaser rail
   (.blog-grid) — are horizontal-scrolling carousels on tablet/mobile;
   this is home-specific and must NOT apply to the catalog page's
   .app-grid, which needs to stay a real wrapping grid (a shared file
   would break the catalog's mobile product display). */
@media (max-width: 1024px) {
    .app-grid, .blog-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 15px;
        padding-bottom: 15px;
        margin-left: -40px; margin-right: -40px;
        padding-left: 40px; padding-right: 40px;
    }
    .app-grid::-webkit-scrollbar, .blog-grid::-webkit-scrollbar { display: none; }
    .app-card { flex: 0 0 220px; }
    .blog-card { flex: 0 0 240px; }
}

@media (max-width: 768px) {
    .app-grid, .blog-grid {
        margin-left: -15px; margin-right: -15px;
        padding-left: 15px; padding-right: 15px;
    }
}

@media (max-width: 600px) {
    .app-grid, .blog-grid { gap: 10px; }
    .app-card { flex: 0 0 175px; }
    .blog-card { flex: 0 0 165px; }
}

@media (max-width: 400px) {
    .app-card { flex: 0 0 150px; }
    .blog-card { flex: 0 0 140px; }
}

/* =========================================
   DESKTOP RAIL ARROWS ("В топі цінителів" and "Новинки/Знижки")
   Both rails stay a single scrollable row on desktop (instead of
   wrapping into extra grid rows) with visible manual scroll arrows —
   the home page's mobile carousel already covers touch/swipe, these
   arrows are specifically for mouse users.
   ========================================= */
.rail-scroll-wrap { position: relative; }

.rail-scroll-btn {
    display: none;
    position: absolute; top: 40%; transform: translateY(-50%); z-index: 5;
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.12); color: #999;
    align-items: center; justify-content: center; cursor: pointer; transition: 0.25s ease; font-size: 14px;
    backdrop-filter: blur(4px);
}
.rail-scroll-btn:hover { background: rgba(194,160,93,0.1); color: var(--accent-gold); border-color: var(--accent-gold); }
.rail-left { left: -22px; }
.rail-right { right: -22px; }

@media (min-width: 1025px) {
    .rail-scroll-btn { display: flex; }

    /* Setting overflow-x here makes the browser compute overflow-y as
       'auto' too (a CSS overflow-module rule, not something we can turn
       off) — without headroom, that clips/scrolls the product card's
       hover-dropdown, which expands ~100px below the card. padding-bottom
       reserves that room inside the scrollable box; the matching negative
       margin pulls the next section back up so total page spacing is
       unchanged from before. */
    #productGrid, #secondaryGrid {
        display: flex !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-behavior: smooth;
        scrollbar-width: none;
        gap: 20px;
        padding-bottom: 120px;
        margin-bottom: -60px;
    }
    #productGrid::-webkit-scrollbar, #secondaryGrid::-webkit-scrollbar { display: none; }
    #productGrid .app-card, #secondaryGrid .app-card {
        flex: 0 0 calc((100% - 4 * 20px) / 5);
    }

    /* When a rail has fewer cards than fit in one row (checked in JS via
       scrollWidth vs clientWidth — see updateRailFit() in app.js), there is
       nothing to scroll: the arrows would just be dead buttons. Cards keep
       their normal fixed width either way (no stretching to fill the row —
       4 cards should look like 4 normal-sized cards, not 4 cards stretched
       to fake a 5th). `.rail-fits` is toggled on the wrapper after every
       render and only controls arrow visibility. */
    .rail-scroll-wrap.rail-fits .rail-scroll-btn { display: none !important; }
}
