:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-soft: #f8f7f4;
  --text: #20201e;
  --muted: #6f6d67;
  --line: #d9d5cc;
  --accent: #903d24;
  --accent-hover: #74301c;
  --shadow: 0 12px 35px rgb(25 25 20 / 0.08);
  --surface-raised: #ffffff;
  --surface-hover: #ffffff;
  --graph-center: #ffffff;
  --graph-mid: #fbfaf8;
  --graph-edge: #f4f2ed;
  --text-soft: #4f4e49;
  --code-bg: #eeece6;
  --search-divider: #ece9e3;
  --range-track: #d8d5cf;
  --node-outline: rgb(74 72 68 / 0.45);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration-color: rgb(144 61 36 / 0.45);
  text-underline-offset: 2px;
}

a:hover,
a:focus-visible {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

.app-header {
  min-height: 94px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.header-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  width: 68px;
  height: 68px;
  flex: 0 0 68px;
  display: block;
  object-fit: contain;
}

.header-title {
  min-width: 0;
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.data-period {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.header-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-stats span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.app-layout {
  height: calc(100vh - 130px);
  min-height: 620px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.graph-panel,
.details-panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.graph-panel {
  display: flex;
  flex-direction: column;
}

.toolbar {
  z-index: 5;
  min-height: 58px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  flex: 1;
}

.search-box input {
  width: 100%;
  min-width: 150px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--surface-soft);
  color: var(--text);
}

.search-box input:focus {
  border-color: #96928a;
  background: var(--surface-raised);
}

.toolbar button {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--text);
}

.toolbar button:hover {
  background: var(--surface-soft);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.toggle input[type="checkbox"] {
  accent-color: var(--accent);
}

.search-results {
  position: absolute;
  z-index: 20;
  top: 57px;
  left: 10px;
  width: min(520px, calc(100% - 20px));
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-result {
  width: 100%;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--search-divider);
  background: transparent;
  text-align: left;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result:focus {
  background: var(--surface-soft);
}

.search-result strong {
  font-size: 0.88rem;
}

.search-result span {
  color: var(--muted);
  font-size: 0.75rem;
}

.search-no-result {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

#graph-container {
  position: relative;
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(
      circle at center,
      var(--graph-center) 0,
      var(--graph-mid) 55%,
      var(--graph-edge) 100%
    );
}

#graph-container canvas {
  outline: none;
}

.loading {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend {
  min-height: 34px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}

.legend-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.legend-dot.community {
  background: #657a72;
}

.legend-dot.outside {
  margin-left: 8px;
  background: #b9b7b0;
}

.details-panel {
  overflow-y: auto;
}

.details-empty,
#details {
  padding: 24px;
}

.details-empty {
  color: var(--muted);
}

.details-empty h2 {
  color: var(--text);
}

.details-period {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.metrics {
  margin: 22px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metrics div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.metrics dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.7rem;
}

.metrics dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
}

.details-section {
  padding: 17px 0;
  border-top: 1px solid var(--line);
}

.details-section p {
  margin-bottom: 0;
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.5;
}

.publication-list {
  margin: 0;
  padding-left: 1.25rem;
}

.publication-list li {
  margin-bottom: 12px;
  padding-left: 3px;
  font-size: 0.82rem;
  line-height: 1.4;
}

.publication-list .publication-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.publication-list .publication-meta a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.publication-list .publication-meta a:hover,
.publication-list .publication-meta a:focus-visible {
  color: var(--accent);
}

.app-footer {
  min-height: 36px;
  padding: 8px 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--code-bg);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .header-meta {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .header-stats {
    justify-content: flex-start;
  }

  .app-layout {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .graph-panel {
    height: 70vh;
    min-height: 520px;
  }

  .details-panel {
    min-height: 300px;
  }

  .app-footer {
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 16px;
  }

  .header-brand {
    gap: 12px;
  }

  .header-logo {
    width: 58px;
    height: 58px;
    flex-basis: 58px;
  }

  .app-layout {
    padding: 8px;
    gap: 8px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .search-box {
    flex-basis: 100%;
  }

  .legend {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .details-empty,
  #details {
    padding: 18px;
  }
}

/* --------------------------------------------------------------------------
 * Mode Communautés
 * ----------------------------------------------------------------------- */
.toolbar .mode-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.toolbar .mode-button.is-active:hover,
.toolbar .mode-button.is-active:focus-visible {
  background: var(--accent-hover);
}

.communities-panel {
  padding: 24px;
}

.communities-heading > p:last-child {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.communities-list {
  display: grid;
  gap: 7px;
}

.community-item {
  width: 100%;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.community-item:hover,
.community-item:focus-visible {
  border-color: #b9b4aa;
  background: var(--surface-raised);
}

.community-item[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.community-swatch {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 1px solid var(--node-outline);
  border-radius: 50%;
}

.community-item-label {
  min-width: 0;
  display: flex;
  flex: 1;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.community-item-label strong {
  font-size: 0.84rem;
  font-weight: 650;
}

.community-item-label small {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.community-focus {
  margin: -4px 0 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.community-focus-heading {
  display: flex;
  align-items: center;
  gap: 11px;
}

.community-focus-heading .community-swatch {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
}

.community-focus-heading .eyebrow {
  margin-bottom: 2px;
}

.community-focus-heading h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.community-metrics {
  margin: 18px 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.community-metrics div {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.community-metrics dt {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.2;
}

.community-metrics dd {
  margin: 4px 0 0;
  font-size: 1rem;
  font-weight: 650;
}

.community-central-members {
  margin-top: 18px;
  padding-bottom: 0;
}

.community-central-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.community-central-list button {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.72rem;
}

.community-central-list button:hover,
.community-central-list button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 600px) {
  .communities-panel {
    padding: 18px;
  }

  .community-metrics {
    grid-template-columns: 1fr 1fr;
  }
}


/* --- Exploration temporelle --- */

.timeline-panel {
  z-index: 4;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.timeline-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timeline-summary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.timeline-label,
.editorial-presets-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.045em;
}

#timeline-period { font-size: 0.9rem; }

.timeline-toggle,
#timeline-reset {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 0.72rem;
}

.timeline-toggle:hover,
.timeline-toggle:focus-visible,
#timeline-reset:hover:not(:disabled),
#timeline-reset:focus-visible:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

#timeline-reset:disabled { opacity: 0.45; cursor: default; }

.timeline-controls { padding-top: 8px; }
.timeline-controls[hidden] { display: none; }
.timeline-controls-actions { display: flex; justify-content: flex-end; margin-bottom: -2px; }

.info-tooltip { position: relative; display: inline-flex; align-items: center; }
.info-button, .info-link-icon {
  width: 16px; height: 16px; display: inline-grid; place-items: center;
  border: 1px solid currentColor; border-radius: 50%;
  font-family: Georgia, serif; font-size: 0.67rem; font-weight: 700; line-height: 1;
}
.info-button { padding: 0; background: transparent; color: var(--muted); }
.info-button:hover, .info-button:focus-visible { color: var(--accent); outline: none; }
.info-tooltip-content {
  position: absolute; z-index: 30; top: calc(100% + 8px); left: -8px;
  width: min(360px, 70vw); padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  box-shadow: var(--shadow); color: var(--text); font-size: 0.72rem;
  font-weight: 400; line-height: 1.4; text-transform: none; letter-spacing: normal;
  opacity: 0; visibility: hidden; transform: translateY(-3px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms;
}
.info-tooltip:hover .info-tooltip-content,
.info-tooltip:focus-within .info-tooltip-content { opacity: 1; visibility: visible; transform: translateY(0); }

.range-slider { position: relative; height: 24px; margin: 0 7px; }
.range-track, .range-fill { position: absolute; top: 11px; height: 3px; border-radius: 999px; }
.range-track { left: 0; right: 0; background: var(--range-track); }
.range-fill { background: var(--accent); }
.range-slider input[type="range"] { position: absolute; inset: 0; width: 100%; height: 24px; margin: 0; appearance: none; background: transparent; pointer-events: none; }
.range-slider input[type="range"]::-webkit-slider-thumb { width: 15px; height: 15px; border: 2px solid #fff; border-radius: 50%; appearance: none; background: var(--accent); box-shadow: 0 0 0 1px rgba(74,72,68,.3); pointer-events: auto; cursor: grab; }
.range-slider input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border: 2px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(74,72,68,.3); pointer-events: auto; cursor: grab; }
.timeline-years { display: flex; justify-content: space-between; margin: -2px 2px 7px; color: var(--muted); font-size: 0.68rem; }
.editorial-presets { display: block; }
.editorial-presets[hidden] { display: none; }
.editorial-presets-label { display: block; margin-bottom: 5px; }
.editorial-periods { display: flex; flex-wrap: nowrap; gap: 4px; }
.editorial-periods button { padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-raised); color: var(--muted); font-size: 0.68rem; line-height: 1.2; white-space: nowrap; }
.editorial-periods button:hover, .editorial-periods button.is-active { border-color: var(--accent); color: var(--accent); }
.editorial-periods button.is-active { background: rgba(144,61,36,.07); font-weight: 700; }

.louvain-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
.louvain-link:hover, .louvain-link:focus-visible { color: var(--accent-hover); text-decoration: underline; }
.info-link-icon { width: 14px; height: 14px; margin-left: 2px; display: inline-grid; vertical-align: 1px; font-size: 0.58rem; }

@media (max-width: 1100px) { .editorial-periods { flex-wrap: wrap; } }
@media (max-width: 600px) {
  .timeline-heading { align-items: flex-start; }
  .timeline-summary { flex-wrap: wrap; }
  .timeline-toggle { white-space: nowrap; }
}


/* Finitions interface : temporalité, terminologie et pied de page */
.timeline-heading {
  justify-content: flex-start;
}

.timeline-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.timeline-toggle {
  margin-left: 4px;
}

.external-link-icon {
  display: inline-block;
  margin-left: 2px;
  font-size: 0.8em;
  line-height: 1;
}

.footer-links {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.gitlab-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.footer-separator {
  color: var(--muted);
}

@media (max-width: 600px) {
  .timeline-summary {
    flex-wrap: wrap;
  }
  .timeline-toggle {
    margin-left: 0;
  }
  .footer-links {
    justify-content: flex-start;
  }
}


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