/* ==========================================================================
   HEADER - Refonte nav 2 niveaux
   ========================================================================== */

.tfd-header {
    position: relative;
    /* Réserve la place laissée vide par .tfd-header__sticky-wrap en position:fixed
       (sorti du flux normal), pour que le hero ne remonte pas se cacher dessous.
       109px = hauteur mesurée des 2 barres de nav ; à ajuster si leur contenu change. */
    height: 109px;
}

/* Mode dépôt d'annonce : une seule barre (logo + Exit), hauteur plus courte.
   65px est une estimation à ajuster une fois visible en réel, même logique
   que le 109px ci-dessus. */
.tfd-header--minimal {
    height: 65px;
}

.tfd-header__minimal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
}

.tfd-header__exit-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 20px;
    border: 1px solid #ddd;
    border-radius: 24px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.tfd-header__exit-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* .site-container (thème parent / bundle tiers) porte overflow:hidden — sans
   incidence directe sur position:fixed, mais gardé par prudence. */
.site-container {
    overflow: visible !important;
}

.tfd-header__sticky-wrap {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border-bottom: 1px solid #eee;
}

/* --------------------------------------------------------------------------
   Barre principale
   -------------------------------------------------------------------------- */

.tfd-header__primary {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 24px;
}

.tfd-header__logo {
    justify-self: start;
}

.tfd-header__logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.tfd-header__logo-name {
    font-weight: 700;
    font-size: 22px;
    color: #222;
}

.tfd-header__cta-wrap {
    justify-self: center;
}

.tfd-header__actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 20px;
}

.tfd-header__icon-link,
.tfd-header__account-trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: #444;
    text-decoration: none;
    font: inherit;
    padding: 0;
}

/* La classe hp-link (conservée pour le JS HivePress) porte un style de survol
   natif qui prenait le pas sur le nôtre (Sign In devenait jaune au survol).
   On resserre la spécificité pour reprendre la main sur cet élément précis. */
.tfd-header__icon-link:hover,
.tfd-header__account-trigger:hover {
    color: var(--primary);
}

.tfd-header__actions .tfd-header__icon-link.hp-link:hover {
    color: var(--primary);
}

.tfd-header__actions .tfd-header__icon-link.hp-link:hover .tfd-header__icon,
.tfd-header__actions .tfd-header__icon-link.hp-link:hover .tfd-header__icon-label {
    color: var(--primary);
}

.tfd-header__icon {
    font-size: 18px;
}

.tfd-header__icon-label {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* Dropdown compte */

.tfd-header__account {
    position: relative;
}

.tfd-header__account-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    display: none;
    flex-direction: column;
    min-width: 180px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 8px 0;
    z-index: 50;
}

.tfd-header__account-panel.is-open {
    display: flex;
}

.tfd-header__account-panel a {
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
}

.tfd-header__account-panel a:hover {
    background: #f7f7f7;
    color: var(--primary);
}

/* Bouton Post an ad */

.tfd-header__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.tfd-header__cta i {
    font-size: 12px;
}

.tfd-header__cta:hover {
    background: var(--hover);
}

/* Burger (masqué sur desktop) */

.tfd-header__burger {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: #333;
    cursor: pointer;
    padding: 0;
}

/* --------------------------------------------------------------------------
   Barre secondaire (catégories)
   -------------------------------------------------------------------------- */

.tfd-header__secondary {
    border-top: 1px solid #f0f0f0;
}

.tfd-header__categories {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    list-style: none;
}

.tfd-header__category {
    position: static;
}

/* Annule margin-bottom: .5rem imposé par une règle générique tierce
   (ol/ul li:not(:last-child), specificité 0,1,2) qui n'exclut pas notre nav.
   Ancré sur .tfd-header__categories pour obtenir une specificité de 0,2,0,
   supérieure à la règle tierce sans recourir à !important. */
.tfd-header__categories > .tfd-header__category {
    margin-bottom: 0;
}

.tfd-header__category > a {
    display: inline-block;
    padding: 12px 0;
    color: #444;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.tfd-header__category > a:hover {
    color: var(--primary);
}

/* Mega panel */

.tfd-header__mega-panel {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 980px;
    display: none;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 28px;
    z-index: 50;
}

.tfd-header__category.is-open .tfd-header__mega-panel {
    display: block;
}

.tfd-mega__top-link {
    display: block;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
    color: #555;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.tfd-mega__top-link:hover {
    color: var(--primary);
}

.tfd-mega__columns {
    display: flex;
    gap: 32px;
}

.tfd-mega__column {
    flex: 1;
    min-width: 160px;
}

.tfd-mega__column-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 700;
    color: #222;
}

.tfd-mega__column-title i {
    font-size: 14px;
    color: #666;
}

.tfd-mega__group {
    margin-top: 20px;
}

.tfd-mega__group:first-of-type {
    margin-top: 0;
}

.tfd-mega__group-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: #222;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.tfd-mega__link-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tfd-mega__column .tfd-mega__link-list li {
    margin-bottom: 0;
}

.tfd-mega__link-list li a {
    display: block;
    padding: 6px 0;
    color: #555;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
}

.tfd-mega__link-list li a:hover {
    color: var(--primary);
}

.tfd-mega__link-list--strong li a {
    color: #333;
    font-weight: 600;
}

.tfd-mega__link-list li a.tfd-mega__more-link {
    color: var(--primary);
    font-weight: 600;
    margin-top: 2px;
}

.tfd-header__more-panel {
    position: absolute;
    top: 100%;
    right: 0;
    display: none;
    min-width: 240px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 16px;
    z-index: 50;
}

.tfd-header__category--more {
    position: relative;
}

.tfd-header__category--more.is-open .tfd-header__more-panel {
    display: block;
}

/* --------------------------------------------------------------------------
   Menu mobile (fallback V1 - panneau plein écran type Leboncoin)
   -------------------------------------------------------------------------- */

.tfd-header__mobile-menu {
    display: none;
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 100;
    overflow-y: auto;
    padding: 24px;
}

.tfd-header__mobile-menu.is-open {
    display: block;
}

/* Page figée derrière le panneau ouvert (classe posée par header-nav.js). */
html.tfd-menu-open {
    overflow: hidden;
}

/* En-tête du panneau : titre + bouton de fermeture (le burger est couvert). */
.tfd-header__mobile-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tfd-header__mobile-title {
    font-size: 18px;
    font-weight: 700;
    color: #202A35;
}

.tfd-header__mobile-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #E3E5E8;
    border-radius: 50%;
    background: #fff;
    color: #202A35;
    font-size: 18px;
    cursor: pointer;
}

.tfd-header__mobile-close:hover,
.tfd-header__mobile-close:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
}

.tfd-header__mobile-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 14px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 20px;
}

.tfd-header__mobile-categories,
.tfd-header__mobile-account {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tfd-header__mobile-menu .tfd-header__mobile-categories li,
.tfd-header__mobile-menu .tfd-header__mobile-account li {
    margin-bottom: 0;
}

.tfd-header__mobile-categories li a {
    display: block;
    padding: 14px 0;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.tfd-header__mobile-account li a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.tfd-header__mobile-account li a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: #666;
}

.tfd-header__mobile-separator {
    border: none;
    border-top: 1px solid #eee;
    margin: 16px 0;
}

/* --------------------------------------------------------------------------
   Responsive - bascule desktop / mobile à 768px
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {

    /* Reserve de hauteur reduite : la barre secondaire est masquee ci-dessous,
       il ne reste que la barre principale. Valeur a confirmer en DevTools sur
       le rendu reel, meme logique que le 109px du mode desktop. */
    .tfd-header {
        height: 57px;
    }

    .tfd-header__icon-label {
        display: none;
    }

    .tfd-header__secondary {
        display: none;
    }

    .tfd-header__burger {
        display: inline-flex;
    }

    .tfd-header__primary {
        display: flex;
        justify-content: space-between;
        padding: 12px 16px;
    }

    .tfd-header__actions > .tfd-header__icon-link,
    .tfd-header__actions > .tfd-header__account {
        display: none;
    }

    .tfd-header__cta-wrap {
        display: none;
    }
}
/* =========================
   Badge de non-lus (messagerie, lot 4) : rempli par tfd-core/assets/js/tfd-message-badge.js
   après chargement, jamais écrit dans le HTML (compatible cache). Rouge comme le badge
   natif du menu compte. Caché (attribut hidden) tant que le compteur vaut 0.
========================= */

.tfd-header__icon-link {
    position: relative;
}

.tfd-header__badge {
    position: absolute;
    top: -6px;
    left: calc(50% + 4px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e5383b;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.tfd-header__badge--inline {
    position: static;
    margin-left: 6px;
    vertical-align: middle;
}

/* hidden (compteur à 0) doit gagner sur le display: inline-flex ci-dessus. */
.tfd-header__badge[hidden] {
    display: none;
}

/* =====================================================================
   AUTHENTIFICATION DANS L'APP (AppMySite) — chantier B
   tfd-core pose html.tfd-app quand navigator.userAgent porte la signature
   AppMySite, et ajoute dans l'en-tête des formulaires HivePress Sign In,
   Forgot password et Register un bloc .tfd-app-auth porteur de l'attribut
   hidden. Hors app : rien ne change, le bloc n'existe pas à l'écran.
   Dans l'app : tout le formulaire est masqué sauf ce bloc (champs, bouton,
   liens Register / Forgot password, boutons sociaux .hp-social-links qui
   vivent dans le même en-tête). Le titre natif de la modale (h3.hp-modal__title)
   et le titre de la page /account/login/ sont hors du <form> : ils restent.
   Register (2026-11-03, child 0.7.84, tfd-core 1.0.51) : ajouté une fois
   l'inscription native AppMySite validée de bout en bout (source version
   2.14.4) : docs/appmysite-favoris/compte-rendu-2026-10-26.md §4.4.
   Cette feuille est chargée sur toutes les pages : les modales de connexion
   sont dans chaque page anonyme.
   ===================================================================== */

html.tfd-app .hp-form--user-login > :not(.hp-form__header),
html.tfd-app .hp-form--user-password-request > :not(.hp-form__header),
html.tfd-app .hp-form--user-register > :not(.hp-form__header),
html.tfd-app .hp-form--user-login .hp-form__header > :not(.tfd-app-auth),
html.tfd-app .hp-form--user-password-request .hp-form__header > :not(.tfd-app-auth),
html.tfd-app .hp-form--user-register .hp-form__header > :not(.tfd-app-auth) {
    display: none;
}

/* Révélation du bloc : [hidden] ne perd que sous html.tfd-app (règle du
   dépôt : toujours une règle [hidden] à côté d'un display). */
html.tfd-app .tfd-app-auth[hidden] {
    display: block;
}

.tfd-app-auth {
    padding: 8px 0 4px;
    text-align: center;
}

.tfd-app-auth__title {
    margin: 0 0 6px;
    font-size: 1.1em;
    font-weight: 600;
    color: #222;
}

.tfd-app-auth__text {
    margin: 0;
    color: #666;
    line-height: 1.5;
}

/* --- Lot 2 (2026-10-26) : dans l'app, la connexion passe par My Account en
   bas de l'écran. Le lien « Sign In » du header et du panneau mobile n'a
   donc pas lieu d'être ; les modales informatives restent sur les actions
   protégées (cœur, Send message, Rate this seller, téléphone). --- */
html.tfd-app .tfd-header__icon-link[href="#user_login_modal"],
html.tfd-app .tfd-header__mobile-account li:has(> a[href="#user_login_modal"]),
html.tfd-app .tfd-header__mobile-account a[href="#user_login_modal"] {
    display: none;
}

/* --- Déconnexion web masquée dans l'app (2026-11-11, child 0.7.90, campagne
   mobile point 3). Dans l'app, la session vit à deux endroits : la session
   native AppMySite et les cookies WordPress que l'app pose dans la WebView.
   Un « Sign Out » web détruit les seconds sans toucher la première : le
   Profile natif reste « connecté », sans bouton de login, et les pages du
   site redeviennent anonymes ; seul remède, Logout puis Login natifs. Dans
   l'app, la déconnexion passe donc par le Profile natif (My Account en bas
   de l'écran), et tous les liens de déconnexion web sont masqués sous
   html.tfd-app. Rien ne change sur le web. Les quatre emplacements :
   1. burger (template-parts/header/mobile-menu.php), wp_logout_url() ;
   2. menu déroulant My account du header (primary-bar.php), affiché
      au-dessus de 900px : tablette, téléphone en paysage ;
   3. item user_logout du menu de compte HivePress (sidebar des pages de
      compte, dès 768px), route /account/logout/ ;
   4. entrée customer-logout du menu WooCommerce natif, sur les pages
      Payment methods et Add payment method (atteintes par URL ou par un
      retour Stripe).
   Sélecteur sur l'adresse pour 1 et 2 (action=logout, que wp_logout_url()
   pose quelle que soit l'URL de connexion), même patron que Sign In
   ci-dessus ; sur la classe native pour 3 et 4. Masquage visuel seulement :
   aucune logique d'authentification n'est modifiée, les URL restent
   valides. Cette feuille est chargée sur toutes les pages, pages de compte
   et pages WooCommerce comprises. --- */
html.tfd-app .tfd-header__mobile-account li:has(> a[href*="action=logout"]),
html.tfd-app .tfd-header__mobile-account a[href*="action=logout"],
html.tfd-app .tfd-header__account-panel a[href*="action=logout"],
html.tfd-app .hp-menu__item--user-logout,
html.tfd-app .woocommerce-MyAccount-navigation-link--customer-logout {
    display: none;
}

/* --- Lot 2 : sur la page /account/login/ (hors modale), le bloc était nu
   sous le titre en grand écran ; il prend un cadre et de l'air. --- */
@media (min-width: 768px) {
    html.tfd-app .hp-page__content .hp-form .tfd-app-auth[hidden] {
        display: block;
        margin: 8px auto 0;
        padding: 28px 24px;
        border: 1px solid #e6e6e6;
        border-radius: 8px;
        background: #fff;
    }
}

/* --- Compte non vérifié (2026-10-26) : la barrière de session de tfd-core
   refuse le cookie d'un compte dont l'email n'est pas vérifié et pose
   body.tfd-unverified. Dans l'app, le bloc dit alors « Activate your
   account » au lieu de « Sign in from the app ». --- */
html.tfd-app body.tfd-unverified .tfd-app-auth__title:not(.tfd-app-auth__title--unverified),
html.tfd-app body.tfd-unverified .tfd-app-auth__text:not(.tfd-app-auth__text--unverified) {
    display: none;
}

html.tfd-app body.tfd-unverified .tfd-app-auth__title--unverified[hidden],
html.tfd-app body.tfd-unverified .tfd-app-auth__text--unverified[hidden] {
    display: block;
}
