/* ============================================================
   Bob — Products
   assets/css/bob-products.css
   Grid + cards for the "prodotto" CPT, plus the AJAX filter buttons
   used by the Bob — Products widget (class-bob-products-widget.php).
   Loaded separately from bob-style.css, but shares the same theme
   custom properties (--bg / --fg / --accent / --ff-*) via :root.
   ============================================================ */

.bb-products {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* ── Filter buttons ─────────────────────────────────────────── */
.bb-products-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.bb-products-filters .bb-products-filter {
    padding: 10px 20px;
    border: 1px solid var(--accent, #E63329);
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font-family: var(--ff-ui, "Space Grotesk", sans-serif);
    font-size: 13px;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background .25s, color .25s, border-color .25s;
}
.bb-products-filters .bb-products-filter:hover {
    background: color-mix(in srgb, var(--accent, #E63329) 12%, transparent);
}
.bb-products-filters .bb-products-filter.is-active {
    background: var(--accent, #E63329);
    border-color: var(--accent, #E63329);
    color: #FFFFFF;
}
/* Color family row: sits right under the season/category row (the
   container's 40px gap would split them into two separate blocks). */
.bb-products-filters + .bb-products-filters--color {
    margin-top: -24px;
}
.bb-products-filters--color .bb-products-filter {
    padding: 8px 16px;
    font-size: 12px;
}

/* ── Grid ───────────────────────────────────────────────────── */
.bb-products-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}
/* While a filter reloads the grid: the cards (not the grid itself, or the
   spinner below would be dimmed too) fade back, and a spinner appears.
   min-height keeps room for it when the grid is short or empty. */
.bb-products-grid > * { transition: opacity .3s ease; }
.bb-products-grid.is-loading { pointer-events: none; min-height: 240px; }
.bb-products-grid.is-loading > * { opacity: .25; }

@keyframes bb-products-spin { to { transform: rotate(360deg); } }
.bb-products-grid::after {
    content: '';
    position: absolute;
    z-index: 2;
    top: 96px; /* near the top: on a long grid the middle may be off-screen */
    left: 50%;
    width: 40px;
    height: 40px;
    margin-left: -20px;
    border: 2px solid color-mix(in srgb, var(--accent, #E63329) 22%, transparent);
    border-top-color: var(--accent, #E63329);
    border-radius: 50%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility 0s linear .2s;
}
/* Short delay: a fast response never flashes the spinner. */
.bb-products-grid.is-loading::after {
    opacity: 1;
    visibility: visible;
    transition: opacity .2s ease .15s, visibility 0s;
    animation: bb-products-spin .8s linear infinite;
}

/* "Carica altri": the arrow becomes a small spinner while loading. */
.bb-products-loadmore-wrap .bb-btn.is-loading { pointer-events: none; opacity: .7; }
.bb-products-loadmore-wrap .bb-btn.is-loading .bb-btn-arrow { display: none; }
.bb-products-loadmore-wrap .bb-btn.is-loading::after {
    content: '';
    width: 13px;
    height: 13px;
    border: 1.5px solid color-mix(in srgb, currentColor 30%, transparent);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: bb-products-spin .7s linear infinite;
}

/* Cards inserted by a filter / Load More (bob-design.js sets .is-entering
   and --bb-i, the card's position in the new batch, for the stagger). */
@keyframes bb-products-card-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}
.bb-products-card.is-entering {
    animation: bb-products-card-in .5s cubic-bezier(.2, .8, .2, 1) both;
    animation-delay: calc(min(var(--bb-i, 0), 12) * 45ms);
}

.bb-products[data-cols="2"] .bb-products-grid { grid-template-columns: repeat(2, 1fr); }
.bb-products[data-cols="3"] .bb-products-grid { grid-template-columns: repeat(3, 1fr); }
.bb-products[data-cols="4"] .bb-products-grid { grid-template-columns: repeat(4, 1fr); }

.bb-products-loadmore-wrap {
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

/* ── Card ───────────────────────────────────────────────────── */
.bb-products-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bb-products-card-link {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-decoration: none;
    color: inherit;
}

.bb-products-media {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    /*background-color: #1A1A18;*/
    background-size: cover;
    background-position: center;
    transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}
.bb-products-card-link:hover .bb-products-media { transform: scale(1.03); }

/* Blurred preview: a ~24px copy of the real photo inlined as --bb-lqip,
   oversized so the blur doesn't leave soft edges. */
.bb-products-media::before {
    content: '';
    position: absolute;
    inset: -10%;
    background: var(--bb-lqip, none) center / cover no-repeat;
    filter: blur(16px);
}

/* Real photo on top. Hidden until loaded only when JS is running
   (.is-enhanced), so it can never stay invisible. During a swatch change
   the new <img> is appended over the old one and fades in. */
/* Selector deliberately heavier than Elementor's `.elementor img
   { height: auto; max-width: 100% }`, which otherwise shrinks the square
   photo inside the 3:4 box and uncovers the blurred preview below it. */
.bb-products .bb-products-media .bb-products-media-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    transition: opacity .6s ease;
}
.bb-products.is-enhanced .bb-products-media-img:not(.is-loaded) { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
    .bb-products-card.is-entering { animation: none; }
    .bb-products .bb-products-media .bb-products-media-img { transition: none; }
}
/* No thumbnail — same striped placeholder used across the design system */
.bb-products-media[data-has-img="0"] {
    background-image: repeating-linear-gradient(135deg, #1A1A18 0 24px, rgba(255,255,255,0.04) 24px 25px) !important;
}

.bb-products-name {
    font-family: var(--ff-display, "Instrument Serif", serif);
    font-style: italic;
    font-weight: 400;
    font-size: 20px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.bb-products-code {
    font-family: var(--ff-mono, "JetBrains Mono", monospace);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.55;
}

/* ── Variant swatches ───────────────────────────────────────── */
.bb-products-card .bb-products-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.bb-products-swatches .bb-products-swatch {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 2px solid transparent;
    outline: 1px solid color-mix(in srgb, var(--fg, #0B131F) 20%, transparent);
    outline-offset: 2px;
    background-size: cover;
    background-position: center;
    background-color: #1A1A18;
    padding: 0;
    cursor: pointer;
    transition: outline-color .2s, transform .2s;
}
.bb-products-swatches .bb-products-swatch:hover { transform: scale(1.08); }
.bb-products-swatches .bb-products-swatch.is-active {
    outline-color: var(--accent, #E63329);
    border-color: var(--bg, #fff);
}

.bb-products-empty {
    margin: 0;
    opacity: 0.6;
    font-family: var(--ff-mono, "JetBrains Mono", monospace);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ── Lightbox (click on a card) ─────────────────────────────── */
/* Built by initProductLightbox() in bob-design.js. Sits above the nav (120)
   and below the store locator modal (200/210) its CTA opens. */
.bb-plb {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.bb-plb[hidden] { display: none; }
.bb-plb-backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--fg, #0B131F) 80%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.bb-plb-dialog {
    position: relative;
    isolation: isolate; /* keeps .bb-btn's hover fill (z-index:-1) above the dialog background */
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    max-height: 100%;
    background: var(--bg, #fff);
    color: var(--fg, #0B131F);
}
.bb-plb-media {
    height: min(calc(100dvh - 190px), 1100px);
    min-height: 240px;
    background: var(--bg-grey, #F5F5F5);
}
.bb-plb-img {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
}
.bb-plb[data-has-img="0"] .bb-plb-img { display: none; }
.bb-plb[data-has-img="0"] .bb-plb-media {
    background: repeating-linear-gradient(135deg, #1A1A18 0 24px, rgba(255,255,255,0.04) 24px 25px);
}
.bb-plb-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
    padding: 20px 24px;
    border-top: 1px solid color-mix(in srgb, var(--fg, #0B131F) 14%, transparent);
}
.bb-plb-name {
    font-family: var(--ff-display, "Instrument Serif", serif);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(22px, 2.4vw, 32px);
    line-height: 1.1;
    letter-spacing: -0.01em;
}
/* Hello Elementor's reset.css paints every button:hover/:focus #c36 —
   the doubled .bb-plb selectors below out-rank it. */
.bb-plb .bb-plb-cta,
.bb-plb .bb-plb-cta:focus {
    padding: 14px 24px;
    background: transparent;
    color: var(--fg, #0B131F);
    font-size: 15px;
    cursor: pointer;
}
.bb-plb .bb-plb-cta:hover,
.bb-plb .bb-plb-cta:focus-visible { background: var(--fg, #0B131F); color: var(--bg, #fff); }
.bb-plb .bb-plb-close,
.bb-plb .bb-plb-close:focus {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--accent, #E63329);
    border-radius: 999px;
    background: var(--bg, #fff);
    color: var(--fg, #0B131F);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background .25s, color .25s;
}
.bb-plb .bb-plb-close:hover,
.bb-plb .bb-plb-close:focus-visible { background: var(--accent, #E63329); color: #fff; }
body.bb-plb-open { overflow: hidden; }

@media (max-width: 600px) {
    .bb-plb { padding: 12px; }
    .bb-plb-media { height: min(calc(100dvh - 230px), 130vw); }
    .bb-plb-bar { padding: 16px; }
    .bb-plb .bb-plb-cta { width: 100%; justify-content: space-between; }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .bb-products-grid,
    .bb-products[data-cols="3"] .bb-products-grid,
    .bb-products[data-cols="4"] .bb-products-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .bb-products-grid,
    .bb-products[data-cols="2"] .bb-products-grid,
    .bb-products[data-cols="3"] .bb-products-grid,
    .bb-products[data-cols="4"] .bb-products-grid { grid-template-columns: 1fr; }
}
