/*
 * AlterMegaMenu – front styles
 *
 * Objectif : reproduire le rendu du legacy ETS Megamenu (cards / icon tiles / logos)
 * mais avec un CSS isolé, lisible et maintenable.
 *
 * Tout est namespacé sous #altermegamenu.am et ses classes .am__*.
 */

/* ---------- tokens ---------- */
#altermegamenu.am {
  --am-bg: #fff;
  --am-muted: rgba(0, 0, 0, 0.65);
  --am-radius: 12px;
  --am-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  --am-gap: 18px;
  --am-border: rgba(0, 0, 0, 0.08);
  --am-accent: #151515;
  position: relative;
}

/* body lock when mobile drawer is open */
body.am-body-locked {
  overflow: hidden;
}

/* offcanvas shell is present in markup but hidden on desktop */
.am__backdrop,
.am__drawerHeader {
  display: none;
}

.am__drawerClose {
  border: 0;
  background: transparent;
  width: 44px;
  height: 44px;
  cursor: pointer;
  position: relative;
}

.am__drawerClose::before,
.am__drawerClose::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  background: #111;
  transform-origin: center;
}

.am__drawerClose::before { transform: translate(-50%, -50%) rotate(45deg); }
.am__drawerClose::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* Barre top-level (peut être surchargée côté thème) */


/* ---------- root ---------- */
.am__root {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 22px;
  align-items: center;
}

.am__rootItem {
  position: relative;
}

.am__rootLink {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  text-decoration: none;
  color: #fff;
  font-weight: 500;
  font-size: 16px;

}

.am__rootLink:hover,
.am__rootItem.is-open > .am__rootLink {
  color: #fff;
  opacity: 0.95;
}

.am__toggle {
  display: none;
}

/* ---------- panel ---------- */
.am__panel {
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 1100;
  width: max-content;
  min-width: 620px;
  max-width: min(1100px, 92vw);
  background: var(--am-bg);
  border-radius: var(--am-radius);
  box-shadow: var(--am-shadow);
}

/* Lot D D.0.1 — kill horizontal scroll caused by closed panels rendered
   with width=1264 at x=292 (right edge 1556 > viewport 1440). visibility:
   hidden + max-height:0 + overflow:hidden was insufficient — the panel's
   width property still computed at max-content so getBoundingClientRect
   kept returning width=1264 and the document scrollWidth stayed at 1564.
   display:none removes from layout entirely. The .is-open state (added
   by altermegamenu.js openPanel) lifts this rule so the panel renders
   at its natural size for the clampPanelToViewport calculation. */
.am__rootItem:not(.is-open) > .am__panel {
  display: none;
}

.am__panelInner {
  padding: 18px;
}

.am__columns {
  display: flex;
  flex-wrap: wrap;
  gap: var(--am-gap);
}

.am__col {
  min-width: 220px;
}

.am__col--3 { width: calc(25% - var(--am-gap)); }
.am__col--4 { width: calc(33.333% - var(--am-gap)); }
.am__col--6 { width: calc(50% - var(--am-gap)); }
.am__col--8 { width: calc(66.666% - var(--am-gap)); }
.am__col--12 { width: 100%; }

.am__block { margin: 0; }

.amm__block_title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--am-accent);
}

.amm__block_title a {
  color: inherit;
  text-decoration: none;
}

.amm__block_title a:hover {
  text-decoration: underline;
}

/* ---------- simple links list ---------- */
.am__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.am__list a {
  color: var(--am-accent);
  text-decoration: none;
  font-weight: 600;
}

.am__list a:hover {
  color: #000;
  text-decoration: underline;
}

/* ---------- cards (legacy: pinned images) ---------- */
.am__cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.am__card {
  position: relative;
  display: block;
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
}

.am__cardImg {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.am__cardLabel {
  position: absolute;
  left: 12px;
  bottom: 10px;
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 16px;
  line-height: 1.05;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.45);
}

/* ---------- icon tiles ---------- */
.am__tiles {
  display: grid;
  gap: 12px;
}

.am__tile {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--am-accent);
  font-weight: 700;
}

.am__tileImg {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
}

.am__tileLabel {
  font-size: 14px;
  font-weight: 700;
}

.am__tile:hover { color: #000; }

/* ---------- brand logos ---------- */
.am__logos {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
}

.am__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
}

.am__logo img {
  max-width: 100%;
  max-height: 34px;
  display: block;
}
button#menu-icon:focus,button.am__drawerClose:focus{outline: none}

/* ---------- two columns list (legacy: 10ML / 50ML) ---------- */
.am__twolists {
  display: flex;
  gap: 14px;
}

.am__twolists_col { flex: 1; }

.am__twolists_title {
  font-weight: 900;
  margin-bottom: 6px;
}

.am__twolists ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.am__twolists a {
  color: var(--am-accent);
  text-decoration: none;
  font-weight: 600;
}

.am__twolists a:hover { text-decoration: underline; }

/* ---------- header container: transparent on desktop ---------- */
@media (min-width: 992px) {
  .am-header-top {
    background: transparent;
  }
}

/* ---------- mobile ---------- */
@media (max-width: 991px) {
  /* offcanvas behaviour */
  #altermegamenu.am {
    background: transparent;
    position: fixed;
    inset: 0;
    z-index: 20000;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
  }

  #altermegamenu.am.am--mobileOpen {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.2s ease;
  }

  .am__backdrop {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(0, 0, 0, 0.55);
  }

  .am__drawer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 340px;
    max-width: 86vw;
    background: #fff;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 18px 22px;
  }

  #altermegamenu.am.am--mobileOpen .am__drawer {
    transform: translateX(0);
  }

  .am__drawerHeader {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0 6px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
  }

  .am__drawerTitle {
    font-weight: 900;
    font-size: 16px;
    color: #111;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .am__drawerSearch {
    margin: 10px 0 12px;
  }

  .am__root {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 0 0;
  }

  .am__rootLink {
    color: var(--am-accent);
    text-transform: none;
    font-weight: 800;
    padding: 14px 46px 14px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  }

  .am__toggle {
    display: inline-flex;
    position: absolute;
    right: 0;
    top: 6px;
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    cursor: pointer;
  }

  .am__toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(0, 0, 0, 0.75);
    border-bottom: 2px solid rgba(0, 0, 0, 0.75);
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .am__toggle[aria-expanded="true"]::after {
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .am__panel {
    position: static;
    width: 100%;
    min-width: 0;
    max-width: none;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
  }

  .am__panelInner { padding: 10px 0 16px; }
  .am__columns { gap: 14px; }

  .am__col--3,
  .am__col--4,
  .am__col--6,
  .am__col--8 {
    width: 100%;
  }

  .am__logos { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .am__cardImg { height: 130px; }
}
/* bouton */
.am-burger--morph{
  width:44px;
  height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border:0;
  background:transparent;
  color:#fff;                 /* stroke = currentColor */
  cursor:pointer;
  -webkit-tap-highlight-color: transparent;
}

.am-burger--morph:focus-visible{
  outline:2px solid rgba(255,255,255,.85);
  outline-offset:3px;
  border-radius:6px;
}

/* svg */
.am-burger__svg{
  width:32px;
  height:32px;
  display:block;
  transition: transform 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.am-burger__g path{
  fill: none;
  stroke: currentColor;
  transition:
          transform 500ms cubic-bezier(0.4, 0, 0.2, 1),
          stroke-dasharray 500ms cubic-bezier(0.4, 0, 0.2, 1),
          stroke-dashoffset 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* origines (comme ton exemple) */
.am-burger__g path:nth-child(1){ transform-origin: 36% 40%; }
.am-burger__g path:nth-child(2){ stroke-dasharray: 29 299; }
.am-burger__g path:nth-child(3){ transform-origin: 35% 63%; }
.am-burger__g path:nth-child(4){ stroke-dasharray: 29 299; }
.am-burger__g path:nth-child(5){ transform-origin: 61% 52%; }
.am-burger__g path:nth-child(6){ transform-origin: 62% 52%; }

/* état ouvert : on se base sur aria-expanded => pas besoin de class JS */
#menu-icon[aria-expanded="true"] .am-burger__svg{
  transform: rotate(90deg);
}

#menu-icon[aria-expanded="true"] .am-burger__g path:nth-child(1){
  transform: translateX(9px) translateY(1px) rotate(45deg);
}
#menu-icon[aria-expanded="true"] .am-burger__g path:nth-child(2){
  stroke-dasharray: 225 299;
  stroke-dashoffset: -72px;
}
#menu-icon[aria-expanded="true"] .am-burger__g path:nth-child(3){
  transform: translateX(9px) translateY(1px) rotate(-45deg);
}
#menu-icon[aria-expanded="true"] .am-burger__g path:nth-child(4){
  stroke-dasharray: 225 299;
  stroke-dashoffset: -72px;
}
#menu-icon[aria-expanded="true"] .am-burger__g path:nth-child(5){
  transform: translateX(9px) translateY(1px) rotate(-45deg);
}
#menu-icon[aria-expanded="true"] .am-burger__g path:nth-child(6){
  transform: translateX(9px) translateY(1px) rotate(45deg);
}

/* accessibilité perf */
@media (prefers-reduced-motion: reduce){
  .am-burger__svg,
  .am-burger__g path{
    transition: none !important;
  }
}