/* ── Présentation guidée ── */
.site-tour {
  background: transparent;
  border: 0;
  color: var(--fg);
  margin: auto;
  max-height: calc(100vh - (2 * var(--page-gutter)));
  max-width: min(var(--content-rail-width), calc(100vw - (2 * var(--page-gutter))));
  overflow: visible;
  padding: 0;
  width: 100%;
}
.site-tour::backdrop {
  background: rgba(var(--bg-rgb), 0.54);
  backdrop-filter: blur(4px);
}
.site-tour:focus { outline: none; }
.site-tour-shell { width: 100%; }
.site-tour-card { max-height: min(84vh, 860px); }
.site-tour .atlas-rameau-help-close {
  display: grid;
  place-items: center;
}
.site-tour .atlas-rameau-help-close svg {
  display: block;
  fill: none;
  height: calc(var(--ui-icon-action-size) / 2);
  stroke: currentColor;
  stroke-width: 1.5;
  width: calc(var(--ui-icon-action-size) / 2);
}
.site-tour-title-band {
  font-weight: 700;
  text-transform: none;
}
/* Pied et pastilles : sous-blocs de la carte de presentation. Le fond de la
   barre est la jauge du parcours — il avance avec les etapes. La barre de
   creation d'un espace porte la meme classe et herite donc de la meme regle. */
.site-tour-footer {
  align-items: center;
  background:
    linear-gradient(
      90deg,
      color-mix(in srgb, var(--profile-secondary) 34%, transparent) 0%,
      color-mix(in srgb, var(--profile-secondary) 6%, transparent) var(--measure-share, 0%),
      transparent var(--measure-share, 0%)
    ),
    rgba(var(--surface-rgb), 0.74);
  border: 1px solid color-mix(in srgb, var(--ui-sub-frame) 52%, var(--border-soft));
  display: flex;
  gap: var(--ui-frame-gap);
  justify-content: space-between;
  padding: var(--ui-frame-pad);
}
.site-tour-progress button {
  background: transparent;
  border: 1px solid var(--ui-sub-frame);
  color: var(--fg);
  cursor: pointer;
  height: var(--ui-icon-action-size);
  padding: 0;
  width: var(--ui-icon-action-size);
}
.site-tour-content {
  display: grid;
}
.site-tour-content > .site-tour-step {
  align-content: start;
  display: grid;
  gap: var(--ui-frame-gap);
}
.site-tour-content > .site-tour-step[hidden] { display: none; }
.site-tour-content .site-tour-copy {
  gap: var(--ui-frame-gap);
  padding: var(--ui-text-pad);
}
/* Chaque texte d'etape tient sur une ligne : le bloc garde donc la meme
   hauteur d'une page a l'autre, sans ligne vide quand la phrase est courte. */
.site-tour-content .site-tour-copy p {
  min-height: 1.34em;
}
.site-tour-page-preview {
  aspect-ratio: 16 / 7.5;
  border: 1px solid var(--ui-sub-frame);
  min-width: 0;
  overflow: hidden;
  position: relative;
}
.site-tour-page-preview iframe {
  border: 0;
  display: block;
  height: 200%;
  pointer-events: none;
  transform: scale(0.5);
  transform-origin: 0 0;
  width: 200%;
}
/* L'Espace est encore en chantier : sa miniature en montre la composition, pas
   le detail. Le cadre reste net, seule l'image part au flou — la vue est un peu
   plus grande que sa fenetre pour que le flou n'eclaircisse pas les bords. */
.site-tour-page-preview[data-site-tour-preview="spaces"] iframe {
  filter: blur(10px);
  height: 208%;
  transform: scale(0.5) translate(-2%, -2%);
  width: 208%;
}
body.site-tour-preview-document * {
  animation: none !important;
  caret-color: transparent !important;
  transition: none !important;
}
body.site-tour-preview-document .atlas-controls,
body.site-tour-preview-document .atlas-panel,
body.site-tour-preview-document .viz-geo-popup {
  display: none !important;
}
/* Seule exception a l'arret des animations dans les miniatures : les fils de
   l'orbite respirent sur la page reelle, une miniature figee les trahirait. */
body.site-tour-preview-document .library-orbit-wire.is-active {
  animation: library-wire-breathe 2.8s ease-in-out infinite !important;
}

html.site-tour-preview-welcome,
body.site-tour-preview-welcome {
  background: transparent !important;
}
.site-tour-dismiss {
  align-items: center;
  display: flex;
  font-size: 0.68rem;
  gap: var(--ui-panel-gap);
  height: var(--ui-button-height);
  padding: 0;
}
.site-tour-progress {
  display: flex;
  gap: var(--ui-frame-gap);
}
.site-tour-progress button {
  background: var(--surface);
  font-size: 0.55rem;
  line-height: 1;
}
/* Une etape franchie recule au gris de l'arriere-plan : elle reste atteignable,
   elle n'est plus ce qu'on regarde. */
.site-tour-progress button.is-done {
  background: var(--neutral-grad);
  color: var(--fg-muted);
}
.site-tour-progress button.is-current { background: var(--ui-sub-grad); }
.site-tour-actions {
  display: flex;
  gap: var(--ui-frame-gap);
}
/* Les deux boutons partagent la largeur du plus large libelle : « Terminer »
   remplace « Suivant » a la derniere etape sans decaler le pied de page. La
   barre de creation d'un espace garde ses deux groupes en flux : ses actions
   sont seules dans leur moitie de barre. */
.site-tour .site-tour-footer .site-tour-actions {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
}
.site-tour-actions button {
  background: var(--area-btn-bg);
  border: 1px solid var(--area-btn-border);
  color: var(--fg);
  cursor: pointer;
  height: var(--ui-button-height);
  padding: var(--ui-button-pad);
}
.site-tour-actions button:disabled {
  cursor: default;
  opacity: 0.38;
}
/* Derniere etape : le bouton ne mene plus ailleurs, il ferme la presentation. */
.site-tour-actions button.is-final {
  background: var(--area-btn-grad);
  border-color: var(--area-btn-grad-hi);
}
@media (max-width: 620px) {
  .site-tour-footer { align-items: stretch; flex-direction: column; }
  .site-tour-progress { justify-content: center; order: -1; }
  .site-tour-actions { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  .site-tour::backdrop { backdrop-filter: none; }
}

/* ── Tags ── */
.tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 5px;
  border: 1px solid var(--border-soft);
  background: rgba(var(--surface-rgb), 0.7);
  color: var(--fg-soft);
  letter-spacing: 0.03em;
}

/* ── Projects grid ── */
#library-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 1rem 1.5rem 1.5rem;
  background: transparent;
  margin-top: 1rem;
  align-items: start;
}
.index-page-layout {
  display: grid;
  grid-template-columns: var(--side-rail-width) minmax(0, var(--content-rail-width)) var(--side-rail-width);
  gap: var(--layout-rail-gap);
  padding: var(--nav-clearance) var(--page-gutter) 3rem;
  align-items: start;
  justify-content: center;
}
#library-page #library-grid {
  width: 100%;
  max-width: var(--content-rail-width);
  padding: 0;
  margin-top: 0;
}

/* Carte = cadre extérieur (contient 2 éléments → double cadre logique) */
.library-card {
  display: flex;
  flex-direction: column;
  gap: var(--ui-frame-gap);
  border: 1px solid var(--thumb-color, #c8c8c0);
  padding: var(--ui-frame-pad);
  background: rgba(var(--surface-rgb), 0.9);
  transition: border-color var(--motion-state) var(--motion-ease);
  min-width: 0;
}
.library-card:hover { border-color: color-mix(in srgb, var(--thumb-color, #c8c8c0) 88%, var(--fg) 12%); }

/* Cadre image */
.card-thumb {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--thumb-color, #c8c8c0);
  overflow: hidden;
  display: block;
  transition: border-color var(--motion-state) var(--motion-ease);
}
.library-card:hover .card-thumb { border-color: color-mix(in srgb, var(--thumb-color, #c8c8c0) 88%, var(--fg) 12%); }

.card-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.card-thumb-placeholder {
  width: 100%;
  height: 100%;
  background:
    var(--thumb-grad, linear-gradient(135deg, color-mix(in srgb, var(--thumb-color, #c8c8c0) 66%, var(--surface)), rgba(var(--surface-rgb), 0.82))),
    repeating-linear-gradient(115deg, rgba(var(--fg-rgb), 0.08) 0 1px, transparent 1px 16px);
}

/* Cadre bandeau — séparé du cadre image */
.card-meta {
  border: 1px solid var(--thumb-color, #c8c8c0);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  gap: 0;
  padding: var(--ui-band-pad);
  background: var(--thumb-grad, rgba(var(--surface-rgb), 0.92));
  transition: border-color var(--motion-state) var(--motion-ease);
  min-height: auto;
}
.library-card:hover .card-meta { border-color: color-mix(in srgb, var(--thumb-color, #c8c8c0) 88%, var(--fg) 12%); }

.card-title {
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.library-card-reference {
  --thumb-color: var(--profile-secondary);
  --thumb-grad: var(--profile-grad-reverse);
}
.library-card-artist {
  --thumb-color: var(--profile-primary);
  --thumb-grad: var(--profile-grad);
}
.library-card-locked .card-thumb img {
  filter: blur(9px);
  transform: scale(1.08);
}
/* Bloc teinté par la couleur de sa catégorie (reference_types.color). */
.library-card-categorized .card-meta {
  background: color-mix(in srgb, var(--thumb-color, #c8c8c0) 20%, rgba(var(--surface-rgb), 0.92));
}
.library-card-categorized .card-title { color: var(--fg); }
.library-card .card-subtitle {
  font-size: 0.62rem;
  color: var(--fg-soft);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar librairie : empilement de 2 blocs séparés, figé au scroll. */
.library-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--ui-panel-gap);
  align-self: start;
  position: sticky;
  top: var(--sticky-clearance);
  max-height: calc(100vh - var(--sticky-clearance) - 24px);
  overflow-y: auto;
  scrollbar-width: none;
}
.library-sidebar::-webkit-scrollbar { display: none; }
.library-block {
  width: 100%;
}
/* Compteur de résultats : ligne libre sous les filtres, hors cadre, réglée sur
   la typo des listes de catégories qui la précèdent. */
.library-sidebar > .library-result-count {
  font-size: var(--ui-list-row-font-size);
  line-height: var(--ui-list-row-line-height);
  margin: 0;
  padding: var(--ui-list-row-pad);
  text-align: center;
}
.library-search-block {
  width: 100%;
}
.library-add-block {
  border: 1px solid var(--profile-primary);
  background: rgba(var(--surface-rgb), 0.9);
  padding: var(--ui-frame-pad);
  box-shadow: 0 16px 44px rgba(var(--shadow-rgb), 0.055);
}
.library-add-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 1px solid var(--profile-primary);
  background: var(--profile-grad);
  color: var(--fg);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  line-height: var(--ui-control-line-height);
  height: var(--ui-button-height);
  padding: var(--ui-button-pad);
  text-align: center;
  text-transform: uppercase;
}
.library-add-button:hover,
.library-add-button:focus-visible {
  background: var(--profile-grad);
  border-color: var(--profile-primary);
  outline: 0;
}
.library-sidebar .library-search-block form {
  display: flex;
  align-items: stretch;
  gap: var(--ui-frame-gap);
}
.library-sidebar .library-search-block input[type="text"] {
  min-width: 0;
  flex: 1 1 auto;
}
.refs-filter .icon-search-button {
  flex: 0 0 var(--ui-control-height);
  height: var(--ui-control-height);
  width: var(--ui-control-height);
  min-width: var(--ui-control-height);
  min-height: var(--ui-control-height);
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--fg);
}
.library-sidebar .refs-filter .icon-search-button {
  flex-basis: var(--ui-control-height);
  width: var(--ui-control-height);
  min-width: var(--ui-control-height);
}
.search-loupe {
  width: 12px;
  height: 12px;
  display: block;
  position: relative;
}
.search-loupe::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 5px;
  width: 8px;
  height: 1px;
  background: currentColor;
}
.search-loupe::after {
  content: "";
  position: absolute;
  right: 1px;
  top: 3px;
  width: 5px;
  height: 5px;
  border: 1px solid currentColor;
  border-left: 0;
  border-bottom: 0;
  transform: rotate(45deg);
}
.library-filter-block {
  border: 1px solid var(--ui-frame);
  background: rgba(var(--surface-rgb), 0.86);
  padding: var(--ui-frame-pad);
  display: grid;
  gap: var(--ui-frame-gap);
  align-content: start;
  box-shadow: 0 16px 44px rgba(var(--shadow-rgb), 0.055);
}
.library-block-label {
  display: block;
  border: 1px solid var(--ui-frame);
  background:
    linear-gradient(90deg, var(--ui-frame-soft) 0%, rgba(var(--surface-rgb), 0.74) 100%);
  color: var(--fg);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  line-height: 1.15;
  padding: var(--ui-band-pad);
  text-transform: uppercase;
  margin-bottom: 0;
}
.library-source-list {
  display: grid;
  gap: var(--ui-frame-gap);
}
.library-source-row {
  align-items: center;
  background: rgba(var(--surface-rgb), 0.72);
  border: 1px solid var(--border-soft);
  color: var(--fg);
  cursor: pointer;
  display: grid;
  font-size: var(--ui-list-row-font-size);
  gap: var(--ui-frame-gap);
  grid-template-columns: minmax(0, 1fr) auto;
  height: var(--ui-list-row-height);
  line-height: var(--ui-list-row-line-height);
  min-width: 0;
  padding: var(--ui-list-row-pad);
}
.library-source-row.is-active {
  background:
    linear-gradient(90deg, var(--profile-secondary-soft) 0%, rgba(var(--surface-rgb), 0.72) 100%);
  border-color: color-mix(in srgb, var(--profile-secondary) 58%, var(--border-soft));
}
.library-source-row:has(input:focus-visible) {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}
.library-source-row > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-source-state {
  background: rgba(var(--surface-rgb), 0.78);
  border: 1px solid var(--border-soft);
  color: var(--fg-muted);
  display: grid;
  flex-shrink: 0;
  font-size: 0.54rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  height: calc(var(--ui-list-row-height) - 4px);
  line-height: 1;
  width: calc(var(--ui-list-row-height) * 2);
}
.library-source-state > span {
  display: grid;
  place-items: center;
}
.library-source-state > span + span {
  border-left: 1px solid var(--border-soft);
}
.library-source-state > .active {
  background: var(--profile-secondary-soft);
  color: var(--fg);
  font-weight: 600;
}
.library-filter-group {
  display: grid;
  gap: var(--ui-frame-gap);
}
.library-mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ui-frame-gap);
}
.library-mode-toggle a {
  align-items: center;
  border: 1px solid var(--border-soft);
  background: rgba(var(--surface-rgb), 0.76);
  color: var(--fg-muted);
  display: flex;
  font-size: 0.62rem;
  height: var(--ui-list-row-height);
  justify-content: center;
  letter-spacing: 0.07em;
  line-height: var(--ui-list-row-line-height);
  padding: var(--ui-list-row-pad);
  text-align: center;
  text-transform: uppercase;
}
/* Même rang que les sources actives juste au-dessus : couleur secondaire. */
.library-mode-toggle a:hover,
.library-mode-toggle a.active {
  border-color: var(--ui-sub-frame-strong);
  background: var(--ui-sub-grad);
  color: var(--fg);
}
#library-grid .library-card:target {
  outline: none;
  box-shadow: none;
}
.index-search-panel {
  display: grid;
  gap: var(--ui-frame-gap);
}

.detail-page {
  --detail-frame: var(--profile-primary);
  --detail-soft: var(--profile-primary-soft);
  border: 1px solid var(--detail-outer-frame, var(--ui-frame));
  background: rgba(var(--surface-rgb), 0.9);
  box-shadow: 0 16px 44px rgba(var(--shadow-rgb), 0.055);
  display: grid;
  gap: var(--ui-frame-gap);
  padding: var(--ui-frame-pad);
}
.detail-page-reference {
  --detail-frame: var(--profile-secondary);
  --detail-soft: var(--profile-secondary-soft);
}

@media (max-width: 1180px) {
  .index-page-layout {
    grid-template-columns: var(--side-rail-width) minmax(0, 1fr);
    justify-content: stretch;
  }
  .index-side-list {
    position: static;
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    max-height: none;
  }
}

@media (max-width: 880px) {
  #library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  #library-grid {
    grid-template-columns: minmax(0, 1fr);
    padding-inline: 0.85rem;
  }
  .index-page-layout {
    grid-template-columns: minmax(0, 1fr);
    padding-inline: 0.85rem;
  }
  .refs-filter,
  .library-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .index-side-list { position: static; }
}
