/* Quiz Kahoot + Flashcards */

/* Alignement avec les fiches (52rem) */
.learning-page main.container {
  max-width: 900px;
}

.page-topic.learning-page main.container > .page-header,
.page-topic.learning-page main.container > .atelier-back,
.page-topic.learning-page main.container > p:has(.atelier-back),
.page-topic.learning-page main.container > .page-actions,
.page-topic.learning-page main.container > .lang-tools,
.page-topic.learning-page main.container > .quiz-wrap,
.page-topic.learning-page main.container > .cards-wrap {
  max-width: 52rem;
  margin-left: auto;
  margin-right: auto;
}

.page-topic.learning-page main.container > p:first-of-type {
  max-width: 52rem;
  margin-left: auto;
  margin-right: auto;
}

.lang-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 1.25rem 0 1.75rem;
  max-width: 100%;
  min-width: 0;
}

@media (max-width: 768px) {
  .lang-tools,
  .page-actions.lang-tools {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin: 1rem 0 1.25rem;
  }

  .lang-tools .btn-tool,
  .lang-tools .btn-try-code {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
    text-align: center;
  }
}

.lang-tools .btn-try-code,
.lang-tools .btn-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.lang-tools .btn-tool:hover,
.lang-tools .btn-try-code:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-tool--quiz {
  background: linear-gradient(135deg, #b5590b, #c93620);
  color: #fff;
}

.btn-tool--cards {
  background: linear-gradient(135deg, #0891b2, #2563eb);
  color: #fff;
}

.btn-tool--code {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

/* Quiz */
.quiz-wrap {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.quiz-progress {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.quiz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-light);
}

.quiz-timer {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
}

.quiz-timer.urgent {
  color: var(--danger);
  animation: pulse 0.6s infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.5; }
}

.quiz-question {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: #0f172a;
  line-height: 1.35;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 560px) {
  .quiz-options { grid-template-columns: 1fr; }
}

.quiz-option {
  padding: 1rem 1.1rem;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  cursor: pointer;
  text-align: left;
  min-height: 56px;
  transition: transform 0.12s, filter 0.12s;
}

.quiz-option:hover:not(:disabled) {
  transform: scale(1.02);
  filter: brightness(1.08);
}

.quiz-option:disabled { cursor: default; opacity: 0.85; }

.quiz-option.selected {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.95), 0 0 0 6px rgba(0, 0, 0, 0.35);
  transform: scale(1.02);
}

.quiz-option.correct { box-shadow: 0 0 0 3px #10b981; }
.quiz-option.wrong { box-shadow: 0 0 0 3px #ef4444; opacity: 0.7; }

.quiz-option:nth-child(1) { background: #e21b3c; }
.quiz-option:nth-child(2) { background: #1368ce; }
.quiz-option:nth-child(3) { background: #d89e00; color: #1b1400; }
.quiz-option:nth-child(4) { background: #26890c; }

.quiz-feedback {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-size: 0.95rem;
}

.quiz-feedback.ok { background: #ecfdf5; color: #047857; }
.quiz-feedback.ko { background: #fef2f2; color: #b91c1c; }

.quiz-results {
  text-align: center;
  padding: 2rem 1rem;
}

.quiz-results h2 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

/* Flashcards */
.cards-wrap {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  min-height: 320px;
}

.cards-progress {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.card-scene {
  perspective: 1000px;
  max-width: 480px;
  margin: 0 auto 1.25rem;
  min-height: 200px;
}

.card-flip {
  position: relative;
  width: 100%;
  min-height: 200px;
  transform-style: preserve-3d;
  transition: transform 0.5s;
  cursor: pointer;
}

.card-flip.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.card-front {
  background: linear-gradient(145deg, #ef4a34, #c1650b);
  color: white;
}

.card-back {
  background: linear-gradient(160deg, #1e3a5f 0%, #334155 100%);
  color: #f8fafc;
  transform: rotateY(180deg);
  border: 2px solid rgba(148, 163, 184, 0.35);
}

.cards-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  padding-top: 0.5rem;
  border-top: 1px solid var(--quiz-border, #e2e8f0);
  margin-top: 0.25rem;
}

.cards-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7.5rem;
  padding: 0.65rem 1.2rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.cards-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

.cards-btn:active:not(:disabled) {
  transform: translateY(0);
}

.cards-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cards-btn--nav {
  background: linear-gradient(135deg, #ef4a34 0%, #ef4a34 100%);
  color: #fff;
}

.cards-btn--nav:hover:not(:disabled) {
  filter: brightness(1.06);
}

.cards-btn--shuffle {
  background: #f8fafc;
  color: #334155;
  border: 2px solid #e2e8f0;
  box-shadow: none;
}

.cards-btn--shuffle:hover:not(:disabled) {
  background: #fff;
  border-color: #ffb199;
  color: #ef4a34;
  box-shadow: 0 4px 12px rgba(239, 74, 52, 0.15);
}

html.theme-dark .cards-btn--shuffle {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.cards-progress {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card-scene {
  margin-bottom: 1.5rem;
}

.cards-wrap .card-face {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(239, 74, 52, 0.2);
}

.cards-wrap .card-front {
  color: #ffffff !important;
}

.cards-wrap .card-back {
  color: #f8fafc !important;
  background: linear-gradient(160deg, #1e3a5f 0%, #334155 100%) !important;
  -webkit-font-smoothing: antialiased;
}

.cards-wrap .card-flip:hover .card-face {
  box-shadow: 0 12px 32px rgba(239, 74, 52, 0.28);
}

/* Cartes claires : texte toujours lisible (même en mode sombre site) */
.quiz-wrap,
.cards-wrap {
  --quiz-text: #0f172a;
  --quiz-muted: #475569;
  --quiz-border: #e2e8f0;
  --quiz-surface: #ffffff;
}

.quiz-meta {
  color: var(--quiz-muted);
}

.quiz-timer {
  color: #ef4a34;
}

.quiz-wrap .quiz-question {
  color: var(--quiz-text);
}

.cards-progress {
  color: var(--quiz-muted);
}

html.theme-dark .quiz-wrap,
html.theme-dark .cards-wrap {
  background: #ffffff;
  border-color: #e2e8f0;
  color: var(--quiz-text);
}

html.theme-dark .quiz-question {
  color: #0f172a !important;
}

html.theme-dark .quiz-meta {
  color: #475569 !important;
}

html.theme-dark .quiz-progress {
  background: #e2e8f0;
}

html.theme-dark .quiz-feedback.ok {
  background: #ecfdf5;
  color: #047857;
}

html.theme-dark .quiz-feedback.ko {
  background: #fef2f2;
  color: #b91c1c;
}

html.theme-dark .quiz-results h2 {
  color: #ef4a34 !important;
}

html.theme-dark .quiz-results p {
  color: #334155 !important;
}

html.theme-dark .learning-page .page-header p,
html.theme-dark .learning-page .atelier-back {
  color: #94a3b8;
}

html.theme-dark .learning-page .page-header-brand h1 {
  color: #f1f5f9;
}

html.theme-dark .cards-wrap .card-front {
  color: #ffffff !important;
}

html.theme-dark .cards-wrap .card-back {
  color: #f8fafc !important;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%) !important;
  border-color: rgba(148, 163, 184, 0.4);
}

html.theme-dark .cards-btn--shuffle {
  background: #f8fafc;
  color: #1e293b;
}

/* Quiz NSI : style cartes (pas couleurs Kahoot) — texte toujours foncé sur fond clair */
.quiz--nsi .quiz-option {
  background: #fff;
  color: #0f172a;
  border: 2px solid #dde3ed;
  box-shadow: none;
  filter: none;
}

.quiz--nsi .quiz-option:nth-child(1),
.quiz--nsi .quiz-option:nth-child(2),
.quiz--nsi .quiz-option:nth-child(3),
.quiz--nsi .quiz-option:nth-child(4) {
  background: #fff;
  color: #0f172a;
}

.quiz--nsi .quiz-option:hover:not(:disabled),
.quiz--nsi .quiz-option:focus-visible:not(:disabled),
.quiz--nsi .quiz-option:active:not(:disabled) {
  transform: none;
  filter: none;
  border-color: #ef4a34;
  background: #eef2ff;
  color: #0f172a;
  outline: none;
  box-shadow: 0 0 0 2px rgba(239, 74, 52, 0.25);
}

.quiz--nsi .quiz-option.selected,
.quiz--nsi .quiz-option.selected:hover,
.quiz--nsi .quiz-option.selected:disabled {
  border-color: #ef4a34;
  background: #e0e7ff;
  color: #8a4308;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25);
  transform: none;
  opacity: 1;
}

.quiz--nsi .quiz-option.correct,
.quiz--nsi .quiz-option.correct:disabled {
  background: #ecfdf5;
  border-color: #059669;
  color: #047857;
  opacity: 1;
  box-shadow: none;
}

.quiz--nsi .quiz-option.wrong,
.quiz--nsi .quiz-option.wrong:disabled {
  background: #fef2f2;
  border-color: #dc2626;
  color: #991b1b;
  opacity: 1;
  box-shadow: none;
}

.quiz--nsi .quiz-option:disabled:not(.correct):not(.wrong):not(.selected) {
  opacity: 1;
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

/* Carte quiz claire : forcer contraste (le mode sombre du site change --text-dark) */
html.theme-dark body.quiz--nsi .quiz-option,
html.theme-dark .quiz--nsi .quiz-option,
html.theme-dark .quiz--nsi .quiz-option:nth-child(n) {
  background: #fff;
  color: #0f172a;
  border-color: #cbd5e1;
}

html.theme-dark .quiz--nsi .quiz-option:hover:not(:disabled),
html.theme-dark .quiz--nsi .quiz-option:focus-visible:not(:disabled),
html.theme-dark .quiz--nsi .quiz-option:active:not(:disabled) {
  background: #eef2ff;
  color: #0f172a;
  border-color: #ef4a34;
}

html.theme-dark .quiz--nsi .quiz-option.selected,
html.theme-dark .quiz--nsi .quiz-option.selected:disabled {
  background: #e0e7ff;
  color: #8a4308;
  border-color: #ef4a34;
}

html.theme-dark .quiz--nsi .quiz-option:disabled:not(.correct):not(.wrong):not(.selected) {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

html.theme-dark .quiz--nsi .quiz-option.correct,
html.theme-dark .quiz--nsi .quiz-option.correct:disabled {
  background: #ecfdf5;
  border-color: #059669;
  color: #047857;
}

html.theme-dark .quiz--nsi .quiz-option.wrong,
html.theme-dark .quiz--nsi .quiz-option.wrong:disabled {
  background: #fef2f2;
  border-color: #dc2626;
  color: #991b1b;
}

/* Exercices : navigation par niveau puis langage */
.ex-app {
  max-width: 52rem;
  margin: 1.25rem auto 2rem;
}

.ex-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
}

.ex-crumb a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.ex-crumb a:hover {
  text-decoration: underline;
}

.ex-crumb__current {
  color: #64748b;
  font-weight: 600;
}

.ex-crumb__sep {
  color: #94a3b8;
}

.ex-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.65rem;
}

.ex-picker-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.ex-picker-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.ex-picker-card__level {
  font-weight: 700;
  font-size: 0.95rem;
  color: #0f172a;
  line-height: 1.35;
}

.ex-picker-card__count {
  font-size: 0.8rem;
  color: #64748b;
}

.ex-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  vertical-align: middle;
}

.ex-star {
  flex-shrink: 0;
  display: block;
}

.ex-star--on path {
  fill: #f59e0b;
}

.ex-star--off path {
  fill: #cbd5e1;
}

.ex-stars__name {
  margin-left: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #92400e;
}

.ex-picker-card__level .ex-stars {
  flex-wrap: wrap;
}

.ex-group__title .ex-stars {
  gap: 0.18rem;
}

.ex-group__title .ex-star {
  width: 20px;
  height: 20px;
}

.ex-level-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.ex-enonce-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ex-enonce-list__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  font-family: inherit;
  padding: 0.75rem 0.9rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.45;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.ex-enonce-list__link:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

/* « Atelier » : exercice de code vérifié dans l'atelier ; « À rédiger » : réponse écrite avec correction possible. */
.ex-tags {
  display: inline-flex;
  flex-shrink: 0;
  align-items: baseline;
  gap: 0.4rem;
}

.ex-kind {
  flex-shrink: 0;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.ex-kind--text {
  background: #f1f5f9;
  color: #475569;
}

.ex-kind--topic {
  background: transparent;
  box-shadow: inset 0 0 0 1px #cbd5e1;
  color: #475569;
  font-weight: 600;
}

html.theme-dark .ex-kind--topic {
  background: transparent;
  box-shadow: inset 0 0 0 1px #475569;
  color: #cbd5e1;
}

html.theme-dark .ex-kind {
  background: rgba(37, 99, 235, 0.28);
  color: #bfdbfe;
}

html.theme-dark .ex-kind--text {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
}

.ex-group {
  margin-bottom: 1.75rem;
}

.ex-group__title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: #0f172a;
}

.ex-group__lang {
  margin-bottom: 1rem;
}

.ex-group__lang-title {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #2563eb;
}

html.theme-dark .ex-picker-card,
html.theme-dark .ex-enonce-list__link {
  background: #1e293b;
  border-color: #334155;
}

html.theme-dark .ex-picker-card__level,
html.theme-dark .ex-enonce-list__link,
html.theme-dark .ex-group__title {
  color: #f1f5f9;
}

html.theme-dark .ex-picker-card__count {
  color: #94a3b8;
}

.ex-picker-card--empty {
  opacity: 0.55;
  cursor: default;
  background: #f8fafc;
}

.ex-group__empty {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #5f6068;
  font-style: italic;
}

html.theme-dark .ex-picker-card--empty {
  background: rgba(15, 23, 42, 0.4);
}

html.theme-dark .ex-star--on path {
  fill: #fbbf24;
}

html.theme-dark .ex-star--off path {
  fill: #475569;
}

html.theme-dark .ex-stars__name {
  color: #fcd34d;
}

/* Liste exercices à compléter (legacy) */
.ex-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem auto 2rem;
  max-width: 52rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ex-list__item {
  margin: 0;
}

.ex-list__link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ex-list__link:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.ex-list__lang {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #2563eb;
}

.ex-list__title {
  font-size: 1rem;
  color: #0f172a;
}

.ex-list__hint {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.45;
}

.ex-list__empty {
  color: #64748b;
  padding: 1rem 0;
}

html.theme-dark .ex-list__link {
  background: #1e293b;
  border-color: #334155;
}

html.theme-dark .ex-list__title {
  color: #f1f5f9;
}

html.theme-dark .ex-list__hint {
  color: #94a3b8;
}

.ex-answer-panel {
  margin-top: 0.45rem;
  padding: 0.6rem 0.7rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ex-answer-input {
  width: 100%;
  min-height: 3rem;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 0.45rem 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.ex-answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ex-answer-btn {
  border-radius: 999px;
  border: 1px solid #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 0.25rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.ex-answer-btn--ghost {
  border-color: #cbd5e1;
  background: transparent;
  color: #475569;
}

.ex-answer-solution {
  margin-top: 0.1rem;
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.5;
}

html.theme-dark .ex-answer-panel {
  border-color: #334155;
  background: #0f172a;
}

html.theme-dark .ex-answer-input {
  border-color: #475569;
  background: #020617;
  color: #e5e7eb;
}

html.theme-dark .ex-answer-btn {
  border-color: #60a5fa;
  background: rgba(37, 99, 235, 0.1);
  color: #bfdbfe;
}

html.theme-dark .ex-answer-btn--ghost {
  border-color: #475569;
  color: #cbd5e1;
}

html.theme-dark .ex-answer-solution {
  color: #e5e7eb;
}

/* Quiz / flashcards / exercices : pas de logo devant le titre, donc pas de retrait du sous-titre
   (celui de style.css l'aligne sous le titre des fiches, après l'icône de 76 px). */
.learning-page .page-header > p {
  padding-left: 0;
}

/* Bouton « Retour » : même alignement centré que les blocs de la page. */
.learning-page main.container > .page-actions {
  max-width: 52rem;
  margin-left: auto;
  margin-right: auto;
}
