/* Base elements and page shell (DESIGN §3). Values come from tokens.css only. */
html {
  /* A focused element is never hidden behind the sticky header or an action bar (DESIGN §10.1). */
  scroll-padding-block: var(--espace-64);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--fond-page);
  color: var(--texte);
  font-family: var(--police-texte);
  font-size: var(--taille-corps);
  line-height: var(--interligne-corps);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: var(--taille-titre-page);
  line-height: var(--interligne-titre-page);
}

h2 {
  font-size: var(--taille-titre-section);
  line-height: var(--interligne-titre-section);
}

h3 {
  font-size: var(--taille-corps);
  line-height: var(--interligne-corps);
}

p {
  margin: 0 0 var(--espace-16);
  max-width: 80ch;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-survol);
}

code,
.mono {
  font-family: var(--police-mono);
  font-size: var(--taille-dense);
  overflow-wrap: normal;
  white-space: nowrap;
}

:focus-visible {
  outline: var(--focus-largeur) solid var(--accent);
  outline-offset: var(--focus-decalage);
}

/* Text for assistive technology only */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--espace-8);
  top: var(--espace-8);
  z-index: 100;
  padding: var(--espace-8) var(--espace-16);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--rayon-champ);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* --- Top bar (DESIGN §3.1) --- */
.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--espace-16);
  box-sizing: border-box;
  min-height: var(--hauteur-entete);
  padding: 0 var(--marge-laterale);
  background: var(--surface);
  border-bottom: 1px solid var(--trait);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: var(--espace-16);
  min-width: 0;
}

.site-logo {
  display: flex;
  flex: none;
}

.site-logo img {
  height: var(--taille-logo);
  width: var(--taille-logo);
}

.site-brand-separator {
  flex: none;
  align-self: stretch;
  margin: var(--espace-12) 0;
  border-left: 1px solid var(--trait);
}

.module-name {
  display: flex;
  align-items: center;
  gap: var(--espace-8);
  font-weight: 600;
  color: var(--texte);
}

.module-logo {
  flex: none;
  height: var(--taille-logo-module);
  width: var(--taille-logo-module);
}
.campaign-name {
  flex: none;
  margin: 0;
  font-weight: 600;
}

.account-menu {
  position: relative;
}

.account-menu-panel {
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 240px;
  margin-top: var(--espace-4);
  padding: var(--espace-8);
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon-panneau);
  box-shadow: var(--ombre-flottante);
}

.account-menu-panel[hidden] {
  display: none;
}

.account-menu-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.account-menu-panel form {
  margin: 0;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-sizing: border-box;
  width: 100%;
  min-height: var(--hauteur-controle);
  padding: var(--espace-8) var(--espace-12);
  border: 0;
  border-radius: var(--rayon-champ);
  background: transparent;
  color: var(--texte);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--accent-fond);
}

.menu-item-detail {
  font-size: var(--taille-aide);
  line-height: var(--interligne-aide);
  color: var(--texte-secondaire);
}

/* --- Navigation (DESIGN §5): the « Comparaison parcellaire » menu on the left, the tools menu on the right,
   and under them, in a campaign only, its name and its path --- */
.site-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: var(--espace-24);
  padding: 0 var(--marge-laterale);
  background: var(--surface);
  border-bottom: 1px solid var(--trait);
}

.campaign-band {
  display: flex;
  align-items: stretch;
  gap: var(--espace-24);
  padding: 0 var(--marge-laterale);
  background: var(--surface-creuse);
  border-bottom: 1px solid var(--trait);
}

.campaign-band .campaign-name {
  align-self: center;
}

.site-nav-group {
  position: relative;
}

.steps {
  display: flex;
  align-items: stretch;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav .nav-toggle {
  display: none;
}

.tools-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.tools-toggle[aria-current] {
  color: var(--accent);
  font-weight: 600;
}

.tools-panel {
  position: absolute;
  z-index: 20;
  right: 0;
  top: 100%;
  min-width: 240px;
  padding: var(--espace-8);
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon-panneau);
  box-shadow: var(--ombre-flottante);
}

.main-menu .tools-panel {
  left: 0;
  right: auto;
}

.tools-panel[hidden] {
  display: none;
}

.tools-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tools-panel .menu-item[aria-current] {
  background: var(--accent-fond);
  color: var(--accent);
  font-weight: 600;
}

/* --- Page structure (DESIGN §3.2) --- */
.status-area {
  padding: 0 var(--marge-laterale);
}

.status-area:empty {
  display: none;
}

.page {
  box-sizing: border-box;
  flex: 1;
  width: 100%;
  max-width: var(--largeur-contenu);
  margin: 0 auto;
  padding: var(--espace-32) var(--marge-laterale);
}

.page.is-wide {
  max-width: none;
}

.page:focus {
  outline: none;
}

.page-header {
  margin-bottom: var(--espace-24);
}

.page-help {
  margin: var(--espace-4) 0 0;
  color: var(--texte-secondaire);
}

.page-help.is-full {
  max-width: none;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--espace-8);
  margin: 0 0 var(--espace-8);
  padding: 0;
  list-style: none;
  font-size: var(--taille-dense);
  line-height: var(--interligne-dense);
}

.breadcrumb li {
  display: flex;
  align-items: center;
  gap: var(--espace-8);
}

/* Chevron drawn with borders so it needs no extra icon (DESIGN §3.2). */
.breadcrumb li + li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-top: 2px solid var(--trait-champ);
  border-right: 2px solid var(--trait-champ);
  transform: rotate(45deg);
}

.breadcrumb a,
.breadcrumb span {
  padding: var(--espace-4) var(--espace-12);
  border: 1px solid var(--trait);
  border-radius: var(--rayon-badge);
  background: var(--surface);
}

.breadcrumb a {
  color: var(--texte-secondaire);
  text-decoration: none;
  transition: background-color var(--duree-survol), border-color var(--duree-survol), color var(--duree-survol);
}

.breadcrumb a:hover {
  border-color: var(--accent);
  background: var(--accent-fond);
  color: var(--accent-survol);
}

.breadcrumb [aria-current="page"] {
  border-color: var(--accent-fond);
  background: var(--accent-fond);
  color: var(--accent-survol);
  font-weight: 600;
}

/* Blocks of a page are 24 px apart whatever margin a block carries (DESIGN §2.4). */
.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--espace-24);
}

.stack.stack > * {
  margin-block: 0;
}

.stack > :empty {
  display: none;
}

.panel > h2:first-child,
.panel > h3:first-child {
  margin: 0 0 var(--espace-16);
}

.panel > h2:first-child:has(+ .field-help),
.panel > h3:first-child:has(+ .field-help) {
  margin-bottom: var(--espace-8);
}

.panel > .field-help {
  margin: 0 0 var(--espace-16);
}

/* Authentication pages: one 400 px column, no navigation (DESIGN §6.1) */
.page.is-focus {
  max-width: var(--largeur-connexion);
  margin: 0 auto;
  padding-top: var(--espace-48);
}

.panel {
  padding: var(--espace-24);
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon-panneau);
}

/* --- Footer (DESIGN §3.1) --- */
.site-footer {
  padding: var(--espace-16) var(--marge-laterale);
  border-top: 1px solid var(--trait);
  font-size: var(--taille-aide);
  line-height: var(--interligne-aide);
  color: var(--texte-secondaire);
}

.site-footer p {
  margin: 0;
  max-width: none;
}

/* --- Responsive (DESIGN §3.3, §11) --- */
@media (max-width: 1023px) {
  .site-nav-bar,
  .campaign-band {
    flex-wrap: wrap;
    gap: 0;
  }

  .site-nav .nav-toggle {
    display: inline-flex;
  }

  .site-nav-group .steps {
    display: none;
    flex-direction: column;
    padding: var(--espace-8) 0;
  }

  .site-nav-group.is-open .steps {
    display: flex;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
