/* ══════════════════════════════════════════════════════
   ecosystem.css — Interactive ecosystem map styles
   Adapts to data-bs-theme="light" / "dark"
   ══════════════════════════════════════════════════════ */

/* ── THEME TOKENS (scoped to eco-page) ── */
.eco-page,
.eco-tooltip,
.eco-panel,
.eco-panel-overlay {
  --eco-core: #f97316;
  --eco-gouv: #7eb8f7;
  --eco-detect: #a78bfa;
  --eco-surface: #fb7185;
  --eco-decept: #fbbf24;
  --eco-panel-w: 420px;

  /* Light mode defaults */
  --eco-bg: #f5f5f5;
  --eco-text: #111;
  --eco-text-dim: rgba(0,0,0,0.55);
  --eco-text-muted: rgba(0,0,0,0.3);
  --eco-text-faint: rgba(0,0,0,0.12);
  --eco-grid: rgba(0,0,0,0.05);
  --eco-conn: rgba(0,0,0,0.2);
  --eco-node-fill: rgba(0,0,0,0.06);
  --eco-ring-opacity: 0.85;
  --eco-glow-opacity: 0.18;
  --eco-panel-bg: rgba(255,255,255,0.97);
  --eco-panel-border: rgba(0,0,0,0.06);
  --eco-panel-section-line: rgba(0,0,0,0.06);
  --eco-chip-bg: rgba(0,0,0,0.03);
  --eco-chip-border: rgba(0,0,0,0.08);
  --eco-chip-text: rgba(0,0,0,0.45);
  --eco-chip-hover-bg: rgba(0,0,0,0.06);
  --eco-chip-hover-border: rgba(0,0,0,0.15);
  --eco-chip-hover-text: rgba(0,0,0,0.7);
  --eco-btn-sec-bg: rgba(0,0,0,0.04);
  --eco-btn-sec-border: rgba(0,0,0,0.1);
  --eco-btn-sec-text: rgba(0,0,0,0.5);
  --eco-btn-sec-hover-bg: rgba(0,0,0,0.08);
  --eco-overlay-bg: rgba(0,0,0,0.15);
  --eco-tooltip-bg: rgba(255,255,255,0.95);
  --eco-tooltip-border: rgba(0,0,0,0.08);
  --eco-tooltip-text: #111;
  --eco-tooltip-dim: rgba(0,0,0,0.4);
  --eco-close-border: rgba(0,0,0,0.08);
  --eco-close-bg: rgba(0,0,0,0.03);
  --eco-close-text: rgba(0,0,0,0.4);
  --eco-close-hover-bg: rgba(0,0,0,0.06);
  --eco-cta-border: rgba(0,0,0,0.08);
  --eco-cta-text: rgba(0,0,0,0.35);
  --eco-mobile-bg: rgba(0,0,0,0.02);
  --eco-mobile-border: rgba(0,0,0,0.06);
  --eco-mobile-hover-bg: rgba(0,0,0,0.04);
  --eco-mobile-hover-border: rgba(0,0,0,0.1);
  --eco-mobile-arrow: rgba(0,0,0,0.15);
  --eco-mobile-label: rgba(0,0,0,0.18);
  --eco-mobile-label-line: rgba(0,0,0,0.06);
  --eco-accent-line-opacity: 0.4;
  --eco-label-fill: rgba(0,0,0,0.55);
  --eco-label-hover: rgba(0,0,0,0.85);
}

html[data-bs-theme=dark] .eco-page,
html[data-bs-theme=dark] .eco-tooltip,
html[data-bs-theme=dark] .eco-panel,
html[data-bs-theme=dark] .eco-panel-overlay {
  --eco-bg: #020202;
  --eco-text: #fff;
  --eco-text-dim: rgba(255,255,255,0.45);
  --eco-text-muted: rgba(255,255,255,0.22);
  --eco-text-faint: rgba(255,255,255,0.10);
  --eco-grid: rgba(255,255,255,0.02);
  --eco-conn: rgba(255,255,255,0.12);
  --eco-node-fill: rgba(255,255,255,0.03);
  --eco-ring-opacity: 0.25;
  --eco-glow-opacity: 0.08;
  --eco-panel-bg: rgba(14,14,14,0.97);
  --eco-panel-border: rgba(255,255,255,0.06);
  --eco-panel-section-line: rgba(255,255,255,0.04);
  --eco-chip-bg: rgba(255,255,255,0.02);
  --eco-chip-border: rgba(255,255,255,0.07);
  --eco-chip-text: rgba(255,255,255,0.4);
  --eco-chip-hover-bg: rgba(255,255,255,0.06);
  --eco-chip-hover-border: rgba(255,255,255,0.15);
  --eco-chip-hover-text: rgba(255,255,255,0.7);
  --eco-btn-sec-bg: rgba(255,255,255,0.04);
  --eco-btn-sec-border: rgba(255,255,255,0.08);
  --eco-btn-sec-text: rgba(255,255,255,0.5);
  --eco-btn-sec-hover-bg: rgba(255,255,255,0.08);
  --eco-overlay-bg: rgba(0,0,0,0.4);
  --eco-tooltip-bg: rgba(20,20,20,0.95);
  --eco-tooltip-border: rgba(255,255,255,0.08);
  --eco-tooltip-text: #fff;
  --eco-tooltip-dim: rgba(255,255,255,0.4);
  --eco-close-border: rgba(255,255,255,0.08);
  --eco-close-bg: rgba(255,255,255,0.03);
  --eco-close-text: rgba(255,255,255,0.4);
  --eco-close-hover-bg: rgba(255,255,255,0.08);
  --eco-cta-border: rgba(255,255,255,0.06);
  --eco-cta-text: rgba(255,255,255,0.3);
  --eco-mobile-bg: rgba(255,255,255,0.025);
  --eco-mobile-border: rgba(255,255,255,0.06);
  --eco-mobile-hover-bg: rgba(255,255,255,0.04);
  --eco-mobile-hover-border: rgba(255,255,255,0.1);
  --eco-mobile-arrow: rgba(255,255,255,0.15);
  --eco-mobile-label: rgba(255,255,255,0.18);
  --eco-mobile-label-line: rgba(255,255,255,0.04);
  --eco-accent-line-opacity: 0.6;
  --eco-label-fill: rgba(255,255,255,0.45);
  --eco-label-hover: rgba(255,255,255,0.8);
}

/* ── PAGE ── */
.eco-page {
  background: var(--eco-bg);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.eco-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--eco-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--eco-grid) 1px, transparent 1px);
  background-size: 80px 80px;
  pointer-events: none;
  z-index: 0;
}

.eco-page::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--eco-core) 30%, var(--eco-core) 70%, transparent);
  opacity: var(--eco-accent-line-opacity);
  z-index: 10;
}

/* ── HEADER ── */
.eco-header {
  text-align: center;
  padding: 48px 24px 12px;
  position: relative;
  z-index: 2;
}

.eco-eyebrow {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  letter-spacing: 3.5px;
  color: var(--eco-text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.eco-title {
  font-family: 'Syne', sans-serif;
  font-size: 38px;
  font-weight: 800;
  color: var(--eco-text);
  letter-spacing: -1px;
  line-height: 1.1;
}
.eco-title .accent { color: var(--eco-core); }

.eco-subtitle {
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  color: var(--eco-text-muted);
  letter-spacing: 1.5px;
  margin-top: 10px;
}

/* ── SVG MAP CONTAINER ── */
.eco-map-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 24px 24px;
  position: relative;
  z-index: 2;
}

.eco-map-svg {
  width: 100%;
  max-width: 1100px;
  height: auto;
}

/* ── GLOW ── */
.eco-glow {
  pointer-events: none;
}

/* ── CONNECTION PATHS ── */
.eco-connection {
  stroke: var(--eco-conn);
  stroke-width: 1.2;
  stroke-dasharray: 5 5;
  fill: none;
  transition: stroke 0.4s, stroke-width 0.4s, stroke-dasharray 0.4s, opacity 0.4s;
}

.eco-map-svg.has-active .eco-connection {
  opacity: 0.15;
}

.eco-connection.highlighted {
  stroke-width: 2;
  stroke-dasharray: none;
  opacity: 1 !important;
}

.eco-connection.highlighted.layer-core     { stroke: rgba(249,115,22,0.5); }
.eco-connection.highlighted.layer-gouv     { stroke: rgba(126,184,247,0.5); }
.eco-connection.highlighted.layer-detect   { stroke: rgba(167,139,250,0.5); }
.eco-connection.highlighted.layer-surface  { stroke: rgba(251,113,133,0.5); }
.eco-connection.highlighted.layer-decept   { stroke: rgba(251,191,36,0.5); }

/* ── NODES ── */
.eco-node {
  cursor: pointer;
  outline: none;
}

.eco-node-bg {
  transition: r 0.3s, fill-opacity 0.3s;
}

.eco-node-ring {
  fill: none;
  stroke-width: 1.5;
  transition: stroke-opacity 0.3s, r 0.3s;
}

.eco-node-glow {
  transition: r 0.4s, opacity 0.4s;
  pointer-events: none;
}

.eco-node-label {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  fill: var(--eco-label-fill);
  text-anchor: middle;
  letter-spacing: 0.5px;
  transition: fill 0.3s;
  pointer-events: none;
}

.eco-node-icon {
  transition: opacity 0.3s;
  pointer-events: none;
}

/* Status dots */
.eco-status-dot {
  transition: r 0.3s;
}

@keyframes ecoPulse {
  0%, 100% { opacity: 1; r: 4; }
  50% { opacity: 0.4; r: 3; }
}
.eco-status-dot.live {
  fill: #22c55e;
  animation: ecoPulse 2s ease-in-out infinite;
}
.eco-status-dot.soon {
  fill: #f59e0b;
  animation: ecoPulse 2.5s ease-in-out infinite;
}

/* Hover / active states */
.eco-node:hover .eco-node-bg,
.eco-node:focus .eco-node-bg {
  fill-opacity: 0.12;
}

.eco-node:hover .eco-node-ring,
.eco-node:focus .eco-node-ring {
  stroke-opacity: 0.7;
}

.eco-node:hover .eco-node-glow,
.eco-node:focus .eco-node-glow {
  opacity: 0.25;
}

.eco-node:hover .eco-node-label,
.eco-node:focus .eco-node-label {
  fill: var(--eco-label-hover);
}

.eco-map-svg.has-active .eco-node {
  opacity: 0.2;
  transition: opacity 0.4s;
}

.eco-map-svg.has-active .eco-node.active,
.eco-map-svg.has-active .eco-node.connected {
  opacity: 1;
}

.eco-node.active .eco-node-ring {
  stroke-opacity: 1;
  stroke-width: 2.5;
}

.eco-node.active .eco-node-glow {
  opacity: 0.35;
}

/* ── TOOLTIP ── */
.eco-tooltip {
  position: fixed;
  background: var(--eco-tooltip-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--eco-tooltip-border);
  border-radius: 8px;
  padding: 8px 14px;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 260px;
}

.eco-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.eco-tooltip-name {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--eco-tooltip-text);
}

.eco-tooltip-tag {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  color: var(--eco-tooltip-dim);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ── SLIDE-IN PANEL ── */
.eco-panel-overlay {
  position: fixed;
  inset: 0;
  background: var(--eco-overlay-bg);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.eco-panel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.eco-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--eco-panel-w);
  height: 100vh;
  background: var(--eco-panel-bg);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--eco-panel-border);
  z-index: 1051;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.eco-panel.open {
  transform: translateX(0);
}

.eco-panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--eco-close-border);
  border-radius: 8px;
  background: var(--eco-close-bg);
  color: var(--eco-close-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  z-index: 2;
}
.eco-panel-close:hover {
  background: var(--eco-close-hover-bg);
  color: var(--eco-text);
}

.eco-panel-header {
  padding: 32px 28px 20px;
  border-bottom: 1px solid var(--eco-panel-section-line);
}

.eco-panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.eco-panel-badge.live {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.25);
  color: #22c55e;
}
.eco-panel-badge.soon {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  color: #f59e0b;
}
.eco-panel-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: ecoPulse 2s ease-in-out infinite;
}
.eco-panel-badge.live .eco-panel-badge-dot { background: #22c55e; }
.eco-panel-badge.soon .eco-panel-badge-dot { background: #f59e0b; }

.eco-panel-ref {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.eco-panel-name {
  font-family: 'Syne', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--eco-text);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.eco-panel-tagline {
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  color: var(--eco-text-dim);
  margin-top: 8px;
  line-height: 1.5;
}

/* Panel body */
.eco-panel-body {
  padding: 24px 28px;
  flex: 1;
}

.eco-panel-section {
  margin-bottom: 24px;
}

.eco-panel-section-title {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--eco-text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.eco-panel-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--eco-panel-section-line);
}

.eco-panel-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.eco-panel-features li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: 'Geist Mono', monospace;
  font-size: 11.5px;
  color: var(--eco-text-dim);
  line-height: 1.4;
}

.eco-panel-features li::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

/* Feature dot colors per layer */
.eco-panel.layer-core .eco-panel-features li::before,
.eco-panel.layer-core .eco-panel-ref { color: var(--eco-core); background: var(--eco-core); }
.eco-panel.layer-gouv .eco-panel-features li::before,
.eco-panel.layer-gouv .eco-panel-ref { color: var(--eco-gouv); background: var(--eco-gouv); }
.eco-panel.layer-detect .eco-panel-features li::before,
.eco-panel.layer-detect .eco-panel-ref { color: var(--eco-detect); background: var(--eco-detect); }
.eco-panel.layer-surface .eco-panel-features li::before,
.eco-panel.layer-surface .eco-panel-ref { color: var(--eco-surface); background: var(--eco-surface); }
.eco-panel.layer-decept .eco-panel-features li::before,
.eco-panel.layer-decept .eco-panel-ref { color: var(--eco-decept); background: var(--eco-decept); }

/* Fix: ref is text, not background */
.eco-panel .eco-panel-ref { background: none; }

/* Integration chips */
.eco-panel-integrations {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.eco-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--eco-chip-border);
  background: var(--eco-chip-bg);
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  color: var(--eco-chip-text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  letter-spacing: 0.3px;
}
.eco-chip:hover {
  background: var(--eco-chip-hover-bg);
  border-color: var(--eco-chip-hover-border);
  color: var(--eco-chip-hover-text);
}

.eco-chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

/* Panel footer */
.eco-panel-footer {
  padding: 20px 28px 28px;
  border-top: 1px solid var(--eco-panel-section-line);
  display: flex;
  gap: 10px;
}

.eco-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  border: none;
}

.eco-btn-primary {
  background: var(--eco-core);
  color: #fff;
}
.eco-btn-primary:hover {
  background: #e2621d;
}

.eco-btn-secondary {
  background: var(--eco-btn-sec-bg);
  border: 1px solid var(--eco-btn-sec-border);
  color: var(--eco-btn-sec-text);
}
.eco-btn-secondary:hover {
  background: var(--eco-btn-sec-hover-bg);
  color: var(--eco-text);
}

/* Coming soon CTA */
.eco-panel-cta {
  text-align: center;
  padding: 20px;
  border: 1px dashed var(--eco-cta-border);
  border-radius: 10px;
}
.eco-panel-cta p {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--eco-cta-text);
  margin-bottom: 12px;
}

/* ── LEGEND ── */
.eco-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 8px 24px 32px;
  position: relative;
  z-index: 2;
  flex-wrap: wrap;
}

.eco-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  color: var(--eco-text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.eco-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.6;
}

/* ── MOBILE FALLBACK ── */
.eco-mobile-fallback {
  display: none;
  padding: 0 20px 40px;
  position: relative;
  z-index: 2;
}

.eco-mobile-layer {
  margin-bottom: 28px;
}

.eco-mobile-layer-label {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--eco-mobile-label);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.eco-mobile-layer-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--eco-mobile-label-line);
}

.eco-mobile-card {
  background: var(--eco-mobile-bg);
  border: 1px solid var(--eco-mobile-border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.eco-mobile-card:hover {
  background: var(--eco-mobile-hover-bg);
  border-color: var(--eco-mobile-hover-border);
}

.eco-mobile-card-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.eco-mobile-card-name {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--eco-text);
}

.eco-mobile-card-tag {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  color: var(--eco-text-dim);
  letter-spacing: 0.5px;
}

.eco-mobile-card-arrow {
  color: var(--eco-mobile-arrow);
  font-size: 18px;
}

/* Layer border accents on mobile cards */
.eco-mobile-card.layer-core   { border-left: 2px solid rgba(249,115,22,0.4); }
.eco-mobile-card.layer-gouv   { border-left: 2px solid rgba(126,184,247,0.4); }
.eco-mobile-card.layer-detect { border-left: 2px solid rgba(167,139,250,0.4); }
.eco-mobile-card.layer-surface{ border-left: 2px solid rgba(251,113,133,0.4); }
.eco-mobile-card.layer-decept { border-left: 2px solid rgba(251,191,36,0.4); }

/* ── SVG LIGHT MODE ADJUSTMENTS ── */
/* In light mode, darken layer colors slightly for better contrast on white */
html:not([data-bs-theme=dark]) .eco-page,
html:not([data-bs-theme=dark]) .eco-panel {
  --eco-core: #e05a10;
  --eco-gouv: #3574b8;
  --eco-detect: #6842b0;
  --eco-surface: #d4455a;
  --eco-decept: #b8860b;
}

/* ── RESPONSIVE ── */
@media (max-width: 1023px) {
  .eco-map-wrap,
  .eco-legend { display: none; }
  .eco-mobile-fallback { display: block; }
  .eco-panel { width: 100%; }
}

@media (min-width: 1024px) {
  .eco-mobile-fallback { display: none; }
}
