:root {
  --magenta: #e6299c;
  --purple: #7c3aed;
  --blue: #2e7fe0;
  --cyan: #22d3ee;
  --gradient: linear-gradient(90deg, var(--magenta), var(--purple), var(--blue), var(--cyan));

  --bg: #faf9fc;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #5c5c72;
  --border: #e6e3ee;
  --shadow: 0 4px 20px rgba(124, 58, 237, 0.08);

  --radius: 18px;
  --max-width: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14121f;
    --surface: #1e1b2e;
    --text: #f2f0f7;
    --text-muted: #b3aec4;
    --border: #322c46;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  }

  .chip-verified {
    color: #4ade80;
  }

  .chip-unverified {
    color: #facc15;
  }
}

* {
  box-sizing: border-box;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

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

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ---------- Barre de sécurité (urgences + sortie rapide) ---------- */
.safety-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: #1a1a2e;
  color: #f2f0f7;
  font-size: 0.78rem;
}

.safety-numbers {
  margin: 0;
}

.safety-numbers a {
  color: #7dd3fc;
  font-weight: 600;
  text-decoration: none;
}

.safety-numbers a:hover {
  text-decoration: underline;
}

.quick-exit-btn {
  background: var(--magenta);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.quick-exit-btn:hover {
  opacity: 0.9;
}

/* ---------- Header / footer ---------- */
.site-header {
  text-align: center;
  padding: 32px 20px 20px;
}

.site-header .logo {
  height: 64px;
  width: auto;
}

.tagline {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.site-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.nav-btn {
  background: none;
  border: none;
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.nav-btn.active {
  background: var(--gradient);
  color: #fff;
  font-weight: 600;
}

.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 30px 20px 50px;
}

.site-footer p {
  margin: 4px 0;
}

/* ---------- Banners ---------- */
.banner {
  max-width: var(--max-width);
  margin: 0 auto 20px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
}

.banner-error {
  border-color: var(--magenta);
  color: var(--magenta);
}

.banner-warning {
  border-color: var(--blue);
  color: var(--blue);
}

/* ---------- Views ---------- */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  border: 1px solid var(--border);
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.intro-card {
  text-align: center;
}

.intro-card h1 {
  margin-top: 0;
  font-size: 2rem;
}

.intro-card p {
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  margin-top: 12px;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn[hidden] {
  display: none;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  background-size: 200% 100%;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-ghost {
  background: transparent;
  color: var(--purple);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--purple);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  text-decoration: underline;
  width: auto;
  margin: 16px auto 0;
  display: block;
  cursor: pointer;
}

/* ---------- Quiz ---------- */
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: var(--gradient);
  width: 0%;
  transition: width 0.3s ease;
}

.quiz-step {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 20px;
}

.quiz-card h2 {
  margin-top: 0;
}

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: -8px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0 8px;
}

.option-btn {
  text-align: left;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option-btn:hover {
  border-color: var(--cyan);
}

.option-btn.active {
  border-color: var(--purple);
  background: linear-gradient(90deg, rgba(230, 41, 156, 0.12), rgba(34, 211, 238, 0.12));
  font-weight: 600;
}

.quiz-nav {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.quiz-nav .btn {
  margin-top: 0;
  width: auto;
  flex: 1;
}

/* ---------- Results / browse ---------- */
.results-header {
  padding-top: 24px;
  margin-bottom: 20px;
}

.results-header h1 {
  margin-bottom: 12px;
}

.results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.results-actions .btn,
.results-header > .btn {
  width: auto;
  margin-top: 0;
  padding: 10px 18px;
  font-size: 0.9rem;
}

.results-theme {
  margin-top: 32px;
}

.results-theme h2 {
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
}

.resource-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 800px) {
  .resource-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    align-items: start;
    gap: 16px;
  }
}

.resource-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--purple);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.resource-card h3 {
  margin: 0 0 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.12);
  color: var(--purple);
}

.chip-muted {
  background: var(--border);
  color: var(--text-muted);
}

.chip-verified,
.chip-unverified {
  display: inline-block;
  margin-bottom: 8px;
}

.chip-verified {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.chip-unverified {
  background: rgba(234, 179, 8, 0.18);
  color: #92600a;
}

.descriptif {
  font-size: 0.95rem;
}

.descriptif p {
  margin: 0 0 8px;
}

.descriptif .rich-list {
  margin: 0 0 8px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.descriptif .rich-list li {
  line-height: 1.5;
}

.descriptif a {
  color: var(--blue);
  word-break: break-word;
}

.descriptif.collapsed {
  max-height: 6.4em;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}

.descriptif-toggle {
  background: none;
  border: none;
  width: auto;
  display: inline-block;
  color: var(--purple);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 0 10px;
  margin: 0;
}

.descriptif-toggle:hover {
  text-decoration: underline;
}

.meta {
  margin: 4px 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.contacts {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.92rem;
}

.contacts a {
  color: var(--blue);
  text-decoration: none;
}

.contacts a:hover {
  text-decoration: underline;
}

/* ---------- Assistant de remplissage (wizard) ---------- */
.wizard-cta {
  margin: 4px 0 14px;
}

.wizard-title {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

.wizard-field {
  margin-bottom: 22px;
}

.wizard-field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
}

.wizard-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.wizard-date-row {
  display: flex;
  gap: 10px;
}

.wizard-date-input {
  text-align: center;
}

/* ---------- Démarches administratives ---------- */
.demarche-card {
  border-left-color: var(--blue);
}

.official-link {
  display: inline-block;
  width: auto;
  margin: 4px 0 12px;
  padding: 8px 16px;
  font-size: 0.88rem;
  text-decoration: none;
}

.checklist-progress {
  margin: 4px 0 12px;
}

.checklist-label {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.checklist-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.checklist-reset {
  background: none;
  border: none;
  width: auto;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 6px 0 0;
  white-space: nowrap;
}

.checklist-reset:hover {
  color: var(--magenta);
  text-decoration: underline;
}

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

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: opacity 0.15s ease;
}

.checklist li.checked {
  opacity: 0.55;
}

.checklist li.checked label {
  text-decoration: line-through;
}

.checklist input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--purple);
  flex-shrink: 0;
  cursor: pointer;
}

.checklist label {
  font-size: 0.92rem;
  cursor: pointer;
}

.tips {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(34, 211, 238, 0.12);
  border-radius: 10px;
  padding: 9px 12px;
  margin: 12px 0 0;
}

.related-demarches {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.related-demarches-title {
  font-size: 1rem;
  margin: 0 0 10px;
}

/* ---------- Browse filters ---------- */
.search-input {
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.more-filters-toggle {
  display: block;
  flex-basis: 100%;
  background: none;
  border: none;
  width: auto;
  color: var(--purple);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 0 14px;
}

.more-filters-toggle:hover {
  text-decoration: underline;
}

.filters-group-label {
  flex-basis: 100%;
  margin: 8px 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-chip.active {
  border-color: transparent;
  background: var(--gradient);
  color: #fff;
}

@media (min-width: 640px) {
  .quiz-nav {
    justify-content: flex-end;
  }
  .quiz-nav .btn {
    min-width: 140px;
  }
  .results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .results-header h1 {
    margin-bottom: 0;
  }
}
