/* RFMB — a compact identity; navigation appears only when it is needed. */
:root { --rfmb-header-height: 84px; --rfmb-header-offset: var(--rfmb-header-height); }
html { scroll-padding-top: calc(var(--rfmb-header-offset) + 16px); }
html:has(body.resource-page) { scroll-padding-top: 0; }
.topline { display: none; }
.header { background: #fff; border-bottom: 1px solid #e3e9ee; }
.header .header-inner { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; column-gap: 32px; min-height: 84px; position: relative; }
.header .brand { display: grid; grid-template-columns: 30px auto minmax(0,1fr); align-items: center; gap: 11px; min-width: 0; justify-self: start; }
.header .brand-mark { display: block; width: 30px; height: 38px; }
.header .brand-name { font-size: 29px; line-height: 1; letter-spacing: -1.1px; }
.header .brand-long { display: block; font-size: 12.5px; line-height: 1.4; font-weight: 400; color: #526575; letter-spacing: 0; border-left: 1px solid #d9e1e7; padding-left: 13px; margin-left: 0; }
.header nav, .rfmb-community-enabled .header nav, .community-page .header nav { display: flex; grid-column: 2; grid-row: 1; position: static; align-items: center; justify-content: flex-end; gap: 24px; min-width: 0; margin: 0; padding: 0; background: #fff; border: 0; box-shadow: none; font-size: 14px; line-height: 1.5; white-space: normal; }
.header nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 0; }
.header .header-search { display: none; }
.header .menu-button { display: none; }
.header :is(a,button):focus-visible { outline: 3px solid #2455c9; outline-offset: 3px; }
.header nav a::after { transition: none; }

/* Native anchors and sticky reading controls follow the measured header. */
.resource-page #contenu { scroll-margin-top: calc(var(--rfmb-header-offset) + 12px); }
.reader .reader-nav { top: calc(var(--rfmb-header-offset) + 16px); }
.reader .reader-panel { scroll-margin-top: calc(var(--rfmb-header-offset) + 24px); }
.reader .reader-guide { top: calc(var(--rfmb-header-offset) + 16px); max-height: calc(100dvh - var(--rfmb-header-offset) - 40px); }
.catalog-sidebar { top: calc(var(--rfmb-header-offset) + 16px); max-height: calc(100dvh - var(--rfmb-header-offset) - 36px); }
.community-page[data-community-page="contribute"] .c-contribution-aside { top: calc(var(--rfmb-header-offset) + 16px); }
.community-page[data-community-page="contribute"] #besoins,
.community-page[data-community-page="contribute"] #proposer,
.dictionary-card { scroll-margin-top: calc(var(--rfmb-header-offset) + 16px); }

@media (max-width:1280px) {
  .header .header-inner { grid-template-columns: minmax(0,1fr) auto; column-gap: 20px; }
  .header .menu-button { display: inline-flex; grid-column: 2; grid-row: 1; align-items: center; justify-content: center; gap: 9px; width: auto; min-width: 44px; min-height: 44px; padding: 10px 12px; border: 1px solid #e1e7ed; border-radius: 10px; background: #f7f9fb; font-size: 14px; line-height: 1.4; }
  .header .menu-button svg { width: 19px; height: 19px; flex-shrink: 0; }
  .header .menu-button:hover, .header .menu-button[aria-expanded="true"] { background: #edf3ff; border-color: #b4c7ed; color: #2455c9; }
  .header nav, .rfmb-community-enabled .header nav, .community-page .header nav { display: none; grid-column: 1 / -1; grid-row: auto; position: absolute; top: calc(100% - 1px); left: 0; right: 0; justify-content: flex-start; align-items: stretch; flex-direction: column; gap: 0; margin: 0; padding: 10px; border: 1px solid #dde5ec; border-radius: 0 0 14px 14px; background: #fff; box-shadow: 0 14px 30px #142d4014; font-size: 16px; max-height: calc(100vh - var(--rfmb-header-height) - 20px); max-height: calc(100dvh - var(--rfmb-header-height) - 20px); overflow-y: auto; overscroll-behavior: contain; }
  .header nav.open, .rfmb-community-enabled .header nav.open, .community-page .header nav.c-menu-open { display: flex; }
  .header nav a { padding: 13px 14px; min-height: 48px; border-radius: 8px; }
  .header nav a:hover, .header nav a[aria-current="page"] { background: #f2f6fc; color: #2455c9; }
  .header nav a::after { display: none; }
  .header nav :is(a,button):focus-visible { outline-offset: -3px; }
  /* Keep native navigation available if JavaScript is absent or still loading. */
  .header:not(.navigation-ready) { position: relative; }
  .header:not(.navigation-ready) .menu-button { display: none; }
  .header:not(.navigation-ready) nav,
  .rfmb-community-enabled .header:not(.navigation-ready) nav,
  .community-page .header:not(.navigation-ready) nav {
    display: flex; grid-column: 1 / -1; grid-row: 2; position: static;
    flex-direction: row; flex-wrap: wrap; gap: 0 16px; align-items: center;
    margin: 0; padding: 0 0 10px; border: 0; border-radius: 0; box-shadow: none;
    max-height: none; overflow: visible; font-size: 14px;
  }
  .header:not(.navigation-ready) nav a { padding: 8px 0; min-height: 44px; }
}
@media (max-width:1260px) {
  .reader .reader-guide { top: auto; max-height: calc(100dvh - var(--rfmb-header-offset) - 48px); }
}
@media (min-width:961px) {
  .reader .reader-nav { max-height: calc(100dvh - var(--rfmb-header-offset) - 36px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .reader .reader-nav :is(a,button):focus-visible { outline-offset: -3px; }
}
@media (max-width:960px) {
  .reader .reader-nav { top: var(--rfmb-header-offset); }
  .reader .reader-panel { scroll-margin-top: calc(var(--rfmb-header-offset) + var(--rfmb-reader-nav-height,60px)); }
  .catalog-sidebar { max-height: none; }
}
@media (max-width:720px) {
  .header .header-inner { width: calc(100% - 32px); gap: 12px; min-height: 84px; padding-block: 11px; }
  .header .brand { grid-template-columns: 26px minmax(0,1fr); grid-template-rows: auto auto; column-gap: 9px; row-gap: 4px; width: auto; max-width: 100%; }
  .header .brand-mark { grid-column: 1; grid-row: 1 / 3; width: 26px; height: 34px; }
  .header .brand-name { grid-column: 2; grid-row: 1; font-size: 23px; line-height: 1; letter-spacing: -.7px; }
  .header .brand-long { grid-column: 2; grid-row: 2; display: block; border: 0; padding: 0; min-width: 0; font-size: 12.5px; line-height: 1.3; }
  .header .menu-button { gap: 7px; padding: 10px; font-size: 13px; border-color: transparent; }
  .header .menu-button svg { width: 18px; height: 18px; }
  .header nav, .rfmb-community-enabled .header nav, .community-page .header nav { left: -1px; right: -1px; padding: 8px; }
}
@media (max-width:360px) {
  .header .brand { grid-template-columns: minmax(0,1fr); }
  .header .brand-mark { display: none; }
  .header .brand-name, .header .brand-long { grid-column: 1; }
}
@media (max-width:960px) and (max-height:500px) {
  :root { --rfmb-header-offset: 0px; }
  .header { position: relative; }
}
@media print {
  :root { --rfmb-header-offset: 0px; }
  .header, .topline { display: none !important; }
}
