/*
 * Alpha118 — système sticky transversal consolidé et conservé après refonte visuelle.
 * Source unique pour le comportement position/top/z-index des barres de commande.
 * Les anciennes déclarations concurrentes ont été retirées de app.css.
 */
:root {
  --eiv-sticky-gap: 8px;
  --eiv-sticky-top: calc(var(--header-height, 64px) + var(--eiv-sticky-gap));
  --eiv-sticky-layer: 48;
}

/* Aucun ancêtre fonctionnel ne doit devenir le conteneur de défilement de la barre. */
.application-frame,
.app-main,
.app-page-content,
[data-idea-library-root],
[data-agreements-root],
[data-what-root],
[data-tracking-root],
[data-activity-root],
.reference-library-page,
.library-reference-controls,
.library-filter-context,
.terrain-page,
.tracking-page-v2,
.activity-page,
.activity-panel,
.what-page-v3,
.what-mode-content,
.what-guided-start,
.what-results-v3,
.what-candidate-library {
  overflow: visible !important;
}

.eiv-sticky-bar {
  position: sticky !important;
  top: var(--eiv-sticky-top) !important;
  z-index: var(--eiv-sticky-layer) !important;
  align-self: start !important;
  width: 100%;
  isolation: isolate;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 26px rgba(64, 58, 92, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.eiv-sticky-bar:focus-within {
  box-shadow:
    0 0 0 3px rgba(105, 201, 195, 0.16),
    0 12px 28px rgba(64, 58, 92, 0.14);
}

/* Boîte à idées : barre sœur des résultats. Collections : barre intégrée à sa grande surface. */
.reference-library-page > .library-sticky-controls,
.collections-space__toolbar {
  margin-block: 0;
}

.library-filter-context {
  display: grid;
  gap: 12px;
}

/* Restauration des positions internes volontairement relatives après nettoyage des anciennes règles. */
.agreements-current .terrain-search label {
  position: relative;
}

.agreements-current .terrain-search label > svg {
  position: static;
}

/* Suivi : le panneau de filtres reste un panneau, seule sa barre principale est sticky. */
.tracking-toolbar-v2.eiv-sticky-bar {
  padding: 10px;
  border: 1px solid rgba(221, 216, 232, 0.86);
  border-radius: 18px;
}

/* Activité récente : uniquement les filtres restent disponibles pendant la lecture de l’historique. */
.activity-toolbar {
  padding: 10px;
  border: 1px solid rgba(221, 216, 232, 0.86);
  border-radius: 17px;
}

.activity-toolbar .activity-filters {
  margin: 0;
}

/* Que fait-on ? : rappel des critères ou commandes de vue pendant le parcours des résultats. */
.what-sticky-context {
  padding: 0;
  border: 1px solid rgba(221, 216, 232, 0.86);
  border-radius: 17px;
  overflow: hidden;
}

.what-sticky-context > .what-criteria-summary {
  margin: 0 !important;
  border: 0 !important;
}

.what-candidate-viewbar.eiv-sticky-bar {
  border-color: rgba(221, 216, 232, 0.86) !important;
}

/* Les ancres et premiers contenus ne passent jamais sous les barres. */
.library-results-heading,
.library-theme-group,
.collections-space,
.collections-space__content,
.terrain-search-results,
.terrain-section,
.tracking-section-v2,
.activity-list,
.what-results-grid,
.what-candidate-groups {
  scroll-margin-top: calc(var(--eiv-sticky-top) + 110px);
}

@media (max-width: 980px) {
  :root {
    --eiv-sticky-gap: 6px;
  }

  .tracking-toolbar-v2.eiv-sticky-bar,
  .activity-toolbar {
    border-radius: 16px;
  }
}

@media (max-width: 680px) {
  :root {
    --eiv-sticky-gap: 4px;
  }

  .eiv-sticky-bar {
    max-height: calc(100dvh - var(--eiv-sticky-top) - 10px);
    overflow-y: auto !important;
    overscroll-behavior: contain;
    box-shadow: 0 8px 20px rgba(64, 58, 92, 0.12);
  }

  .reference-library-page .library-sticky-controls {
    gap: 8px;
    padding: 8px;
  }

  .collections-space__toolbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .reference-library-page .library-filter-toggle--toolbar,
  .reference-library-page .library-view-switch {
    min-width: 0;
    width: 100%;
  }

  .activity-toolbar .activity-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: thin;
  }

  .activity-toolbar .activity-filter {
    flex: 0 0 auto;
  }

  .what-sticky-context {
    max-height: min(42dvh, 300px);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .eiv-sticky-bar {
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

html,
body {
  overflow-x: clip !important;
}

