/* Whiznoch storefront layout fixes: product grid + cards, section headings, header navigation.
   Loaded LAST in whiznoch/layout.blade.php. Scoped with body.app-layout-standard so it wins over
   the older rules in whiznoch.css, platform-refinements.css, mobile-app.css, etc.
   Layout only: colours and theme stay with the existing palette files. */

/* =====================================================================
   1. Product grid
   ===================================================================== */
body.app-layout-standard .market-grid:not(.app-scroll-row) {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
    gap: 20px !important;
    align-items: stretch !important;
}
body.app-layout-standard .market-grid:not(.app-scroll-row) > .advertisement { grid-column: 1 / -1; }

/* =====================================================================
   2. Product card
   ===================================================================== */
body.app-layout-standard .market-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    overflow: hidden;
}

/* One image shape everywhere; product screenshots are anchored to the top so headlines stay visible */
body.app-layout-standard .market-card-image {
    display: block;
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 4 / 3 !important;
    overflow: hidden;
}
body.app-layout-standard .market-card-image picture,
body.app-layout-standard .market-card-image .product-picture {
    display: block;
    width: 100%;
    height: 100%;
}
body.app-layout-standard .market-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}
body.app-layout-standard .market-card-placeholder {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    text-align: center;
}

/* Body: stacked, with the price/actions block pinned to the bottom of every card */
body.app-layout-standard .market-card-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    padding: 14px;
}
body.app-layout-standard .market-card-labels {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
body.app-layout-standard .market-card h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3 !important;
    min-height: 2.6em;
    max-height: 2.6em;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}
body.app-layout-standard .market-card h3 a { color: inherit; text-decoration: none; }
body.app-layout-standard .market-card .market-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .8rem;
}

/* Rating row: five stars, filled by the average; an outline placeholder when there are no reviews */
body.app-layout-standard .market-card .market-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 22px;
    font-size: .8rem;
}
body.app-layout-standard .market-card .market-stars { display: inline-flex; gap: 2px; line-height: 1; }
body.app-layout-standard .market-card .market-star { font-size: 1rem; line-height: 1; color: rgba(128, 140, 165, .45); }
body.app-layout-standard .market-card .market-star.is-full { color: #f5b301; }
body.app-layout-standard .market-card .market-star.is-half {
    background: linear-gradient(90deg, #f5b301 50%, rgba(128, 140, 165, .45) 50%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
body.app-layout-standard .market-card .market-rating.is-placeholder strong { font-size: .76rem; font-weight: 500; opacity: .65; white-space: nowrap; }

/* Whole card opens the product; the save button stays clickable above it */
body.app-layout-standard .market-card h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
body.app-layout-standard .market-card .market-card-save { position: absolute; z-index: 3; }
body.app-layout-standard .market-card:focus-within { outline: 2px solid #6a1fe8; outline-offset: 2px; }

/* Bottom row:  [ sales count ........ price ] */
body.app-layout-standard .market-card-bottom {
    margin-top: auto;
    padding-top: 12px;
    display: flex !important;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px 10px;
    border-top: 1px solid rgba(128, 140, 165, .22);
}
body.app-layout-standard .market-sales-count { flex: 1 1 auto; min-width: 0; font-size: .74rem; line-height: 1.3; }
body.app-layout-standard .market-card-price-wrap {
    flex: 0 0 auto;
    margin: 0 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: 2px 6px;
    text-align: right;
}
body.app-layout-standard .market-card-price-wrap small { font-size: .68rem; opacity: .7; }
body.app-layout-standard .market-card-price-wrap del { font-size: .72rem; }
body.app-layout-standard .market-card-price { font-size: 1.08rem; font-weight: 800; line-height: 1.1; }

/* =====================================================================
   3. Section headings ("Popular Products", "Explore the collection")
   ===================================================================== */
body.app-layout-standard .market-popular-heading,
body.app-layout-standard .market-catalog-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px 18px;
    text-align: left;
}

/* =====================================================================
   4. Phones: two columns, price above the sales count
   ===================================================================== */
@media (max-width: 700px) {
    body.app-layout-standard .market-grid:not(.app-scroll-row) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }
    body.app-layout-standard .market-card-body { padding: 11px; gap: 6px; }
    body.app-layout-standard .market-card h3 { font-size: .92rem; }
    body.app-layout-standard .market-card .market-star { font-size: .9rem; }
    body.app-layout-standard .market-card .market-rating.is-placeholder strong { display: none; }
    body.app-layout-standard .market-card-bottom { flex-direction: column-reverse; align-items: flex-start; gap: 4px; }
    body.app-layout-standard .market-card-price-wrap { margin: 0; justify-content: flex-start; text-align: left; }

    body.app-layout-standard .market-popular-heading,
    body.app-layout-standard .market-catalog-heading {
        flex-direction: column;
        align-items: flex-start !important;
        justify-content: flex-start;
    }
}
@media (max-width: 340px) {
    body.app-layout-standard .market-grid:not(.app-scroll-row) { grid-template-columns: minmax(0, 1fr) !important; }
}

/* =====================================================================
   5. Header navigation: no more labels breaking letter by letter
   ===================================================================== */
body.app-layout-standard .header .navlinks a,
body.app-layout-standard .header .navlinks summary { white-space: nowrap; }

/* Wide screens: one tidy row. */
@media (min-width: 1200px) {
    body.app-layout-standard .header .wrap.nav {
        max-width: min(1400px, calc(100% - 32px));
        flex-wrap: nowrap;
        gap: 14px;
    }
    body.app-layout-standard .header .navlinks {
        flex: 1 1 auto;
        min-width: 0;
        gap: clamp(10px, 1.1vw, 20px);
    }
    body.app-layout-standard .header .header-search { flex: 0 1 190px; min-width: 140px; }
    body:not(.is-authenticated) .header .menu-btn { display: none; }
}
/* Below 1440px the cart shows just the icon and count. */
@media (min-width: 1200px) and (max-width: 1439px) {
    body.app-layout-standard .header .header-cart-link > span:not([data-cart-count]) { display: none; }
}

/* Narrower screens: use the menu button instead of squeezing every link into the bar. */
@media (max-width: 1199px) {
    body:not(.is-authenticated) .header .navlinks {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin: 0;
        padding: 14px 22px 22px;
        background: var(--platform-panel, #fff);
        border-bottom: 1px solid var(--platform-line, #dce3ef);
        box-shadow: 0 20px 28px #14182720;
    }
    body:not(.is-authenticated) .header .navlinks.open { display: flex; }
    body:not(.is-authenticated) .header .menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}
