/* ============ Eventic - futuristic dark theme ============ */
:root {
  --bg: #070a14;
  --bg2: #0b1020;
  --surface: rgba(16, 22, 42, .72);
  --surface-solid: #101a30;
  --border: rgba(120, 160, 255, .14);
  --text: #e8edf8;
  --muted: #8b96b4;
  --accent: #38e1ff;   /* business / cyan */
  --accent2: #b26bff;  /* nonprofit / violet */
  --ok: #4ade80;
  --radius: 14px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  /* hauteur pilotée par flex : le layout occupe tout l'espace sous l'entête,
     quelle que soit la hauteur réelle de celle-ci */
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
}

/* ---- ambient background ---- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(90, 130, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 130, 255, .05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, #000 30%, transparent 100%);
}
.bg-glow {
  position: fixed; z-index: 0; pointer-events: none;
  width: 55vw; height: 55vw; border-radius: 50%;
  filter: blur(120px); opacity: .16;
}
.bg-glow-1 { top: -20vw; right: -12vw; background: var(--accent); }
.bg-glow-2 { bottom: -25vw; left: -10vw; background: var(--accent2); }

/* ============ Topbar ============ */
.topbar {
  position: relative; z-index: 5; flex-shrink: 0;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(10, 14, 28, .9), rgba(10, 14, 28, .65));
  backdrop-filter: blur(14px);
}
.filters-toggle {
  display: none;
  width: 38px; height: 38px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: .2s;
  align-items: center; justify-content: center;
}
.filters-toggle:hover { border-color: var(--accent); color: var(--accent); }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 700; letter-spacing: .02em;
}
.brand-name em {
  font-style: normal;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tag { font-size: .72rem; color: var(--muted); letter-spacing: .04em; }

.topbar-stats { display: flex; gap: 26px; margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.stat-num {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  color: var(--accent);
}
.stat:nth-child(2) .stat-num { color: var(--accent2); }
.stat:nth-child(3) .stat-num { color: var(--ok); }
.stat-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.lang-toggle {
  font-family: var(--font-display); font-weight: 600; font-size: .85rem;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; transition: .2s;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ============ Layout ============ */
.layout {
  position: relative; z-index: 2;
  display: flex; flex: 1; min-height: 0;
}

/* ============ Sidebar ============ */
.sidebar {
  width: 272px; flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 18px 0 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(12, 17, 34, .85), rgba(9, 13, 26, .85));
  backdrop-filter: blur(14px);
}
.sidebar-head { padding: 0 16px; }
.sidebar-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0 16px 20px;
  scrollbar-width: thin; scrollbar-color: rgba(120,160,255,.25) transparent;
}
.data-block { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); }
.data-updated { font-size: .72rem; letter-spacing: .02em; color: var(--accent); margin: 0 0 6px; }
.data-note { font-size: .72rem; line-height: 1.5; color: rgba(232, 237, 248, .55); margin: 0; }
/* pied de sidebar épinglé : toujours visible, sans défilement */
.sidebar-foot {
  flex-shrink: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: rgba(9, 13, 26, .92);
}
.powered { margin: 0; font-size: .72rem; }
.powered a { color: rgba(232, 237, 248, .55); text-decoration: none; transition: color .2s; }
.powered a:hover { color: var(--accent); }
.powered strong { font-weight: 600; }
.sidebar-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.sidebar-actions { display: flex; gap: 12px; }
.sidebar-head h2 { font-family: var(--font-display); font-size: 1rem; letter-spacing: .05em; text-transform: uppercase; }
.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: .75rem; cursor: pointer; opacity: .85;
}
.link-btn:hover { opacity: 1; text-decoration: underline; }

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 20px;
  color: var(--muted); transition: border-color .2s;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-wrap input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: .85rem; font-family: var(--font-body);
}
.search-wrap input::placeholder { color: var(--muted); }

.filter-group { margin-bottom: 20px; }
.filter-group h3 {
  font-size: .68rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 9px;
}
.chip-row { display: flex; gap: 6px; }
.chip-row.wrap { flex-wrap: wrap; }
.chip-col { display: flex; flex-direction: column; gap: 5px; }

.chip {
  font-family: var(--font-body); font-size: .76rem; font-weight: 500;
  color: var(--muted); background: rgba(255,255,255,.03);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; transition: .18s;
  text-align: left;
}
.chip:hover { border-color: rgba(120,160,255,.4); color: var(--text); }
.chip.active {
  color: var(--text); background: rgba(56, 225, 255, .1);
  border-color: rgba(56, 225, 255, .45);
  box-shadow: 0 0 12px rgba(56, 225, 255, .12);
}
.chip .count { color: var(--muted); font-size: .68rem; margin-left: 5px; }

.select {
  width: 100%; padding: 9px 12px;
  background: var(--surface-solid); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-family: var(--font-body); font-size: .82rem; cursor: pointer;
}

/* ============ Canvas ============ */
.canvas-wrap { position: relative; flex: 1; overflow: hidden; }
#mindmap { width: 100%; height: 100%; display: block; cursor: grab; }
#mindmap.dragging { cursor: grabbing; }

.canvas-controls {
  position: absolute; right: 18px; top: 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.canvas-controls button {
  width: 38px; height: 38px; font-size: 1rem;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; backdrop-filter: blur(10px); transition: .2s;
}
.canvas-controls button:hover { border-color: var(--accent); color: var(--accent); }

.legend {
  position: absolute; left: 18px; bottom: 16px;
  display: flex; align-items: center; gap: 18px;
  font-size: .74rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 16px; backdrop-filter: blur(10px);
}
.legend > span { display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend-hint { opacity: .65; }

.empty-state {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: .95rem; pointer-events: none;
}
.empty-state[hidden] { display: none; }

/* ---- SVG nodes ---- */
.link-line {
  fill: none; stroke: rgba(120, 160, 255, .18); stroke-width: 1.2;
  transition: stroke .2s;
}
.link-line.lvl1 { stroke: rgba(120, 160, 255, .3); stroke-width: 1.6; }

.node { cursor: pointer; outline: none; }
.node circle { transition: filter .2s, r .2s; }
/* focus clavier : indicateur sur le cercle, pas de rectangle natif */
.node:focus-visible circle { stroke: var(--accent2); stroke-width: 2.4; }

.node-center circle.core { fill: url(#gradCenter); }
.node-center text {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  fill: #fff; text-anchor: middle;
}
.node-center .sub { font-size: 8.5px; font-weight: 500; fill: rgba(255,255,255,.75); letter-spacing: .12em; }

.node-region circle {
  fill: #101a30; stroke: rgba(120,160,255,.5); stroke-width: 1.4;
}
.node-region text {
  font-family: var(--font-display); font-weight: 600; font-size: 11.5px;
  fill: var(--text); text-anchor: middle;
}
.node-region .rcount { font-size: 9px; fill: var(--muted); font-family: var(--font-body); }
.node-region.rname-l text { font-size: 9.4px; }
.node-region.rname-xl text { font-size: 8.4px; }
.node-region.rname-l .rcount, .node-region.rname-xl .rcount { font-size: 8.5px; }
.node-region:hover circle { stroke: var(--accent); filter: drop-shadow(0 0 6px rgba(56,225,255,.5)); }
.node-region:focus-visible circle { stroke: var(--accent2); stroke-width: 2.2; }

/* ---- Mise en évidence d'une région (clic sur son nœud) ---- */
.node, .link-line { transition: opacity .3s ease; }
#view.has-highlight .node:not(.hl):not(.node-center),
#view.has-highlight .link-line:not(.hl) { opacity: .12; }
#view.has-highlight .node-center { opacity: .45; }
#view.has-highlight .node-region.hl circle {
  stroke: var(--accent); stroke-width: 2.6;
  fill: #14264a;
  filter: drop-shadow(0 0 14px rgba(56,225,255,.85));
}
#view.has-highlight .node-region.hl text { fill: #fff; }
#view.has-highlight .node-event.hl circle {
  filter: drop-shadow(0 0 8px rgba(56,225,255,.6));
}
#view.has-highlight .node-event.hl text { fill: #fff; }
#view.has-highlight .link-line.hl { stroke: rgba(120,180,255,.55); }

/* ---- Bascule carte / liste ---- */
.view-toggle {
  display: flex; gap: 2px; margin-right: 10px;
  border: 1px solid var(--border); border-radius: 8px; padding: 2px;
  background: rgba(12, 17, 34, .6);
}
.view-toggle button {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 26px; border: none; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background .2s, color .2s;
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button.active { background: rgba(56, 225, 255, .14); color: var(--accent); }

/* ---- Vue liste ---- */
.canvas-wrap[data-view="list"] #mindmap,
.canvas-wrap[data-view="list"] .canvas-controls,
.canvas-wrap[data-view="list"] .legend { display: none; }

.list-view {
  position: absolute; inset: 0; overflow-y: auto;
  padding: 18px clamp(14px, 4vw, 48px) 60px;
  scrollbar-width: thin; scrollbar-color: rgba(120,160,255,.25) transparent;
}
.list-month {
  font-family: var(--font-display); font-size: .82rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
  margin: 22px 0 8px; position: sticky; top: 0; z-index: 2;
  background: linear-gradient(180deg, rgba(7,10,20,.96), rgba(7,10,20,.85));
  padding: 6px 0;
}
.list-month.past-head { color: var(--muted); }
.list-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left; cursor: pointer;
  padding: 10px 14px; margin-bottom: 6px;
  background: rgba(12, 17, 34, .55); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  transition: border-color .2s, background .2s, transform .15s;
}
.list-row:hover { border-color: var(--accent); background: rgba(18, 26, 48, .8); transform: translateX(3px); }
.list-row.past { opacity: .55; }
.lr-date {
  display: flex; flex-direction: column; align-items: center; flex-shrink: 0;
  min-width: 44px; padding: 4px 6px; border-radius: 8px;
  background: rgba(56, 225, 255, .08); border: 1px solid rgba(56,225,255,.18);
}
.lr-date b { font-family: var(--font-display); font-size: 1.05rem; line-height: 1.1; }
.lr-date i { font-style: normal; font-size: .68rem; color: var(--muted); text-transform: uppercase; }
.lr-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lr-name { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-meta { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-price { font-family: var(--font-display); font-size: .85rem; color: var(--text); flex-shrink: 0; }
.lr-price.free { color: var(--accent); }
.badge-soon {
  font-style: normal; font-size: .64rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: #071018; background: var(--accent);
  border-radius: 4px; padding: 1.5px 6px; margin-left: 8px; vertical-align: 2px;
}

/* ---- Infobulle de la carte ---- */
.map-tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  max-width: 300px; padding: 7px 11px;
  background: rgba(10, 15, 30, .95); border: 1px solid var(--accent);
  border-radius: 8px; font-size: .78rem; line-height: 1.4; color: var(--text);
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
}

/* évènement imminent (moins de 14 jours) : halo plus vif et plus rapide */
.node-event.soon .pulse { animation-duration: 1.4s; stroke-width: 1.8; }
.node-event.soon circle { stroke-width: 2; }

.node-event circle { stroke-width: 1.2; }
.node-event circle { fill: rgba(56, 225, 255, .16); stroke: var(--accent); }
.node-event text {
  font-size: 9.5px; fill: var(--text); font-family: var(--font-body);
  pointer-events: none;
}
.node-event:hover circle, .node-event.selected circle {
  filter: drop-shadow(0 0 8px currentColor);
}
.node-event:hover circle, .node-event.selected circle { filter: drop-shadow(0 0 9px rgba(56,225,255,.9)); }
.node-event.selected circle { stroke-width: 2.4; }

/* past events: dimmed, no pulse */
.node-event.past circle { opacity: .4; }
.node-event.past text { opacity: .5; }
.node-event.past .pulse { display: none; }

.pulse {
  animation: pulse 3.2s ease-in-out infinite;
  transform-origin: center; transform-box: fill-box;
}
@keyframes pulse {
  0%, 100% { opacity: .35; transform: scale(1); }
  50% { opacity: .08; transform: scale(1.45); }
}

/* ============ Detail panel ============ */
.detail {
  position: absolute; right: 0; top: 0; bottom: 0; z-index: 8;
  width: 340px; padding: 26px 24px;
  background: linear-gradient(180deg, rgba(13, 18, 36, .96), rgba(10, 14, 28, .96));
  border-left: 1px solid var(--border);
  backdrop-filter: blur(16px);
  overflow-y: auto;
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.detail-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
}
.detail-close:hover { color: var(--text); border-color: var(--accent); }

.detail-type {
  display: inline-block; font-size: .68rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px; margin-bottom: 14px;
}
.detail-type { color: var(--accent); background: rgba(56,225,255,.1); border: 1px solid rgba(56,225,255,.35); }

.detail h2 { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.3; margin-bottom: 10px; }
.detail-desc { font-size: .85rem; color: var(--muted); line-height: 1.55; margin-bottom: 20px; }

.detail-meta { display: flex; flex-direction: column; gap: 12px; margin-bottom: 26px; }
.detail-meta > div {
  display: flex; justify-content: space-between; gap: 12px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--border);
}
.detail-meta dt { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.detail-meta dd { font-size: .84rem; font-weight: 500; text-align: right; }

.detail-cta {
  display: block; text-align: center;
  font-family: var(--font-display); font-weight: 600; font-size: .9rem;
  color: #06121c; text-decoration: none;
  background: linear-gradient(90deg, var(--accent), #6ee7ff);
  border-radius: 11px; padding: 12px;
  transition: .2s;
}
.detail-cta:hover { filter: brightness(1.12); box-shadow: 0 0 22px rgba(56,225,255,.35); }

/* ============ Accessibility ============ */
button:focus-visible, .chip:focus-visible, .select:focus-visible,
input:focus-visible, .detail-cta:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.node:focus-visible { outline: none; }
.node:focus-visible circle { stroke: #fff; stroke-width: 2.4; }

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; opacity: .25; }
  .detail { animation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .topbar { gap: 14px; }
  .topbar-stats { display: none; }
  .filters-toggle { display: inline-flex; }
  .sidebar {
    position: absolute; z-index: 7; height: 100%;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 12px 0 32px rgba(0, 0, 0, .45);
  }
  .sidebar.open { transform: none; }
  .detail { width: 100%; }
}
