/* Henon Academy — mêmes couleurs et mêmes polices que Caisse claire. Classes préfixées « ha- ». */
:root {
  --bg: #f7f5f2;
  --bg-2: #eeeae4;
  --surface: #ffffff;
  --ink: #1c1a17;
  --ink-soft: #6b6660;
  --border: #e6e2db;
  --border-2: #d8d2c7;
  --accent: #b8863f;
  --accent-dark: #8f6528;
  --accent-soft: #f4e9d8;
  --henon: #e5366a;
  --night: #140b09;
  --ok: #2f7a4d;
  --ok-soft: #e4f2e8;
  --warn: #a8660b;
  --warn-soft: #fbefd9;
  --err: #c4432a;
  --err-soft: #fbe9e4;
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --shadow: 0 8px 24px -10px rgba(28, 26, 23, .18);
  --h: 46px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --display: "Cormorant", Georgia, serif;
  --body: "Karla", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); min-height: 100dvh; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
p { margin: 0; }
a { color: var(--accent-dark); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }

.ha-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h); padding: 0 18px; border-radius: var(--r-sm); border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; font-weight: 700; text-decoration: none; color: var(--ink); }
.ha-btn:hover { border-color: var(--accent); }
.ha-btn:disabled { opacity: .55; cursor: default; }
.ha-btn.ha-gold { background: var(--accent); border-color: var(--accent); color: #fff; }
.ha-btn.ha-gold:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.ha-btn.ha-quiet { border-color: transparent; background: transparent; color: var(--ink-soft); font-weight: 500; }
.ha-btn.ha-danger { color: var(--err); }
.ha-btn.ha-wide { width: 100%; }

.ha-field { display: block; margin-bottom: 14px; }
.ha-field > span { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 4px; }
.ha-field input, .ha-select { width: 100%; min-height: var(--h); padding: 0 12px; border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--surface); }
.ha-error { color: var(--err); font-size: 14px; min-height: 22px; margin: 6px 0; }
.ha-muted { color: var(--ink-soft); font-size: 14px; }

/* ---------- pages centrées : connexion, invitation, choix du profil, code PIN ---------- */
.ha-center { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.ha-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.ha-card form { text-align: left; margin-top: 20px; }
.ha-logo { width: 64px; height: 64px; margin-bottom: 10px; }
.ha-title i { color: var(--accent-dark); }
.ha-sub { color: var(--ink-soft); margin-top: 6px; }

.ha-profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; margin-top: 22px; }
.ha-profile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); cursor: pointer; min-height: 44px; }
.ha-profile:hover { border-color: var(--accent); }
.ha-avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 20px; flex: none; }
.ha-avatar.ha-sm { width: 40px; height: 40px; font-size: 17px; }

.ha-dots { display: flex; justify-content: center; gap: 14px; margin: 22px 0 6px; }
.ha-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-2); }
.ha-dots span.ha-on { background: var(--accent); border-color: var(--accent); }
.ha-dots.ha-shake { animation: ha-shake .35s; }
@keyframes ha-shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.ha-pad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 280px; margin: 8px auto 0; }
.ha-pad button { min-height: 58px; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg); font-size: 22px; font-weight: 700; cursor: pointer; }
.ha-pad button:active { background: var(--accent-soft); }
.ha-pad .ha-ghost { border-color: transparent; background: transparent; font-size: 15px; font-weight: 500; color: var(--ink-soft); }

/* ---------- application ---------- */
.ha-app { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
.ha-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.ha-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ha-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-size: 13px; font-weight: 700; white-space: nowrap; }
.ha-chip.ha-warn { background: var(--warn-soft); color: var(--warn); }
.ha-chip.ha-ok { background: var(--ok-soft); color: var(--ok); }
.ha-chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ha-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px; margin-bottom: 14px; }
.ha-panel h2 { margin-bottom: 6px; }
.ha-note { background: var(--warn-soft); color: var(--warn); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.ha-steps { list-style: none; padding: 0; margin: 12px 0 0; }
.ha-steps li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--border); }
.ha-steps b { font-family: var(--display); font-size: 20px; color: var(--accent-dark); min-width: 18px; }

.ha-member { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
.ha-member-name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; }
.ha-member-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ha-member-actions { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.ha-member-link { grid-column: 1 / -1; min-width: 0; }
.ha-link-box { background: var(--bg); border: 1px dashed var(--border-2); border-radius: var(--r-sm); padding: 12px; font-size: 14px; }
.ha-link-box code { display: block; word-break: break-all; margin: 8px 0; font-size: 13px; }
@media (min-width: 620px) {
  .ha-member-actions { grid-template-columns: minmax(0, 1.3fr) auto auto; align-items: center; }
}

.ha-nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--border); display: flex; justify-content: center; }
.ha-nav button { flex: 1; max-width: 220px; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; color: var(--ink-soft); }
.ha-nav button[aria-current="page"] { color: var(--accent-dark); font-weight: 700; }
.ha-nav svg { width: 22px; height: 22px; }

.ha-toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translateX(-50%); background: var(--night); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100vw - 32px); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.ha-member > div:empty { display: none; }

/* ---------- parcours ---------- */
.ha-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ha-bar { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin: 8px 0 4px; }
.ha-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); transition: width .6s cubic-bezier(.2, .8, .2, 1); animation: ha-grow .8s cubic-bezier(.2, .8, .2, 1) both; transform-origin: left; }
@keyframes ha-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.ha-resume { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.ha-resume-title { font-family: var(--display); font-size: 21px; font-weight: 600; line-height: 1.2; }
.ha-chapter { margin: 22px 0 8px; }
.ha-chapter-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-bottom: 8px; }
.ha-chapter-head h2 { font-size: 21px; }
.ha-chapter-head .ha-muted { font-size: 13px; }
.ha-chapter-num { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-dark); font-family: var(--display); font-size: 20px; font-weight: 700; }
.ha-lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ha-lesson { width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left; min-height: 60px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.ha-lesson:hover { border-color: var(--accent); }
.ha-lesson-mark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-2); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; }
.ha-lesson.ha-in_progress .ha-lesson-mark { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.ha-lesson.ha-done .ha-lesson-mark { background: var(--ok); border-color: var(--ok); }
.ha-lesson-text { display: grid; gap: 2px; min-width: 0; }
.ha-lesson-title { font-weight: 700; }
.ha-lesson-go { color: var(--ink-soft); font-size: 22px; }
.ha-soon { padding: 6px 0 0 46px; }

/* ---------- leçon ---------- */
.ha-lesson-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.ha-lesson-top .ha-btn { padding-left: 0; }
.ha-lesson-h1 { font-size: 26px; margin: 14px 0 4px; }
.ha-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 20px 18px; margin: 14px 0; min-height: 200px; }
.ha-block > * + * { margin-top: 12px; }
.ha-block h2 { font-size: 24px; }
.ha-block p { font-size: 17px; line-height: 1.55; }
.ha-kicker { font-size: 13px !important; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-dark); font-weight: 700; margin-bottom: 0; }
.ha-steps-list { margin: 0; padding: 0; list-style: none; counter-reset: ha-step; display: grid; gap: 10px; }
.ha-steps-list li { counter-increment: ha-step; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; align-items: start; font-size: 17px; line-height: 1.5; }
.ha-steps-list li::before { content: counter(ha-step); width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.ha-checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ha-checklist label { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; font-size: 17px; }
.ha-checklist input { width: 22px; height: 22px; accent-color: var(--ok); flex: none; }
.ha-options { display: grid; gap: 10px; }
.ha-option { min-height: 54px; padding: 12px 14px; text-align: left; font-size: 17px; line-height: 1.35; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.ha-option:hover:not(:disabled) { border-color: var(--accent); }
.ha-option:disabled { cursor: default; }
.ha-option.ha-right, .ha-order.ha-right { border-color: var(--ok); background: var(--ok-soft); }
.ha-option.ha-wrong { border-color: var(--err); background: var(--err-soft); }
.ha-feedback { border-radius: var(--r-sm); padding: 12px 14px; font-size: 16px; animation: ha-fade .35s ease both; }
.ha-feedback p { font-size: 16px; margin-top: 6px; }
.ha-feedback .ha-btn { margin-top: 10px; }
.ha-feedback.ha-right { background: var(--ok-soft); color: #1f5a37; }
.ha-feedback.ha-wrong { background: var(--warn-soft); color: #7a4a08; }
@keyframes ha-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.ha-order { list-style: none; margin: 0; padding: 8px; display: grid; gap: 8px; border: 1px solid transparent; border-radius: var(--r); }
.ha-order li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 6px 6px 14px; border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--surface); font-size: 17px; }
.ha-order-move { display: flex; gap: 2px; }
.ha-order-move .ha-btn { min-width: 44px; padding: 0; font-size: 20px; }
.ha-inline-actions { display: flex; gap: 10px; }
.ha-amount-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; }
.ha-amount { min-height: 54px; padding: 0 14px; font-size: 22px; font-weight: 700; border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--surface); width: 100%; }
.ha-unit { font-size: 22px; font-weight: 700; color: var(--ink-soft); }
.ha-lesson-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ha-feedback .ha-inline-actions { margin-top: 10px; flex-wrap: wrap; }
.ha-lesson-nav .ha-btn { min-width: 130px; }
.ha-done { text-align: center; padding: 28px 18px; }
.ha-done > * + * { margin-top: 12px; }
.ha-done-mark { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; background: var(--ok); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 38px; animation: ha-pop .6s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes ha-pop { from { transform: scale(0); } to { transform: scale(1); } }
.ha-done-score { font-size: 17px; }
.ha-done-actions { display: grid; gap: 10px; margin-top: 18px !important; }
.ha-btn { text-align: center; }

/* ---------- exercice en situation (Caisse claire) ---------- */
.ha-situation { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 14px 16px; }
.ha-situation > * + * { margin-top: 8px; }
.ha-situation p { font-size: 16px; }
.ha-drawer { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ha-drawer li { padding: 6px 12px; border: 1px solid var(--border-2); border-radius: 999px; background: var(--surface); font-size: 15px; }
.ha-block h3 { font-size: 20px; }
.ha-checks { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.ha-checks li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; font-size: 16px; line-height: 1.4; }
.ha-check-mark { font-weight: 700; }
.ha-checks .ha-ok .ha-check-mark { color: var(--ok); }
.ha-checks .ha-ko .ha-check-mark { color: var(--err); }
