/* ======================================================================
   Sauce Brands Grid  —  v1.9.0
   Widget: sauce-brands-grid
   4-col (desktop) / 3-col (tablet) / 2-col (mobile) grid of brand items.
   Items: square (1x1), horizontal (2x1), vertical (1x2). Collapsed borders.
   Transparent widget + items. Sticky taxonomy filter under the site header.
   ====================================================================== */

.sauce-brands-grid {
    --sbg-cols:        4;
    --sbg-border:      #326F64;
    --sbg-pad:         28px;
    --sbg-logo-h:      88px;
    --sbg-desc-color:  rgba(255, 255, 255, 0.7);
    --sbg-arrow-color: #326F64;
    /* Offset below the site's sticky header for the sticky filter. */
    --sbg-header-h:    80px;
    --sbg-filter-gap:  0px;
    --sbg-fund-pad:    8px 18px;          /* fund button padding (normal) */
    --sbg-fund-pad-stuck: 6px 14px;       /* fund button padding when stuck */
    --sbg-filter-bg:   var(--sauce-forest, #1B3E38);  /* sticky filter bar bg */
    --sbg-logo-desc-gap: 16px;            /* distance logo -> description */
    --sbg-filters-mb:  24px;              /* space below filters when not stuck */
    --sbg-overlay:     transparent;       /* hover gradient overlay */

    background: transparent;
    width: 100%;
    position: relative;
}

/* ── Filter bar (sticky, sits under the site header) ─────────────────── */
.sbg__filters {
    position: sticky;
    top: calc(var(--sbg-header-h) + var(--sbg-filter-gap));
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 16px 0;
    margin-bottom: var(--sbg-filters-mb);
    background: transparent;
    transition: background 0.25s ease, padding 0.25s ease, margin 0.25s ease;
}
/* When stuck the space below collapses. */
.sbg__filters.is-stuck { margin-bottom: 0; }
/* When stuck under the header: forest bg + tighter padding. */
.sbg__filters.is-stuck {
    background: var(--sbg-filter-bg);
    padding: 10px 0;
}
.sbg__filter {
    appearance: none;
    border: 1px solid #fff;
    background: transparent;
    color: #ffffff;
    font: inherit;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: var(--sbg-fund-pad);
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, padding 0.25s ease;
}
/* Hover state mirrors the active state (hot sauce). */
.sbg__filter:hover,
.sbg__filter.is-active {
    background: var(--sauce-hot-sauce, #FF5338);
    border-color: var(--sauce-hot-sauce, #FF5338);
    color: #ffffff;
}
.sbg__filters.is-stuck .sbg__filter { padding: var(--sbg-fund-pad-stuck); }

/* ── Grid ────────────────────────────────────────────────────────────── */
.sbg__grid {
    display: grid;
    grid-template-columns: repeat(var(--sbg-cols), 1fr);
    grid-auto-rows: var(--sbg-row-h, 300px);   /* JS sets = column width (square) */
    grid-auto-flow: row dense;      /* fill gaps left by spanning items */
    /* Collapsed borders: the grid draws top+left, each cell draws right+bottom. */
    border-top:  1px solid var(--sbg-border);
    border-left: 1px solid var(--sbg-border);
    transition: opacity 0.25s ease;
}
.sbg__grid.is-swapping { opacity: 0; }

/* Horizontal/vertical in-content arrow: white fill + forest icon on its own hover. */
.sbg__item .sbg__inner > .sbg__arrow:hover {
    background: #fff;
}
.sbg__item .sbg__inner > .sbg__arrow:hover svg path {
    stroke: var(--ui-custom-f6620da5-color);
}

/* Square base sizing via an aspect-ratio spacer in each cell. */
.sbg__item {
    position: relative;
    border-right:  1px solid var(--sbg-border);
    border-bottom: 1px solid var(--sbg-border);
    overflow: hidden;
    background: transparent;
}
.sbg__item--square     { grid-column: span 1; grid-row: span 1; }
.sbg__item--horizontal { grid-column: span 2; grid-row: span 1; }
.sbg__item--vertical   { grid-column: span 1; grid-row: span 2; }

/* ── Item link / inner ───────────────────────────────────────────────── */
.sbg__inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: var(--sbg-pad);
    text-decoration: none;
    box-sizing: border-box;
    z-index: 2;
}

/* Hover background image */
.sbg__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
.sbg__bg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sbg__item:hover .sbg__bg,
.sbg__item:focus-within .sbg__bg { opacity: 1; }

/* Gradient overlay: sits between the bg image and the content, on hover. */
.sbg__overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: var(--sbg-overlay);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
.sbg__item:hover .sbg__overlay,
.sbg__item:focus-within .sbg__overlay { opacity: 1; }

/* Logo + description */
.sbg__logo {
    height: var(--sbg-logo-h);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sbg-logo-desc-gap);
}
.sbg__logo img { max-height: 100%; max-width: 80%; width: auto; object-fit: contain; display: block; }
.sbg__desc {
    margin: 0;
    color: var(--sbg-desc-color);
    max-width: 80%;
}

/* ── Arrow ───────────────────────────────────────────────────────────── */
.sbg__arrow {
    width: 48px;
    height: 48px;
    border: 1px solid var(--sbg-arrow-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sbg-arrow-color);
    background: transparent;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.35s ease, color 0.35s ease, border-color 0.35s ease, opacity 0.35s ease;
}
.sbg__arrow svg { width: 20px; height: 20px; }

/* SQUARE: arrow only on hover; colour change happens on hover of the arrow
   circle itself (not the whole card). */
.sbg__item--square .sbg__arrow {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: var(--sbg-pad);
    transform: translateX(-50%);
    opacity: 0;
}
.sbg__item--square:hover .sbg__arrow,
.sbg__item--square:focus-within .sbg__arrow { opacity: 1; }
.sbg__item--square .sbg__arrow:hover,
.sbg__item--square .sbg__arrow:focus {
    background: #ffffff;
    border-color: #ffffff;
    color: var(--sauce-forest, #1B3E38);
}

/* HORIZONTAL: left-aligned, content starts at top. Logo, desc, then the
   external-link arrow in flow below. */
.sbg__item--horizontal .sbg__inner {
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    padding-top: var(--sbg-pad);
    padding-bottom: calc(var(--sbg-pad) + 56px);   /* clear the cs bar */
}
.sbg__item--horizontal .sbg__logo { justify-content: flex-start; }
.sbg__item--horizontal .sbg__desc { max-width: none; }
.sbg__item--horizontal .sbg__inner > .sbg__arrow { margin-top: 24px; position: relative; z-index: 3; }

/* VERTICAL: top-aligned (not centred). Logo, desc, then arrow stacked. */
.sbg__item--vertical .sbg__inner {
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    padding-top: var(--sbg-pad);
    padding-bottom: calc(var(--sbg-pad) + 56px);
}
.sbg__item--vertical .sbg__inner > .sbg__arrow { margin-top: 28px; position: relative; z-index: 3; }

/* ── Case-study button (vertical / horizontal) ───────────────────────────
   "CASE STUDY" text visible by default at the bottom. On hover a coloured
   button (with text + circled arrow) slides up from the bottom of the card. */
.sbg__cs-label {
    position: absolute;
    z-index: 2;
    left: 0; right: 0; bottom: 0;
    padding: 20px var(--sbg-pad);
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    pointer-events: none;
}
.sbg__item--horizontal .sbg__cs-label { text-align: left; }
.sbg__item--vertical   .sbg__cs-label { text-align: center; }

.sbg__cs {
    position: absolute;
    z-index: 3;
    left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px var(--sbg-pad);
    min-height: 64px;
    box-sizing: border-box;
    background: var(--sbg-cs-bg, var(--sauce-mustard, #966311));
    color: var(--sbg-cs-color, #1B3E38);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.4,0,0.1,1);
}
.sbg__item--vertical .sbg__cs { justify-content: center; }
.sbg__item:hover .sbg__cs,
.sbg__item:focus-within .sbg__cs { opacity: 1; transform: translateY(0); }
/* Hovering the button itself keeps colours; just dims slightly. */
.sbg__cs:hover { opacity: var(--sbg-cs-hover-op, 0.9); }
/* Arrow inside the button: inherits the button text colour. */
.sbg__cs .sbg__arrow {
    width: 38px; height: 38px;
    margin-left: auto;
    border-color: currentColor;
    color: inherit;
}
.sbg__item--vertical .sbg__cs .sbg__arrow { margin-left: 14px; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sauce-brands-grid { --sbg-cols: 3; }
}
@media (max-width: 767px) {
    .sauce-brands-grid { --sbg-cols: 2; --sbg-logo-h: 64px; --sbg-pad: 18px; }
    /* On a 2-col grid a horizontal item would fill the whole row; keep it
       spanning 2 (full width) and vertical spanning 2 rows. */
    .sbg__item--horizontal { grid-column: span 2; }
    .sbg__item--vertical   { grid-column: span 1; grid-row: span 2; }
    .sbg__arrow { width: 40px; height: 40px; }
    .sbg__cs { padding: 14px 18px; font-size: 0.85em; }
}
