/* ==========================================================================
   IFEP · Menú mòbil — Proposta C («Què vols fer avui?»)
   Tot encapsulat sota el prefix .ifep-mm per evitar conflictes amb Divi
   i amb els estils del tema TemaIFEP.
   ========================================================================== */

/* ---------- Tokens ---------- */
.ifep-mm {
  --ifep-mm-blue: #043EA7;          /* blau IFEP (web actual) */
  --ifep-mm-navy: #00225E;          /* blau fosc botons (web actual) */
  --ifep-mm-text: #2F2F2F;          /* text nivell 1 (web actual) */
  --ifep-mm-text-2: #4A4A4A;        /* text nivell 2 (web actual) */
  --ifep-mm-label: #5B6475;         /* etiquetes de bloc */
  --ifep-mm-line: #E3E6EE;          /* separadors */
  --ifep-mm-soft: #F3F5FA;          /* fons suau, hover */
  --ifep-mm-tint: #EAF0FC;          /* fons targeta empreses */
  --ifep-mm-bg: #FFFFFF;
  --ifep-mm-font: "SuisseBPIntl Regular", Helvetica, Arial, sans-serif;
  --ifep-mm-font-strong: "SuisseBPIntl 500", "SuisseBPIntl Regular", Helvetica, Arial, sans-serif;
  --ifep-mm-gutter: 20px;
  --ifep-mm-bar-h: 64px;
  --ifep-mm-speed: 260ms;
  --ifep-mm-z: 100000;              /* per sobre de la capçalera de Divi (99999) */
}

/* ---------- Reset local ---------- */
.ifep-mm,
.ifep-mm *,
.ifep-mm *::before,
.ifep-mm *::after { box-sizing: border-box; }
/* :where() deixa l'especificitat a zero perquè les classes BEM sempre guanyin */
.ifep-mm :where(ul, li) { list-style: none; margin: 0; padding: 0; }
.ifep-mm :where(p, h2) { margin: 0; padding: 0; }
.ifep-mm :where(a) { text-decoration: none; }
.ifep-mm :where(button) { font: inherit; margin: 0; -webkit-appearance: none; appearance: none; }
.ifep-mm :where(svg) { display: block; flex: none; }
.ifep-mm :focus-visible { outline: 3px solid var(--ifep-mm-blue); outline-offset: 2px; border-radius: 6px; }

/* Text només per a lectors de pantalla */
.ifep-mm__sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Contenidor ---------- */
.ifep-mm {
  position: fixed;
  inset: 0;
  z-index: var(--ifep-mm-z);
  background: var(--ifep-mm-bg);
  color: var(--ifep-mm-text);
  font-family: var(--ifep-mm-font);
  font-size: 16px;
  line-height: 1.35;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--ifep-mm-speed) ease;
  -webkit-font-smoothing: antialiased;
}
.ifep-mm[hidden] { display: none !important; }
.ifep-mm.is-open { transform: none; }

/* Bloqueig del scroll de la pàgina mentre el menú és obert */
html.ifep-mm-lock,
html.ifep-mm-lock body { overflow: hidden !important; }

/* Només en mòbil i tauleta (punt de tall de Divi: 980 px) */
@media (min-width: 981px) {
  .ifep-mm { display: none !important; }
}

/* ---------- Barra superior ---------- */
.ifep-mm__bar {
  flex: none;
  height: calc(var(--ifep-mm-bar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 8px 0 var(--ifep-mm-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ifep-mm-line);
  background: var(--ifep-mm-bg);
  position: relative;
  z-index: 2;
}
.ifep-mm__logo { display: inline-flex; align-items: center; min-height: 44px; }
.ifep-mm__logo img { height: 26px; width: auto; display: block; }

.ifep-mm__icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--ifep-mm-text);
  cursor: pointer;
}
.ifep-mm__icon:hover { background: var(--ifep-mm-soft); }
.ifep-mm__icon svg { width: 24px; height: 24px; }

/* ---------- Nivells (drill-down) ---------- */
.ifep-mm__viewport { position: relative; flex: 1 1 auto; overflow: hidden; }

.ifep-mm__level {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--ifep-mm-bg);
  padding-bottom: 24px;
  transition: transform var(--ifep-mm-speed) ease;
}
.ifep-mm__level[hidden] { display: none; }
.ifep-mm__level--2 { transform: translateX(100%); }
.ifep-mm.is-drilled .ifep-mm__level--1 { transform: translateX(-30%); }
.ifep-mm__level--2.is-active { transform: none; }

/* ---------- Cerca ---------- */
.ifep-mm__search { padding: 12px var(--ifep-mm-gutter) 0; }
.ifep-mm__field {
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 14px;
  border: 1.5px solid var(--ifep-mm-line); border-radius: 12px;
  background: var(--ifep-mm-soft);
}
.ifep-mm__field:focus-within { border-color: var(--ifep-mm-blue); background: var(--ifep-mm-bg); }
.ifep-mm__field svg { width: 20px; height: 20px; color: var(--ifep-mm-label); }
.ifep-mm__field input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; background: transparent; outline: none; box-shadow: none;
  font-family: var(--ifep-mm-font); font-size: 16px; /* 16 px evita el zoom automàtic d'iOS */
  color: var(--ifep-mm-text); padding: 0; margin: 0;
}
.ifep-mm__field input::placeholder { color: #6B7385; opacity: 1; }
.ifep-mm__field input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- Pregunta i targetes ---------- */
.ifep-mm__ask {
  padding: 16px var(--ifep-mm-gutter) 0;
  font-family: var(--ifep-mm-font-strong);
  font-size: 22px; line-height: 1.2; color: var(--ifep-mm-text);
}
.ifep-mm__tiles {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px var(--ifep-mm-gutter) 0 !important;
}
.ifep-mm__tile {
  position: relative;
  width: 100%; height: 100%; min-height: 84px;
  display: grid; align-content: space-between; gap: 8px;
  padding: 12px 14px;
  border: 1.5px solid var(--ifep-mm-line); border-radius: 14px;
  background: var(--ifep-mm-bg);
  color: var(--ifep-mm-text);
  font-family: var(--ifep-mm-font-strong); font-size: 16px; line-height: 1.25;
  text-align: left; cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.ifep-mm__tile:hover { border-color: var(--ifep-mm-blue); }
.ifep-mm__tile svg { width: 28px; height: 28px; color: var(--ifep-mm-blue); }

/* Fletxa que indica que la targeta obre un segon nivell */
.ifep-mm__tile .ifep-mm__more {
  position: absolute; top: 12px; right: 10px;
  width: 20px; height: 20px; color: var(--ifep-mm-label);
}
.ifep-mm__tile.is-current { border-color: var(--ifep-mm-blue); background: var(--ifep-mm-soft); }

.ifep-mm__tiles-wide { grid-column: 1 / -1; }
.ifep-mm__tile--wide {
  min-height: 64px;
  grid-template-columns: auto 1fr auto;
  align-items: center; align-content: center; gap: 14px;
  background: var(--ifep-mm-tint); border-color: transparent;
}
.ifep-mm__tile--wide small {
  display: block; margin-top: 2px;
  font-family: var(--ifep-mm-font); font-size: 13px; line-height: 1.3;
  color: var(--ifep-mm-text-2);
}
.ifep-mm__tile--wide .ifep-mm__go { width: 20px; height: 20px; color: var(--ifep-mm-label); }

/* ---------- Llistes de segon nivell ---------- */
.ifep-mm__back {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 48px; margin: 8px 8px 0; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent;
  font-family: var(--ifep-mm-font-strong); font-size: 15px; color: var(--ifep-mm-blue);
  cursor: pointer;
}
.ifep-mm__back:hover { background: var(--ifep-mm-soft); }
.ifep-mm__back svg { width: 20px; height: 20px; }
.ifep-mm__title {
  padding: 4px var(--ifep-mm-gutter) 8px !important;
  font-family: var(--ifep-mm-font-strong) !important;
  font-size: 24px !important; line-height: 1.2 !important; font-weight: 500 !important;
  color: var(--ifep-mm-text) !important;
}
.ifep-mm__title:focus { outline: none; }

.ifep-mm__group { padding: 16px 0 4px; }
.ifep-mm__group:first-of-type { padding-top: 4px; }
.ifep-mm__group + .ifep-mm__group { border-top: 1px solid var(--ifep-mm-line); margin-top: 8px; }
.ifep-mm__label {
  padding: 0 var(--ifep-mm-gutter) 6px;
  font-family: var(--ifep-mm-font-strong);
  font-size: 12px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ifep-mm-label);
}
.ifep-mm__link {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 8px var(--ifep-mm-gutter);
  font-size: 18px; line-height: 1.25; color: var(--ifep-mm-text);
}
.ifep-mm__link:hover { background: var(--ifep-mm-soft); color: var(--ifep-mm-text); }
.ifep-mm__link[aria-current="page"] { color: var(--ifep-mm-blue); box-shadow: inset 3px 0 0 var(--ifep-mm-blue); }
.ifep-mm__link--all { font-family: var(--ifep-mm-font-strong); font-size: 17px; color: var(--ifep-mm-blue); }
.ifep-mm__link--all:hover { color: var(--ifep-mm-blue); }
.ifep-mm__link--all svg { width: 18px; height: 18px; }

/* ---------- Enllaços secundaris ---------- */
.ifep-mm__sep { height: 1px; background: var(--ifep-mm-line); margin: 16px var(--ifep-mm-gutter) 0; }
/* Enllaços secundaris com a botons llargs, amb el mateix pes visual que les targetes */
.ifep-mm__secondary {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px var(--ifep-mm-gutter) 0 !important;
}
.ifep-mm__secondary a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 46px; padding: 0 14px;
  border: 1.5px solid var(--ifep-mm-line); border-radius: 12px;
  background: var(--ifep-mm-bg);
  font-family: var(--ifep-mm-font-strong); font-size: 16px; color: var(--ifep-mm-text);
  transition: border-color .15s ease;
}
.ifep-mm__secondary a svg { width: 16px; height: 16px; color: var(--ifep-mm-label); }
.ifep-mm__secondary a:hover { border-color: var(--ifep-mm-blue); color: var(--ifep-mm-text); }
.ifep-mm__secondary a[aria-current="page"] { border-color: var(--ifep-mm-blue); background: var(--ifep-mm-soft); }
.ifep-mm__help { padding: 14px var(--ifep-mm-gutter) 0 !important; font-size: 15px; color: var(--ifep-mm-text-2); }
.ifep-mm__help a { font-family: var(--ifep-mm-font-strong); color: var(--ifep-mm-blue); }
.ifep-mm__help a:hover { text-decoration: underline; }

/* ---------- Peu fix ---------- */
.ifep-mm__foot {
  flex: none;
  display: grid; grid-template-columns: auto 1fr; gap: 10px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--ifep-mm-line);
  background: var(--ifep-mm-bg);
  box-shadow: 0 -8px 20px -14px rgba(0, 0, 0, .25);
  position: relative; z-index: 2;
}
.ifep-mm__btn {
  min-height: 52px; padding: 0 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px;
  font-family: var(--ifep-mm-font-strong); font-size: 15px; line-height: 1.1;
  white-space: nowrap; text-align: center;
  transition: background-color .15s ease, color .15s ease;
}
.ifep-mm__btn svg { width: 18px; height: 18px; }
.ifep-mm__btn--secondary { border: 1.5px solid var(--ifep-mm-navy); color: var(--ifep-mm-navy); background: var(--ifep-mm-bg); }
.ifep-mm__btn--secondary:hover { background: var(--ifep-mm-soft); color: var(--ifep-mm-navy); }
.ifep-mm__btn--primary { background: var(--ifep-mm-blue); color: #FFFFFF; }
.ifep-mm__btn--primary:hover { background: var(--ifep-mm-navy); color: #FFFFFF; }

/* Pantalles molt estretes (320 px) */
@media (max-width: 359px) {
  .ifep-mm { --ifep-mm-gutter: 16px; }
  .ifep-mm__tile { min-height: 104px; font-size: 15px; }
  .ifep-mm__foot { grid-template-columns: 1fr 1fr; }
  .ifep-mm__btn { font-size: 14px; padding: 6px 10px; white-space: normal; }
}

/* ---------- Pantalles baixes: el menú cap sencer sense scroll ---------- */
/* Per sota de 760 px d'alçada, les targetes passen a format horitzontal */
@media (max-height: 759px) {
  .ifep-mm .ifep-mm__tile {
    min-height: 60px;
    grid-template-columns: auto 1fr; align-items: center; align-content: center; gap: 10px;
    padding: 10px 12px;
  }
  .ifep-mm .ifep-mm__tile--drill,
  .ifep-mm .ifep-mm__tile--wide { grid-template-columns: auto 1fr auto; }
  .ifep-mm .ifep-mm__tile--wide { min-height: 56px; }
  .ifep-mm__tile svg { width: 24px; height: 24px; }
  .ifep-mm__tile .ifep-mm__more { position: static; width: 18px; height: 18px; }
  .ifep-mm__ask { font-size: 20px; padding-top: 14px; }
}
/* Per sota de 620 px d'alçada (p. ex. iPhone SE amb la barra del navegador) */
@media (max-height: 619px) {
  .ifep-mm { --ifep-mm-bar-h: 56px; }
  .ifep-mm__field { height: 42px; }
  .ifep-mm__search { padding-top: 10px; }
  .ifep-mm__ask { font-size: 18px; padding-top: 10px; }
  .ifep-mm__tiles { gap: 6px; padding-top: 8px !important; }
  .ifep-mm .ifep-mm__tile { min-height: 50px; padding: 8px 10px; font-size: 15px; }
  .ifep-mm .ifep-mm__tile--wide { min-height: 50px; }
  .ifep-mm__tile--wide small { display: none; }
  .ifep-mm__sep { margin-top: 10px; }
  .ifep-mm__secondary { gap: 6px; padding-top: 10px !important; }
  .ifep-mm__secondary a { min-height: 42px; font-size: 15px; }
  .ifep-mm__help { padding-top: 10px !important; font-size: 14px; }
  .ifep-mm__foot { padding-top: 8px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .ifep-mm__btn { min-height: 46px; }
}

/* Sense animacions si l'usuari ho ha demanat */
@media (prefers-reduced-motion: reduce) {
  .ifep-mm,
  .ifep-mm__level,
  .ifep-mm__tile { transition: none !important; }
}

/* ---------- Botó hamburguesa de la capçalera (mòdul Codi de Divi) ---------- */
.ifep-burger {
  /* width: 44px !important;
  height: 44px !important; */
  display: inline-grid !important;
  place-items: center;
  padding: 0 !important;
  margin: 0;
  border: 0 !important;
  border-radius: 10px;
  background: transparent !important;
  color: #043EA7;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.ifep-burger:hover { background: #F3F5FA !important; }
.ifep-burger:focus-visible { outline: 3px solid #043EA7; outline-offset: 2px; }
.ifep-burger svg { width: 26px; height: 26px; display: block; }
