/* ============================================================
   style.css — Thème clair/sombre, couleurs par domaine, animations.
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --bg-card: #ffffff;
  --bg-soft: #eef1f7;
  --text: #1f2937;
  --text-soft: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 4px 16px rgba(20, 30, 60, 0.07);
  --shadow-lg: 0 10px 30px rgba(20, 30, 60, 0.13);
  --radius: 16px;
  --accent: #6d28d9;

  /* Couleurs signature par domaine */
  --c-python: #2563eb;
  --c-ml: #7c3aed;
  --c-maths: #16a34a;
  --c-coran: #d97706;
  --c-web: #0891b2;
  --c-blender: #ea580c;
}

[data-theme="dark"] {
  --bg: #0f1420;
  --bg-card: #1a2032;
  --bg-soft: #232b40;
  --text: #e7ecf5;
  --text-soft: #9aa6bd;
  --border: #2c3550;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

.hidden { display: none !important; }

/* ---------------- Connexion ---------------- */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #fde68a33, transparent),
              linear-gradient(160deg, #6d28d9 0%, #2563eb 100%);
}
.login-card {
  width: min(380px, 92vw); background: var(--bg-card); border-radius: 22px;
  padding: 34px 28px; box-shadow: var(--shadow-lg); text-align: center;
  display: flex; flex-direction: column; gap: 12px; animation: pop 0.5s ease;
}
.login-sun { font-size: 54px; animation: spin-slow 14s linear infinite; }
.login-card h1 { font-size: 30px; letter-spacing: -0.5px; }
.login-sub { color: var(--text-soft); margin-bottom: 8px; }
.login-card input {
  padding: 13px 15px; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--bg-soft); color: var(--text); font-size: 15px; transition: border 0.2s;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-error { color: #dc2626; font-size: 14px; min-height: 18px; font-weight: 600; }
.login-hint { color: var(--text-soft); font-size: 12.5px; margin-top: 4px; }

/* ---------------- Coque app ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center;
  gap: 14px; padding: 10px 18px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow); flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 19px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.brand-sun { animation: spin-slow 18s linear infinite; display: inline-block; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-btn {
  border: none; background: transparent; color: var(--text-soft); cursor: pointer;
  padding: 9px 13px; border-radius: 10px; font-size: 14px; font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.nav-btn:hover { background: var(--bg-soft); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.role-badge {
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft); white-space: nowrap;
}
.role-badge.eleve { background: #ddd6fe; color: #5b21b6; }
.role-badge.parent { background: #bfdbfe; color: #1e40af; }
.icon-btn {
  border: none; background: var(--bg-soft); color: var(--text); cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px; font-size: 17px; transition: transform 0.15s, background 0.2s;
}
.icon-btn:hover { transform: translateY(-1px); background: var(--border); }

.content { max-width: 1100px; margin: 0 auto; padding: 22px 18px 60px; }
.section { display: none; animation: fade-up 0.35s ease; }
.section.active { display: block; }

h2.section-title { font-size: 23px; margin-bottom: 4px; letter-spacing: -0.4px; }
.section-sub { color: var(--text-soft); margin-bottom: 20px; font-size: 14.5px; }

/* ---------------- Cartes & grilles ---------------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid-domains { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* Bloc domaine (dashboard) */
.domain-card {
  position: relative; cursor: pointer; overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
  border-top: 4px solid var(--dc, var(--accent));
}
.domain-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.domain-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.domain-emoji { font-size: 26px; }
.domain-name { font-weight: 700; font-size: 15.5px; }
.domain-theme { font-size: 12.5px; color: var(--text-soft); }

/* Anneau de progression circulaire */
.ring-wrap { display: flex; align-items: center; gap: 14px; }
.ring { --val: 0; width: 64px; height: 64px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 8; }
.ring .ring-bg { stroke: var(--bg-soft); }
.ring .ring-fg {
  stroke: var(--dc, var(--accent)); stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1);
}
.ring-pct { font-weight: 800; font-size: 20px; }
.ring-label { font-size: 12px; color: var(--text-soft); }

/* Barre de progression */
.bar { height: 12px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.bar > span {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #2563eb);
  transition: width 1s cubic-bezier(.4,0,.2,1);
}
.bar.dc > span { background: var(--dc); }

/* En-tête dashboard : progression globale + streak */
.hero {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 22px;
}
.hero-global h3 { font-size: 15px; color: var(--text-soft); font-weight: 600; }
.hero-global .big { font-size: 44px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; margin: 4px 0 12px; }
.streak-card { text-align: center; display: flex; flex-direction: column; justify-content: center; }
.streak-flame { font-size: 40px; animation: flicker 1.6s ease-in-out infinite; }
.streak-num { font-size: 38px; font-weight: 800; }
.streak-label { font-size: 13px; color: var(--text-soft); }
.week-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.week-pill {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--bg-soft); color: var(--text-soft);
}
.week-pill.current { background: var(--accent); color: #fff; transform: scale(1.08); }
.week-pill.done { background: #16a34a; color: #fff; }

/* ---------------- Calendrier hebdo ---------------- */
.cal { overflow-x: auto; }
.cal table { border-collapse: collapse; width: 100%; min-width: 540px; }
.cal th, .cal td { padding: 7px; text-align: center; border: 1px solid var(--border); }
.cal th { font-size: 12.5px; color: var(--text-soft); font-weight: 700; }
.cal td.dom-label { text-align: left; font-weight: 600; font-size: 13px; white-space: nowrap; }
.checkbox {
  width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--border);
  cursor: pointer; display: inline-grid; place-items: center; transition: all 0.15s; background: var(--bg-card);
}
.checkbox:hover { border-color: var(--dc, var(--accent)); }
.checkbox.on { background: var(--dc, var(--accent)); border-color: var(--dc, var(--accent)); }
.checkbox.on::after { content: "✓"; color: #fff; font-weight: 800; font-size: 15px; animation: pop 0.25s ease; }
.checkbox.readonly { cursor: default; opacity: 0.85; }

/* ---------------- Page cours ---------------- */
.back-btn { background: var(--bg-soft); border: none; color: var(--text); cursor: pointer;
  padding: 8px 14px; border-radius: 10px; font-weight: 600; margin-bottom: 14px; }
.course-head { border-top: 5px solid var(--dc); }
.week-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.week-tab { border: 1px solid var(--border); background: var(--bg-card); color: var(--text-soft);
  padding: 7px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13px; }
.week-tab.active { background: var(--dc); color: #fff; border-color: var(--dc); }
.course-text { line-height: 1.7; }
.course-text h1 { font-size: 21px; margin: 4px 0 10px; }
.course-text h1:first-child { margin-top: 0; }
.course-text pre { background: var(--bg-soft); padding: 12px; border-radius: 10px; overflow-x: auto;
  font-size: 13px; margin: 10px 0; border: 1px solid var(--border); }
.course-text code { font-family: ui-monospace, "Cascadia Code", monospace; }
.course-text p { margin: 8px 0; }
.course-text table { border-collapse: collapse; margin: 10px 0; font-size: 13.5px; }
.course-text th, .course-text td { border: 1px solid var(--border); padding: 5px 10px; }

.status-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 16px; }
.status-pick { display: flex; gap: 6px; }
.status-opt { border: 1.5px solid var(--border); background: var(--bg-card); color: var(--text-soft);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; }
.status-opt.active { color: #fff; border-color: transparent; }
.status-opt.active[data-s="nc"] { background: #9ca3af; }
.status-opt.active[data-s="encours"] { background: #f59e0b; }
.status-opt.active[data-s="maitrise"] { background: #16a34a; }

.exo { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 10px 0; background: var(--bg-card); }
.exo-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.exo-level { font-size: 11px; font-weight: 800; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.5px; }
.exo-level.facile { background: #dcfce7; color: #166534; }
.exo-level.moyen { background: #fef9c3; color: #854d0e; }
.exo-level.difficile { background: #fee2e2; color: #991b1b; }
.exo-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-sm { border: none; cursor: pointer; padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 13px; }
.btn-reveal { background: var(--bg-soft); color: var(--text); }
.btn-validate { background: var(--dc); color: #fff; }
.btn-validate.done { background: #16a34a; }
.corrige { margin-top: 10px; padding: 12px; background: var(--bg-soft); border-radius: 10px;
  border-left: 3px solid var(--dc); white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 13px; }

/* Quiz */
.quiz-q { margin: 14px 0; }
.quiz-q p { font-weight: 600; margin-bottom: 6px; }
.quiz-opt { display: block; width: 100%; text-align: left; border: 1.5px solid var(--border);
  background: var(--bg-card); color: var(--text); padding: 9px 13px; border-radius: 10px;
  margin: 5px 0; cursor: pointer; font-size: 14px; transition: all 0.15s; }
.quiz-opt:hover { border-color: var(--dc); }
.quiz-opt.sel { border-color: var(--dc); background: var(--bg-soft); }
.quiz-opt.correct { background: #dcfce7; border-color: #16a34a; color: #166534; }
.quiz-opt.wrong { background: #fee2e2; border-color: #dc2626; color: #991b1b; }
.quiz-result { font-weight: 700; font-size: 17px; margin-top: 12px; text-align: center; }

/* ---------------- Suivi : graphe + checklist ---------------- */
.svg-chart { width: 100%; height: auto; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--text-soft); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* Badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge { text-align: center; padding: 14px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg-card); opacity: 0.45; filter: grayscale(1); transition: all 0.3s; }
.badge.unlocked { opacity: 1; filter: none; box-shadow: var(--shadow); }
.badge.unlocked .badge-icon { animation: pop 0.5s ease; }
.badge-icon { font-size: 32px; }
.badge-name { font-weight: 700; font-size: 13.5px; margin-top: 4px; }
.badge-desc { font-size: 11.5px; color: var(--text-soft); }

/* Journal */
.journal-date { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.journal-date input { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--bg-soft); color: var(--text); font-size: 14px; }
textarea {
  width: 100%; min-height: 200px; padding: 14px; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--bg-card); color: var(--text); font-size: 15px; font-family: inherit; resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }
.save-hint { font-size: 12.5px; color: var(--text-soft); margin-top: 8px; }

/* Boutons généraux */
.btn-primary { background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 12px 18px; border-radius: 12px; font-weight: 700; font-size: 15px; transition: transform 0.15s, opacity 0.2s; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); cursor: pointer;
  padding: 10px 16px; border-radius: 11px; font-weight: 600; }
.btn-danger { background: #dc2626; color: #fff; border: none; cursor: pointer;
  padding: 10px 16px; border-radius: 11px; font-weight: 600; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mt { margin-top: 16px; }
.readonly-note { background: #bfdbfe; color: #1e40af; padding: 8px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600; margin-bottom: 16px; display: inline-block; }
[data-theme="dark"] .readonly-note { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .exo-level.facile { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .exo-level.moyen { background: #713f12; color: #fde68a; }
[data-theme="dark"] .exo-level.difficile { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .quiz-opt.correct { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .quiz-opt.wrong { background: #7f1d1d; color: #fecaca; }

/* ---------------- Toast & confettis ---------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px);
  background: #16a34a; color: #fff; padding: 13px 22px; border-radius: 12px; font-weight: 700;
  box-shadow: var(--shadow-lg); z-index: 100; opacity: 0; transition: all 0.4s cubic-bezier(.2,.8,.2,1);
  pointer-events: none; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; }

/* ---------------- Animations ---------------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes spin-slow { to { transform: rotate(360deg); } }
@keyframes flicker { 0%,100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.12) rotate(2deg); } }

/* ---------------- Responsive ---------------- */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .nav { order: 3; width: 100%; }
  .topbar { gap: 8px; }
  .hero-global .big { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
