/**
 * LPINZ product template visibility rules.
 *
 * The body classes are set in lpinz-product-fields.php based on the product's
 * meta. This stylesheet hides sections and their corresponding nav anchors
 * when the relevant data is empty — replacing the old custom-JS approach.
 */

/* Extra Information empty → hide the section row and any nav anchors that
   point to it. The .btn-extra-info-toggle class is applied to multiple
   anchors in the Uncode product template (the section nav row + the
   "Quick Links" sidebar), so this catches both. */
body.lpinz-no-extra-info .extra-info,
body.lpinz-no-extra-info .btn-extra-info-toggle {
    display: none !important;
}

/* Hide the wrapping .btn-container of the toggle anchor where the browser
   supports :has(), so we don't leave a blank gap from Uncode's wrapper. */
body.lpinz-no-extra-info .btn-container:has(.btn-extra-info-toggle) {
    display: none !important;
}

/* ------------------------------------------------------------------
 * No gallery → hide the dynamic gallery row.
 *
 * The product template's [vc_gallery] (id "gallery-60118") renders an
 * empty wrapper when the product has no gallery images. The DOM
 * hierarchy that creates the visible white space is:
 *
 *   .vc_row.row-internal.row-container      ← outermost, has h-padding
 *     .row.row-child
 *       .wpb_row.row-inner
 *         .wpb_column...
 *           .uncol > .uncoltable > .uncell > .uncont
 *             #gallery-60118                 ← the empty grid
 *
 * Hide the outermost row (`.vc_row.row-internal`) when its descendant
 * gallery exists — that removes all surrounding padding too.
 * ------------------------------------------------------------------ */
body.lpinz-no-gallery .vc_row.row-internal:has(#gallery-60118),
body.lpinz-no-gallery .vc_row.row-internal:has(#gallery-601189) {
    display: none !important;
}
/* Fallback for browsers without :has() — also hide the gallery element
   directly so it can't contribute any layout height. */
body.lpinz-no-gallery #gallery-60118,
body.lpinz-no-gallery #gallery-601189 {
    display: none !important;
}

/* When the gallery row above is hidden, the parent .uncont (which also
   holds the featured image) keeps its theme-injected
   `padding-bottom: 20px !important` and leaves visible white space below
   the image. Zero it out — but ONLY on the .uncont that contained the
   gallery, so other column paddings on the page are untouched. */
body.lpinz-no-gallery .uncell > .uncont:has(#gallery-60118),
body.lpinz-no-gallery .uncell > .uncont:has(#gallery-601189) {
    padding-bottom: 0 !important;
}

/* ------------------------------------------------------------------
 * [lpinz_product_category_button] hover state.
 *
 * Default Uncode behaviour for an outline button is to fill the background
 * with the button color on hover and keep the label white. Louise wants
 * the category button's label to switch to dark navy on hover instead.
 * Covers both Uncode markup variants (.button-text span and direct text).
 * ------------------------------------------------------------------ */
a.custom-link.btn.border-width-0.lpinz-product-cat-btn.btn-outline:hover,
a.custom-link.btn.border-width-0.lpinz-product-cat-btn.btn-outline:focus,
a.custom-link.btn.border-width-0.lpinz-product-cat-btn.btn-outline:hover .button-text,
a.custom-link.btn.border-width-0.lpinz-product-cat-btn.btn-outline:focus .button-text {
    color: #175691 !important;
}
