/* ==========================================
   COLLECTION PAGE HEADER BANNER

   A wide hero image with overlaid copy, uploaded per collection in the
   admin (Storefront-independent: Lunar → Collections → edit).

   Responsive model:
   - phone   : shorter banner (2:1), smaller copy, heading clamps to 2 lines
   - tablet  : ~2.4:1
   - desktop : ~2.6:1 with a max height so ultrawide does not get a wall
   - short   : <=820px tall viewports trim the ratio so the copy and the
               first product row stay above the fold (1366x768 laptops)
   The image keeps a fixed aspect-ratio box, so there is no layout shift
   while it loads.

   Width: the banner is a direct child of `.store-content`, so it simply
   takes 100% of that container. Mirroring the container's gutter/max-width
   formulas by hand worked, but left the banner short of the page edge at
   every width that fell between two breakpoints. Inheriting the width
   means the banner edges stay flush with the product grid below it at
   every screen resolution, with no breakpoints to keep in step.
   ========================================== */

.collection-banner {
    position: relative;
    display: flex;
    align-items: flex-end;
    box-sizing: border-box;

    /*
     * Fill the parent `.store-content` column so the banner is always as
     * wide as the product grid beneath it, at any resolution.
     */
    width: 100%;
    max-width: none;
    margin: clamp(0.5rem, 1.5vw, 1rem) auto clamp(1.5rem, 3vw, 2.5rem);
    overflow: hidden;
    border-radius: clamp(1rem, 2.5vw, 1.75rem);
    background: #10131a;
    isolation: isolate;

    /*
     * The banner owns the aspect ratio, not the <picture>/<img>.
     *
     * The image is absolutely positioned (so the copy can overlay it), which
     * removes it from flow — putting aspect-ratio on the image therefore gave
     * the container no height at all and it collapsed to a thin strip sized
     * only by the copy. The ratio has to live on this element.
     */
    aspect-ratio: 2 / 1;
}

.collection-banner picture {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.collection-banner img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gradient scrim guarantees contrast over any photo. */
.collection-banner::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        to top,
        rgba(6, 8, 12, 0.82) 0%,
        rgba(6, 8, 12, 0.45) 45%,
        rgba(6, 8, 12, 0.12) 100%
    );
    pointer-events: none;
}

.collection-banner-copy {
    position: relative;
    z-index: 2;
    box-sizing: border-box;
    width: 100%;
    padding: clamp(1rem, 3vw, 2.25rem);
    color: #fff;
}

.collection-banner-eyebrow {
    margin: 0 0 0.25rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: clamp(0.62rem, 0.58rem + 0.2vw, 0.75rem);
    font-weight: 750;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.collection-banner-copy h1 {
    margin: 0;
    color: #fff;
    font-size: clamp(1.4rem, 1.1rem + 2vw, 2.75rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    /* Long collection names must not push the banner taller. */
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.collection-banner-note {
    max-width: 46ch;
    margin: 0.5rem 0 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: clamp(0.8rem, 0.76rem + 0.3vw, 1rem);
    line-height: 1.5;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* ==========================================
   TABLET (>= 768px): wider crop
   ========================================== */
/*
 * Tablet crop. Width is inherited from `.store-content`, so nothing to set
 * here — the banner never drifts away from the grid, whatever the width.
 */
@media (min-width: 768px) {
    .collection-banner {
        aspect-ratio: 12 / 5;
    }
}

/* ==========================================
   DESKTOP (>= 1025px): cinematic, height capped
   ========================================== */
@media (min-width: 1025px) {
    .collection-banner {
        aspect-ratio: 13 / 5;
        /* Cap the height so an ultrawide monitor does not get a giant slab. */
        max-height: 30rem;

        /* Silence-unused: keeps the ratio from being overridden when the
           max-height clamps, preserving edge-to-edge artwork. */
        min-height: 18rem;
    }
}

/* ==========================================
   SHORT VIEWPORTS — 1366x768 class laptops

   A 13:5 ratio inside a ~1300px column needs ~500px of height, and
   `.store-content` adds ~3.3rem of top padding on top of that, so the
   banner alone fills most of a 768px-tall screen. Trim the ratio so the
   copy and the first product row stay in view. The copy is bottom-aligned,
   so the artwork crops from the top and the text is never cut.
   ========================================== */
@media (min-width: 1025px) and (max-height: 820px) {
    .collection-banner {
        aspect-ratio: 3 / 1;
        max-height: 26rem;
        min-height: 15rem;
    }
}

/* ==========================================
   SMALL PHONES (<= 400px)
   ========================================== */
@media (max-width: 400px) {
    .collection-banner {
        /* Width is inherited from `.store-content`; only the rounding and
           copy padding need tightening at this size. */
        border-radius: 1rem;
    }

    .collection-banner-copy {
        padding: 0.85rem;
    }
}

/* ==========================================
   FALLBACK for browsers without `picture` support or a missing file.
   ========================================== */
@media (prefers-reduced-data: reduce) {
    .collection-banner img {
        /* Keep the solid colour rather than downloading a large hero. */
        visibility: hidden;
    }
}

/* ==========================================
   COLLECTION PAGE — FILTERS & SORTING
   Sidebar filters on desktop, stacked above
   the grid on tablet/phone.
   ========================================== */

.collection-listing {
    display: grid;
    grid-template-columns: 16rem minmax(0, 1fr);
    gap: clamp(1.25rem, 3vw, 2.5rem);
    align-items: start;
    margin-top: clamp(1.25rem, 3vw, 2rem);
}

.collection-filters {
    position: sticky;
    top: 6.5rem;
    padding: 1.1rem 1.15rem;
    border: 1px solid #e8e8e8;
    border-radius: 1rem;
    background: #fff;
}

.collection-filters-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.collection-filters-head h2 {
    margin: 0;
    color: #222;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.collection-filters-clear {
    padding: 0;
    border: 0;
    color: #1d3686;
    background: none;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.collection-filter-group {
    padding: 0.95rem 0;
    border-top: 1px solid #efefef;
}

.collection-filter-group:first-of-type {
    border-top: 0;
}

.collection-filter-group h3 {
    margin: 0 0 0.6rem;
    color: #222;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.collection-filter-field select {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.65rem;
    border: 1px solid #dcdcdc;
    border-radius: 0.55rem;
    color: #222;
    background: #fff;
    font-size: 0.86rem;
    cursor: pointer;
}

.collection-filter-field select:focus-visible,
.collection-price-inputs input:focus-visible,
.collection-price-range:focus-visible {
    outline: 2px solid #1d3686;
    outline-offset: 2px;
}

.collection-price-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    color: #555;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.collection-price-range {
    width: 100%;
    accent-color: #1d3686;
    cursor: pointer;
}

.collection-price-inputs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.55rem;
}

.collection-price-inputs input {
    width: 100%;
    min-width: 0;
    padding: 0.42rem 0.5rem;
    border: 1px solid #dcdcdc;
    border-radius: 0.5rem;
    color: #222;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.collection-filter-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #333;
    font-size: 0.86rem;
    cursor: pointer;
}

.collection-filter-check input {
    width: 1rem;
    height: 1rem;
    accent-color: #1d3686;
    cursor: pointer;
}

.collection-listing-main {
    min-width: 0;
}

.collection-listing-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.9rem;
}

.collection-results-count {
    margin: 0;
    color: #666;
    font-size: 0.86rem;
}

.collection-results-count strong {
    color: #222;
    font-weight: 700;
}

/* Fade the grid while Livewire re-queries instead of collapsing it */
.collection-products-grid {
    transition: opacity 160ms ease;
}

.collection-products-grid.is-loading {
    opacity: 0.45;
    pointer-events: none;
}

.collection-empty-results {
    margin-top: 0.5rem;
}

@media (max-width: 900px) {
    .collection-listing {
        grid-template-columns: minmax(0, 1fr);
    }

    .collection-filters {
        position: static;
    }
}

/* Collection listing grid: the legacy `.product-grid` rule in app.css forces
   four fixed columns, which ignores the filter sidebar and squeezes cards.
   Use an auto-fill track that respects the current column width. */
.collection-listing .product-grid.collection-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr));
    gap: clamp(1rem, 1.6vw, 1.5rem);
    /* Equal-height rows keep the absolute ribbon/media inside each card. */
    align-items: stretch;
    grid-auto-rows: 1fr;
}

/* Fade the grid while Livewire re-queries instead of collapsing it */
.collection-products-grid {
    transition: opacity 160ms ease;
}

.collection-products-grid.is-loading {
    opacity: 0.45;
    pointer-events: none;
}
