/* ==========================================================================
   1. Design tokens
   ========================================================================== */
:root {
  --tp-bg:          #f7f5f2;
  --tp-surface:     #ffffff;
  --tp-text:        #201d1b;
  --tp-muted:       #625d58;
  --tp-accent:      #a3312a;
  --tp-accent-text: #ffffff;
  --tp-correct:     #1e6b45;
  --tp-incorrect:   #a3312a;
  --tp-border:      #e2ddd6;
  --tp-danger:      #a3312a;
  --tp-radius:      10px;
  --tp-shadow:      0 2px 12px rgba(0, 0, 0, .10);
  --tp-transition:  0.2s ease;
}

/* ==========================================================================
   2. Thème alternatif
   ========================================================================== */
[data-theme="dark"] {
  --tp-bg:      #17140f;
  --tp-surface: #241f1a;
  --tp-text:    #f2ede6;
  --tp-muted:   #b3aca3;
  --tp-accent:  #e2685c;
  --tp-border:  #3a332b;
  --tp-correct: #6fbf94;
  --tp-incorrect: #e2685c;
  --tp-shadow:  0 2px 16px rgba(0, 0, 0, .4);
}

/* Le reste du site (public/css/main.css, header, footer) est en thème clair
   fixe, sans bascule automatique. On ne suit donc pas prefers-color-scheme
   ici : cela désynchroniserait le fond de la page (toujours clair) et le
   texte de l'app (qui serait devenu clair sur fond clair). Le thème sombre
   ci-dessus reste disponible via [data-theme="dark"] si un bouton de bascule
   est ajouté un jour. */

/* ==========================================================================
   3. Layout app principal
   ========================================================================== */
.tp-app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  background: var(--tp-bg);
  color: var(--tp-text);
}

.tp-screen {
  display: none;
}

.tp-screen--active {
  display: block;
}

/* ==========================================================================
   4. Zone A / en-tête
   ========================================================================== */
.tp-title {
  font-size: clamp(2rem, 6vw, 3rem);
  margin: 0 0 .5rem;
  text-align: center;
}

.tp-tagline {
  text-align: center;
  color: var(--tp-muted);
  line-height: 1.5;
  margin: 0 0 1.5rem;
}

.tp-h2 {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  margin: 0 0 1rem;
}

/* ==========================================================================
   5. Zone B / contenu principal
   ========================================================================== */
.tp-mode-options {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
  .tp-mode-options {
    grid-template-columns: 1fr;
  }
}

.tp-mode-card {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.tp-mode-desc {
  color: var(--tp-muted);
  font-size: .9rem;
  margin: 0;
}

.tp-length-buttons {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.tp-progress {
  color: var(--tp-muted);
  font-size: .9rem;
  margin: 0 0 .25rem;
}

.tp-theme {
  color: var(--tp-accent);
  font-weight: 600;
  margin: 0 0 .75rem;
}

.tp-question-text {
  font-size: clamp(1.1rem, 3.5vw, 1.4rem);
  margin: 0 0 1.25rem;
}

/* ==========================================================================
   6. Zone C / saisie / formulaires
   ========================================================================== */
.tp-label {
  display: block;
  font-size: .9rem;
  color: var(--tp-muted);
  margin-bottom: .25rem;
}

.tp-select {
  width: 100%;
  padding: .6rem;
  border-radius: var(--tp-radius);
  border: 1px solid var(--tp-border);
  background: var(--tp-bg);
  color: var(--tp-text);
  font-size: 1rem;
}

.tp-answers {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.tp-answer {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  width: 100%;
  text-align: left;
  padding: .9rem 1rem;
  background: var(--tp-surface);
  border: 2px solid var(--tp-border);
  border-radius: var(--tp-radius);
  color: var(--tp-text);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color var(--tp-transition), background var(--tp-transition);
}

.tp-answer__letter {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--tp-muted);
}

.tp-answer:hover {
  border-color: var(--tp-accent);
}

.tp-answer.tp-answer--selected {
  border-color: var(--tp-accent);
  background: color-mix(in srgb, var(--tp-accent) 10%, var(--tp-surface));
}

.tp-answer.tp-answer--correct {
  border-color: var(--tp-correct);
  background: color-mix(in srgb, var(--tp-correct) 12%, var(--tp-surface));
}

.tp-answer.tp-answer--incorrect {
  border-color: var(--tp-incorrect);
  background: color-mix(in srgb, var(--tp-incorrect) 12%, var(--tp-surface));
}

.tp-answer:disabled {
  cursor: default;
}

/* ==========================================================================
   7. Composants génériques
   ========================================================================== */
.tp-btn {
  display: inline-block;
  padding: .7rem 1.4rem;
  border-radius: var(--tp-radius);
  border: 1px solid var(--tp-border);
  background: var(--tp-surface);
  color: var(--tp-text);
  font-size: 1rem;
  cursor: pointer;
  transition: transform var(--tp-transition), opacity var(--tp-transition);
}

.tp-btn--primary {
  background: var(--tp-accent);
  border-color: var(--tp-accent);
  color: var(--tp-accent-text);
  font-weight: 600;
}

.tp-btn--link {
  background: transparent;
  border: none;
  color: var(--tp-accent);
  text-decoration: underline;
  padding: .4rem 0;
  display: block;
  margin: 0 auto;
}

.tp-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.tp-btn:focus-visible {
  outline: 2px solid var(--tp-accent);
  outline-offset: 2px;
}

.tp-answer:focus-visible {
  outline: 2px solid var(--tp-accent);
  outline-offset: 2px;
}

.tp-length-btn.tp-length-btn--selected {
  border-color: var(--tp-accent);
  background: var(--tp-accent);
  color: var(--tp-accent-text);
}

.tp-rules {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--tp-surface);
  border-radius: var(--tp-radius);
  border: 1px solid var(--tp-border);
}

.tp-reveal-block {
  margin-bottom: 1rem;
}

.tp-reveal-block h3 {
  margin: 0 0 .25rem;
  font-size: 1rem;
  color: var(--tp-muted);
}

.tp-sources {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tp-sources a {
  color: var(--tp-accent);
}

.tp-verdict {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.tp-verdict--correct {
  color: var(--tp-correct);
}

.tp-verdict--incorrect {
  color: var(--tp-incorrect);
}

.tp-score-provisional {
  color: var(--tp-muted);
  margin-bottom: 1.5rem;
}

.tp-final-score {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 .25rem;
}

.tp-profile {
  font-style: italic;
  color: var(--tp-accent);
}

.tp-final-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.tp-final-list li {
  padding: .5rem .75rem;
  border-radius: var(--tp-radius);
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
}

.tp-final-list li.tp-final-item--correct {
  border-left: 4px solid var(--tp-correct);
}

.tp-final-list li.tp-final-item--incorrect {
  border-left: 4px solid var(--tp-incorrect);
}

.tp-final-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.tp-error {
  margin-top: 1rem;
  padding: .75rem 1rem;
  background: color-mix(in srgb, var(--tp-danger) 15%, var(--tp-surface));
  border: 1px solid var(--tp-danger);
  border-radius: var(--tp-radius);
  color: var(--tp-text);
}

.tp-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tp-border);
  text-align: center;
  font-size: .9rem;
  color: var(--tp-muted);
}

.tp-footer a {
  color: var(--tp-accent);
}

/* ==========================================================================
   8. États
   ========================================================================== */
.tp-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   9. Responsive
   ========================================================================== */
@media (max-width: 600px) {
  .tp-app {
    padding: .75rem;
  }

  .tp-final-actions {
    flex-direction: column;
  }

  .tp-final-actions .tp-btn {
    width: 100%;
    text-align: center;
  }
}
