/* ==========================================================================
   MISSA — header only
   Scoped strictly to the site header (and its hamburger drawer). Colors
   pulled from the MISSA logo: blue #0f70b7, red #e51b20, near-black ink.
   Layout: row 1 = menu | logo+poster | search | connexion
           row 2 = page title, full width
   Several rules re-declare what styleV4.css sets (.titre column layout,
   3em paddings, %-widths) so the legacy look can't leak through.
   ========================================================================== */

:root {
  --hdr-primary: #0f70b7;
  --hdr-primary-dark: #0b5690;
  --hdr-primary-soft: rgba(15, 112, 183, 0.12);
  --hdr-accent: #e51b20;
  --hdr-accent-dark: #b81318;
  --hdr-ink: #16181c;
  --hdr-ink-soft: #4b5563;
  --hdr-muted: #6b7280;
  --hdr-border: rgba(15, 112, 183, 0.18);
  --hdr-shadow: 0 10px 28px rgba(15, 23, 42, 0.13);
  --hdr-shadow-lg: 0 22px 50px rgba(15, 23, 42, 0.22);
  --hdr-radius: 16px;
  --hdr-radius-pill: 999px;
  --hdr-font: 'Inter', 'Segoe UI', sans-serif;
}

header, header * {
  font-family: var(--hdr-font);
  box-sizing: border-box;
}

/* ------------------------------ frame ------------------------------ */

header {
  display: grid;
  /* Single row on every page: the page title always sits between the logo
     (+ "Postez votre annonce") and the search ("Rechercher une annonce"). */
  grid-template-columns: auto auto minmax(0, 1.6fr) minmax(0, 1.3fr) 0.6fr;
  grid-template-areas: "menu logo titre search connexion";
  align-items: center;
  column-gap: 14px;
  row-gap: 4px;
  /* Near-opaque gradient instead of a translucent + blurred backdrop: a sticky
     element with backdrop-filter re-blurs everything behind it on every scroll
     frame, which is the main cause of header scroll lag. */
  background: linear-gradient(120deg, rgb(255, 255, 255), rgb(247, 250, 253));
  border: 1px solid rgba(15, 112, 183, 0.12);
  border-radius: var(--hdr-radius);
  box-shadow: var(--hdr-shadow);
  padding: 10px 16px;
  margin-bottom: 14px;
  position: sticky;
  top: 8px;
  z-index: 50;
}

/* ------------------------------ hamburger + drawer ------------------------------ */

header .menu {
  grid-area: menu;
  display: flex;
  align-items: center;
  width: auto; /* V4 sets 18% */
}

header #menu__toggle {
  display: none;
}

header .menu__btn {
  width: 42px;
  height: 42px;
  border-radius: var(--hdr-radius-pill);
  background: var(--hdr-primary-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 160ms ease;
}

header .menu__btn:hover {
  background: rgba(15, 112, 183, 0.2);
}

header .menu__btn > span,
header .menu__btn > span::before,
header .menu__btn > span::after {
  content: '';
  display: block;
  position: relative;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--hdr-primary-dark);
}

header .menu__btn > span::before {
  top: -6px;
}

header .menu__btn > span::after {
  top: 4px;
}

header .menu__box {
  position: fixed;
  top: 0;
  left: -105%;
  width: min(300px, 88vw);
  height: 100vh;
  margin: 0;
  padding: 24px 14px 20px;
  border-radius: 0 24px 24px 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(18px);
  box-shadow: var(--hdr-shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
  list-style: none;
  transition: left 220ms ease;
  z-index: 100;
}

header #menu__toggle:checked ~ .menu__box {
  left: 0;
}

header .menu__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 4px;
  border-radius: 14px;
  color: var(--hdr-ink-soft);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease;
}

header .menu__item i {
  color: var(--hdr-primary);
  width: 1.1em;
  text-align: center;
}

header .menu__item:hover {
  background: var(--hdr-primary-soft);
  color: var(--hdr-primary-dark);
}

/* ------------------------------ logo + poster / title rows ------------------------------ */

/* .titre wraps logo + nom-page in the template; display:contents lets its
   children sit directly on the header grid (logo row 1, title row 2). */
header .titre {
  display: contents;
}

header .titre .logo {
  grid-area: logo;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  margin: 0;
  text-align: center;
}

/* taglines stacked above the logo image */
header .titre .brand-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin: 0;
  min-width: 0;
}

header .titre .brand-lines .missa-nom {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--hdr-primary-dark);
  line-height: 1.3;
  text-align: center;
}

header .titre .brand-lines h1 {
  margin: 0;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hdr-muted);
  line-height: 1.3;
  text-align: center;
}

header .titre .logo-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 0;
}

header .titre img,
header .titre .logo img {
  width: 96px;
  height: 96px;
  min-width: 0;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  padding: 3px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
}

header .titre .nom-page {
  grid-area: titre;
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  text-align: center;
}

/* current page name: the main heading of the header (middle column) */
header .titre .nom-page h2 {
  margin: 2px 0 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--hdr-primary-dark);
  line-height: 1.25;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------ search ------------------------------ */

header .header-search {
  grid-area: search;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(100%, 380px);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--hdr-border);
  border-radius: var(--hdr-radius-pill);
  padding: 4px 5px 4px 14px;
  min-width: 0;
  margin: 0;
}

header .header-search__icon {
  color: var(--hdr-muted);
  font-size: 0.85rem;
}

header .header-search input {
  flex: 1 1 120px;
  min-width: 60px;
  width: auto;
  border: none;
  outline: none;
  background: transparent;
  box-shadow: none;
  font-size: 0.9rem;
  color: var(--hdr-ink);
  padding: 0.35rem 0;
  margin: 0;
}

header .header-search__btn {
  flex: 0 0 auto;
  margin: 0;
  border: none;
  border-radius: var(--hdr-radius-pill);
  padding: 0.38rem 0.85rem;
  font-weight: 700;
  font-size: 0.74rem;
  color: white;
  background: linear-gradient(135deg, var(--hdr-primary), var(--hdr-primary-dark));
  cursor: pointer;
  white-space: nowrap;
  transition: transform 160ms ease, filter 160ms ease;
}

header .header-search__btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

/* ------------------------------ account actions ------------------------------ */

header .connexion {
  grid-area: connexion;
  width: auto; /* V4 sets 20% */
  min-width: 0;
  display: flex;
  justify-content: flex-end;
}

/* Account actions laid out as a 2-column grid:
   mon_profil     | mon_groupe
   administration | déconnexion */
header .connexion-actions {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: flex-end;
  align-items: stretch;
  gap: 6px;
  padding: 0; /* V4 sets 1em on .connexion div */
}

header .connexion-actions .button,
header .connexion-actions .user-pill {
  width: 100%;
  justify-content: center;
}

/* Logged out (Connexion / Inscription): stack them in a single column. */
header .connexion .connexion-actions--stack {
  grid-template-columns: auto;
}

header .connexion .button,
header .titre .button {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin: 0;
  border: none;
  border-radius: var(--hdr-radius-pill);
  padding: 0.3rem 0.62rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--hdr-primary), var(--hdr-primary-dark));
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

/* kill styleV4's ::after sliding-overlay effect inside the header */
header .button::after {
  display: none;
}

header .connexion .button:hover,
header .titre .button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

header .titre .logo .button {
  background: linear-gradient(135deg, var(--hdr-accent), var(--hdr-accent-dark));
}

header .connexion .button.button--accent {
  background: linear-gradient(135deg, var(--hdr-accent), var(--hdr-accent-dark));
}

header .connexion .button.button--muted {
  background: rgba(75, 85, 99, 0.85);
}

header .user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.28rem 0.6rem;
  border-radius: var(--hdr-radius-pill);
  background: var(--hdr-primary-soft);
  color: var(--hdr-primary-dark);
  font-weight: 700;
  font-size: 0.7rem;
  text-decoration: none;
  white-space: nowrap;
}

/* ------------------------------ responsive ------------------------------ */

@media (max-width: 960px) {
  header {
    grid-template-columns: auto auto minmax(0, 1fr);
    grid-template-areas:
      "menu logo connexion"
      "titre titre titre"
      "search search search";
  }

  header .header-search {
    justify-self: stretch;
    width: 100%;
  }
}

@media (max-width: 640px) {
  header {
    padding: 8px 10px;
  }

  header .titre img,
  header .titre .logo img {
    width: 54px;
    height: 54px;
  }

  header .titre .logo .button {
    font-size: 0.68rem;
    padding: 0.3rem 0.55rem;
  }

  header .titre .brand-lines {
    display: none;
  }

  header .titre .nom-page h2 {
    font-size: 1.05rem;
  }

  header .connexion .button {
    font-size: 0.68rem;
    padding: 0.3rem 0.55rem;
  }
}

/* ------------------------------ scrolled: one tiny line ------------------------------ */
/* Title slides into row 1, between the poster button and the search bar.
   These rules sit after the media queries and out-rank them via body.scrolled. */

body.scrolled header {
  grid-template-columns: auto auto minmax(0, 1.6fr) minmax(0, 1fr) auto;
  grid-template-areas: "menu logo titre search connexion";
  row-gap: 0;
  padding: 10px 14px;
  border-radius: var(--hdr-radius);
}

body.scrolled header .titre .nom-page {
  grid-area: titre;
  min-width: 0;
}

body.scrolled header .titre .brand-lines {
  display: none;
}

body.scrolled header .titre .logo {
  flex-direction: row;
}

body.scrolled header .titre .nom-page h2 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--hdr-primary-dark);
  text-align: center;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.scrolled header .titre img,
body.scrolled header .titre .logo img {
  width: 32px;
  height: 32px;
  padding: 2px;
}

body.scrolled header .menu__btn {
  width: 32px;
  height: 32px;
}

body.scrolled header .header-search {
  justify-self: end;
  width: 100%;
  max-width: 300px;
  padding: 2px 3px 2px 10px;
}

body.scrolled header .header-search input {
  font-size: 0.8rem;
  padding: 0.22rem 0;
}

body.scrolled header .header-search__btn {
  font-size: 0.66rem;
  padding: 0.26rem 0.6rem;
}

body.scrolled header .connexion .button,
body.scrolled header .titre .button {
  font-size: 0.70rem;
  padding: 0.35rem 0.60rem;
}

body.scrolled header .user-pill {
  font-size: 0.70rem;
  padding: 0.35rem 0.60rem;
}

body.scrolled header .connexion-actions {
  flex-wrap: nowrap;
}
