/* ============================================================
   ORIENTATION PRO — Futurama Theme
   Layout responsive : ≥ 768 px → deux colonnes
                       < 768 px → empilé
   Contraste ≥ 4.5:1 (WCAG 2.1 AA), police min 16 px
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Palette Futurama : violet foncé + vert néon + blanc */
  --color-bg:          #0d0d1a;
  --color-surface:     #1a1a2e;
  --color-surface-alt: #16213e;
  --color-border:      #2a2a4a;
  --color-primary:     #7b2fff;   /* violet */
  --color-accent:      #00e5ff;   /* cyan néon */
  --color-success:     #39ff14;   /* vert néon */
  --color-text:        #e8e8f0;   /* blanc cassé — contraste > 7:1 sur bg */
  --color-text-muted:  #9090b0;   /* gris clair — contraste ≈ 4.6:1 sur bg */
  --color-dot-active:  #00e5ff;
  --color-dot-inactive:#3a3a5a;
  --color-dot-boost:   #39ff14;

  --font-base: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-size-base: 16px;
  --font-size-sm:   14px;
  --font-size-lg:   20px;
  --font-size-xl:   24px;

  --radius:    8px;
  --radius-lg: 16px;
  --gap:       1.5rem;
  --transition: 150ms ease;
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #1a0533 0%, #0d1a33 100%);
  border-bottom: 2px solid var(--color-primary);
  padding: 1rem var(--gap);
}

.header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

.futurama-poster {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 2px solid var(--color-primary);
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(123, 47, 255, 0.5);
}

.header-text h1 {
  font-size: var(--font-size-xl);
  color: var(--color-accent);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
  line-height: 1.2;
}

.header-subtitle {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* ── Main layout ────────────────────────────────────────────── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: var(--gap);
  padding: var(--gap);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ── Quiz panel (colonne gauche) ────────────────────────────── */
.quiz-panel {
  flex: 0 0 380px;
  min-width: 280px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  padding-right: 0.5rem;
}

/* Scrollbar stylisée */
.quiz-panel::-webkit-scrollbar {
  width: 6px;
}
.quiz-panel::-webkit-scrollbar-track {
  background: var(--color-surface);
}
.quiz-panel::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: 3px;
}

#quiz-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Fieldset / question ────────────────────────────────────── */
fieldset.question-group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  transition: border-color var(--transition);
}

fieldset.question-group:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.2);
}

fieldset.question-group legend {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-accent);
  padding: 0 0.5rem;
  line-height: 1.4;
}

.question-hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  display: block;
}

/* ── Radio / checkbox options ───────────────────────────────── */
.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.options-list.options-inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
  font-size: var(--font-size-base);
  color: var(--color-text);
  user-select: none;
}

.option-label:hover {
  background: rgba(123, 47, 255, 0.15);
  border-color: var(--color-primary);
}

.option-label input[type="radio"],
.option-label input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  cursor: pointer;
}

.option-label input[type="radio"]:checked + span,
.option-label input[type="checkbox"]:checked + span {
  color: var(--color-accent);
  font-weight: 600;
}

.option-label:has(input:checked) {
  background: rgba(0, 229, 255, 0.1);
  border-color: var(--color-accent);
}

/* ── Bouton Recommencer ─────────────────────────────────────── */
.btn-reset {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  background: linear-gradient(135deg, var(--color-primary), #5500cc);
  color: #fff;
  font-size: var(--font-size-base);
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.03em;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-reset:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-reset:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

.btn-reset:active {
  transform: translateY(0);
}

/* ── Chart panel (colonne droite) ───────────────────────────── */
.chart-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.chart-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.chart-header h2 {
  font-size: var(--font-size-lg);
  color: var(--color-accent);
}

.active-count {
  font-size: var(--font-size-base);
  color: var(--color-success);
  font-weight: 600;
}

.chart-container {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 400px;
  position: relative;
}

.chart-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── SVG éléments ───────────────────────────────────────────── */
.dot-active {
  fill: var(--color-dot-active);
  stroke: rgba(0, 229, 255, 0.4);
  stroke-width: 1.5;
  cursor: pointer;
  transition: r 0.1s ease;
}

.dot-active:hover,
.dot-active:focus {
  fill: #fff;
  stroke: var(--color-accent);
  stroke-width: 2;
}

.dot-boost {
  fill: var(--color-dot-boost);
  stroke: rgba(57, 255, 20, 0.4);
  stroke-width: 1.5;
  cursor: pointer;
}

.dot-inactive {
  fill: var(--color-dot-inactive);
  stroke: none;
  opacity: 0.35;
  pointer-events: none;
}

.chart-axis-line {
  stroke: var(--color-border);
  stroke-width: 1;
}

.chart-tick-text {
  fill: var(--color-text-muted);
  font-size: 11px;
  font-family: var(--font-base);
}

.chart-grid-line {
  stroke: var(--color-border);
  stroke-width: 0.5;
  stroke-dasharray: 4 4;
}

.chart-fallback {
  fill: var(--color-text-muted);
  font-size: 14px;
  font-family: var(--font-base);
  text-anchor: middle;
}

/* ── Infobulle ──────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  pointer-events: none;
  z-index: 1000;
  max-width: 220px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--transition);
}

.tooltip.visible {
  opacity: 1;
}

.tooltip-label {
  font-weight: 700;
  color: var(--color-accent);
  display: block;
  margin-bottom: 0.25rem;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--color-text-muted);
}

.tooltip-row strong {
  color: var(--color-text);
}

/* ── Légende ────────────────────────────────────────────────── */
.chart-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  flex-wrap: wrap;
}

.legend-item {
  font-size: 1.2rem;
  line-height: 1;
}

.legend-active  { color: var(--color-dot-active); }
.legend-inactive { color: var(--color-dot-inactive); opacity: 0.6; }

/* ── Labels d'axes ──────────────────────────────────────────── */
.axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 0.75rem var(--gap);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* ── Loading / messages ─────────────────────────────────────── */
.loading-msg {
  color: var(--color-text-muted);
  font-style: italic;
  padding: 1rem;
}

/* ── Responsive : < 768 px → empilé ────────────────────────── */
@media (max-width: 767px) {
  .app-main {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .quiz-panel {
    flex: none;
    max-width: 100%;
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }

  .chart-panel {
    min-height: 360px;
  }

  .chart-container {
    min-height: 300px;
  }

  .header-text h1 {
    font-size: var(--font-size-lg);
  }

  .options-list.options-inline {
    flex-direction: column;
  }
}

/* ── Responsive : ≥ 768 px → deux colonnes ─────────────────── */
@media (min-width: 768px) {
  .app-main {
    flex-direction: row;
    align-items: flex-start;
  }

  .quiz-panel {
    position: sticky;
    top: 1rem;
  }
}

/* ── Focus visible global ───────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

fieldset.question-group {
  animation: fadeIn 0.2s ease both;
}

/* ── Infobulle dynamique (#chart-tooltip) ───────────────────── */
#chart-tooltip {
  display: none;
  position: fixed;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  pointer-events: none;
  z-index: 1000;
  max-width: 240px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  line-height: 1.5;
}

#chart-tooltip strong {
  color: var(--color-accent);
}

/* ── Compteur de métiers actifs ─────────────────────────────── */
.chart-counter {
  font-size: var(--font-size-base);
  color: var(--color-success);
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  text-align: right;
}

/* ── Message fallback (aucun métier) ────────────────────────── */
p.chart-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  text-align: center;
  padding: 1rem;
  background: transparent;
  fill: unset; /* override SVG rule */
}

/* ── Erreur base de données ─────────────────────────────────── */
.chart-error {
  padding: 1rem;
  color: #ff6b6b;
  font-size: var(--font-size-base);
}

/* ── Points SVG interactifs ─────────────────────────────────── */
#chart-container svg circle[tabindex="0"]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
