/* =====================================================================
   faistonsite — styles communs (toutes les pages)
   Thème clair et premium : blanc cassé, texte presque noir, boutons noirs,
   miel en touche (badges, progression, accents).
   ===================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,400..800&family=Instrument+Sans:wght@400;500;600&family=JetBrains+Mono:wght@500;600&display=swap");

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f2f1ec;
  --line: #e4e2db;
  --line-strong: #cfccc3;
  --text: #141412;
  --muted: #6e6b64;
  --honey: #e9a93b;
  --honey-soft: #fcefd3;
  --honey-text: #8a5600;
  --ok: #2f7d4a;
  --danger: #b8382a;

  --font-display: "Bricolage Grotesque", "Segoe UI", sans-serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r-s: 0;
  --r-m: 0;
  --r-l: 0;
  --shadow: none;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1200px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--text); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--honey-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0;
}
h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); font-weight: 750; }
h2 { font-size: clamp(1.8rem, 3.6vw, 2.8rem); }
h3 { font-size: 1.25rem; letter-spacing: -0.015em; }
p { margin: 0; }
.muted { color: var(--muted); }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 50px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 0;
  font-family: var(--font-mono); font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s, transform .15s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--honey); color: var(--text); }
.btn-primary:hover { background: var(--text); color: #fff; }
.btn-dark { background: var(--text); color: #fff; }
.btn-dark:hover { background: var(--honey); color: var(--text); }
.btn .chev { width: 8px; height: 8px; border-right: 2px solid currentColor; border-top: 2px solid currentColor; transform: rotate(45deg); transition: transform .25s var(--ease); }
.btn:hover .chev { transform: translateX(3px) rotate(45deg); }
.btn-ghost { border-color: var(--line-strong); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--text); }
.btn-small { min-height: 38px; padding: 0 14px; font-size: .72rem; }
.btn-danger { border-color: #e8c3bd; color: var(--danger); background: transparent; }
.btn-danger:hover { border-color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: progress; }

/* ---------- En-tête ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(250, 250, 247, .82);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.brand {
  display: inline-flex; align-items: center;
  font-family: var(--font-display); font-weight: 750; font-size: 1.2rem;
  letter-spacing: -0.04em; color: var(--text); text-decoration: none;
}
/* Le logo : carré noir bordé de miel, carré miel au centre */
.brand::before {
  content: ""; width: 16px; height: 16px; margin-right: 10px; flex: none;
  background: var(--honey); box-shadow: inset 0 0 0 3px #141412, 0 0 0 1.5px var(--honey);
}
.nav { display: flex; align-items: center; gap: 24px; }
.nav a { color: var(--muted); text-decoration: none; font-family: var(--font-mono); font-size: .74rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; transition: color .2s; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); }
.nav .badge { margin-left: 6px; }
.lbl-short { display: none; }
@media (max-width: 760px) {
  .nav .hide-mobile { display: none; }
  .nav { gap: 14px; }
}
@media (max-width: 520px) {
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .nav { gap: 12px; font-size: .92rem; }
  .nav .btn-small { padding: 0 12px; min-height: 34px; }
}

.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 0; background: var(--honey); color: var(--text);
  font-size: .75rem; font-weight: 700; line-height: 1;
}

.site-footer { border-top: 1px solid var(--line); padding: 40px 0 56px; color: var(--muted); font-size: .92rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.site-footer a { color: var(--muted); }

/* ---------- Formulaires ---------- */
.auth-page { min-height: calc(100svh - 68px); display: grid; place-items: center; padding: 48px var(--gutter); }
.panel {
  width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: clamp(24px, 5vw, 40px); box-shadow: var(--shadow);
}
.panel h1 { font-size: clamp(2rem, 6vw, 2.6rem); }
.panel > p { margin-top: 10px; color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 0; padding: 4px; margin: 26px 0 22px; }
.tabs button { border: 0; background: transparent; padding: 10px; border-radius: 0; cursor: pointer; color: var(--muted); font-family: var(--font-mono); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; transition: background .2s, color .2s; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20, 20, 18, .1); }
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: .92rem; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-s);
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px rgba(20, 20, 18, .08); }
.field .hint { font-size: .85rem; color: var(--muted); }
.form-msg { font-size: .95rem; padding: 12px 14px; border-radius: var(--r-s); }
.form-msg.error { background: #fbebe8; color: #8f2a1f; }
.form-msg.success { background: #e7f3ea; color: #1f5a33; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; justify-self: start; }

/* ---------- Espace élève ---------- */
.page { padding: 40px 0 80px; }
.page-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 32px; }
.progressbar { height: 8px; background: var(--surface-2); border-radius: 0; overflow: hidden; width: min(320px, 100%); }
.progressbar span { display: block; height: 100%; background: var(--honey); width: 0; transition: width .6s var(--ease); }

.paywall { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.paywall.single { grid-template-columns: minmax(0, 480px); }
.pay-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 30px; display: grid; gap: 14px; align-content: start; box-shadow: var(--shadow); }
.pay-card .price { font-family: var(--font-display); font-size: 2.6rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1; }
.pay-card ol { margin: 0; padding-left: 20px; color: var(--muted); display: grid; gap: 6px; }
@media (max-width: 760px) { .paywall { grid-template-columns: 1fr; } }

.course { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 28px; align-items: start; }
.course-nav { position: sticky; top: 88px; max-height: calc(100svh - 110px); overflow: auto; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.course-nav details { border-bottom: 1px solid var(--line); }
.course-nav details:last-child { border-bottom: 0; }
.course-nav summary { cursor: pointer; padding: 16px 18px; font-weight: 600; list-style: none; }
.course-nav summary::-webkit-details-marker { display: none; }
.course-nav summary small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.lesson-link {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  padding: 10px 18px; background: none; border: 0; cursor: pointer; color: var(--muted);
}
.lesson-link:hover { background: var(--surface-2); color: var(--text); }
.lesson-link[aria-current="true"] { background: var(--honey-soft); color: var(--text); }
.lesson-link .dot { flex: none; width: 14px; height: 14px; margin-top: 5px; border-radius: 0; border: 2px solid var(--line-strong); }
.lesson-link.done .dot { background: var(--honey); border-color: var(--honey); }
.player { aspect-ratio: 16 / 9; background: #111; border-radius: var(--r-m); overflow: hidden; }
.player iframe { width: 100%; height: 100%; border: 0; }
.player .empty { height: 100%; display: grid; place-items: center; color: #a9a69f; padding: 24px; text-align: center; }
.lesson-body { margin-top: 24px; display: grid; gap: 16px; }
.lesson-body h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.lesson-body .desc { white-space: pre-line; color: var(--muted); max-width: 72ch; }
.lesson-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 960px) {
  .course { grid-template-columns: 1fr; }
  .course-nav { position: static; max-height: none; order: 2; }
}

.notice { border: 1px solid var(--line); border-radius: var(--r-m); padding: 20px 22px; background: var(--surface); }
.notice + .notice { margin-top: 12px; }

/* ---------- Messagerie (façon WhatsApp) ---------- */
.chat-page { height: calc(100svh - 68px); display: grid; }
.chat {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%; min-height: 0; background: var(--surface);
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 0;
  display: grid; place-items: center; background: var(--text); color: #fff;
  font-family: var(--font-display); font-weight: 750; font-size: .95rem;
}
.chat-head .who { display: grid; line-height: 1.25; min-width: 0; }
.chat-head .who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .status { font-size: .85rem; color: var(--muted); }
.chat-head .status.typing { color: var(--honey-text); }
.chat-head .back { display: none; }
.chat-thread {
  overflow-y: auto; padding: 16px clamp(12px, 3vw, 28px); display: flex; flex-direction: column; gap: 4px;
  background-color: #f4f2ec;
  background-image: radial-gradient(rgba(20, 20, 18, .06) 1px, transparent 1px);
  background-size: 20px 20px;
}
.day-sep { align-self: center; margin: 14px 0 8px; padding: 4px 12px; border-radius: 0; background: var(--surface); color: var(--muted); font-size: .8rem; box-shadow: 0 1px 2px rgba(20, 20, 18, .08); }
.bubble {
  position: relative; max-width: min(78%, 560px); padding: 8px 12px 6px; border-radius: 2px;
  background: var(--surface); align-self: flex-start; word-wrap: break-word; overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(20, 20, 18, .08);
  animation: pop .22s var(--ease);
}
.bubble.mine { align-self: flex-end; background: var(--honey-soft); border-radius: 2px; }
.bubble + .bubble.gap { margin-top: 8px; }
.bubble .text { white-space: pre-wrap; }
.bubble img { border-radius: 10px; margin: 2px 0 4px; max-height: 320px; width: auto; cursor: zoom-in; background: var(--surface-2); min-width: 120px; min-height: 80px; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: .72rem; color: var(--muted); margin-top: 2px; }
.ticks { display: inline-flex; }
.ticks svg { width: 16px; height: 11px; }
.ticks.read { color: #2b7bd6; }
.bubble.pending { opacity: .6; }
.bubble.failed .meta { color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 34ch; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-form textarea {
  flex: 1; min-height: 44px; max-height: 140px; resize: none; padding: 11px 16px;
  border-radius: 0; border: 1px solid var(--line-strong); background: var(--surface); line-height: 1.4;
}
.chat-form textarea:focus { outline: none; border-color: var(--text); }
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 0; border: 0; cursor: pointer;
  display: grid; place-items: center; background: transparent; color: var(--muted); transition: background .2s, color .2s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.send { background: var(--text); color: #fff; }
.icon-btn.send:hover { background: #2c2b27; color: #fff; }
.icon-btn svg { width: 22px; height: 22px; }
.chat-locked { padding: 16px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface); }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 9, .88); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-height: 92svh; max-width: 92vw; border-radius: 10px; }

/* ---------- Admin ---------- */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.admin-tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 14px; cursor: pointer;
  color: var(--muted); font-family: var(--font-mono); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; margin-bottom: -1px; transition: color .2s, border-color .2s;
}
.admin-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100svh - 220px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--surface); }
.inbox-list { border-right: 1px solid var(--line); display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.inbox-list .search { padding: 12px; border-bottom: 1px solid var(--line); }
.inbox-list .search input { width: 100%; min-height: 40px; border-radius: 0; padding: 8px 14px; border: 1px solid var(--line); background: var(--surface-2); }
.inbox-items { overflow-y: auto; }
.inbox-item {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer;
}
.inbox-item:hover { background: var(--surface-2); }
.inbox-item[aria-current="true"] { background: var(--honey-soft); }
.inbox-item .avatar { grid-row: span 2; background: var(--surface-2); color: var(--text); }
.inbox-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item .time { font-size: .78rem; color: var(--muted); }
.inbox-item .preview { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item.unread .time { color: var(--honey-text); font-weight: 600; }
.inbox-thread { min-height: 0; }
.inbox-thread .placeholder { height: 100%; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; background: #f4f2ec; }
@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; height: calc(100svh - 190px); }
  .inbox.show-thread .inbox-list { display: none; }
  .inbox:not(.show-thread) .inbox-thread { display: none; }
  .inbox .chat-head .back { display: grid; }
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; padding: 3px 8px; border-radius: 0; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.tag.ok { background: #e3f1e7; color: var(--ok); }
.tag.wait { background: var(--honey-soft); color: var(--honey-text); }
.tag.off { background: #f8e4e0; color: var(--danger); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toolbar input { min-height: 42px; padding: 8px 14px; border-radius: 0; border: 1px solid var(--line-strong); background: var(--surface); width: min(320px, 100%); }

.content-editor { display: grid; gap: 16px; }
.module-block { border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px; background: var(--surface); display: grid; gap: 12px; }
.module-block header { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.lesson-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); }

dialog {
  width: min(560px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--r-l);
  background: var(--surface); color: var(--text); padding: 28px; box-shadow: 0 30px 80px -20px rgba(20, 20, 18, .35);
}
dialog::backdrop { background: rgba(20, 20, 18, .45); backdrop-filter: blur(2px); }
dialog h2 { font-size: 1.6rem; margin-bottom: 18px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.check { display: flex; gap: 10px; align-items: center; }
.check input { width: 18px; height: 18px; accent-color: var(--text); }

/* ---------- Notifications ---------- */
.toast-zone { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(460px, calc(100vw - 32px)); }
.toast { padding: 14px 18px; border-radius: var(--r-s); background: var(--text); color: #fff; box-shadow: 0 16px 40px -12px rgba(20, 20, 18, .4); animation: pop .25s var(--ease); }
.toast.error { background: #8f2a1f; }
.toast.success { background: #1f5a33; }

.page-msg { padding: 64px 0; text-align: center; color: var(--muted); }

/* Chargement : le logo qui tourne et respire */
.loader { min-height: 46vh; display: grid; place-items: center; }
.loader-mark {
  position: relative; width: 46px; height: 46px; background: #141412;
  box-shadow: 0 0 0 2px var(--honey);
  animation: loader-turn 1.6s cubic-bezier(.7, 0, .3, 1) infinite;
}
.loader-mark::after {
  content: ""; position: absolute; inset: 9px; background: var(--honey);
  animation: loader-breathe 1.6s cubic-bezier(.7, 0, .3, 1) infinite;
}
@keyframes loader-turn { 0%, 15% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
@keyframes loader-breathe { 0%, 15% { transform: scale(1); } 40% { transform: scale(.35); } 70%, 100% { transform: scale(1); } }

/* Bouton en attente : petit logo qui tourne devant le texte */
.busy-mark {
  position: relative; width: 12px; height: 12px; flex: none; margin-right: 10px;
  background: #141412; box-shadow: 0 0 0 1.5px currentColor;
  animation: loader-turn 1.2s cubic-bezier(.7, 0, .3, 1) infinite;
}
.busy-mark::after { content: ""; position: absolute; inset: 3px; background: var(--honey); }
.btn[disabled] { cursor: progress; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
