/* ============================================
   QUIZZOSCOPE - CSS
   ============================================ */

/* --- Variables --- */
:root {
  --bg:          #f4f0ff;
  --surface:     #ffffff;
  --primary:     #7c3aed;
  --primary-lt:  #a78bfa;
  --primary-dk:  #5b21b6;
  --accent:      #f472b6;
  --correct:     #10b981;
  --wrong:       #ef4444;
  --text:        #1e1b4b;
  --muted:       #6b7280;
  --border:      #e5e7eb;
  --shadow-sm:   0 2px 8px rgba(124,58,237,.10);
  --shadow:      0 6px 24px rgba(124,58,237,.15);
  --shadow-lg:   0 12px 40px rgba(124,58,237,.22);
  --r:           18px;
  --r-sm:        10px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
svg { display: block; }

/* --- App Shell --- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* --- Screens --- */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  animation: fadeIn .3s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   HOME SCREEN
   ============================================ */
#screen-home {
  background: linear-gradient(160deg, var(--primary) 0%, #9333ea 55%, var(--accent) 100%);
}

.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
  color: #fff;
  position: relative;
}
.home-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.home-deco-cats {
  display: flex;
  justify-content: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 1;
}
.home-deco-cats svg { filter: drop-shadow(0 6px 12px rgba(0,0,0,.3)); }

.app-title {
  font-size: clamp(2.2rem, 7vw, 4rem);
  font-weight: 900;
  letter-spacing: -1.5px;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 12px rgba(0,0,0,.2);
}
.app-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 600;
  opacity: .9;
  margin-top: .35rem;
  position: relative;
  z-index: 1;
}

/* --- Home form (pseudo + bouton) --- */
.home-form {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: var(--r);
  padding: 1.5rem;
  margin-top: 1.75rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  position: relative;
  z-index: 1;
}

.pseudo-label {
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.85);
}
.pseudo-input {
  width: 100%;
  border: 2px solid rgba(255,255,255,.4);
  border-radius: var(--r-sm);
  padding: .8rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(255,255,255,.95);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.pseudo-input::placeholder { color: #9ca3af; font-weight: 600; }
.pseudo-input:focus {
  border-color: var(--primary-lt);
  box-shadow: 0 0 0 3px rgba(167,139,250,.35);
}
.pseudo-hint {
  font-size: .8rem;
  font-weight: 600;
  color: rgba(255,255,255,.8);
  min-height: 1.2em;
}
.pseudo-hint.warn { color: #fca5a5; }
.pseudo-hint.info { color: #6ee7b7; }

.btn-start {
  background: #fff;
  color: var(--primary-dk);
  border-radius: 99px;
  padding: .9rem;
  font-weight: 900;
  font-size: 1.05rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  transition: transform .2s, box-shadow .2s;
  margin-top: .25rem;
}
.btn-start:hover  { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.btn-start:active { transform: translateY(0); }

/* --- Leaderboard --- */
.leaderboard-section {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  width: 100%;
}
.lb-title {
  font-size: 1.1rem;
  font-weight: 900;
  color: #fff;
  margin-bottom: .75rem;
  text-align: center;
}
/* Result screen: fond clair → titre sombre */
#leaderboard-result .lb-title { color: var(--text); }

.lb-list {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.lb-empty {
  text-align: center;
  padding: 1.75rem 1rem;
  color: var(--muted);
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.6;
}
.lb-loading { opacity: .5; }

.lb-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.lb-row:last-child { border-bottom: none; }
.lb-row.lb-me {
  background: #f5f3ff;
  border-left: 4px solid var(--primary);
}
.lb-rank {
  font-size: .85rem;
  font-weight: 900;
  color: var(--muted);
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.lb-rank-gold   { color: #f59e0b; font-size: 1.2rem; }
.lb-rank-silver { color: #94a3b8; font-size: 1.1rem; }
.lb-rank-bronze { color: #c47d3a; font-size: 1rem; }
.lb-mini-cat { width: 40px; height: 40px; flex-shrink: 0; }
.lb-mini-cat svg { width: 40px; height: 40px; }
.lb-info { flex: 1; min-width: 0; }
.lb-pseudo {
  font-weight: 800;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.lb-me-tag {
  font-size: .65rem;
  font-weight: 900;
  background: var(--primary);
  color: #fff;
  border-radius: 99px;
  padding: .1rem .45rem;
  letter-spacing: .03em;
  flex-shrink: 0;
}
.lb-score {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.lb-score-total {
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
}
.lb-score-me { color: var(--correct); }

/* ============================================
   QUIZ SCREEN
   ============================================ */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.btn-icon:hover { background: #fee2e2; color: var(--wrong); }

.progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  transition: width .4s ease;
  width: 0%;
}
.progress-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}

.score-pill {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: .9rem;
  padding: .35rem .9rem;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- Question Wrap --- */
.question-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

/* --- Question Card --- */
.question-card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 1.5rem;
  width: 100%;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.q-type-badge {
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
  background: #ede9fe;
  border-radius: 99px;
  padding: .25rem .75rem;
  align-self: flex-start;
}

.q-cat-wrap { width: 120px; height: 120px; }
.q-cat-wrap svg { width: 120px; height: 120px; }

.q-pair {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: center;
}
.q-pair .q-cat-wrap { width: 90px; height: 90px; }
.q-pair .q-cat-wrap svg { width: 90px; height: 90px; }

.q-separator { font-size: 1.5rem; opacity: .3; }

.q-label {
  font-size: clamp(.95rem, 2.5vw, 1.15rem);
  font-weight: 700;
  text-align: center;
  color: var(--text);
  line-height: 1.4;
}
.q-name {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 900;
  color: var(--primary-dk);
  text-align: center;
}

/* --- Options --- */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  width: 100%;
}
.options-grid.tf-grid {
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.option-btn {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: .9rem 1rem;
  font-family: inherit;
  font-size: clamp(.82rem, 2vw, .95rem);
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  display: flex;
  align-items: center;
  gap: .6rem;
  text-align: left;
  line-height: 1.3;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--primary-lt);
  background: #faf5ff;
  transform: translateY(-2px);
}
.option-btn:active:not(:disabled) { transform: translateY(0); }
.option-btn.correct {
  border-color: var(--correct);
  background: #d1fae5;
  color: #065f46;
  animation: bounceIn .3s ease;
}
.option-btn.wrong {
  border-color: var(--wrong);
  background: #fee2e2;
  color: #991b1b;
  animation: shake .3s ease;
}
.option-btn:disabled { cursor: default; }
.option-btn .opt-mini-cat { width: 36px; height: 36px; flex-shrink: 0; }
.option-btn .opt-mini-cat svg { width: 36px; height: 36px; }

.tf-btn {
  padding: 1.5rem;
  justify-content: center;
  font-size: 1.2rem;
  border-radius: var(--r);
  flex-direction: column;
  gap: .25rem;
}
.tf-btn .tf-icon { font-size: 2rem; }
.tf-btn.tf-vrai { border-color: var(--correct); color: #065f46; }
.tf-btn.tf-vrai:hover:not(:disabled) { background: #d1fae5; }
.tf-btn.tf-faux { border-color: var(--wrong); color: #991b1b; }
.tf-btn.tf-faux:hover:not(:disabled) { background: #fee2e2; }

/* --- Job-to-person grid & reveal --- */
.j2p-grid {
  grid-template-columns: 1fr 1fr;
}
.j2p-btn {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: .75rem .5rem;
  gap: .4rem;
  position: relative;
}
.j2p-btn .opt-mini-cat { width: 52px; height: 52px; }
.j2p-btn .opt-mini-cat svg { width: 52px; height: 52px; }
.j2p-btn .opt-name {
  font-size: clamp(.75rem, 1.8vw, .88rem);
  line-height: 1.25;
  word-break: break-word;
}
/* Checkmark / cross overlay on answered buttons */
.j2p-btn.correct::after {
  content: '✓';
  position: absolute;
  top: .35rem; right: .5rem;
  font-size: 1.1rem;
  color: var(--correct);
  font-weight: 900;
}
.j2p-btn.wrong::after {
  content: '✗';
  position: absolute;
  top: .35rem; right: .5rem;
  font-size: 1.1rem;
  color: var(--wrong);
  font-weight: 900;
}

/* Reveal panel */
.j2p-reveal {
  display: none;
  align-items: center;
  gap: 1rem;
  border-radius: var(--r);
  padding: 1rem 1.25rem;
  margin-top: .5rem;
  width: 100%;
  animation: fadeIn .25s ease;
}
.j2p-correct {
  background: #d1fae5;
  border: 2px solid var(--correct);
}
.j2p-wrong {
  background: #fee2e2;
  border: 2px solid var(--wrong);
}
.j2p-reveal-icon { font-size: 1.8rem; flex-shrink: 0; }
.j2p-reveal-cat  { width: 64px; height: 64px; flex-shrink: 0; }
.j2p-reveal-cat svg { width: 64px; height: 64px; }
.j2p-reveal-text { min-width: 0; }
.j2p-reveal-label {
  font-size: .8rem;
  font-weight: 700;
  opacity: .7;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.j2p-correct .j2p-reveal-label { color: #065f46; }
.j2p-wrong   .j2p-reveal-label { color: #991b1b; }
.j2p-reveal-name {
  font-size: 1.1rem;
  font-weight: 900;
  margin-top: .1rem;
  word-break: break-word;
}
.j2p-correct .j2p-reveal-name { color: #065f46; }
.j2p-wrong   .j2p-reveal-name { color: #991b1b; }

/* --- Next button --- */
.btn-next {
  background: var(--primary);
  color: #fff;
  border-radius: 99px;
  padding: .75rem 2rem;
  font-weight: 800;
  font-size: 1rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
  display: none;
}
.btn-next.visible { display: block; }
.btn-next:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* --- Feedback inline --- */
.feedback-inline {
  font-size: .95rem;
  font-weight: 700;
  padding: .6rem 1.2rem;
  border-radius: 99px;
  text-align: center;
  margin-top: .5rem;
  animation: fadeIn .25s ease;
}
.feedback-inline.correct { background: #d1fae5; color: #065f46; }
.feedback-inline.wrong   { background: #fee2e2; color: #991b1b; }

/* ============================================
   RESULT SCREEN
   ============================================ */
#screen-result {
  background: var(--bg);
  justify-content: flex-start;
  align-items: center;
  padding: 2rem 1rem;
}
.result-outer {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.result-box {
  background: var(--surface);
  border-radius: var(--r);
  padding: 2rem 2rem 1.5rem;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn .4s cubic-bezier(.175,.885,.32,1.275);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1); }
}

.result-cat-wrap { display: flex; justify-content: center; margin-bottom: 1rem; }
.result-cat-wrap svg { width: 140px; height: 140px; }
.result-title { font-size: 1.5rem; font-weight: 900; }
.result-pseudo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: .15rem;
}
.result-fraction {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--primary);
  margin: .5rem 0;
}
.result-message { color: var(--muted); font-weight: 600; font-size: 1rem; }
.result-actions {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1.75rem;
}

/* --- Buttons --- */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #9333ea);
  color: #fff;
  border-radius: 99px;
  padding: .85rem 2rem;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.btn-secondary {
  background: var(--bg);
  color: var(--primary);
  border-radius: 99px;
  padding: .85rem 2rem;
  font-weight: 700;
  font-size: 1rem;
  border: 2px solid var(--border);
  transition: background .2s, border-color .2s;
}
.btn-secondary:hover { background: #ede9fe; border-color: var(--primary-lt); }

/* --- Animations --- */
@keyframes bounceIn {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-5px); }
  40%     { transform: translateX(5px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

/* --- Confetti --- */
.confetti {
  position: fixed;
  width: 10px; height: 10px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 9999;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .options-grid { grid-template-columns: 1fr; }
  .options-grid.tf-grid { grid-template-columns: 1fr 1fr; }
  .q-pair .q-cat-wrap { width: 72px; height: 72px; }
  .q-pair .q-cat-wrap svg { width: 72px; height: 72px; }
  .result-outer { padding: 0; }
  .home-form { margin-top: 1.25rem; }
}
@media (min-width: 900px) {
  .options-grid:not(.tf-grid) { grid-template-columns: repeat(2, 1fr); }
}
