/**
 * Cartes produit des blocs « Essentiels », « Sélection » et « Meilleures ventes »
 * (templates hook/essentials.tpl, products_selection.tpl, best-seller.tpl → _partials/mh-pcard.tpl).
 *
 * Chaque ligne de la carte a une hauteur fixe, même vide : marques, noms, prix et
 * boutons sont alignés d'une carte à l'autre. Toute modification de ce fichier doit
 * s'accompagner d'un changement du paramètre ?v= dans les trois templates (les
 * fichiers statiques sont mis en cache un an).
 */

.mh-pcard,
.mh-pgrid {
  --mh-navy: #0c193a;
  --mh-orange: #e65021;
  --mh-orange-dark: #cf4419;
  --mh-green: #1f9d55;
  --mh-amber: #d97706;
  --mh-muted: #8a93a3;
  --mh-line: #e8ebf0;
}

/* ------------------------------------------------------------------ */
/* Section titles                                                      */
/* Element + class selectors: they must beat the theme's               */
/* `.page-index .home-ess h2`, `.fd-pushs-b .fd-b-l h2`… (home.css).    */
/* ------------------------------------------------------------------ */
div.mh-ess h2.mh-eyebrow,
section.mh-hero h2.mh-eyebrow {
  position: static;
  margin: 0 0 12px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e65021;
}

div.mh-ess h3.mh-title,
section.mh-hero h3.mh-title,
div.mh-blp h2.mh-title,
div.fd-pushs-b.mh-selection h2.mh-title {
  position: static;
  margin: 0;
  padding: 0;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: #0c193a;
  text-transform: none;
}

section.mh-hero h2.mh-eyebrow::before,
section.mh-hero h2.mh-eyebrow::after,
section.mh-hero h3.mh-title::before,
section.mh-hero h3.mh-title::after,
div.mh-ess h2.mh-eyebrow::before,
div.mh-ess h2.mh-eyebrow::after,
div.mh-ess h3.mh-title::before,
div.mh-ess h3.mh-title::after,
div.mh-blp h2.mh-title::before,
div.mh-blp h2.mh-title::after,
div.fd-pushs-b.mh-selection h2.mh-title::before,
div.fd-pushs-b.mh-selection h2.mh-title::after {
  content: none;
  display: none;
}

div.mh-blp h2.mh-title--center {
  text-align: center;
}

div.mh-blp p.mh-subtitle {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
  color: #6b7383;
}

/* ------------------------------------------------------------------ */
/* Hero (essentials.tpl): title row, then visual + two cards.          */
/* ------------------------------------------------------------------ */
section.mh-hero {
  margin: 40px 0 64px;
  padding: 0;
}

.mh-hero__head {
  margin: 0 0 28px;
}

section.mh-hero h3.mh-title {
  max-width: 760px;
  font-size: 40px;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.mh-hero__body {
  display: grid;
  /* 607px = the visual at its natural ratio for the cards' height (~429px): no crop whatever the
     width of the theme's fluid container (up to 1440px); the extra width goes to the cards. */
  grid-template-columns: minmax(0, 607px) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.mh-hero__body--noimage {
  grid-template-columns: minmax(0, 1fr);
}

/* The visual takes the height of the cards, corners match the cards. */
.mh-hero__visual {
  position: relative;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #eef0f4;
  border-radius: 20px;
}

.mh-hero__visual img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% 50%;
}

section.mh-hero .mh-pgrid {
  margin: 0;
  gap: 16px;
}

/* Taller photos in the hero: the cards then match the visual's natural height (1140px container). */
section.mh-hero .mh-pcard .mh-pcard__media {
  height: 232px;
}

/* Below 1200px the visual would be cropped too much: it goes on its own row, uncropped. */
@media (max-width: 1199.98px) {
  .mh-hero__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .mh-hero__visual {
    min-height: 0;
    aspect-ratio: 842 / 595;
  }

  section.mh-hero .mh-pcard .mh-pcard__media {
    height: 210px;
  }
}

@media (max-width: 991.98px) {
  section.mh-hero {
    margin: 28px 0 48px;
  }

  section.mh-hero h3.mh-title {
    font-size: 30px;
  }
}

@media (max-width: 575.98px) {
  /* The theme drops the container gutter on phones: the sections bring their own 16px. */
  section.mh-hero {
    margin: 20px 0 40px;
    padding: 0 16px;
  }

  div.mh-blp {
    padding: 0 16px;
  }

  section.mh-hero .mh-pgrid {
    margin: 0 -16px;
  }

  .mh-hero__head {
    margin-bottom: 18px;
  }

  section.mh-hero h3.mh-title {
    font-size: 26px;
  }

  .mh-hero__visual {
    border-radius: 16px;
  }

  section.mh-hero .mh-pcard .mh-pcard__media {
    height: 170px;
  }
}

/* ------------------------------------------------------------------ */
/* Seasonal selection on the home page (products_selection_promo.tpl). */
/* products_selection_promo.css uses !important everywhere: element +  */
/* class selectors and !important are needed to win.                   */
/* ------------------------------------------------------------------ */
div.home-psp {
  margin: 0 0 64px !important;
  padding: 48px 48px 52px !important;
  background: linear-gradient(180deg, #f6f7fa 0%, #f1f3f7 100%) !important;
  border-radius: 24px;
}

div.home-psp div.fd-pushs-b.mh-selection,
div.home-psp div.fd-pushs-b.mh-selection div.fd-b-l,
div.home-psp div.fd-pushs-b.mh-selection div.fd-b-r {
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

div.home-psp div.fd-pushs-b.mh-selection h2.mh-title {
  margin: 0 0 28px;
}

div.home-psp .mh-pgrid {
  margin: 0;
}

div.home-psp .mh-pcard {
  border-color: #e3e7ee;
  box-shadow: 0 1px 2px rgba(12, 25, 58, 0.04);
}

@media (max-width: 991.98px) {
  div.home-psp {
    padding: 32px 24px 36px !important;
    border-radius: 20px;
  }
}

@media (max-width: 575.98px) {
  div.home-psp {
    margin: 0 0 40px !important;
    padding: 28px 16px 24px !important;
    border-radius: 0;
  }

  div.home-psp .mh-pgrid {
    margin: 0 -16px;
  }

  div.home-psp div.fd-pushs-b.mh-selection h2.mh-title {
    margin-bottom: 18px;
  }
}

/* ------------------------------------------------------------------ */
/* Grid                                                                */
/* ------------------------------------------------------------------ */
.mh-pgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 28px 0 0;
  padding: 0;
}

.mh-pgrid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ------------------------------------------------------------------ */
/* Card — sober: white photo, one price, compact cart button.          */
/* Every row has a fixed height (empty rows included) so brands,       */
/* names, prices and buttons line up across the grid.                  */
/* ------------------------------------------------------------------ */
.mh-pcard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch; /* theme-classic centres .aa-ItemLink children */
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--mh-line);
  border-radius: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mh-pcard:hover {
  border-color: #d3d9e3;
  box-shadow: 0 12px 30px rgba(12, 25, 58, 0.08);
}

/* Visual */
.mh-pcard .mh-pcard__media {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  height: 210px;
  padding: 40px 20px 18px;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid #f0f2f5;
  text-decoration: none;
}

.mh-pcard__media picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
}

.mh-pcard__media img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 0.35s ease;
}

.mh-pcard:hover .mh-pcard__media img {
  transform: scale(1.04);
}

.mh-pcard__badge,
.mh-pcard__discount {
  position: absolute;
  top: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  height: 24px;
  white-space: nowrap;
  border-radius: 6px;
}

/* Merchandising label (Essentiel, Top vente…): quiet tag, orange dot, sentence case. */
.mh-pcard__badge {
  left: 12px;
  gap: 6px;
  max-width: calc(100% - 92px);
  padding: 0 9px 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: 0.01em;
  color: var(--mh-navy);
  background: #f1f3f7;
}

.mh-pcard__badge::before {
  content: '';
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  background: var(--mh-orange);
  border-radius: 50%;
}

/* Discount */
.mh-pcard__discount {
  right: 12px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 24px;
  letter-spacing: 0;
  color: #fff;
  background: var(--mh-orange);
}

/* Energy class: compact arrow in the EU scale colours (replaces the Diadems chevron). */
.mh-pcard .mh-pcard__energy {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  height: 20px;
  min-width: 30px;
  margin: 0;
  padding: 0 12px 0 7px;
  font-size: 11px;
  font-weight: 800;
  line-height: 20px;
  letter-spacing: 0.02em;
  color: #fff;
  background: #8a93a3;
  border-radius: 3px 0 0 3px;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
}

.mh-pcard .mh-energy-appp,
.mh-pcard .mh-energy-app,
.mh-pcard .mh-energy-ap,
.mh-pcard .mh-energy-a { background: #00a651; }
.mh-pcard .mh-energy-b { background: #4cb848; }
.mh-pcard .mh-energy-c { background: #b3cf2a; color: #1f2a10; }
.mh-pcard .mh-energy-d { background: #f2d900; color: #3b3200; }
.mh-pcard .mh-energy-e { background: #fcb814; color: #3b2a00; }
.mh-pcard .mh-energy-f { background: #f36f21; }
.mh-pcard .mh-energy-g { background: #e2231a; }

/* Body */
.mh-pcard__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  padding: 14px 16px 0;
}

.mh-pcard__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 14px;
  overflow: hidden;
  font-size: 10.5px;
  line-height: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mh-pcard__brand {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  color: var(--mh-navy);
}

.mh-pcard__ref {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--mh-muted);
}

article.mh-pcard h3.mh-pcard__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  height: 40px;
  margin: 8px 0 0;
  padding: 0;
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  color: var(--mh-navy);
}

article.mh-pcard h3.mh-pcard__name::after {
  content: none;
}

.mh-pcard .mh-pcard__name a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.mh-pcard:hover .mh-pcard__name a {
  color: var(--mh-orange);
}

/* Stretched link: the whole card opens the product, the cart button keeps its own action. */
.mh-pcard .mh-pcard__name a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
}

.mh-pcard__reviews {
  display: flex;
  align-items: center;
  height: 18px;
  margin-top: 6px;
  overflow: hidden;
}

.mh-pcard__reviews > div,
.mh-pcard__reviews .product-list-reviews {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 !important;
  padding: 0 !important;
}

.mh-pcard__reviews .grade-stars {
  display: flex;
  align-items: center;
  gap: 1px;
  margin: 0 !important;
}

.mh-pcard__reviews .star,
.mh-pcard__reviews .star span {
  display: flex;
  width: 12px;
  height: 12px;
  margin: 0 !important;
}

.mh-pcard__reviews svg {
  width: 12px;
  height: 12px;
}

.mh-pcard__reviews .comments-nb,
.mh-pcard__reviews [class*='nb'] {
  font-size: 11.5px;
  line-height: 18px;
  color: var(--mh-muted);
}

/* Delivery: the theme script rewrites .shipsubdelay with the delivery dates. */
.mh-pcard__delivery {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 18px;
  margin-top: 6px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
  color: #5b6475;
}

.mh-pcard__delivery .stock,
.mh-pcard__delivery .shipsubdelay {
  display: inline;
  margin: 0;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  background: none;
  border: 0;
}

.mh-pcard__delivery .kl {
  font-weight: 600;
  color: var(--mh-navy) !important;
}

.mh-pcard__dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  background: var(--mh-green);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.14);
}

.mh-pcard__dot--order {
  background: var(--mh-amber);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.14);
}

/* Foot: price on the left, cart button on the right. */
.mh-pcard__foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 16px;
  pointer-events: none; /* clicks on the price fall through to the stretched product link */
}

.mh-pcard__foot form,
.mh-pcard__btn {
  pointer-events: auto;
}

.mh-pcard__foot form {
  flex: 0 0 auto;
  margin: 0;
}

.mh-pcard__prices {
  display: grid;
  grid-template-rows: 15px 28px;
  align-items: end;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.mh-pcard__old,
.mh-pcard__price {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mh-pcard__old {
  font-size: 12px;
  line-height: 15px;
  color: #9aa2b1;
  text-decoration: line-through;
}

.mh-pcard__price {
  font-size: 21px;
  font-weight: 800;
  line-height: 28px;
  letter-spacing: -0.015em;
  color: var(--mh-navy);
}

.mh-pcard__price small {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--mh-muted);
}

/* Tax display: HT by default (B2B shop); `html.mh-tax-incl` (header switch) shows TTC instead. */
.mh-pcard [data-mh-tax='incl'] {
  display: none;
}

html.mh-tax-incl .mh-pcard [data-mh-tax='excl'] {
  display: none;
}

html.mh-tax-incl .mh-pcard [data-mh-tax='incl'] {
  display: inline;
}

/* Compact square button */
.mh-pcard .mh-pcard__btn {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  color: #fff;
  background: var(--mh-navy);
  border: 0;
  border-radius: 12px;
  box-shadow: none;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.mh-pcard .mh-pcard__btn svg {
  width: 20px;
  height: 20px;
}

.mh-pcard .mh-pcard__btn:hover,
.mh-pcard .mh-pcard__btn:focus-visible {
  color: #fff;
  background: var(--mh-orange);
  box-shadow: 0 6px 14px rgba(230, 80, 33, 0.25);
}

.mh-pcard .mh-pcard__btn:focus-visible {
  outline: 2px solid var(--mh-orange);
  outline-offset: 2px;
}

.mh-pcard .mh-pcard__btn--view {
  color: var(--mh-navy);
  background: #fff;
  border: 1px solid #d5dae2;
}

.mh-pcard .mh-pcard__btn--view:hover,
.mh-pcard .mh-pcard__btn--view:focus-visible {
  color: #fff;
  background: var(--mh-navy);
  border-color: var(--mh-navy);
  box-shadow: 0 6px 14px rgba(12, 25, 58, 0.18);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 1199.98px) {
  /* 960px container: four cards only fit if the gaps get tighter. */
  .mh-pgrid--4 {
    gap: 14px;
  }

  .mh-pcard .mh-pcard__media {
    height: 190px;
  }

  .mh-pcard__body {
    padding: 12px 14px 0;
  }

  .mh-pcard__foot {
    padding: 10px 14px 14px;
  }

  .mh-pcard__price {
    font-size: 19px;
  }

  .mh-pcard .mh-pcard__btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }
}

@media (max-width: 991.98px) {
  .mh-pgrid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  div.mh-ess h3.mh-title,
  section.mh-hero h3.mh-title,
  div.mh-blp h2.mh-title,
  div.fd-pushs-b.mh-selection h2.mh-title {
    font-size: 26px;
  }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
  div.home-psp {
    padding: 36px 24px 40px !important;
  }
}

/* Phones: a swipeable row, the next card peeking to invite the gesture. */
@media (max-width: 575.98px) {
  .mh-pgrid,
  .mh-pgrid--4 {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 74%;
    gap: 12px;
    margin-right: -16px;
    margin-left: -16px;
    padding: 4px 16px 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mh-pgrid::-webkit-scrollbar {
    display: none;
  }

  .mh-pcard {
    scroll-snap-align: start;
  }

  .mh-pcard .mh-pcard__media {
    height: 180px;
  }

  div.mh-ess h3.mh-title,
  section.mh-hero h3.mh-title,
  div.mh-blp h2.mh-title,
  div.fd-pushs-b.mh-selection h2.mh-title {
    font-size: 23px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mh-pcard,
  .mh-pcard__media img,
  .mh-pcard .mh-pcard__btn {
    transition: none;
  }

  .mh-pcard:hover .mh-pcard__media img {
    transform: none;
  }
}
