/* ==========================================================================
   Sous-menu « Nos agents » de l'en-tête (design v3, maquette « mega ») : inc/header-mega.php.
   Une carte blanche sous l'en-tête, sur sa largeur : trois familles de métiers, puis la carte « Un besoin
   précis ? » et les pages par métier. Ouverte au survol ou au clavier (focus) de « Nos agents ».
   Ordinateur seulement : à 1024 px et moins, le menu mobile garde la liste du menu WordPress.
   ========================================================================== */

.agentsia-mega { display: none; }

/* ===== Barre blanche de l'en-tête (maquette « Nav sticky ») =====
   Une carte blanche (coins 4 px, filet) derrière le logo, le menu et les boutons : elle apparaît dès qu'on fait
   défiler la page (.is-scrolled, posé par header-mega.js) et quand le sous-menu « Nos agents » est ouvert. L'en-tête
   perd alors sa crème translucide : seule la carte reste, comme dans la maquette ; le logo se réduit un peu. */
.agentsia-header-container { position: relative; isolation: isolate; }
.agentsia-header-container::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 14px;
  right: 14px;
  height: 60px;
  box-sizing: border-box;
  border: 1px solid rgb(0 0 0 / .1);
  border-radius: var(--r-card, 4px);
  background: #fff;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity .5s cubic-bezier(.16, 1, .3, 1);
  pointer-events: none;
}
.agentsia-header { transition: background-color .5s cubic-bezier(.16, 1, .3, 1), -webkit-backdrop-filter .5s, backdrop-filter .5s; }
/* En haut de page, l'en-tête est transparent (le fond de la page, ou le bandeau coloré d'une page agent, passe
   dessous) ; dès qu'on défile, la carte blanche prend le relais. */
.agentsia-header:not(.is-scrolled) { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.agentsia-header.is-scrolled {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.agentsia-header.is-scrolled .agentsia-header-container::before { opacity: 1; }
.agentsia-header-container > .wp-block-image img { transform-origin: 0 50%; transition: scale .7s cubic-bezier(.16, 1, .3, 1); }
.agentsia-header.is-scrolled .agentsia-header-container > .wp-block-image img { scale: .79; }
@media (max-width: 1024px) {
  .agentsia-header-container::before { left: 10px; right: 10px; height: calc(100% - 16px); }
}
@media (prefers-reduced-motion: reduce) {
  .agentsia-header, .agentsia-header-container::before, .agentsia-header-container > .wp-block-image img { transition: none; }
}

@media (min-width: 1025px) {
  .agentsia-header-container { position: relative; }
  .agentsia-nav-menu > li.agentsia-has-mega { position: static; }
  /* Passerelle de survol : sous le lien « Nos agents », jusqu'à la carte (l'en-tête laisse environ 24 px entre
     les deux). Sans elle, la souris sortait de l'élément en descendant et le sous-menu se refermait. */
  .agentsia-nav-menu > li.agentsia-has-mega > a { position: relative; }
  .agentsia-nav-menu > li.agentsia-has-mega > a::before {
    content: "";
    position: absolute;
    left: -16px;
    right: -16px;
    top: 100%;
    height: 40px;
  }

  /* Ouvert : la barre du menu prend sa carte blanche (voir « Barre blanche » plus haut), le lien se souligne
     et sa flèche se retourne. */
  .agentsia-header-container:has(.agentsia-has-mega:is(:hover, .is-open, :focus-within))::before { opacity: 1; }
  /* Voile sombre sur la page derrière le sous-menu ouvert (maquette : noir 14 %), sans bloquer la souris. */
  .agentsia-header-container::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background: rgb(26 26 26 / .14);
    opacity: 0;
    pointer-events: none;
    transition: opacity .5s cubic-bezier(.16, 1, .3, 1);
  }
  .agentsia-header-container:has(.agentsia-has-mega:is(:hover, .is-open, :focus-within))::after { opacity: 1; }

  /* Flèche : le chevron de la maquette (au lieu du caractère « ⌄ »), qui pivote à l'ouverture */
  .agentsia-nav-menu > li.agentsia-has-mega > a::after {
    content: "";
    width: 16px;
    height: 16px;
    margin-left: 4px;
    opacity: 1;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5' stroke='%23000' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5' stroke='%23000' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transform: none;
    transition: transform .35s cubic-bezier(.16, 1, .3, 1);
  }
  .agentsia-nav-menu > li.agentsia-has-mega:is(:hover, .is-open, :focus-within) > a::after { transform: rotate(180deg); }

  /* Soulignement du lien ouvert (1 px, qui se trace de gauche à droite) */
  .agentsia-nav-menu > li.agentsia-has-mega > a {
    background: linear-gradient(currentColor, currentColor) left calc(100% + 0px) / 0 1px no-repeat;
    transition: background-size .5s cubic-bezier(.16, 1, .3, 1);
  }
  .agentsia-nav-menu > li.agentsia-has-mega:is(:hover, .is-open, :focus-within) > a { background-size: 100% 1px; }
  /* La liste WordPress reste dans la page (menu mobile), mais pas sur ordinateur. */
  .agentsia-nav-menu > li.agentsia-has-mega > .sub-menu { display: none; }

  .agentsia-mega {
    --mega-ease: cubic-bezier(.16, 1, .3, 1);
    position: absolute;
    z-index: 1000;
    top: calc(50% + 32px); /* sous la barre blanche (60 px centrés), 8 px d'écart avec la carte */
    left: 14px;
    right: 14px;
    display: block;
    padding-top: 6px; /* passerelle de survol entre la barre et la carte */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity .35s var(--mega-ease), transform .5s var(--mega-ease), visibility 0s linear .35s;
  }
  .agentsia-nav-menu > li.agentsia-has-mega:hover > .agentsia-mega,
  .agentsia-nav-menu > li.agentsia-has-mega.is-open > .agentsia-mega,
  .agentsia-nav-menu > li.agentsia-has-mega:focus-within > .agentsia-mega {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: opacity .35s var(--mega-ease), transform .5s var(--mega-ease), visibility 0s;
  }

  .agentsia-mega__in {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) 220px;
    gap: 24px;
    align-items: start;
    padding: 24px 24px 24px 0;
    border: 1px solid rgb(0 0 0 / .1);
    border-radius: var(--r-card, 4px);
    background: #fff;
    text-align: left;
  }
  .agentsia-mega__col { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding-left: 24px; border-left: 1px solid #efeee9; }
  .agentsia-mega__col:first-child { border-left-color: transparent; }
  .agentsia-mega__col--pro { align-self: stretch; padding-left: 0; border-left: 0; }
  .agentsia-mega__h { display: flex; flex-direction: column; gap: 2px; }
  .agentsia-mega__k { font-size: var(--fs-kicker, 10px); font-weight: 700; line-height: 1.4; letter-spacing: .02em; text-transform: uppercase; color: var(--ink); }
  .agentsia-mega__h b { font-family: var(--display); font-size: var(--fs-h5, 20px); font-weight: 400; line-height: 1.2; letter-spacing: -0.4px; color: var(--ink); }

  .agentsia-mega__cards { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
  .agentsia-nav-menu .agentsia-mega a,
  .agentsia-mega__a {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-start;
    min-height: 0;
    padding: 6px 8px;
    border-radius: var(--r-card, 4px);
    background: none;
    box-shadow: none;
    font-size: inherit;
    font-weight: 400;
    color: var(--ink);
    text-decoration: none;
    transition: background-color .25s var(--mega-ease);
  }
  @media (hover: hover) { .agentsia-nav-menu .agentsia-mega a.agentsia-mega__a:hover { background: #f5f4ee; color: var(--ink); } }
  .agentsia-mega__v { position: relative; flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: var(--r-card, 4px); background: linear-gradient(180deg, var(--c1, #f3f3e7), var(--c2, #f3f3e7)); }
  .agentsia-mega__v img { position: absolute; left: -6%; top: -31%; width: 112%; max-width: none; height: auto; }
  .agentsia-mega__a > span { display: flex; flex-direction: column; min-width: 0; }
  .agentsia-mega__a b { font-size: var(--fs-sm, 14px); font-weight: 500; line-height: 1.3; letter-spacing: -0.02em; }
  .agentsia-mega__a i { font-size: var(--fs-xs, 12px); font-style: normal; line-height: 1.35; color: var(--text-2); }
  .agentsia-mega__go { flex: none; width: 16px; height: 16px; margin-left: auto; margin-right: 4px; opacity: 0; transform: translateX(-6px); transition: opacity .3s var(--mega-ease), transform .4s var(--mega-ease); }
   .agentsia-mega a:focus-visible .agentsia-mega__go { opacity: 1; transform: none; }
@media (hover: hover) { .agentsia-mega a:hover .agentsia-mega__go { opacity: 1; transform: none; } }

  /* Carte « Un besoin précis ? » */
  .agentsia-nav-menu .agentsia-mega a.agentsia-mega__promo {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    min-height: 260px;
    height: 100%;
    padding: 18px;
    overflow: hidden;
    border-radius: var(--r-card, 4px);
    background: #1a1a1a;
    color: #fff;
  }
  .agentsia-mega__promo-t { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
  .agentsia-mega__promo-t b { font-family: var(--display); font-size: var(--fs-h5, 20px); font-weight: 400; line-height: 1.2; letter-spacing: -0.4px; }
  .agentsia-mega__promo-t span { font-size: var(--fs-xs, 12px); line-height: 1.4; color: rgb(255 255 255 / .7); }
  /* L'agent reste en bas à droite, derrière le texte : sa hauteur suit celle de la carte (66 %), sa largeur en
     découle, pour ne jamais monter jusqu'au titre ni passer sous « Nous écrire ». */
  .agentsia-mega__promo img { position: absolute; z-index: 0; right: -8%; bottom: 0; width: auto; height: 66%; max-width: 62%; object-fit: contain; object-position: 100% 100%; transition: transform .6s var(--mega-ease); }
  @media (hover: hover) { .agentsia-mega__promo:hover img { transform: translateY(-4%); } }
  .agentsia-mega__promo-go { position: relative; z-index: 2; display: inline-flex; gap: 6px; align-items: center; font-size: var(--fs-sm, 14px); }

  /* Pages par métier */
  .agentsia-nav-menu .agentsia-mega a.agentsia-mega__lp {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
    align-items: center;
    margin-top: 8px;
    padding: 14px 16px;
    background: #fafaf5;
  }
  @media (hover: hover) { .agentsia-nav-menu .agentsia-mega a.agentsia-mega__lp:hover { background: #efeee9; } }
  .agentsia-mega__lp .agentsia-mega__k { grid-column: 1; color: var(--text-2); }
  .agentsia-mega__lp b { grid-column: 1; font-size: var(--fs-body, 16px); font-weight: 500; }
  .agentsia-mega__lp .agentsia-mega__go { grid-column: 2; grid-row: 1 / 3; margin: 0; opacity: 1; transform: none; }

  /* Bas de carte : tous les agents */
  .agentsia-mega__more { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; margin-left: 24px; padding-top: 14px; border-top: 1px solid #efeee9; font-size: var(--fs-sm, 14px); color: var(--text-2); }
  .agentsia-nav-menu .agentsia-mega .agentsia-mega__more a { display: inline-flex; gap: 6px; padding: 0; color: var(--ink); }
  .agentsia-mega__more .agentsia-mega__go { width: 14px; height: 14px; margin: 0; opacity: 1; transform: none; transition: transform .35s var(--mega-ease); }
  @media (hover: hover) { .agentsia-mega__more a:hover .agentsia-mega__go { transform: translateX(3px); } }
}
@media (prefers-reduced-motion: reduce) {
  .agentsia-mega, .agentsia-mega * { transition: none !important; }
}
