/*
 * frontend + editor (Gutenberg) content (in the iframe)
 * does not apply to the editor (Gutenberg) UI in general
 */

/* Search terms and result titles can contain a single long word or URL. Native
 * typography settings cannot wrap that text, so allow an emergency break
 * instead of letting a mobile results page grow wider than the screen. */
.lpu-search-page .wp-block-query-title,
.lpu-search-page .wp-block-post-title {
  overflow-wrap: anywhere;
}

/* Search has no native spacing setting between its label and its controls.
 * Give visible labels breathing room without adding a gap for hidden ones. */
.wp-block-search__label:not(.screen-reader-text) {
  display: block;
  margin-block-end: var(--wp--preset--spacing--xs);
}

/* Note on handling the absence of gaps between LPU sections ("bands").
 * By default, WordPress adds a gap between top-level page blocks through the
 * parent container's blockGap setting.
 *
 * Page templates keep a medium blockGap on wp:post-content for ordinary blocks.
 * The top-level .lpu-section marker cancels that gap between adjacent editorial
 * sections; section/content boundaries receive their own compact spacing below.
 * For adjacent sections nested in another container, set that container's
 * blockGap to zero when they should touch.
 *
 */

/* Share top and bottom padding across sections. Split Sections apply it
 * inside their text zones so images can fill their own zones.
 * The inset follows the xl-fluid preset: ramping from 400px to 1200px keeps
 * whole-number coefficients and holds its minimum on every phone width. */
.lpu-section:is(.wp-block-group, .wp-block-cover) {
  padding-block: var(--wp--custom--spacing--section-inset);
}

/* Keep the old values available for saved blocks until all sites are migrated.
 * The editor gets its spacing choices from theme.json. */
:root {
  --wp--preset--spacing--section-compact: calc(var(--wp--custom--spacing--section) * 0.75);
  --wp--preset--spacing--section-standard: var(--wp--custom--spacing--section);
  --wp--preset--spacing--section-generous: calc(var(--wp--custom--spacing--section) * 1.5);
  --wp--preset--spacing--section-extra-generous: calc(var(--wp--custom--spacing--section) * 2);
}

/* Keep the original mobile value for legacy content and the gallery offsets.
 * WordPress emits the theme.json settings.custom.spacing.section token on :root
 * after this stylesheet. Use html:root to increase specificity and win in the
 * cascade.
 */
@media (max-width: 781px) {
  html:root {
    --wp--custom--spacing--section: 3rem;
  }
}

/*****************************************************************************/
/* HEADER SHELL                                                              */
/*****************************************************************************/
.lpu-header {
  /* anchors mega menu */
  position: relative;
  z-index: 10;
  /* Equal top and bottom padding keeps the menu button, which is centered
   * on the full header, aligned with the logo in compact layouts. */
  padding-block: var(--wp--custom--header--padding-block);
  /* Default color for the logo and menu foreground elements. */
  --lpu-header-foreground: var(--wp--preset--color--vert-fonce);
}

/*****************************************************************************/
/* TRANSPARENT HEADER STATE                                                  */
/*****************************************************************************/
/* .lpu-header-transparent = must use transparent header.
 * .lpu-header-transparent is set on the body by the php code of the theme.
 * Set if meta on a post, meta set when user activate a custom setting in the
 * page editor.
 */
body.lpu-header-transparent .lpu-header {
  /* Keep the transparent Home header out of normal flow so that the content
  can be at the top, right under the header (instead of below the header). */
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
}

/* 
 * Apply the transparent header option.
 * Selector applies only when the header has been set as transparent on this
 * page and there is no mobile menu overlay nor a mega-menu open.
 * Opening a menu restores the Group's native background setting.
 * Applying transparency only in those cases allows a background color
 * set on a menu entry to have an effect. Allows a change of background for a
 * parent menu item to apply to its mega-menu*/
 body.lpu-header-transparent
 .lpu-header:not(:has(
   .wp-block-navigation__responsive-container.is-menu-open,
   .wp-block-navigation-submenu__toggle[aria-expanded="true"],
   .wp-block-navigation__submenu-icon[aria-expanded="true"]
   )) {
  /* Palette backgrounds use !important, so this state must override them. */
  background: transparent !important;
}

/* A saved Header template part can omit the Group's background. Give an open
 * menu an opaque surface in that case, while keeping editor-set backgrounds. */
body.lpu-header-transparent
  .lpu-header:not(.has-background):has(
    .wp-block-navigation__responsive-container.is-menu-open,
    .wp-block-navigation-submenu__toggle[aria-expanded="true"],
    .wp-block-navigation__submenu-icon[aria-expanded="true"]
  ) {
  background-color: var(--wp--preset--color--ecru);
}

/* Absolute positioning removes the transparent header from the normal
 * document flow, so it is not naturally under the admin bar.
 * Therefore account for WordPress's fixed admin bar when an editor
 * is previewing the page while logged in. Without this offset the admin bar
 * covers the top of the header and makes its contents appear shorter than
 * the opaque state. */
body.admin-bar.lpu-header-transparent .lpu-header {
  top: 32px;
}
/* WordPress uses a taller admin bar on narrow screens. */
@media screen and (max-width: 782px) {
  body.admin-bar.lpu-header-transparent .lpu-header {
    top: 46px;
  }
}

/* With menu transparent off, add more room below the header.
 * WordPress uses the global blockGap as the default between top-level
 * template blocks. Override it only for the gap from header to main. */
body:not(.lpu-header-transparent)
  .wp-site-blocks > header.wp-block-template-part + main.wp-block-group {
  margin-block-start: var(--wp--preset--spacing--xl);
}

/* Farm homepages start directly below their opaque header in the mockup. */
.wp-site-blocks > header.wp-block-template-part + main.wp-block-group:has(
  > .wp-block-post-content > .lpu-hero:first-child + .lpu-farm-topic
) {
  margin-block-start: 0;
}

/* The opening section starts behind the transparent header, which is out of flow. */
body.lpu-header-transparent .wp-site-blocks > main.wp-block-group {
  margin-block-start: 0;
}

/* On a transparent header, the page setting controls the logo and default menu
 * foreground color independently from the header background. */
body.lpu-header-foreground-ecru .lpu-header {
  --lpu-header-foreground: var(--wp--preset--color--ecru);
}

/* Open menus default to green; the Group controls the header background. */
body
  .lpu-header:has(
    /* in mobile mode : clicked on the hamburger buton and the mobile menu is
    open */
    .wp-block-navigation__responsive-container.is-menu-open,
    /* Core's actual expanded state, for mouse, touch and keyboard alike. */
    .wp-block-navigation-submenu__toggle[aria-expanded="true"],
    .wp-block-navigation__submenu-icon[aria-expanded="true"]
  ) {
  --lpu-header-foreground: var(--wp--preset--color--vert-fonce);
}

/*****************************************************************************/
/* HEADER FOREGROUND, FOCUS, AND LOGO VARIANTS                               */
/*****************************************************************************/
/* Put the page's default color on Navigation so links and controls inherit it.
 * Zero specificity lets native Global Styles and block color settings win. */
:where(.lpu-header .wp-block-navigation) {
  color: var(--lpu-header-foreground);
}

/* There are two logo variants (configured in the Customizer).
 * custom-logo is the green variant and lpu-logo-ecru is the ecru variant.
 * They follow the selected foreground color. */
body.lpu-header-foreground-ecru
  .lpu-header
  .wp-block-site-logo:where(:has(img.lpu-logo-ecru))
  img.custom-logo {
  display: none;
}

body.lpu-header-foreground-ecru
  .lpu-header
  .wp-block-site-logo
  img.lpu-logo-ecru {
  display: block;
}

/* Every open menu uses the green logo on its opaque ecru background. */
body
  .lpu-header:has(
    .wp-block-navigation__responsive-container.is-menu-open,
    .wp-block-navigation-submenu__toggle[aria-expanded="true"],
    .wp-block-navigation__submenu-icon[aria-expanded="true"]
  )
  .wp-block-site-logo
  img.custom-logo {
  display: block;
}

body
  .lpu-header:has(
    .wp-block-navigation__responsive-container.is-menu-open,
    .wp-block-navigation-submenu__toggle[aria-expanded="true"],
    .wp-block-navigation__submenu-icon[aria-expanded="true"]
  )
  .wp-block-site-logo
  img.lpu-logo-ecru {
  display: none;
}

/*****************************************************************************/
/* HEADER NAVIGATION CONTAINER                                               */
/*****************************************************************************/
/* The site logo sits inside the navigation, in the center grid track. Core
 * wraps it in a nav item li; only its own track is sized (auto), so the logo
 * never overlaps the two flanking nav-groups. */
.lpu-header .wp-block-site-logo {
  margin: 0;
  width: var(--wp--custom--header--logo-width);
}

/* The header link stacks the green logo (custom_logo) and the ecru variant in
 * the same grid cell; the visibility rules above pick which one shows. */
.lpu-header__logo .custom-logo-link {
  display: grid;
}

.lpu-header__logo .custom-logo-link > img {
  grid-area: 1 / 1;
}

/* Hide the ecru variant by default. The selected and open-state rules above
 * have greater specificity and choose the visible variant. */
.lpu-header .wp-block-site-logo img.lpu-logo-ecru {
  display: none;
}

.lpu-header .wp-block-navigation {
  margin-inline: auto;
  min-width: 0;
}

.lpu-header .wp-block-navigation__responsive-container,
.lpu-header .wp-block-navigation__responsive-close,
.lpu-header .wp-block-navigation__responsive-dialog,
.lpu-header .wp-block-navigation__responsive-container-content {
  width: 100%;
}

.lpu-header .wp-block-navigation__container {
  width: 100%;
  max-width: none;
  align-items: center;
}

/* The header navigation menu is a gridbox containing : a nav-group on each side
and the site logo in the center. Nav-group is a lightweight group-like block.
Done this way so that the logo can be centered while also having items on either
side of it that "hugs" the logo. The other constraint is that the overlay (mobile)
menu also works using native wordpress functionality. */
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-navigation__container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

/*****************************************************************************/
/* HEADER LINK TYPOGRAPHY AND INTERACTION                                    */
/*****************************************************************************/
/* Enable hiding a home link menu entry if we are in the homepage.
 * When the mobile overlay opens, WordPress sets its menu items to display: flex.
 * Including .wp-block-navigation gives this selector enough specificity to
 * override that rule, keeping the home link hidden in the overlay as well as
 * in the desktop menu (without using !important). */
body.home .wp-block-navigation .wp-block-home-link.lpu-hide-on-home {
  display: none;
}

/* Increase specificity to beat Core CSS that reduces padding with the following
selector :
`.wp-block-navigation-item.open-on-click .wp-block-navigation-submenu__toggle` */
.lpu-header
  .wp-block-navigation-item__content.wp-block-navigation-item__content.wp-block-navigation-item__content {
  padding-inline: 0.75rem;
}

.lpu-header .wp-block-navigation-item__content:focus-visible,
.lpu-header .wp-block-navigation__submenu-icon:focus-visible,
.lpu-header .wp-block-navigation__responsive-container-open:focus-visible,
.lpu-header .wp-block-navigation__responsive-container-close:focus-visible {
  outline: 2px solid currentColor;
}

.lpu-header .custom-logo-link:focus-visible {
  outline: 2px solid var(--lpu-header-foreground);
  /* too much offset, default is ok */
  /* outline-offset: 3px; */
}

.lpu-header .wp-block-navigation-item__content:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

/* Default navigation buttons follow the page's header foreground over photos.
 * Set the fallback on the group so individual button styles can override it. */
.lpu-header .wp-block-navigation .wp-block-buttons {
  --lpu-button-text: var(--lpu-header-foreground);
}

/* Let separated buttons follow the same wrapping setting as menu labels so
 * they can shrink before the header switches to compact mode. */
.lpu-header .wp-block-buttons.lpu-menu-separate-last .wp-block-button__link {
  white-space: var(--lpu-header-label-white-space, nowrap);
}

/* The overlay stacks menu entries vertically, so give separated buttons
 * their extra space above the block when the overlay opens. */
.lpu-header
  .wp-block-navigation__responsive-container.is-menu-open
  .wp-block-buttons.lpu-menu-separate-last {
  margin-block-start: var(--wp--preset--spacing--sm);
}

.lpu-header .wp-block-navigation__responsive-container.is-menu-open {
  /* This overlay also has width: 100%; keep its padding inside the viewport. */
  box-sizing: border-box;
  padding: 1.5rem;
  background: var(--wp--preset--color--ecru);
}

/* Core falls back to black for an uncolored overlay. Inherit Navigation's
 * color instead, while leaving explicit overlay text colors to Core. */
.lpu-header
  .wp-block-navigation
  .wp-block-navigation__responsive-container.is-menu-open:not(.has-text-color) {
  color: inherit;
}

.lpu-header
  .wp-block-navigation__responsive-container.is-menu-open
  .wp-block-navigation-item__content {
  font-size: var(--wp--custom--header--overlay-font-size);
}

/* In this theme the header can switch to a hamburger menu (overlay) above the 
 * usual 600px. It's called the compact mode (see .lpu-navigation--compact).
 * Compact mode is activated if its links no longer fit the available width. 
 * WP Core disables some CSS required for the overlay above 600px but we need it
 * when overlay is activated in compact mode (>600px). We re-enabl the required
 CSS here.
 * (.is-menu-open tells the overlay menu is open whether we are in the the
 * native <600px or >600px in compact mode) */
.lpu-header
  .wp-block-navigation__responsive-container.is-menu-open
  .lpu-nav-group__list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.lpu-header
  .wp-block-navigation__responsive-container.is-menu-open
  .wp-block-navigation__submenu-container {
  padding-block-start: var(--wp--preset--spacing--xs);
}

/* The site logo is a nav item on desktop; in Core's open overlay it would
 * become an entry of the vertical list, so it is hidden there. */
.lpu-header
  .wp-block-navigation__responsive-container.is-menu-open
  li:has(.lpu-header__logo) {
  display: none;
}

/*****************************************************************************/
/* HEADER NAVIGATION GROUPS                                                  */
/*****************************************************************************/
/* Desktop nav-group: each group is a grid item hugging its rail edge.
 * min-width: 0 lets its 1fr track shrink below the labels' natural width so
 * navigation.js can detect when the top-level items no longer fit. Scoped to
 * the closed container so the mobile overlay keeps Core's stacked list. */
/* Make sure our custom wp:lpu/nav-group blocks inherit the gap values like
 * wp native navigation blocks do. */
.lpu-header .lpu-nav-group,
.lpu-header .lpu-nav-group__list {
  gap: inherit;
}

.lpu-header .lpu-nav-group__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .lpu-nav-group {
  position: static;
  min-width: 0;
}

.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .lpu-nav-group__list {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

/* content of nav section on the left justified towards the logo */
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .lpu-header__navigation
  > .wp-block-navigation-item:first-child {
  justify-content: end;
}

/* The closing group sits in the last (1fr) track; pack its items toward the
 * rail's outer edge so the three regions mirror each other. */
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .lpu-nav-group:last-child
  .lpu-nav-group__list {
  justify-content: flex-end;
}

/* Opt in with lpu-menu-separate-last on the last entry of the right group.
 * The spacer takes spare width after the label and chevron. It can shrink
 * as the header narrows and is capped on wide screens. */
.lpu-header
  :where(.wp-block-navigation__responsive-container:not(.is-menu-open) .lpu-nav-group:last-child > .lpu-nav-group__list)
  > * + :last-child:is(.lpu-menu-separate-last, :has(> .wp-block-buttons.lpu-menu-separate-last)) {
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: minmax(0, 1fr);
  flex: 1 1 min-content;
  max-inline-size: max-content;

  &::before {
    content: "";
    inline-size: 1.5rem;
    max-inline-size: 100%;
  }
}

/* Let the network opt into word wrapping before overflow triggers compact mode.
 * Scope the variable to the closed menu so the overlay keeps its own layout. */
.lpu-header-label-wrapping .lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open) {
  --lpu-header-label-white-space: normal;
}

/* The default single-line labels preserve the desktop composition. */
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .lpu-nav-group
  > .lpu-nav-group__list
  > .wp-block-navigation-item
  > .wp-block-navigation-item__content {
  white-space: var(--lpu-header-label-white-space, nowrap);
}

/*****************************************************************************/
/* DESKTOP SUBMENU / MEGA-MENU PANEL                                         */
/*****************************************************************************/
/* Desktop: keep the whole nav stack static so the full-width submenu panel
 * anchors to .lpu-header (position: relative) rather than to the nav rail. */
.lpu-header .wp-block-navigation,
.lpu-header .wp-block-navigation__responsive-container:not(.is-menu-open),
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-navigation__responsive-close,
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-navigation__responsive-dialog,
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-navigation__responsive-container-content {
  position: static;
}

/* parent of the mega-menu. mega-menu is positioned */
.lpu-header li.wp-block-navigation-submenu {
  position: static;
}

/* Mega-menu: the full-width element that opens when a menu-item is opened. It
is the .wp-block-navigation__submenu-container in .lpu-header.
:not(.is-menu-open) is to disable this rule when using the mobile version of the
meny
*/
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-navigation__submenu-container {
  top: 100%;
  /* Avoid Core's panel fade so the default ecru panel and opaque header
   * appear together when a submenu opens. */
  transition: none;
  inset-inline: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--wp--preset--spacing--sm) var(--wp--preset--spacing--md);
  width: auto;
  min-width: 0;
  height: auto;
  padding-block-start: var(--wp--preset--spacing--md);
  padding-inline: clamp(
    var(--wp--preset--spacing--md),
    3vw,
    var(--wp--preset--spacing--lg)
  );
  padding-block-end: var(--wp--preset--spacing--md);
  border: 0;
  /* Override Core's black submenu default without replacing Navigation's
   * selected color or a color set on the parent submenu item. */
  color: inherit;
  z-index: 1;
}

/* Raise the controls, not their parent items: the full-width panels must
 * remain in the header's stacking context so siblings can sit above them. */
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .lpu-nav-group__list
  > .wp-block-navigation-item
  > .wp-block-navigation-item__content,
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .lpu-nav-group__list
  > .wp-block-navigation-item
  > .wp-block-navigation__submenu-icon,
.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-site-logo {
  position: relative;
  z-index: 2;
}

.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-navigation__submenu-container
  > .wp-block-navigation-item {
  flex: 0 0 var(--wp--custom--header--mega-menu-item-column-width);
  width: var(--wp--custom--header--mega-menu-item-column-width);
  min-width: 0;
}

.lpu-header
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-navigation__submenu-container
  > .wp-block-navigation-item
  > .wp-block-navigation-item__content {
  display: block;
  padding: var(--wp--preset--spacing--xs) 0;
  width: 100%;
  min-width: 0;
  text-wrap: balance;
}

.lpu-header .wp-block-navigation__responsive-container:not(.is-menu-open) {
  padding-inline: 0;
}

/*****************************************************************************/
/* OPTIONAL MEGA-MENU EXTRA CONTENT                                          */
/*****************************************************************************/
/* Optional extra mega-menu content (intro, images, see navigation-content.php)
Hidden by default, enabled on desktop only.*/
.lpu-menu-link-image,
.lpu-menu-intro {
  display: none;
}

/* desktop-only code */
@media (min-width: 600px) {
  /* Without an intro column, distribute the fixed-width link cards across
   * the panel instead of leaving the whole group aligned to the left edge. */
  .lpu-header
    nav:not(.lpu-navigation--compact)
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .lpu-nav-group__list
    > .wp-block-navigation-submenu
    > .wp-block-navigation__submenu-container:not(:has(> .lpu-menu-intro)) {
    justify-content: space-evenly;
  }

  .lpu-header
    nav:not(.lpu-navigation--compact)
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .lpu-nav-group__list
    > .wp-block-navigation-submenu
    > .wp-block-navigation__submenu-container:not(:has(> .lpu-menu-intro))
    > .wp-block-navigation-item
    > .wp-block-navigation-item__content {
    text-align: center;
  }

  /* Have the (optional) first item .lpu-menu-intro reserving the first
   * column of the grid, the the other items take the remainder columns.
   * It is a bit tricky to implement with gridbox.
   * Reserve the intro column for up to 10 rows of fixed-width links.
   * Row gaps must stay zero: otherwise unused rows add 10 empty gaps.
   * Link margins supply the vertical spacing only on occupied rows. */
  .lpu-header
    nav:not(.lpu-navigation--compact)
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .lpu-nav-group__list
    > .wp-block-navigation-submenu
    > .wp-block-navigation__submenu-container:has(> .lpu-menu-intro) {
    display: grid;
    grid-template-columns:
      calc(
        var(--wp--custom--header--mega-menu-intro-column-width) +
          var(--wp--preset--spacing--sm)
      )
      repeat(auto-fill, var(--wp--custom--header--mega-menu-item-column-width));
    grid-auto-flow: row;
    grid-auto-rows: auto;
    align-content: start;
    row-gap: 0;
  }

  .lpu-header
    nav:not(.lpu-navigation--compact)
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .lpu-nav-group__list
    > .wp-block-navigation-submenu
    > .wp-block-navigation__submenu-container:has(> .lpu-menu-intro)
    > .wp-block-navigation-item {
    margin-block-end: var(--wp--preset--spacing--sm);
  }

  .lpu-header
    nav:not(.lpu-navigation--compact)
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .lpu-nav-group__list
    > .wp-block-navigation-submenu
    > .wp-block-navigation__submenu-container
    > .lpu-menu-intro {
    display: block;
    grid-column: 1;
    grid-row: 1 / span 10;
    width: var(--wp--custom--header--mega-menu-intro-column-width);
    padding-block: var(--wp--preset--spacing--xs);
    font-family: var(--wp--preset--font-family--dm-sans);
    font-size: var(--wp--preset--font-size--text);
  }

  .lpu-header
    nav:not(.lpu-navigation--compact)
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .lpu-nav-group__list
    > .wp-block-navigation-submenu
    > .wp-block-navigation__submenu-container
    > .wp-block-navigation-item
    > .wp-block-navigation-item__content
    > .lpu-menu-link-image {
    display: block;
  }
}

.lpu-header .lpu-menu-link-image,
.lpu-header .lpu-menu-intro-image {
  width: 100%;
  height: auto;
}

.lpu-header .lpu-menu-link-image {
  margin-block-start: var(--wp--preset--spacing--xs);
  aspect-ratio: var(--wp--custom--header--mega-menu-item-image-ratio);
  object-fit: cover;
}

.lpu-header .lpu-menu-intro-image {
  margin-block-end: var(--wp--preset--spacing--xs);
  aspect-ratio: var(--wp--custom--header--mega-menu-intro-image-ratio);
  object-fit: cover;
}

.lpu-header .lpu-menu-intro p {
  margin: 0;
}

.lpu-header .lpu-menu-intro p + p {
  margin-block-start: var(--wp--preset--spacing--xs);
}

/* Make Mega-menu "regular text content" use "normal" body typography instead of
inheriting the menu labels' style. */
.lpu-header :is(
  .lpu-menu-intro-heading,
  .lpu-menu-intro-text,
  .lpu-menu-link-description
) {
  font-family: var(--wp--preset--font-family--dm-sans);
  text-transform: none;
}

.lpu-header .lpu-menu-intro-heading {
  font-weight: 700;
}

.lpu-header .wp-block-navigation-item:has(> .lpu-menu-link-description) {
  align-items: stretch;
  flex-direction: column;
}

/*****************************************************************************/
/* COMPACT HEADER NAVIGATION                                                 */
/*****************************************************************************/
/* Compact presentation, selected by navigation.js when one nav-group no
 * longer fits in its track. The grid keeps the logo in the middle; the two
 * groups are dropped. Core still owns the open overlay; these rules only
 * choose the closed presentation, mirroring Core's own responsive (<600px)
 * presentation so the switch between the two is seamless. */
.lpu-header .lpu-header__navigation.lpu-navigation--compact {
  display: block;
}

.lpu-header
  .lpu-header__navigation.lpu-navigation--compact
  .wp-block-navigation__responsive-container-open {
  display: flex;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  position: absolute;
  inset-inline-start: clamp(1rem, 3vw, 3rem);
  inset-block-start: 50%;
  z-index: 3;
  transform: translateY(-50%);
}

.lpu-header
  .lpu-header__navigation.lpu-navigation--compact
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .wp-block-navigation__container {
  display: flex;
  justify-content: center;
}

.lpu-header
  .lpu-header__navigation.lpu-navigation--compact
  .wp-block-navigation__responsive-container:not(.is-menu-open)
  .lpu-nav-group {
  display: none;
}

/*****************************************************************************/
/* PHONE PRESENTATION                                                        */
/*****************************************************************************/
/* Below 600px Core hides the entire closed Navigation container so only the
 * hamburger survives. Keep the compact closed presentation on phones too:
 * centered logo with the open button at the rail's start, the same closed
 * look the JavaScript class produces at larger widths. */
@media screen and (max-width: 600px) {
  .lpu-header
    nav.lpu-header__navigation
    .wp-block-navigation__responsive-container:not(.is-menu-open) {
    display: block;
  }

  .lpu-header
    nav.lpu-header__navigation
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .wp-block-navigation__container {
    display: flex;
    justify-content: center;
  }

  .lpu-header
    nav.lpu-header__navigation
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .lpu-nav-group {
    display: none;
  }

  .lpu-header
    .wp-block-navigation__responsive-container:not(.is-menu-open)
    .wp-block-navigation__responsive-container-close {
    display: none;
  }

  .lpu-header
    nav.lpu-header__navigation
    .wp-block-navigation__responsive-container-open {
    display: flex;
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    position: absolute;
    inset-inline-start: clamp(1rem, 3vw, 3rem);
    inset-block-start: 50%;
    z-index: 3;
    transform: translateY(-50%);
  }
}

/*****************************************************************************/
/* HERO SECTION                                                              */
/*****************************************************************************/
/* Fanny's hero uses a tapered, irregular stroke. A mask keeps it the same
 * color as the optional heading and removes it when that heading is deleted. */
.lpu-hero .lpu-hero__title {
  /* The stroke must stay proportional when an editor enters a short title. */
  inline-size: fit-content;
  max-inline-size: 100%;
}

.lpu-hero .lpu-hero__title::after {
  display: block;
  /* Keep the 264:12 SVG ratio so the mask can use the full width as the title grows. */
  inline-size: min(7.75em, 90%);
  aspect-ratio: 22 / 1;
  margin-block-start: var(--wp--preset--spacing--xs);
  background-color: currentColor;
  content: "";
  -webkit-mask: url("../images/hero-title-line.svg") left center / contain
    no-repeat;
  mask: url("../images/hero-title-line.svg") left center / contain no-repeat;
}

.lpu-hero .lpu-hero__title.lpu-hero-no-line::after {
  content: none;
}

/*****************************************************************************/
/* CARD GRID                                                                 */
/*****************************************************************************/
/* Keep these static slugs (and WordPress's native presets) in sync with
 * aspect ratios defined in settings.dimensions in theme.json.
 */
.lpu-card-grid.lpu-card-images-square {
  --lpu-card-image-ratio: 1 / 1;
}

.lpu-card-grid.lpu-card-images-4-3 {
  --lpu-card-image-ratio: 4 / 3;
}

.lpu-card-grid.lpu-card-images-3-4 {
  --lpu-card-image-ratio: 3 / 4;
}

.lpu-card-grid.lpu-card-images-3-2 {
  --lpu-card-image-ratio: 3 / 2;
}

.lpu-card-grid.lpu-card-images-2-3 {
  --lpu-card-image-ratio: 2 / 3;
}

.lpu-card-grid.lpu-card-images-16-9 {
  --lpu-card-image-ratio: 16 / 9;
}

.lpu-card-grid.lpu-card-images-9-16 {
  --lpu-card-image-ratio: 9 / 16;
}

.lpu-card-grid.lpu-card-images-portrait-card {
  --lpu-card-image-ratio: 7 / 8;
}

/* A shared ratio also needs equal column widths to give equal image heights.
 * Apply it only when the Group explicitly selects a preset. Without a format
 * class, native column and Image settings remain in control. Keep Core's
 * stacked mobile layout and the carousel's own card widths. */
@media (min-width: 782px) {
  .lpu-card-grid[class*="lpu-card-images-"]:not(.is-style-lpu-card-carousel)
    .lpu-card-grid__columns > .lpu-card {
    flex-basis: 0 !important;
    flex-grow: 1;
  }
}

/* Core gives constrained Group children auto side margins with !important.
 * Override those margins for this track so it escapes the root padding. */
.lpu-card-grid.is-style-lpu-card-carousel .lpu-card-grid__columns {
  max-width: none;
  margin-left: calc(var(--wp--style--root--padding-left, 0px) * -1) !important;
  margin-right: calc(
    var(--wp--style--root--padding-right, 0px) * -1
  ) !important;
  /* Core Columns forces wrapping below 782px. */
  flex-wrap: nowrap !important;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
}

.lpu-card-grid.is-style-lpu-card-carousel .lpu-card-grid__columns .lpu-card {
  /* Keep desktop cards near one third of wideSize; 80vw leaves room for a peek
   * at the next card on phones. Core Column forces 100% flex-basis on mobile. */
  flex: 0 0 min(80vw, calc(var(--wp--style--global--wide-size) / 3)) !important;
  scroll-snap-align: start;
}

/* Leave the native scrollbar visible if JS cannot create the navigation dots. */
.lpu-card-grid.is-style-lpu-card-carousel[data-lpu-carousel-ready]
  .lpu-card-grid__columns {
  scrollbar-width: none;
}

.lpu-card-grid.is-style-lpu-card-carousel[data-lpu-carousel-ready]
  .lpu-card-grid__columns::-webkit-scrollbar {
  display: none;
}

.lpu-card-carousel__nav {
  margin-block-start: var(--wp--preset--spacing--sm);
}

.lpu-card-carousel__dots {
  display: flex;
  justify-content: center;
}

.lpu-card-carousel__dot {
  display: inline-grid;
  place-items: center;
  /* Larger click target around the small ring shown in the mockups. */
  width: 2rem;
  height: 2rem;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.lpu-card-carousel__dot::before {
  /* Include the ring border in the small dot's intended diameter. */
  box-sizing: border-box;
  width: 0.5rem;
  height: 0.5rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "";
}

.lpu-card-carousel__dot[aria-current="true"]::before {
  background: currentColor;
}

.lpu-card-carousel__nav button:focus-visible,
.lpu-card-grid__columns:focus-visible {
  outline: 2px solid var(--wp--preset--color--vert-fonce);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--wp--preset--color--blanc);
}

/* The "Colonnes de cartes" pattern has an image at the top of each column.
 * In the editor, "Images d'en-tête > Proportion" lets the user choose
 * a common aspect ratio (e.g. square or 7:8) for all those images.
 * This adds a lpu-card-images-* class.
 *
 * While that option is set, make those images fill their column width so
 * equal-width columns with the same ratio have equal-height images.
 * !important overrides any saved dimensions.
 * Clearing the option removes the class and restores individual sizing.
 *
 * Only direct Image blocks at the start of a column, or immediately after
 * a Heading at the start, are affected. Other images keep their own settings. */
.lpu-card-grid[class*="lpu-card-images-"] > .lpu-card-grid__columns > .lpu-card
  > :is(.wp-block-image:first-child, .wp-block-heading:first-child + .wp-block-image) {
  width: 100% !important;
  height: auto !important;
  max-width: none;
}

/* The Group ratio and cover cropping are fallbacks: WordPress writes explicit
 * Image ratios and fill modes inline, so neither property should be !important.
 * Keep full column width; uploaded files and saved Image
 * attributes are untouched. Individual ratio overrides can change card heights. */
.lpu-card-grid[class*="lpu-card-images-"] > .lpu-card-grid__columns > .lpu-card
  > :is(.wp-block-image:first-child, .wp-block-heading:first-child + .wp-block-image) img {
  display: block;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: var(--lpu-card-image-ratio);
  object-fit: cover;
}

/* Keep card buttons at their natural width alongside the title. In the editor,
 * full labels can move onto another line instead of shrinking the button. */
.lpu-card__body > .wp-block-buttons {
  flex-shrink: 0;
}

/*****************************************************************************/
/* FARM HOMEPAGE TOPIC LINKS                                                  */
/*****************************************************************************/
/* The Paris farm requested this behavior in its homepage brief under
 * "GRANDE PHOTO REPRÉSENTATIVE" and "AU SURVOL". Hovering over the large
 * photo on desktop reveals clickable thumbnails for that section's topics.
 *
 * Use the "Section de contenu" pattern with this Gutenberg block structure.
 *   Group (lpu-section)
 *     Heading
 *     Group (wide alignment, lpu-farm-topic__photo)
 *       Image (large representative photo)
 *       Group (flex layout, lpu-farm-topic__links)
 *         Paragraph per topic (one link wrapping its label and inline image)
 */

/* A deeper crop on phones keeps the subject legible at the narrower width. */
.lpu-farm-topic__photo > .wp-block-image img {
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* Touchscreens show the same links in a single column with a clear tap area. */
.lpu-farm-topic__links > p {
  flex-basis: 100%;
}

.lpu-farm-topic__links a {
  display: flex;
  align-items: center;
  gap: var(--wp--preset--spacing--xs);
  min-block-size: 2.75rem;
  text-underline-offset: 0.2em;
}

.lpu-farm-topic__links img {
  max-inline-size: 7rem;
}

main .lpu-farm-topic__links img {
  display: none;
}

@media (min-width: 782px) {
  .lpu-farm-topic__photo > .wp-block-image img {
    aspect-ratio: 2 / 1;
  }
}

@media (min-width: 782px) and (hover: hover) and (pointer: fine) {
  /* The photo and strip are one hover area so the pointer can reach the links.
   * Clipping keeps the links in the tab order. Focus or a URL fragment opens
   * the strip and exposes the destination. */
  main .lpu-farm-topic__photo:not(:hover, :focus-within, :has(:target))
    > .lpu-farm-topic__links {
    max-block-size: 0;
    overflow: clip;
  }

  main .lpu-farm-topic__links > p {
    flex: 1 1 8rem;
    max-inline-size: 13rem;
  }

  main .lpu-farm-topic__links a {
    flex-direction: column;
    align-items: flex-start;
    padding-block-start: var(--wp--preset--spacing--sm);
  }

  main .lpu-farm-topic__links img {
    display: block;
    order: -1;
    inline-size: 100%;
    max-inline-size: none;
    block-size: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }
}

/*****************************************************************************/
/* FARM SELECTOR                                                             */
/*****************************************************************************/
/* :where() so that global style heading (style editor) has priority over this*/
:where(.lpu-farm-selector > .wp-block-heading) {
  margin-block-end: var(--wp--preset--spacing--xl-fluid);
}

.lpu-farm-selector__separator.wp-block-image {
  flex: 0 0 clamp(5.5rem, 6vw, 6rem);
}

@media (max-width: 781px) {
  .wp-block-group.lpu-farm-selector__farms {
    flex-direction: column;
    margin-block-start: var(--wp--preset--spacing--xl);
  }

  .lpu-farm-selector__separator.wp-block-image {
    width: clamp(3rem, 15vw, 6rem);
  }
}

/*****************************************************************************/
/* TEXT COLUMNS BAND                                                         */
/*****************************************************************************/
/* Spacing between title and the rest of the content (the columns) defined by
 * CSS variable. Allows  Global Styles to replace that default. */
.lpu-columns-text > .lpu-columns-text__title {
  --lpu-heading-margin-bottom: calc(var(--wp--preset--spacing--xl) * 2);
  text-wrap: balance;
}

@media (max-width: 781px) {
  .lpu-columns-text > .lpu-columns-text__title {
    --lpu-heading-margin-bottom: var(--wp--preset--spacing--xl);
  }
}

/*.wp-block-columns.is-style-lpu-pin-bottom makes the last element in each
column of a wp:columns go to the bottom.
Designed to allow having buttons all aligned (at the bottom) if used*/
.wp-block-columns.is-style-lpu-pin-bottom > .wp-block-column {
  display: flex;
  flex-direction: column;
}

/* !important to prevent inline styling from breaking is-style-lpu-pin-bottom */
.wp-block-columns.is-style-lpu-pin-bottom > .wp-block-column > :last-child {
  /* push to the bottom */
  margin-block-start: auto !important;
  margin-block-end: 0 !important;
}

.wp-block-columns.is-style-lpu-pin-bottom
  > .wp-block-column
  > :nth-last-child(2) {
  margin-block-end: var(--wp--preset--spacing--md);
}

/*****************************************************************************/
/* ILLUSTRATED COLUMNS AND INFORMATION BADGES                                */
/*****************************************************************************/
/* Size centered figures against the column. With auto side margins, Firefox
 * can collapse a figure that depends on its image's percentage width. */
.lpu-illustrated-columns__image:not(.is-resized) {
  width: min(100%, 13rem);
}

.lpu-illustrated-columns__image:not(.is-resized) img {
  width: 100%;
}

.lpu-information-badges__image,
.lpu-information-badges__portrait {
  width: min(100%, 10.5rem);
  margin-inline: auto;
}

/* Preserve the crop on previously inserted badges that predate the native
 * Image block settings. */
.lpu-information-badges__portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
}

/*****************************************************************************/
/* GRAPHIC CALL-TO-ACTION BAND                                               */
/*****************************************************************************/
.lpu-graphic-band > .wp-block-heading {
  text-wrap: balance;
}

/*****************************************************************************/
/* SECTION RESPONSIVE (781px)                                                */
/*****************************************************************************/
@media (max-width: 781px) {
  /* The gallery's large offsets create a stagger across desktop columns.
   * Once Core stacks those columns, the offsets would become empty screens
   * between photographs. Native spacing presets cannot switch them off. */
  .lpu-staggered-gallery .wp-block-spacer {
    display: none;
  }

  .lpu-card-grid,
  .lpu-farm-selector,
  .lpu-columns-text,
  .lpu-graphic-band {
    padding-inline: var(--wp--preset--spacing--md);
  }
}

/*****************************************************************************/
/* GENERIC MAIN AND FOOTER TRANSITION                                        */
/*****************************************************************************/
/* too risky. may prevent a user from achieving what he wants.  */
/* main.wp-block-group {
  min-height: 30vh;
} */

/* Keep the Post Content blockGap for ordinary blocks. Designed sections use
 * the lpu-section marker so adjacent section backgrounds touch. */
.wp-block-post-content > .lpu-section {
  margin-block-start: 0;
}

/* The following block owns the space at a section/content boundary. */
.wp-block-post-content > .lpu-section + :not(.lpu-section),
.wp-block-post-content > :not(.lpu-section) + .lpu-section {
  margin-block-start: var(--wp--preset--spacing--xl-fluid);
}

/* A between-placement Pastille has zero height at the boundary. Do not add
 * the usual section/content gap to the block that immediately follows it. */
.wp-block-post-content > .lpu-pastille--between + :not(.lpu-section) {
  margin-block-start: 0;
}

.wp-block-post-content:has(> :first-child:not(.lpu-section)) {
  padding-block-start: var(--wp--preset--spacing--xl-fluid);
}

/* There can often be accidentally an empty paragraph at the end of a post.
 * This is bad for our theme because it leads to an empty space between the last
 * section and the bottom of the page.
 * Hide that direct child and remove the extra verticl space. */
.wp-block-post-content > p:empty:last-child {
  display: none;
}

 /* There is padding at the bottom of a post except if : 
  * - last element is a section
  * - last element is is an empty paragraph and the element before that is a
  *   section */
.wp-block-post-content:has(> :last-child:not(.lpu-section, p:empty)),
.wp-block-post-content:has(> :nth-last-child(2):not(.lpu-section) + p:empty:last-child) {
  padding-block-end: var(--wp--preset--spacing--xl-fluid);
}

/* The footer follows the final editorial section directly. */
.wp-site-blocks > main + footer.wp-block-template-part {
  margin-block-start: 0;
}

/*****************************************************************************/
/* FOOTER COMPONENT                                                          */
/*****************************************************************************/
/* Shared footer frame. The footer Navigation receives site-local content at
 * render time, while its layout and visual treatment remain shared. */

.lpu-footer::after {
  position: absolute;
  right: clamp(1.25rem, 4vw, 3.5rem);
  bottom: clamp(1rem, 3vw, 2rem);
  width: clamp(2.25rem, 4vw, 3.5rem);
  height: clamp(2.25rem, 4vw, 3.5rem);
  background: url("../images/footer/footer-star-ecru.svg") center / contain
    no-repeat;
  content: "";
  display: none;
}

/* for narrow viewports */
.lpu-footer .wp-block-navigation__container {
  grid-template-columns: 1fr;
}

/* for intermediary viewports and up*/
@media (min-width: 600px) {
  .lpu-footer .wp-block-navigation__container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* 0-2-0 specificity to always beat wp Core CSS */
  .lpu-footer > .lpu-footer__bottom {
    /* back to default value for this element (same value as wp core set by a
    .is-layout-flex {} rule) */
    align-items: center;
    flex-direction: unset;
  }
}

/* for larger viewports */
@media (min-width: 900px) {
  .lpu-footer .wp-block-navigation__container {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* collides with footer content under a certain size */
  .lpu-footer::after {
    display: block;
  }
}

/* 0-2-0 specificity to always beat wp Core CSS */
.lpu-footer > .lpu-footer__bottom {
  align-items: flex-start;
  flex-direction: column;
}

/* Keep the responsive grid while Core's gap inheritance applies Navigation's
 * editable horizontal and vertical spacing to its menu groups. */
.lpu-footer .wp-block-navigation__container {
  display: grid !important;
  align-items: start;
}

.lpu-footer .wp-block-navigation__container > .wp-block-navigation-submenu {
  display: block;
}

.lpu-footer
  .wp-block-navigation__container
  > .wp-block-navigation-submenu
  > .wp-block-navigation-item__content {
  margin-block-end: 0.65rem;
}

/* Core's submenu rules are fairly specific. We overwrite them here with what
 * we want.
 * Repeat the direct-child relationship and force the footer columns open;
 * unlike the header, these submenus are always expanded. */
.lpu-footer
  .wp-block-navigation__container
  > .wp-block-navigation-submenu
  > .wp-block-navigation__submenu-container {
  position: static !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto !important;
  min-width: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

.lpu-footer
  .wp-block-navigation__submenu-container
  > .wp-block-navigation-item {
  display: block;
}

/* Core sets submenus to black by default. We want our default color
(ecru).
 * so we inherit (our default color) instead of black. 
 * Explicitly set color on menu entries will work.  
 */
.lpu-footer
  .wp-block-navigation
  .wp-block-navigation__submenu-container:not(.has-text-color) {
  color: inherit;
}

.lpu-footer
  .wp-block-navigation__submenu-container
  > .wp-block-navigation-item
  > .wp-block-navigation-item__content::before {
  content: "> ";
}

.lpu-footer .wp-block-navigation-item__content:hover,
.lpu-footer .wp-block-navigation-item__content:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.lpu-footer
  .wp-block-navigation__container
  > .wp-block-navigation-submenu:last-child {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  padding-block-start: 0.75rem;
  border-top: 1px solid rgba(248, 248, 240, 0.35);
}

.lpu-footer
  .wp-block-navigation__container
  > .wp-block-navigation-submenu:last-child
  > .wp-block-navigation__submenu-container
  > .wp-block-navigation-item
  > .wp-block-navigation-item__content::before {
  content: "> ";
}

/* 0-2-0 specificity to always beat wp Core CSS */
.lpu-footer > .lpu-footer__bottom {
  margin-block-start: var(--wp--preset--spacing--lg);
}

/* keep the text narrow. Important in narrow viewports */
.lpu-footer__intro {
  max-width: 24rem;
}
/* working to delete this */
@media (max-width: 900px) {
  /* 0-2-0 specificity to always beat wp Core CSS */
  .lpu-footer > .lpu-footer__main {
    flex-direction: column;
  }
}

/*****************************************************************************/
/* BUTTONS                                                                   */
/*****************************************************************************/
/* Normal and interactive-state colours come from theme.json. Presets scope
 * fallback variables only, allowing native Global Styles and local state
 * settings to follow WordPress precedence without forced colour rules. */
/* Gutenberg can omit the style class for Contour. Use the link's inherited
 * text colour as its resting fallback and its actual ink for the state border.
 * The header foreground and explicit button colours still take precedence. */
:where(.wp-block-button:not([class*="is-style-"]),
  .wp-block-button.is-style-default,
  .wp-block-button.is-style-lpu-button-regular) > .wp-block-button__link {
  --wp--custom--button--text-color: currentColor;
  --lpu-button-hover-border: currentColor;
}

/* Let the fill paint through the border in the normal state, including custom
 * colors and gradients. Keep its width to avoid a size change on hover, and
 * low specificity so an explicit Gutenberg border color still takes priority. */
:where(.is-style-lpu-button-filled .wp-block-button__link,
  .is-style-lpu-button-filled-white .wp-block-button__link) {
  border-color: transparent;
}

/* Two contrasting rings keep keyboard focus visible on light and coloured
 * sections, even when the button text matches the surrounding background. */
.wp-block-button__link:focus-visible {
  outline: 2px solid var(--wp--preset--color--vert-fonce);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--wp--preset--color--blanc);
}

/* Animations */
@media (prefers-reduced-motion: no-preference) {
  .wp-site-blocks .wp-block-button__link {
    transition: color 100ms ease, background-color 100ms ease,
      border-color 100ms ease;
  }

  /* the following rules make images (in a card) zoom-in when hovered */
  .wp-site-blocks .lpu-card > .wp-block-image:not(:has(> a)):not(.wp-lightbox-container) {
    /* Prevent images from taking more space, clip instead.
       Avoid overlap issues when zoming-in on hover. */
    overflow: clip;
  }

  .wp-site-blocks .lpu-card > .wp-block-image:not(:has(> a)):not(.wp-lightbox-container) img {
    transition: transform 100ms ease-out;
  }
  
  .wp-site-blocks .lpu-card:is(:hover, :focus-within)
    > .wp-block-image:not(:has(> a)):not(.wp-lightbox-container) img {
    transform: scale(1.025);
  }
}

/* Arrow button: hidden text for a11y on the frontend, arrow icon via ::after.
 * .wp-site-blocks exists on the frontend only — scope the text-hiding rule
 * there so the editor keeps the label visible and editable. */
.wp-site-blocks [data-lpu-arrow="true"] .wp-block-button__link,
.wp-site-blocks [data-lpu-arrow="true"] .wp-block-button__link:hover,
.wp-site-blocks [data-lpu-arrow="true"] .wp-block-button__link:focus-visible {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.5rem;
  min-width: 3.5rem;
  height: 2.5rem;
  padding: 0;
  overflow: hidden;
  text-indent: 100%;
  white-space: nowrap;
}

.wp-site-blocks [data-lpu-arrow="true"] .wp-block-button__link::after {
  position: absolute;
  inset: 0;
  width: 1.75rem;
  height: 1.25rem;
  margin: auto;
  background-color: currentColor;
  content: "";
  mask: url("../images/arrow-right.svg") center / contain no-repeat;
  -webkit-mask: url("../images/arrow-right.svg") center / contain no-repeat;
}

/* In colonnes de cartes, make the arrow button line up with the (first line) of
 * the title. Use this the technique explained in this article : 
 * https://blog.kizu.dev/fixing-baselines/.
 * Lining them up is done using baseline alignment. */
.lpu-card > .wp-block-group.is-layout-flex
  > h3:has(+ .wp-block-buttons > [data-lpu-arrow="true"]:only-child) {
  /* Let the two blocks share a baseline.
   * A zero-height line before the title exports a baseline halfway down one
   * H3 line. On line-height itself, 1lh uses the parent H3's metrics. */
  align-self: baseline;

  /* Create a block before the title text.
   * We'll place it in the middle of the line.
   * Height and font-size 0 so it doesn't take space. */
  &::before {
    /* a zero-width character */
    content: "\200B";
    display: block;
    height: 0;
    font-size: 0;
    /* 1lh refers to the parent's line height. Here the parent is the h3 */
    line-height: 1lh;
  }

  & + .wp-block-buttons {
    align-self: baseline;
    display: grid;
    align-items: center;

    /* Share a cell with the button. The empty first item's baseline is at
     * the pill's center regardless of the pill's height. */
    &::before {
      content: "";
      height: 0;
      grid-area: 1 / 1;
    }

    & > .wp-block-button {
      grid-area: 1 / 1;
      /* The editable link is inline-block. Give its wrapper the link's
       * actual height so text leading cannot shift the marker's center. */
      display: grid;
    }
  }
}

/* Keep card arrows close to the height of regular text buttons. */
.wp-site-blocks
  .lpu-card-grid
  .wp-block-button[data-lpu-arrow="true"]
  .wp-block-button__link {
  height: 2.5rem;
}
