/* ============================================================
   QCM — feuille de style
   Direction : la copie d'examen / le cahier Seyès francais.
   Marge rouge, encre bleu-nuit, stylo vert pour les corrections,
   note finale encerclee en rouge comme sur une copie corrigee.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600;8..60,700&family=Public+Sans:wght@400;500;600;700&display=swap');

:root {
  --desk: #eae6da;
  --paper: #fffdf8;
  --ink: #1f2a44;
  --ink-soft: #5b6478;
  --marge: #b23a2e;
  --marge-soft: #b23a2e1a;
  --stylo: #1f7a53;
  --stylo-soft: #1f7a531a;
  --line: rgba(31, 42, 68, 0.1);
  --ruled: rgba(31, 42, 68, 0.045);
  --radius: 6px;
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --margin-w: 44px;
}

@media (min-width: 640px) {
  :root {
    --margin-w: 64px;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  margin: 0 0 0.5em;
  line-height: 1.25;
}

p {
  margin: 0 0 1em;
}

.hidden {
  display: none !important;
}

/* -------------------- Bureau / page -------------------- */

.desk {
  min-height: 100%;
  display: flex;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px) 16px;
}

.page {
  position: relative;
  width: 100%;
  max-width: 660px;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 35px,
      var(--ruled) 35px,
      var(--ruled) 36px
    ),
    var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(31, 42, 68, 0.06), 0 12px 32px rgba(31, 42, 68, 0.12);
  padding: 24px 24px 40px calc(var(--margin-w) + 20px);
  min-height: 70vh;
}

.page::before {
  /* la marge rouge du cahier */
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--margin-w);
  width: 2px;
  background: var(--marge);
  opacity: 0.7;
}

/* -------------------- En-tete -------------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pseudo-chip,
.nav-link {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.pseudo-chip:hover,
.nav-link:hover {
  border-color: var(--ink-soft);
  background: rgba(31, 42, 68, 0.04);
}

.pseudo-chip:focus-visible,
.nav-link:focus-visible,
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--marge);
  outline-offset: 2px;
}

/* -------------------- Boutons -------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(31, 42, 68, 0.3);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

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

/* -------------------- Vue upload -------------------- */

.view-intro h1 {
  font-size: 1.6rem;
}

.view-intro > p {
  color: var(--ink-soft);
  max-width: 46ch;
}

.mode-switch {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.mode-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.mode-tab:hover {
  border-color: var(--ink-soft);
}

.mode-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.topic-form {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 46ch;
}

.topic-form .field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 8px;
}

.topic-form .field-label:first-child {
  margin-top: 0;
}

.topic-form input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 1rem;
}

.topic-form input:focus-visible {
  border-color: var(--marge);
}

.dropzone {
  position: relative;
  margin-top: 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone::after {
  /* coin de page corne */
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, transparent 50%, var(--desk) 50%);
  border-bottom-left-radius: 3px;
}

.dropzone.drag-over {
  border-color: var(--marge);
  background: var(--marge-soft);
}

.dropzone-label {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.dropzone-hint {
  color: var(--ink-soft);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.dropzone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-chosen {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  font-weight: 600;
}

.file-chosen.visible {
  display: flex;
}

.actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-error {
  color: var(--marge);
  font-size: 0.9rem;
  margin-top: 12px;
  min-height: 1.2em;
}

/* -------------------- Vue chargement -------------------- */

.view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  text-align: center;
}

.pen-spinner {
  width: 46px;
  height: 46px;
  margin-bottom: 20px;
}

.pen-spinner circle {
  fill: none;
  stroke: var(--marge);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 120 80;
  transform-origin: center;
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-step {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* -------------------- Vue quiz -------------------- */

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.875rem;
  color: var(--ink-soft);
  font-weight: 500;
  margin-bottom: 8px;
}

.quiz-progress {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  margin-bottom: 28px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--ink);
  transition: width 0.25s ease;
}

.question-stem {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  margin-bottom: 20px;
}

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

.option {
  border-bottom: 1px solid var(--line);
}

.option:first-child {
  border-top: 1px solid var(--line);
}

.option-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  text-align: left;
  padding: 14px 4px;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
}

.option-btn:hover:not(:disabled) {
  background: rgba(31, 42, 68, 0.035);
}

.option-btn:disabled {
  cursor: default;
}

.option-marker {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--ink-soft);
}

.option.is-correct .option-marker {
  border-color: var(--stylo);
  background: var(--stylo-soft);
}

.option.is-wrong .option-marker {
  border-color: var(--marge);
  background: var(--marge-soft);
}

.option-text {
  flex: 1;
}

.option-reference {
  flex: none;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.option-mark {
  flex: none;
  width: 20px;
  height: 20px;
}

.option-mark path {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: draw-mark 0.35s ease forwards;
}

.mark-correct path {
  stroke: var(--stylo);
}

.mark-wrong path {
  stroke: var(--marge);
}

@keyframes draw-mark {
  to {
    stroke-dashoffset: 0;
  }
}

.quiz-footer {
  margin-top: 28px;
  display: flex;
  justify-content: flex-end;
}

/* -------------------- Vue score -------------------- */

.view-score {
  text-align: center;
}

.grade-circle {
  width: 160px;
  height: 160px;
  margin: 12px auto 8px;
}

.grade-circle circle {
  fill: none;
  stroke: var(--marge);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  animation: circle-grade 0.9s ease-out 0.15s forwards;
}

.grade-circle .grade-circle-2 {
  animation-delay: 0.35s;
  opacity: 0.6;
}

@keyframes circle-grade {
  to {
    stroke-dashoffset: 0;
  }
}

.grade-number {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 2.75rem;
}

.grade-comment {
  font-size: 1.05rem;
  margin-bottom: 28px;
}

.score-review {
  text-align: left;
  margin-top: 8px;
}

.score-review h2 {
  font-size: 1.1rem;
}

.review-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.review-item .option-mark {
  margin-top: 3px;
}

.review-item-text {
  flex: 1;
}

.review-item-ref {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* -------------------- Vue historique -------------------- */

.history-list {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.history-grade {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--marge);
  min-width: 3.4em;
}

.history-filename {
  font-weight: 600;
}

.history-date {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.empty-state {
  color: var(--ink-soft);
  margin-top: 16px;
}

/* -------------------- Modale pseudo -------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 42, 68, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(31, 42, 68, 0.25);
  text-align: center;
}

.modal-card h1 {
  font-size: 1.4rem;
}

.modal-card p {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

#pseudoForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

#pseudoInput {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 1rem;
  text-align: center;
}

#pseudoInput:focus-visible {
  border-color: var(--marge);
}

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