/* Alter Finder — ambiance "veilleuse" : nuit violette, lueur pêche.
   Pensé pour être lisible et apaisant même en pleine dissociation. */

:root {
  --night:   #221c2e;
  --surface: #2d2540;
  --line:    #3d3355;
  --mist:    #ede8f6;
  --faded:   #a79bc2;
  --peach:   #f0a98c;
  --sage:    #93c7a5;
  --rose:    #dd97ac;
}

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

body {
  background: var(--night);
  color: var(--mist);
  font-family: "Atkinson Hyperlegible", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  min-height: 100vh;
}

h1, h2, .display {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  letter-spacing: 0.01em;
}

a { color: var(--peach); }

/* ---------- Coquille commune ---------- */
.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 4px;
  font-size: 15px;
  color: var(--faded);
}
.topbar a { text-decoration: none; margin-left: 16px; }
.brand { font-family: "Fraunces", serif; font-size: 17px; color: var(--mist); }
.brand::before { content: "🐾 "; }

/* ---------- Boutons ---------- */
button {
  font-family: inherit;
  font-size: 18px;
  color: var(--mist);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
button:hover { border-color: var(--peach); }
button:active { transform: scale(.98); }
button:focus-visible { outline: 3px solid var(--peach); outline-offset: 2px; }
button.primary { background: var(--peach); color: #33221a; border: none; font-weight: 700; }
button.ghost { background: transparent; color: var(--faded); border-color: transparent; font-size: 15px; }
button.ghost:hover { color: var(--mist); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}
.card h1 { font-size: 26px; margin-bottom: 6px; }
.card p.sub { color: var(--faded); font-size: 15px; margin-bottom: 26px; }
label { display: block; font-size: 15px; color: var(--faded); margin: 16px 0 6px; }
input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  color: var(--mist);
  background: var(--night);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--peach);
  border-color: transparent;
}
.error { color: var(--rose); font-size: 15px; margin-top: 14px; min-height: 1.4em; }

/* ---------- Quiz ---------- */
.quiz-stage {
  min-height: 72vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 34px;
  text-align: center;
}
.q-number { color: var(--faded); font-size: 15px; letter-spacing: .08em; text-transform: uppercase; }
.q-text {
  font-family: "Fraunces", serif;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.25;
  position: relative;
}
/* la "veilleuse" : halo qui respire doucement derrière la question */
.q-text::before {
  content: "";
  position: absolute;
  inset: -40px -20px;
  background: radial-gradient(ellipse at center, rgba(240,169,140,.14), transparent 70%);
  z-index: -1;
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: .5; transform: scale(1); }
  50%      { opacity: 1;  transform: scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .q-text::before { animation: none; }
}

.answers { display: flex; flex-direction: column; gap: 12px; }
.answers button { font-size: 19px; padding: 16px; }
.answers .a-oui        { border-left: 6px solid var(--sage); }
.answers .a-plutot_oui { border-left: 6px solid color-mix(in srgb, var(--sage) 55%, var(--surface)); }
.answers .a-jsp        { border-left: 6px solid var(--line); }
.answers .a-plutot_non { border-left: 6px solid color-mix(in srgb, var(--rose) 55%, var(--surface)); }
.answers .a-non        { border-left: 6px solid var(--rose); }

/* ---------- Résultats ---------- */
.result-title { font-size: 24px; text-align: center; margin-bottom: 8px; }
.result-sub { text-align: center; color: var(--faded); font-size: 15px; margin-bottom: 24px; }
.candidate {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 10px;
}
.candidate:first-of-type {
  border-color: var(--peach);
  box-shadow: 0 0 24px rgba(240,169,140,.12);
}
.candidate .name { font-family: "Fraunces", serif; font-size: 22px; }
.candidate .pct { color: var(--faded); font-size: 15px; white-space: nowrap; }
.candidate .notes { color: var(--faded); font-size: 14px; width: 100%; }
.candidate-wrap .candidate { flex-wrap: wrap; }
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

/* ---------- Admin ---------- */
.admin-grid { display: grid; gap: 28px; }
.list-head { display: flex; gap: 10px; margin-bottom: 14px; }
.list-head input { flex: 1; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.row .actions { display: flex; gap: 8px; }
.row .actions button { font-size: 14px; padding: 6px 12px; border-radius: 8px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; color: var(--faded); font-size: 15px; }
.attr-block { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.attr-block h3 { font-size: 17px; margin-bottom: 4px; }
.attr-block .q { color: var(--faded); font-size: 14px; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--night);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.chip button { border: none; background: none; color: var(--rose); font-size: 14px; padding: 0; }
.form-grid { display: grid; gap: 4px; }
dialog {
  background: var(--surface);
  color: var(--mist);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
}
dialog::backdrop { background: rgba(15, 11, 22, .75); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.ok { color: var(--sage); font-size: 15px; min-height: 1.4em; margin-top: 10px; }

/* ---------- Correctif : les sections masquées le sont vraiment ---------- */
[hidden] { display: none !important; }

/* ---------- Candidats cliquables ---------- */
.candidate { cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.candidate:hover { border-color: var(--peach); transform: translateY(-1px); }

/* ---------- Fiche d'alter ---------- */
.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  margin-top: 10px;
}
.sheet-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.sheet-photo {
  width: 120px; height: 120px;
  border-radius: 20px;
  object-fit: cover;
  border: 2px solid var(--peach);
  background: var(--night);
}
.sheet-photo.placeholder {
  display: grid; place-items: center;
  font-size: 48px;
  border-color: var(--line);
}
.sheet-head h2 { font-size: 30px; }
.sheet-notes { color: var(--faded); margin-top: 6px; font-size: 16px; }
.sheet-attrs { margin-top: 24px; display: grid; gap: 8px; }
.sheet-attr {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 10px 14px;
  background: var(--night);
  border-radius: 10px;
  font-size: 16px;
}
.sheet-attr .k { color: var(--faded); }
.sheet-empty { color: var(--faded); font-size: 15px; margin-top: 18px; }


/* ---------- Miniatures dans la liste des alters ---------- */
.row { align-items: center; }
.row .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-thumb {
  width: 40px; height: 40px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.row-thumb.placeholder {
  display: grid; place-items: center;
  background: var(--night);
  font-size: 18px;
}

/* ---------- Centrage des boîtes de dialogue ----------
   (le reset global * { margin: 0 } annulait le centrage natif) */
dialog { margin: auto; }

/* ---------- Paws, le loup gardien du site ---------- */
.brand::before { content: none; } /* remplacé par le vrai logo */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}
.card-logo {
  width: 84px; height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--peach);
  display: block;
  margin: 0 auto 16px;
}
.corner-paws {
  position: fixed;
  bottom: 18px; right: 18px;
  width: 74px; height: 74px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  opacity: .85;
  pointer-events: none; /* ne gêne jamais les clics */
  z-index: 5;
}
@media (max-width: 720px) {
  .corner-paws { width: 54px; height: 54px; bottom: 12px; right: 12px; }
}

/* ---------- Choix multiples dans la fiche d'alter ---------- */
.hint { color: var(--faded); font-size: 13px; font-weight: normal; }
.check-group {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 4px;
}
.check {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--night);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 15px;
  cursor: pointer;
  margin: 0;
  user-select: none;
}
.check:has(input:checked) {
  border-color: var(--peach);
  background: color-mix(in srgb, var(--peach) 14%, var(--night));
}
.check input { accent-color: var(--peach); cursor: pointer; }

/* ---------- Dialogue d'alter agrandi, photo en en-tête ---------- */
dialog.dialog-large { width: min(780px, 94vw); }
.dialog-head {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 18px;
}
.dialog-head h2 { font-size: 26px; }
.dialog-photo {
  width: 92px; height: 92px;
  border-radius: 18px;
  object-fit: cover;
  border: 2px solid var(--peach);
  flex-shrink: 0;
}
.dialog-photo.placeholder {
  display: grid; place-items: center;
  font-size: 38px;
  background: var(--night);
  border-color: var(--line);
}
.check span { white-space: nowrap; } /* fini les pastilles qui se plient */

/* ---------- Félicitations & compteur de fronts ---------- */
.congrats {
  background: color-mix(in srgb, var(--sage) 16%, var(--surface));
  border: 1px solid var(--sage);
  border-radius: 16px;
  padding: 18px 22px;
  margin-bottom: 14px;
  font-family: "Fraunces", serif;
  font-size: 22px;
  text-align: center;
}
.congrats .found-count {
  display: block;
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: 14px;
  color: var(--faded);
  margin-top: 6px;
}
.found-badge {
  color: var(--faded);
  font-size: 13px;
  margin-left: 8px;
}

/* ---------- Ligne compteur dans le dialogue ---------- */
.found-line { color: var(--faded); font-size: 14px; margin-top: 4px; }

/* ---------- Sous-questions ---------- */
.sub-block {
  margin: 14px 0 0 22px;
  border-left: 3px solid var(--peach);
  background: color-mix(in srgb, var(--peach) 5%, var(--surface));
}
.sub-tag { color: var(--peach); font-size: 14px; font-family: "Atkinson Hyperlegible", sans-serif; }
.sub-attr {
  margin-left: 22px;
  padding-left: 14px;
  border-left: 3px solid var(--peach);
}

/* Flèche de sous-question en tête de pastille, bien distincte de la croix */
.chip .sub-add { color: var(--peach); font-size: 15px; }

/* ---------- La bulle de Paws ---------- */
.paws-bubble {
  position: fixed;
  bottom: 100px; right: 20px;
  max-width: 240px;
  background: var(--surface);
  border: 1px solid var(--peach);
  border-radius: 16px 16px 4px 16px;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.4;
  z-index: 6;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .35);
}
.paws-bubble.pop { animation: bubble-pop .25s ease-out; }
@keyframes bubble-pop {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .paws-bubble.pop { animation: none; }
}
@media (max-width: 720px) {
  .paws-bubble { bottom: 74px; right: 14px; max-width: 190px; font-size: 14px; }
}

/* ---------- La devinette ---------- */
.guess-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.guess-photo {
  width: 150px; height: 150px;
  border-radius: 26px;
  object-fit: cover;
  border: 3px solid var(--peach);
  box-shadow: 0 0 40px rgba(240, 169, 140, .2);
}
.guess-photo.placeholder {
  display: grid; place-items: center;
  font-size: 56px;
  background: var(--surface);
  border-color: var(--line);
}
.guess-pct { color: var(--faded); font-size: 15px; }

/* ---------- Bouton de sourdine ---------- */
.sound-toggle {
  background: none;
  border: none;
  font-size: 17px;
  padding: 2px 6px;
  margin-left: 14px;
  cursor: pointer;
  opacity: .8;
}
.sound-toggle:hover { opacity: 1; border-color: transparent; }

/* ---------- Barre de filtres de l'admin ---------- */
.list-head.filters { flex-wrap: wrap; gap: 8px; }
.list-head.filters select { font-size: 15px; padding: 9px 12px; }
.list-head.filters #filterSelect { flex: 1; min-width: 180px; }

/* ═══════════ PAGE STATISTIQUES ═══════════ */
.shell-wide { max-width: 900px; }
.shell-wide section { margin-top: 42px; }
.section-sub { color: var(--faded); font-size: 15px; margin: 6px 0 20px; }
.empty-note { color: var(--faded); font-size: 15px; padding: 18px 0; }

/* Chiffres clés */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}
.stat-num {
  display: block;
  font-family: "Fraunces", serif;
  font-size: 34px;
  color: var(--peach);
  line-height: 1.1;
}
.stat-lab { color: var(--faded); font-size: 14px; }

/* Podium */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.pod {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 170px;
  text-align: center;
}
.pod-medal { font-size: 26px; }
.pod-photo {
  width: 84px; height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--line);
  margin: 6px 0 8px;
}
.pod-1 .pod-photo { width: 104px; height: 104px; border-color: var(--peach); box-shadow: 0 0 30px rgba(240,169,140,.25); }
.pod-2 .pod-photo { border-color: #c9c9d6; }
.pod-3 .pod-photo { border-color: #c09070; }
.pod-photo.placeholder { display: grid; place-items: center; font-size: 34px; background: var(--surface); }
.pod-name { font-family: "Fraunces", serif; font-size: 18px; line-height: 1.2; }
.pod-count { color: var(--faded); font-size: 14px; margin-bottom: 8px; }
.pod-step {
  width: 100%;
  border-radius: 12px 12px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
}
.pod-1 .pod-step { height: 92px; background: color-mix(in srgb, var(--peach) 22%, var(--surface)); border-color: var(--peach); }
.pod-2 .pod-step { height: 64px; }
.pod-3 .pod-step { height: 44px; }

/* Donuts */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}
.chart-card h3 { font-family: "Fraunces", serif; font-size: 18px; margin-bottom: 10px; }
.donut { width: 160px; height: 160px; display: block; margin: 0 auto 12px; }
.donut-seg { transition: opacity .15s ease; }
.donut:hover .donut-seg { opacity: .45; }
.donut .donut-seg:hover { opacity: 1; }
.donut-num { fill: var(--mist); font-family: "Fraunces", serif; font-size: 26px; }
.donut-cap { fill: var(--faded); font-size: 11px; }
.legend { list-style: none; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.legend .lg-name { flex: 1; }
.legend .lg-num { color: var(--faded); white-space: nowrap; font-size: 13px; }

/* Classement */
.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}
.rank-pos { width: 26px; color: var(--faded); font-size: 14px; text-align: right; }
.rank-thumb { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; }
.rank-thumb.placeholder { display: grid; place-items: center; background: var(--surface); font-size: 17px; }
.rank-name { flex: 1; font-size: 16px; min-width: 120px; }
.rank-note { display: block; color: var(--faded); font-size: 13px; }
.rank-bar { flex: 1.2; height: 8px; background: var(--night); border-radius: 999px; overflow: hidden; min-width: 60px; }
.rank-bar span { display: block; height: 100%; background: var(--peach); border-radius: 999px; }
.rank-num { color: var(--faded); font-size: 15px; width: 34px; text-align: right; }

@media (max-width: 620px) {
  .pod { width: 120px; }
  .rank-bar { display: none; }
}

/* Sous-titre de sous-question dans les graphiques */
.chart-parent {
  display: block;
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: 13px;
  color: var(--peach);
  margin-top: 2px;
}

/* ---------- Filtres actifs ---------- */
.active-filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px;
}
.filter-chip {
  background: color-mix(in srgb, var(--peach) 14%, var(--night));
  border-color: var(--peach);
}
.filter-chip .fc-attr { color: var(--faded); font-size: 12px; }

/* ---------- Recadrage de photo ---------- */
#cropDialog { width: min(420px, 94vw); }
.crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--night);
  border: 1px solid var(--line);
  touch-action: none;
}
#cropCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#cropCanvas:active { cursor: grabbing; }
/* Repère visuel : le cercle correspond à l'aperçu rond du site */
.crop-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(240,169,140,.55);
  border-radius: 16px;
}
.crop-mask::before {
  content: "";
  position: absolute;
  inset: 8%;
  border: 2px dashed rgba(240,169,140,.45);
  border-radius: 50%;
}
.crop-zoom {
  width: 100%;
  accent-color: var(--peach);
  padding: 0;
  background: none;
  border: none;
}

/* ---------- Photo éditable au survol ---------- */
.photo-edit {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 18px;
}
.photo-edit .dialog-photo { display: block; }
.photo-overlay {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: rgba(20, 15, 28, .62);
  display: grid;
  place-items: center;
  font-size: 30px;
  opacity: 0;
  transition: opacity .16s ease;
  pointer-events: none;
}
.photo-edit:hover .photo-overlay,
.photo-edit:focus-within .photo-overlay { opacity: 1; }
.photo-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 10;
  background: var(--night);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
}
.photo-menu button {
  background: none;
  border: none;
  border-radius: 9px;
  text-align: left;
  font-size: 15px;
  padding: 9px 12px;
  color: var(--mist);
}
.photo-menu button:hover { background: var(--surface); border-color: transparent; }
.photo-menu button.danger { color: var(--rose); }

/* ---------- Barre d'actions flottante au-dessus du dialogue ---------- */
dialog.float-bar {
  background: transparent;
  border: none;
  padding: 0;
  overflow: visible;
  max-height: none;
}
.dialog-inner { position: relative; }
.dialog-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  max-height: 78vh;
  overflow-y: auto;
}
.dialog-float {
  position: absolute;
  top: -54px;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  z-index: 5;
}
.dialog-float .error {
  margin: 0;
  flex: 1;
  min-height: 0;
  font-size: 14px;
  text-align: right;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
}
.dialog-float button {
  font-size: 15px;
  padding: 9px 18px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
  backdrop-filter: blur(6px);
}
.dialog-float button.ghost {
  background: color-mix(in srgb, var(--surface) 85%, black);
  border-color: var(--line);
  color: var(--mist);
}
@media (max-width: 560px) {
  .dialog-float { top: -46px; gap: 6px; }
  .dialog-float button { font-size: 14px; padding: 8px 12px; }
  .dialog-body { padding: 20px; max-height: 74vh; }
}
