/* ==========================================================================
   SLU Bento Box Widget
   A bento grid of self-contained cells. Each cell carries its own col/row span;
   grid-auto-flow: dense packs them with no ragged holes. Pure CSS, no JS.

   Balance model:
   - --slu-bento-cols  : column count (set per breakpoint by the Columns control)
   - --slu-bento-row-h : fixed row height (grid-auto-rows) so a 2-row box is
                          exactly twice a 1-row box, gaps included
   - per cell: --slu-bento-col-span / --slu-bento-row-span

   Span clamping: there is no native span-minmax(), so we clamp the column span
   with min(span, cols). A box can therefore never span past the current column
   count when the grid narrows — the classic "last column overflows the grid"
   bug. At 1 column everything becomes a clean stack automatically.

   Hello Elementor reset overrides: bare <a> and heading colours carry
   !important (see CLAUDE.md "Elementor / theme CSS").
   ========================================================================== */

.slu-bento {
    --slu-bento-cols: 4;
    --slu-bento-row-h: 180px;
    --slu-bento-gap: 12px;

    display: grid;
    grid-template-columns: repeat(var(--slu-bento-cols), minmax(0, 1fr));
    grid-auto-rows: var(--slu-bento-row-h);
    grid-auto-flow: dense;
    gap: var(--slu-bento-gap);
    width: 100%;
}

/* ── Cell ──────────────────────────────────────────────────────────────── */
.slu-bento__cell {
    --slu-bento-col-span: 1;
    --slu-bento-row-span: 1;
    --slu-bento-cell-bg: #f4f4f4;
    --slu-bento-cell-fg: #1a1a1a;

    /* Clamp the column span to the live column count. min() is the robust
       stand-in for the not-yet-shipped span-minmax(). */
    grid-column: span min(var(--slu-bento-col-span), var(--slu-bento-cols));
    grid-row: span var(--slu-bento-row-span);

    position: relative;
    overflow: hidden;
    background-color: var(--slu-bento-cell-bg);
    color: var(--slu-bento-cell-fg);
    border-radius: 16px;
    min-width: 0;   /* let the track shrink rather than overflow on long text */
    transition: transform .25s ease, box-shadow .25s ease;
}

/* Background image layer + legibility overlay */
.slu-bento__bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: 0;
}
.slu-bento__overlay {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: .3;
    z-index: 1;
    pointer-events: none;
}
/* Cells with an image default to light text for contrast unless overridden. */
.slu-bento__cell--has-image { --slu-bento-cell-fg: #ffffff; }

/* Link wrapper fills the cell without introducing its own box. */
.slu-bento__link {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: block;
    text-decoration: none !important;
    color: inherit !important;   /* beat Hello reset + kit link colour */
}
/* Lightbox cells hint that the image enlarges on click. */
.slu-bento__link--lightbox { cursor: zoom-in; }

/* Content sits above the image/overlay. */
.slu-bento__content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;   /* overridden per-item by content_align */
    gap: 6px;
    padding: 20px;
    pointer-events: none;        /* let clicks fall through to the link layer */
}
.slu-bento__content > * { pointer-events: auto; }

.slu-bento__title {
    margin: 0;
    color: inherit !important;   /* beat kit heading colour */
    font-weight: 600;
    line-height: 1.2;
}
.slu-bento__text {
    margin: 0;
    color: inherit !important;
    line-height: 1.45;
    opacity: .92;
}

/* ── Button ──────────────────────────────────────────── */
/* Rendered inside .slu-bento__content (a direct child, so pointer-events are
   re-enabled by the `.slu-bento__content > *` rule above). It sits above the
   image/overlay because content is z2. Base look is intentionally plain — the
   widget's Button style controls layer on top, all with !important to beat the
   Hello Elementor <a>/<button> reset. margin-top:auto is NOT set so the button
   hugs the rest of the content block; content_align positions the whole block. */
.slu-bento__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;      /* overridden by the Alignment control */
    margin-top: 8px;
    padding: 10px 18px;
    border: 0 solid transparent;
    border-radius: 8px;
    background-color: #1a1a1a;
    color: #fff;
    font: inherit;
    line-height: 1.1;
    text-decoration: none !important;   /* beat Hello reset */
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.slu-bento__button:hover {
    transform: translateY(-1px);
}

/* ── Hover lift ────────────────────────────────────────────────────────── */
.slu-bento--hover-lift .slu-bento__cell:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 34px rgba(0,0,0,.16);
}

/* ── Force single column on mobile ─────────────────────────────────────── */
/* JS-free. At the mobile breakpoint every bento collapses to a single column
   and every box flattens to 1×1, so a tall/wide box doesn't stay oversized once
   it's alone on its row. Overriding the span vars keeps the min(span, cols)
   clamp mechanic intact. 767px matches Elementor's default mobile breakpoint.
   Unconditional — the Force-Single-Column switch only affects the intermediate
   (tablet) range now, since mobile always stacks. */
@media (max-width: 767px) {
    .slu-bento {
        --slu-bento-cols: 1;
    }
    /* Override the resolved grid properties directly (not the span vars): the
       span vars are written inline per cell, and an inline custom property beats
       a stylesheet rule setting the same var, so overriding grid-row/grid-column
       with !important is the only thing that reliably wins here. */
    .slu-bento .slu-bento__cell {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }
}
