/* ===================== Ferrymas Header ===================== */
.fmh {
  --fmh-bg: #151515;
  --fmh-accent: #b9c13a;
  --fmh-logo-h: 70px;
  --fmh-cols: 4;
  --fmh-gap: clamp(20px, 3.5vw, 72px);
  --fmh-size: clamp(15px, 1.1vw, 21px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  color: #fff;
  font-family: var(--fmh-font, inherit), "Jost", "Futura", "Century Gothic", sans-serif;
  transition: background-color .3s ease, box-shadow .3s ease;
}
.fmh *, .fmh *::before, .fmh *::after { box-sizing: border-box; }

/* Home: transparente con degradado para que el texto se lea sobre la foto */
.fmh--overlay {
  background: linear-gradient(to bottom, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
}
.fmh--solid,
.fmh.is-scrolled,
.fmh.is-open {
  background: var(--fmh-bg);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}

/* ---------- Barra ---------- */
.fmh__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: var(--fmh-gap);
  max-width: 1760px;
  margin: 0 auto;
  padding: clamp(6px, 1vw, 20px) clamp(16px, 3vw, 48px);
  transition: padding .3s ease;
}
.fmh.is-scrolled .fmh__bar { padding-top: 5px; padding-bottom: 5px; }

.fmh__nav {
  display: flex;
  align-items: center;
  gap: var(--fmh-gap);
  min-width: 0;
}
/* Los enlaces se reparten por todo el ancho de cada mitad */
.fmh__nav--left,
.fmh__nav--right { justify-content: space-evenly; }

/* Lupa pegada a "Productos" como en el diseño */
.fmh__group { display: inline-flex; align-items: center; gap: 6px; }

.fmh__link {
  position: relative;
  color: #fff !important;
  font-size: var(--fmh-size);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: .01em;
  text-decoration: none !important;
  white-space: nowrap;
  padding: 4px 0;
}
.fmh__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--fmh-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s ease;
}
.fmh__link:hover::after,
.fmh__link:focus-visible::after,
.fmh__link[aria-expanded="true"]::after { transform: scaleX(1); }

.fmh__search-btn,
.fmh__burger,
.fmh__search-close,
.fmh__drawer-toggle {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
  line-height: 0;
}
.fmh__search-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; }
.fmh__search-btn svg { width: calc(var(--fmh-size) * 1.1); height: calc(var(--fmh-size) * 1.1); }
.fmh__search-btn:hover { color: var(--fmh-accent); }

.fmh a:focus-visible,
.fmh button:focus-visible,
.fmh input:focus-visible {
  outline: 2px solid var(--fmh-accent);
  outline-offset: 4px;
}

/* ---------- Logo ---------- */
.fmh__logo { display: block; line-height: 0; }
.fmh__logo img {
  display: block;
  height: var(--fmh-logo-h);
  width: auto;
  max-width: none;
  transition: height .3s ease;
}
.fmh.is-scrolled .fmh__logo img { height: calc(var(--fmh-logo-h) * .68); }

.fmh__burger,
.fmh__search-btn--mobile { display: none; }

/* ---------- Megamenú (tipo Leroy Merlin) ---------- */
.fmh__panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  color: #1d1d1d;
  border-top: 3px solid var(--fmh-accent);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .22);
  font-size: 15px;
  line-height: 1.35;
}
.fmh__panel[hidden] { display: none; }
.fmh__mm {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  max-width: 1600px;
  margin: 0 auto;
  height: min(640px, calc(100vh - var(--fmh-h, 140px) - 16px));
  height: min(640px, calc(100dvh - var(--fmh-h, 140px) - 16px));
}

/* Columna izquierda: categorías principales */
.fmh__mm-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid #e6e6e6;
}
.fmh__mm-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}
.fmh__mm-item {
  position: relative;
  display: block;
  padding: 13px 20px 13px 28px;
  font-size: 16px;
  color: #1d1d1d !important;
  text-decoration: none !important;
}
.fmh__mm-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--fmh-accent);
  opacity: 0;
}
.fmh__mm-item.is-active { background: #f4f5e6; font-weight: 500; }
.fmh__mm-item.is-active::before { opacity: 1; }

.fmh__mm-name { min-width: 0; }

/* Miniatura redonda de la categoría */
.fmh__mm-item:has(.fmh__mm-thumb) {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 20px 9px 22px;
}
.fmh__mm-thumb {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #eef0e0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
  transition: box-shadow .2s ease, transform .2s ease;
}
.fmh__mm-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  border-radius: 50%;
}
.fmh__mm-thumb--txt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6d7317;
  font-weight: 700;
  font-size: 17px;
}
.fmh__mm-item:hover .fmh__mm-thumb { transform: scale(1.06); }
.fmh__mm-item.is-active .fmh__mm-thumb { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--fmh-accent); }
@media (prefers-reduced-motion: reduce) {
  .fmh__mm-thumb { transition: none; }
  .fmh__mm-item:hover .fmh__mm-thumb { transform: none; }
}

.fmh__mm-all {
  display: block;
  padding: 16px 24px;
  border-top: 1px solid #e6e6e6;
  color: #1d1d1d !important;
  font-weight: 700;
  text-decoration: none !important;
}
.fmh__mm-all:hover { color: #6d7317 !important; }

/* Lado derecho: subcategorías */
.fmh__mm-main {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px clamp(24px, 3vw, 56px) 32px;
}
.fmh__mm-pane[hidden] { display: none; }
.fmh__mm-head {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 1px solid #e6e6e6;
}
.fmh__mm-title {
  font-size: clamp(20px, 1.6vw, 26px);
  font-weight: 700;
  color: #1d1d1d !important;
  text-decoration: none !important;
}
.fmh__mm-seeall {
  margin-left: auto;
  font-weight: 500;
  color: #6d7317 !important;
  white-space: nowrap;
}
.fmh__mm-groups,
.fmh__mm-links--flat {
  column-count: var(--fmh-cols);
  column-gap: 40px;
}
.fmh__mm-group {
  break-inside: avoid;
  padding-bottom: 26px;
}
.fmh__mm-group-title {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: #1d1d1d !important;
  text-decoration: none !important;
}
.fmh__mm-links { list-style: none; margin: 0; padding: 0; }
.fmh__mm-links li { break-inside: avoid; }
.fmh__mm-links a {
  display: inline-block;
  padding: 5px 0;
  color: #3d3d3d !important;
  text-decoration: none !important;
}
.fmh__mm-links--flat a { padding: 8px 0; font-size: 16px; }
.fmh__mm-links a:hover,
.fmh__mm-group-title:hover,
.fmh__mm-title:hover { color: #6d7317 !important; text-decoration: underline !important; }

@media (max-width: 1199px) {
  .fmh__mm { grid-template-columns: 280px 1fr; }
  .fmh__mm-thumb { flex-basis: 34px; width: 34px; height: 34px; }
  .fmh__mm-item:has(.fmh__mm-thumb) { gap: 12px; }
  .fmh__mm-groups, .fmh__mm-links--flat { column-count: min(var(--fmh-cols), 2); }
}

/* ---------- Overlay búsqueda ---------- */
.fmh__search {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(10, 10, 10, .82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(80px, 14vh, 160px) 16px 16px;
}
.fmh__search[hidden] { display: none; }
.fmh__search-inner { position: relative; width: min(860px, 100%); }
.fmh__search-form {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 999px;
  padding: 6px 6px 6px 28px;
}
.fmh__search-input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: clamp(18px, 2vw, 24px);
  color: #1d1d1d;
  padding: 12px 0;
  box-shadow: none !important;
}
.fmh__search-submit {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: var(--fmh-accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fmh__search-close {
  position: absolute;
  top: -56px;
  right: 0;
  font-size: 44px;
  line-height: 1;
  color: #fff;
}

/* ---------- Drawer móvil ---------- */
.fmh__drawer {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--fmh-bg);
  border-top: 1px solid rgba(255, 255, 255, .12);
  max-height: calc(100vh - var(--fmh-h, 70px));
  max-height: calc(100dvh - var(--fmh-h, 70px));
  overscroll-behavior: contain;
  overflow-y: auto;
}
.fmh__drawer[hidden] { display: none; }
.fmh__drawer-list,
.fmh__drawer-cats { list-style: none; margin: 0; padding: 0; }
.fmh__drawer-item { border-bottom: 1px solid rgba(255, 255, 255, .1); }
.fmh__drawer-row { display: flex; align-items: center; }
.fmh__drawer a {
  display: block;
  flex: 1;
  padding: 16px 20px;
  color: #fff !important;
  font-size: 19px;
  text-decoration: none !important;
}
.fmh__drawer-toggle {
  width: 56px;
  height: 56px;
  position: relative;
}
.fmh__drawer-toggle::before,
.fmh__drawer-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 2px;
  background: var(--fmh-accent);
  transform: translate(-50%, -50%);
  transition: transform .2s ease;
}
.fmh__drawer-toggle::after { transform: translate(-50%, -50%) rotate(90deg); }
.fmh__drawer-toggle[aria-expanded="true"]::after { transform: translate(-50%, -50%) rotate(0); }
.fmh__drawer-cats { background: rgba(255, 255, 255, .05); padding: 6px 0; }
.fmh__drawer-cats[hidden] { display: none; }
.fmh__drawer-cats a { padding: 12px 20px 12px 32px; font-size: 17px; }
.fmh__drawer-cats .fmh__drawer-toggle { width: 52px; height: 48px; }
.fmh__drawer-sub { list-style: none; margin: 0; padding: 4px 0 8px; background: rgba(0, 0, 0, .25); }
.fmh__drawer-sub[hidden] { display: none; }
.fmh__drawer-sub a { padding: 10px 20px 10px 48px; font-size: 15px; opacity: .88; }

.fmh-spacer { height: 90px; margin-bottom: var(--fmh-top-gap, 40px); }
@media (max-width: 991px) {
  .fmh-spacer { margin-bottom: calc(var(--fmh-top-gap, 40px) * .6); }
}

/* ---------- Tablet / móvil ---------- */
@media (max-width: 1199px) {
  .fmh { --fmh-gap: clamp(16px, 2.4vw, 28px); --fmh-size: clamp(15px, 1.45vw, 17px); }
  .fmh__bar { column-gap: clamp(20px, 3vw, 36px); }
  .fmh__logo img { height: calc(var(--fmh-logo-h) * .75); }
}
@media (max-width: 991px) {
  .fmh__bar {
    grid-template-columns: 44px 1fr 44px;
    column-gap: 12px;
    padding: 8px 16px;
  }
  .fmh__nav { display: none; }
  .fmh__burger,
  .fmh__search-btn--mobile { display: inline-flex; }
  .fmh__logo { justify-self: center; }
  .fmh__logo img { height: 46px; }
  .fmh.is-scrolled .fmh__logo img { height: 38px; }
  .fmh__panel { display: none !important; }

  .fmh__burger {
    width: 44px;
    height: 44px;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 0 9px;
  }
  .fmh__burger span {
    display: block;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .25s ease, opacity .2s ease;
  }
  .fmh__burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
  .fmh__burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .fmh__burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
  .fmh__search-btn--mobile { width: 44px; height: 44px; justify-self: end; }
  .fmh__search-btn--mobile svg { width: 24px; height: 24px; }
}
@media (min-width: 992px) {
  .fmh__drawer { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .fmh, .fmh * { transition: none !important; }
}

/* Header fijo: anclas (#id) y scrollIntoView no quedan tapados */
html { scroll-padding-top: calc(var(--fmh-h, 120px) + 12px); }
html.fmh-lock { overflow: hidden; }

/* Cabecera por encima del sticky de Optima, por debajo de modales de PrestaShop (z 1050) */
body > .fmh { z-index: 1030; }

/* #header solo envuelve el hueco reservado en páginas interiores */
#header { background: transparent; }
