/* ================================================================
   EduCarette : compte élève (en-tête, fenêtre de connexion, toast)
   et éléments de reprise de progression dans les cours.
   Chargé automatiquement par auth.js, sur toutes les pages.
   Utilise les jetons du design system Organic (organic-ds.css).
   ================================================================ */

.ec-auth, .ec-modal-overlay, .ec-toast, .ec-resume-banner, .exo-restart, .ec-chapter-done {
  --ecc-ink: var(--color-neutral-900, #2b2621);
  --ecc-muted: var(--color-neutral-700, #6b6158);
  --ecc-line: var(--color-neutral-300, #e6ddd0);
  --ecc-paper: var(--color-neutral-100, #fbf8f3);
  --ecc-accent: var(--color-accent-700, #8c491a);
  --ecc-accent-soft: var(--color-accent-100, #fbeee4);
  --ecc-sage: var(--color-accent-2-700, #56613f);
  --ecc-sage-soft: var(--color-accent-2-100, #eef1e6);
  font-family: var(--font-body, 'Figtree', system-ui, sans-serif);
}

/* ── En-tête : zone du compte ─────────────────────────────── */
.ec-auth { display: flex; align-items: center; gap: 10px; position: relative; }
.ec-auth button { font: inherit; cursor: pointer; }
.ec-auth-login {
  background: none; border: 0; padding: 8px 6px; font-size: 14px; font-weight: 600; color: var(--ecc-muted);
}
.ec-auth-login:hover { color: var(--ecc-ink); }
.ec-auth-register {
  border: 0; border-radius: 999px; padding: 0 20px; min-height: 42px; font-size: 14px; font-weight: 700;
  background: var(--ecc-accent); color: var(--color-accent-100, #fff);
}
.ec-auth-register:hover { background: var(--color-accent-600, #a4561f); }
.ec-auth-icon {
  display: none; width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--ecc-line);
  background: #fff; color: var(--ecc-ink); align-items: center; justify-content: center;
}
.ec-auth-user {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; min-height: 42px;
  border: 1.5px solid var(--ecc-line); border-radius: 999px; background: #fff; color: var(--ecc-ink); font-weight: 600; font-size: 14px;
}
.ec-auth-user:hover, .ec-auth-user[aria-expanded="true"] { border-color: var(--color-accent-400, #d99a6c); }
.ec-auth-avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--color-accent-200, #f5d5bf); color: var(--color-accent-800, #6e3813); font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.ec-auth-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-auth-menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 120; width: 260px; padding: 8px;
  background: #fff; border: 1px solid var(--ecc-line); border-radius: 16px; box-shadow: 0 18px 40px rgba(43, 38, 33, .14);
}
.ec-auth-menu[hidden] { display: none; }
.ec-auth-menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--ecc-line); margin-bottom: 6px; display: grid; gap: 2px; }
.ec-auth-menu-pseudo { font-size: 15px; color: var(--ecc-ink); overflow: hidden; text-overflow: ellipsis; }
.ec-auth-menu-email { font-size: 13px; color: var(--ecc-muted); overflow: hidden; text-overflow: ellipsis; }
.ec-auth-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--ecc-ink); font-size: 14px; font-weight: 600; text-align: left; text-decoration: none;
}
.ec-auth-menu-item[hidden] { display: none; }
.ec-auth-menu-item:hover, .ec-auth-menu-item:focus-visible { background: var(--ecc-paper); text-decoration: none; color: var(--ecc-ink); outline: none; }
.ec-auth-menu-item svg { flex: none; color: var(--ecc-accent); }
.ec-auth-menu-resume { background: var(--ecc-accent-soft); color: var(--color-accent-800, #6e3813); }
.ec-auth-menu-resume span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-auth-logout svg { color: var(--ecc-muted); }

@media (max-width: 760px) {
  .ec-auth-login, .ec-auth-register { display: none; }
  .ec-auth-icon { display: inline-flex; }
  .ec-auth-name, .ec-auth-user > svg { display: none; }
  .ec-auth-user { padding: 4px; }
  .ec-auth-menu { right: -52px; width: min(300px, calc(100vw - 32px)); }
}

/* ── Fenêtre de connexion ─────────────────────────────────── */
html.ec-auth-lock { overflow: hidden; }
.ec-modal-overlay {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: rgba(43, 38, 33, .45); opacity: 0; transition: opacity .18s ease;
}
.ec-modal-overlay[hidden] { display: none; }
.ec-modal-overlay.open { opacity: 1; }
.ec-modal {
  position: relative; width: 100%; max-width: 420px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--ecc-paper); border-radius: 28px; padding: 32px 28px 26px; color: var(--ecc-ink);
  box-shadow: 0 30px 80px rgba(43, 38, 33, .25); transform: translateY(8px); transition: transform .18s ease;
}
.ec-modal-overlay.open .ec-modal { transform: none; }
.ec-modal-close {
  position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: none; color: var(--ecc-muted); cursor: pointer; display: grid; place-items: center;
}
.ec-modal-close:hover { background: var(--color-neutral-200, #f3ede4); color: var(--ecc-ink); }
.ec-modal-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-heading, 'Caprasimo', serif); font-size: 20px; margin-bottom: 18px; }
.ec-modal h2 { font-family: var(--font-heading, 'Caprasimo', serif); font-weight: 400; font-size: 28px; line-height: 1.15; margin: 0 0 6px; color: var(--ecc-ink); }
.ec-modal-lede { margin: 0 0 18px; color: var(--ecc-muted); font-size: 15px; line-height: 1.5; }
.ec-modal-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 18px;
  background: var(--color-neutral-200, #f3ede4); border-radius: 999px;
}
.ec-modal-tabs[hidden] { display: none; }
.ec-modal-tabs button {
  border: 0; border-radius: 999px; min-height: 40px; background: none; font: inherit; font-size: 14px; font-weight: 700;
  color: var(--ecc-muted); cursor: pointer;
}
.ec-modal-tabs button.is-active { background: #fff; color: var(--ecc-ink); box-shadow: 0 1px 3px rgba(43, 38, 33, .12); }
.ec-modal form { display: grid; gap: 14px; }
.ec-modal form[hidden] { display: none; }
.ec-field { display: grid; gap: 6px; font-size: 14px; font-weight: 700; color: var(--ecc-ink); }
.ec-field small { font-weight: 500; color: var(--ecc-muted); margin-left: 6px; }
.ec-field input {
  min-height: 48px; padding: 0 14px; border: 1.5px solid var(--color-neutral-400, #d4c8b8); border-radius: 12px;
  background: #fff; font: inherit; font-weight: 500; font-size: 16px; color: var(--ecc-ink);
}
.ec-field input:focus { outline: 2px solid var(--color-accent-500, #c67139); outline-offset: 1px; border-color: var(--color-accent-500, #c67139); }
.ec-modal-msg { margin: 0; padding: 10px 12px; border-radius: 12px; background: #fbeae7; color: #9a2c1e; font-size: 14px; line-height: 1.45; }
.ec-modal-msg.is-ok { background: var(--ecc-sage-soft); color: var(--ecc-sage); }
.ec-modal-msg[hidden] { display: none; }
.ec-modal-submit {
  min-height: 50px; border: 0; border-radius: 999px; background: var(--ecc-accent); color: #fff;
  font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 2px;
}
.ec-modal-submit:hover { background: var(--color-accent-600, #a4561f); }
.ec-modal-submit:disabled { opacity: .6; cursor: progress; }
.ec-modal-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.ec-modal-link { border: 0; background: none; padding: 4px 0; font: inherit; font-size: 14px; color: var(--ecc-muted); cursor: pointer; text-align: left; }
.ec-modal-link strong { color: var(--ecc-accent); }
.ec-modal-link:hover { color: var(--ecc-ink); text-decoration: underline; }
.ec-modal-legal { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ecc-muted); }
.ec-modal-legal a { color: var(--ecc-muted); text-decoration: underline; }
@media (max-width: 480px) {
  .ec-modal-overlay { place-items: end center; padding: 0; }
  .ec-modal { border-radius: 24px 24px 0 0; max-height: 92vh; padding: 28px 20px 22px; }
}

/* ── Notification ─────────────────────────────────────────── */
.ec-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 1100; transform: translate(-50%, 16px); opacity: 0;
  max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: 999px;
  background: var(--ecc-ink); color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 12px 30px rgba(43, 38, 33, .25);
  transition: opacity .25s ease, transform .25s ease;
}
.ec-toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ── Bandeau « Reprendre » dans un cours ──────────────────── */
.ec-resume-banner { background: var(--ecc-accent-soft); border-bottom: 1px solid var(--color-accent-200, #f5d5bf); }
.ec-resume-banner-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.ec-resume-banner p { margin: 0; flex: 1 1 260px; font-size: 15px; color: var(--color-accent-900, #4f280e); }
.ec-resume-banner-btn {
  border: 0; border-radius: 999px; min-height: 40px; padding: 0 20px; background: var(--ecc-accent); color: #fff;
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.ec-resume-banner-close {
  border: 0; background: none; width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1;
  color: var(--color-accent-800, #6e3813); cursor: pointer;
}

/* ── Exercices repris ─────────────────────────────────────── */
.exo-restart {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 18px; border-radius: 14px; background: var(--ecc-sage-soft); color: var(--ecc-sage);
}
.exo-restart p { margin: 0; font-weight: 600; font-size: 14.5px; }
.exo-restart button {
  border: 1.5px solid currentColor; background: #fff; color: var(--ecc-sage); border-radius: 999px;
  min-height: 36px; padding: 0 16px; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}

/* ── Fin de chapitre Organic ──────────────────────────────── */
.ec-chapter-done {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 40px 0 8px; padding: 22px 24px; border-radius: 22px; background: var(--ecc-accent-soft); border: 1px solid var(--color-accent-200, #f5d5bf);
}
.ec-chapter-done[data-state="completed"] { background: var(--ecc-sage-soft); border-color: var(--color-accent-2-200, #dde3cf); }
.ec-chapter-done strong { font-family: var(--font-heading, 'Caprasimo', serif); font-weight: 400; font-size: 21px; }
.ec-chapter-done p { margin: 4px 0 0; color: var(--ecc-muted); font-size: 15px; }
.ec-chapter-done-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ec-chapter-done-btn {
  border: 0; cursor: pointer; min-height: 46px; padding: 0 22px; border-radius: 999px;
  background: var(--ecc-accent); color: #fff; font: 700 15px var(--font-body, 'Figtree', sans-serif);
}
.ec-chapter-done-btn:hover { background: var(--color-accent-600, #a4561f); }
.ec-chapter-done a.ec-chapter-done-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1.5px solid var(--color-neutral-400, #d4c8b8); background: #fff; color: var(--ecc-ink);
  font: 700 14.5px var(--font-body, 'Figtree', sans-serif); text-decoration: none;
}
.ec-chapter-done strong { color: var(--ecc-ink); }
#cours-content + .ec-chapter-done { max-width: 860px; }
.ec-chapter-done-undo { border: 0; background: none; font: inherit; font-size: 13.5px; color: var(--ecc-muted); text-decoration: underline; cursor: pointer; }

/* Les liens du site (.ec a) ne doivent pas recolorer le menu du compte. */
.ec-auth a.ec-auth-menu-item { color: var(--ecc-ink); text-decoration: none; }
.ec-auth a.ec-auth-menu-item.ec-auth-menu-resume { color: var(--color-accent-800, #6e3813); }
.ec-auth a.ec-auth-menu-item:hover { color: var(--ecc-ink); text-decoration: none; }

/* ── Accès classe sur les cartes de fiche ─────────────────── */
.ec-dl-classe {
  display: block; width: 100%; margin: -2px 0 2px; padding: 6px 4px; border: 0; background: none; cursor: pointer;
  font: 600 12.5px/1.4 var(--font-body, 'Figtree', sans-serif); color: var(--color-accent-800, #6e3813); text-align: left; text-decoration: underline;
}
.ec-dl-classe:hover { color: var(--color-accent-600, #a4561f); }
.ec-dl-item--paid.is-unlocked { border-color: var(--color-accent-2-500, #8a9a6c); background: var(--color-accent-2-100, #eef1e6); }
.ec .ec-dl-item--paid.is-unlocked .ec-dl-buy { background: var(--color-accent-2-700, #56613f); color: #fff; }
.ec-dl-item--paid.is-unlocked .ec-dl-note { color: var(--color-accent-2-800, #434c31); }
.ec-auth-menu-classe span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Case à cocher (inscription newsletter) ------------------------------------ */
.ec-field--checkbox { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; }
.ec-field--checkbox input { min-height: auto; width: 18px; height: 18px; margin-top: 2px; flex: none; border-radius: 5px; padding: 0; accent-color: var(--ecc-accent); }
.ec-field--checkbox span { font-size: 13.5px; line-height: 1.4; font-weight: 500; }

/* --- Encadré « fiche offerte » (inscription newsletter) ------------------------ */
.ec-offre {
  display: flex; align-items: flex-start; gap: 12px; margin: 4px 0 14px; padding: 14px;
  border: 1.5px solid var(--color-accent-2-500, #8a9a6c); border-radius: 12px;
  background: var(--color-accent-2-100, #eef1e6); cursor: pointer;
}
.ec-offre:hover { border-color: var(--color-accent-2-700, #56613f); }
.ec-offre:has(input:checked) { background: var(--color-accent-2-200, #dfe5d0); border-color: var(--color-accent-2-700, #56613f); }
.ec-offre input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--color-accent-2-700, #56613f); }
.ec-offre-text { display: flex; flex-direction: column; gap: 4px; font: 400 12.5px/1.45 var(--font-body, 'Figtree', sans-serif); color: var(--color-accent-2-800, #434c31); }
.ec-offre-text strong { font-size: 14px; font-weight: 700; color: var(--color-text, #2b2621); }
.ec-offre-badge {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; padding: 3px 9px; border-radius: 999px;
  background: var(--color-accent-2-700, #56613f); color: #fff; font: 700 10.5px/1.2 var(--font-body, 'Figtree', sans-serif);
  letter-spacing: .06em; text-transform: uppercase;
}

/* --- Menu du compte : interrupteur « Nouveautés par e-mail » -------------------- */
.ec-auth-menu-newsletter span:not(.ec-auth-switch) { flex: 1 1 auto; text-align: left; white-space: nowrap; }
.ec-auth-switch {
  position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px;
  background: var(--color-neutral-300, #d9d2c7); transition: background .15s;
}
.ec-auth-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.ec-auth-menu-newsletter[aria-checked="true"] .ec-auth-switch { background: var(--color-accent-2-700, #56613f); }
.ec-auth-menu-newsletter[aria-checked="true"] .ec-auth-switch::after { transform: translateX(14px); }
