/* ============================================================
   Claude University · La SPA — feuille de style partagée
   Liée par chaque page : <link rel="stylesheet" href="../assets/styles.css">
   Objectif : chaleureux, distinctif, éditorial (à la Tufte),
   calme et professionnel. Imprimable. 100 % hors-ligne :
   aucune ressource externe (polices système + SVG inline seulement).
   ============================================================ */

:root {
  /* ---- Surfaces ---- */
  --paper:      #fdf6ee;   /* crème chaud SPA */
  --paper-2:    #f6ead9;   /* sable — encarts, chips */
  --card:       #ffffff;   /* fond des composants */

  /* ---- Encre ---- */
  --ink:        #2a2320;   /* brun quasi-noir */
  --ink-soft:   #6b5d52;   /* texte secondaire */
  --rule:       #ecdecb;   /* filets, bordures */

  /* ---- Identité : orange SPA (accent principal) ---- */
  --brand:        #d1560e;   /* orange — grands titres, bordures */
  --brand-ink:    #a5430f;   /* orange foncé — petit texte AA, liens */
  --brand-bright: #ea6a1e;   /* orange vif — aplats, chips */
  --brand-bg:     #fcecdd;   /* orange très pâle — fonds */

  /* ---- Teal ardoise (accent secondaire, calme) ---- */
  --teal:       #1d6a75;
  --teal-deep:  #114b54;
  --teal-bg:    #e9f1f2;

  /* ---- Sémantique ---- */
  --gold:       #a9760a;   --gold-bg:  #fbf1d6;   /* à retenir */
  --red:        #b23b2e;   --red-bg:   #fbe6e2;   /* attention */
  --green:      #2c7a4f;   --green-bg: #e6f2ea;   /* réussite  */

  /* ---- Typographie ---- */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --maxw: 700px;
  --radius: 16px;
  --shadow:    0 1px 2px rgba(60,40,20,.05), 0 10px 26px -16px rgba(90,55,20,.28);
  --shadow-sm: 0 1px 2px rgba(60,40,20,.05), 0 4px 12px -8px rgba(90,55,20,.22);

  /* Patte SVG (orange) — filigrane discret */
  --paw: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='%23d1560e'%3E%3Cellipse cx='50' cy='64' rx='27' ry='23'/%3E%3Ccircle cx='23' cy='41' r='11.5'/%3E%3Ccircle cx='41' cy='25' r='11.5'/%3E%3Ccircle cx='59' cy='25' r='11.5'/%3E%3Ccircle cx='77' cy='41' r='11.5'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.64;
  padding: 0 20px 5rem;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--maxw); margin: 0 auto; }

::selection { background: var(--brand-bg); }

/* Focus clavier — visible et cohérent partout */
:focus-visible {
  outline: 3px solid var(--brand-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- En-tête de cours ---------- */
.course-head {
  max-width: var(--maxw);
  margin: 0 auto 1rem;
  padding: 1.5rem 0 1rem;
  border-bottom: 2px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  font-family: var(--sans);
}
.course-head .brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 800; letter-spacing: .01em; color: var(--brand-ink);
  font-size: .82rem; text-transform: uppercase;
}
.course-head .brand::before {
  content: ""; width: 1.15rem; height: 1.15rem; flex: none;
  background: var(--paw) center/contain no-repeat;
}
.course-head .brand span { color: var(--ink-soft); font-weight: 500; text-transform: none; letter-spacing: 0; }
.course-head .lesson-no {
  font-size: .74rem; font-weight: 700; color: var(--brand-ink);
  text-transform: uppercase; letter-spacing: .05em;
  background: var(--brand-bg); border-radius: 999px; padding: .3rem .8rem;
}

/* ---------- Titres & rythme ---------- */
.kicker {
  font-family: var(--sans);
  display: inline-flex; align-items: center; gap: .5rem;
  text-transform: uppercase; letter-spacing: .1em;
  font-size: .72rem; font-weight: 800; color: var(--brand-ink);
  margin: 2.6rem 0 .5rem;
}
.kicker::before {
  content: ""; width: 1.6rem; height: 2px; background: var(--brand-bright); border-radius: 2px;
}
h1 {
  font-size: clamp(2rem, 6vw, 2.5rem); line-height: 1.12; font-weight: 800;
  letter-spacing: -.01em; color: var(--brand); margin: .1rem 0 1rem;
  text-wrap: balance;
}
h2 {
  font-size: 1.45rem; line-height: 1.22; font-weight: 800; letter-spacing: -.005em;
  color: var(--ink); margin: 2.8rem 0 .7rem; padding-bottom: .35rem;
  border-bottom: 1px solid var(--rule);
  text-wrap: balance;
}
h3 {
  font-size: 1.12rem; font-weight: 700; color: var(--teal-deep);
  margin: 1.8rem 0 .4rem; font-family: var(--sans);
}
.subtitle {
  font-size: 1.18rem; color: var(--ink-soft); font-style: italic;
  line-height: 1.5; margin: -.2rem 0 1.2rem; text-wrap: pretty;
}

p { margin: .85rem 0; text-wrap: pretty; }
a {
  color: var(--brand-ink); text-decoration-thickness: 1.5px;
  text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, var(--brand-ink) 45%, transparent);
  transition: color .15s, text-decoration-color .15s;
}
a:hover { color: var(--brand-bright); text-decoration-color: currentColor; }
strong { font-weight: 700; color: var(--ink); }
em { font-style: italic; }

ul, ol { padding-left: 1.4rem; }
li { margin: .4rem 0; }
ul li::marker { color: var(--brand-bright); }
ol li::marker { color: var(--brand-ink); font-weight: 700; }

/* ---------- Encarts (callouts) ---------- */
.box {
  font-family: var(--sans); font-size: .96rem; line-height: 1.55;
  border-radius: var(--radius); padding: 1.15rem 1.35rem; margin: 1.6rem 0;
  border: 1px solid var(--rule); background: var(--card); box-shadow: var(--shadow-sm);
}
.box .box-title {
  font-weight: 800; font-size: .76rem; text-transform: uppercase;
  letter-spacing: .07em; margin-bottom: .45rem; display: block; color: var(--ink-soft);
}
.box p:first-of-type { margin-top: 0; }
.box p:last-child { margin-bottom: 0; }

.box.key  { background: var(--gold-bg);  border-color: #eaddb0; }
.box.key  .box-title { color: var(--gold); }
.box.warn { background: var(--red-bg);   border-color: #f0cdc7; }
.box.warn .box-title { color: var(--red); }
.box.tip  { background: var(--green-bg); border-color: #c6e2d1; }
.box.tip  .box-title { color: var(--green); }
.box.info { background: var(--teal-bg);  border-color: #c4dbde; }
.box.info .box-title { color: var(--teal-deep); }

/* ---------- Bloc « victoire du jour » ---------- */
.win {
  position: relative; overflow: hidden;
  border: 1px solid #f0d3b8; border-radius: 18px;
  padding: 1.4rem 1.6rem; margin: 2rem 0;
  background: var(--card); box-shadow: var(--shadow);
}
.win::after {   /* patte filigrane discrète */
  content: ""; position: absolute; right: -1.4rem; top: -1.6rem;
  width: 7.5rem; height: 7.5rem; background: var(--paw) center/contain no-repeat;
  opacity: .05; transform: rotate(12deg); pointer-events: none;
}
.win .win-label {
  font-family: var(--sans); font-weight: 800; color: var(--brand-ink);
  text-transform: uppercase; letter-spacing: .07em; font-size: .76rem;
  display: inline-flex; align-items: center; gap: .45rem;
}
.win h2, .win h3 { margin-top: .25rem; border: none; padding: 0; color: var(--ink); }
.win > *:last-child { margin-bottom: 0; }

/* ---------- Prompt / bloc à copier ---------- */
.prompt-block {
  font-family: var(--mono); font-size: .9rem; line-height: 1.55;
  background: #241f1b; color: #f3ecdf;
  border-radius: 10px; padding: 1.1rem 1.2rem; margin: 1.1rem 0;
  white-space: pre-wrap; word-break: break-word;
  border: 1px solid #3a322b;
}
.prompt-block .ph { color: #f0a96a; font-style: italic; } /* champ à remplir */

/* ---------- Citations / sources ---------- */
.cite { font-family: var(--sans); font-size: .82rem; color: var(--ink-soft); }
sup.ref a {
  font-family: var(--sans); font-size: .68rem; text-decoration: none; font-weight: 800;
  color: var(--brand-ink); background: var(--brand-bg);
  padding: .05rem .3rem; border-radius: 5px; margin-left: .1rem;
}
sup.ref a:hover { background: var(--brand-bright); color: #fff; }
.sources {
  font-family: var(--sans); font-size: .84rem; color: var(--ink-soft);
  border-top: 2px solid var(--rule); margin-top: 2.6rem; padding-top: 1.1rem;
}
.sources li { margin: .35rem 0; }
.lang-note { font-style: italic; }

/* ---------- Interactif : QCM ---------- */
.quiz {
  font-family: var(--sans); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1.4rem 1.5rem; margin: 1.7rem 0;
  background: var(--card); box-shadow: var(--shadow-sm);
}
.quiz .quiz-q { font-weight: 700; font-size: 1.02rem; margin-bottom: .9rem; display: block; color: var(--ink); }
.quiz-opts { display: flex; flex-direction: column; gap: .55rem; }
.quiz-opt {
  position: relative; text-align: left; font: inherit; font-size: .96rem;
  padding: .8rem 1rem; min-height: 44px; border: 1.5px solid var(--rule); border-radius: 10px;
  background: var(--paper); color: var(--ink); cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--teal); box-shadow: 0 1px 0 var(--teal); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.is-right { border-color: var(--green); background: var(--green-bg); font-weight: 700; }
.quiz-opt.is-wrong { border-color: var(--red);   background: var(--red-bg); }
.quiz-opt .mark { float: right; font-weight: 800; margin-left: .5rem; }
.quiz-opt.is-right .mark { color: var(--green); }
.quiz-opt.is-wrong .mark { color: var(--red); }
.quiz-feedback {
  margin-top: 1rem; font-size: .92rem; line-height: 1.5;
  padding: .8rem 1rem; border-radius: 10px; display: none;
  border-left: 4px solid transparent;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.good { background: var(--green-bg); color: #1c5637; border-left-color: var(--green); }
.quiz-feedback.bad  { background: var(--red-bg);   color: #7a2419; border-left-color: var(--red); }

/* ---------- Interactif : auto-test (révéler) ---------- */
.reveal {
  font-family: var(--sans); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1.3rem 1.5rem; margin: 1.7rem 0;
  background: var(--card); box-shadow: var(--shadow-sm);
}
.reveal .reveal-q { font-weight: 700; margin-bottom: .8rem; color: var(--ink); }
.reveal-btn {
  font: inherit; font-size: .92rem; font-weight: 700; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center;
  color: var(--teal-deep); background: var(--teal-bg);
  border: 1.5px solid var(--teal); border-radius: 10px; padding: .55rem 1rem;
  transition: background .15s;
}
.reveal-btn:hover { background: #dcebec; }
.reveal-a { display: none; margin-top: .9rem; line-height: 1.56; }
.reveal-a.show { display: block; }

/* ---------- Rappel « demandez à Claude » ---------- */
.ask-teacher {
  font-family: var(--sans); font-size: .92rem; line-height: 1.5;
  background: var(--teal-bg); border: 1px solid #c4dbde;
  border-radius: var(--radius); padding: 1.05rem 1.3rem; margin: 1.9rem 0;
}
.ask-teacher strong { color: var(--teal-deep); }

/* ---------- Suivi d'avancement ---------- */
.progress-panel {
  font-family: var(--sans); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; margin: 1.7rem 0;
  background: var(--card); box-shadow: var(--shadow-sm);
}
.progress-panel p { margin: .65rem 0 0; font-size: .9rem; color: var(--ink-soft); }
.progress-action {
  min-height: 44px; border: 1.5px solid var(--teal-deep); border-radius: 999px;
  background: var(--teal-deep); color: #fff; font-family: var(--sans);
  font-weight: 800; font-size: .95rem; padding: .65rem 1.15rem; cursor: pointer;
}
.progress-action:hover { background: var(--teal); border-color: var(--teal); }
.progress-action:disabled { opacity: .75; cursor: default; }
.progress-action.is-complete { background: var(--green); border-color: var(--green); }
.progress-status {
  display: inline-block; margin-left: .7rem; font-family: var(--sans);
  font-size: .86rem; color: var(--ink-soft);
}
.progress-status[data-kind="good"] { color: var(--green); font-weight: 700; }
.progress-status[data-kind="bad"] { color: var(--red); font-weight: 700; }
.progress-summary {
  margin-top: .75rem; font-family: var(--sans); font-size: .92rem;
  font-weight: 800; color: var(--teal-deep);
}

.auth-box {
  font-family: var(--sans); display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 1rem; align-items: start; border: 1px solid #f0d3b8; border-radius: var(--radius);
  padding: 1.15rem 1.3rem; margin: 1.4rem 0; background: var(--brand-bg);
  box-shadow: var(--shadow-sm);
}
.auth-copy strong { display: block; font-size: 1rem; color: var(--ink); margin: .1rem 0 .3rem; }
.auth-copy p { font-size: .9rem; line-height: 1.45; color: var(--ink-soft); margin: 0; }
.auth-label {
  display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 800; color: var(--brand-ink);
}
.auth-form label {
  display: block; font-size: .78rem; font-weight: 800; color: var(--brand-ink); margin-bottom: .35rem;
}
.auth-row { display: flex; gap: .55rem; align-items: stretch; }
.auth-row input {
  min-width: 0; flex: 1; min-height: 44px; border: 1.5px solid #f0d3b8;
  border-radius: 10px; padding: .55rem .75rem; font: inherit; font-size: .92rem;
  background: var(--card); color: var(--ink);
}
.auth-row button {
  min-height: 44px; border: 1.5px solid var(--brand-ink); border-radius: 10px;
  padding: .55rem .9rem; font: inherit; font-size: .88rem; font-weight: 800;
  background: var(--brand-ink); color: #fff; cursor: pointer; white-space: nowrap;
}
.auth-row button:disabled { opacity: .7; cursor: default; }
.auth-message { min-height: 1.25rem; margin: .55rem 0 0; font-size: .84rem; color: var(--ink-soft); }
.auth-message[data-kind="good"] { color: var(--green); font-weight: 700; }
.auth-message[data-kind="bad"] { color: var(--red); font-weight: 700; }

/* ---------- Navigation ---------- */
.lesson-nav {
  font-family: var(--sans); font-size: .9rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border-top: 2px solid var(--rule); margin-top: 3rem; padding-top: 1.3rem;
}
.lesson-nav a {
  text-decoration: none; font-weight: 700; color: var(--brand-ink);
  border: 1.5px solid var(--rule); border-radius: 12px; padding: .7rem 1rem;
  background: var(--card); transition: border-color .15s, background .15s;
  flex: 1 1 12rem; min-width: 0;
}
.lesson-nav a:hover { border-color: var(--brand); background: var(--brand-bg); }
.lesson-nav .nav-next { margin-left: auto; text-align: right; }
.lesson-nav .nav-label {
  display: block; font-size: .7rem; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 800; margin-bottom: .15rem;
}

/* ---------- Composant : la carte des 4D ---------- */
.dgrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .85rem;
  font-family: var(--sans); margin: 1.7rem 0;
}
.dcard {
  border: 1.5px solid var(--rule); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; background: var(--card); position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.dcard .d-verb {
  font-size: .7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--brand-ink);
}
.dcard .d-name { font-size: 1.18rem; font-weight: 800; margin: .1rem 0 .35rem; color: var(--teal-deep); }
.dcard .d-desc { font-size: .9rem; line-height: 1.48; color: var(--ink); margin: 0; }
.dcard.is-active { border-color: var(--teal); border-width: 2px; background: var(--teal-bg); }
.dloop-legend {
  font-family: var(--sans); font-size: .84rem; color: var(--ink-soft);
  display: grid; gap: .5rem; margin: .6rem 0 0;
}
.dloop-legend b { color: var(--ink); }
.dloop-legend .swatch {
  display: inline-block; width: .8rem; height: .8rem; border-radius: 3px;
  vertical-align: middle; margin-right: .4rem;
}
@media (max-width: 520px) {
  .dgrid { grid-template-columns: 1fr; }
  .progress-status { display: block; margin: .6rem 0 0; }
  .auth-box { grid-template-columns: 1fr; }
  .auth-row { flex-direction: column; }
  .auth-row button { width: 100%; }
}

/* ---------- Divers ---------- */
hr { border: none; border-top: 2px solid var(--rule); margin: 2.6rem 0; }
.pill {
  font-family: var(--sans); font-size: .72rem; font-weight: 700;
  background: var(--brand-bg); color: var(--brand-ink);
  border: 1px solid #f0d3b8; border-radius: 999px; padding: .15rem .65rem;
}

/* ============================================================
   Sombre (confort écran)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f1b18; --paper-2: #2a2521; --card: #262019;
    --ink: #efe6da; --ink-soft: #b6a99a; --rule: #3d352d;
    --brand: #f5904f; --brand-ink: #f0a96a; --brand-bright: #ff9d5c; --brand-bg: #3a271a;
    --teal: #6bb8c2; --teal-deep: #9ad4dc; --teal-bg: #17343a;
    --gold: #d9b25a; --gold-bg: #33280f; --red: #e58575; --red-bg: #3a221e;
    --green: #7fc79c; --green-bg: #1c2f22;
  }
  a { text-decoration-color: color-mix(in srgb, var(--brand-ink) 55%, transparent); }
  .win { background: linear-gradient(180deg, var(--brand-bg) 0%, var(--card) 45%); }
  .prompt-block { background: #16120f; border-color: #332b24; }
  .quiz-opt:hover:not(:disabled) { box-shadow: none; }
  sup.ref a:hover { color: #1f1b18; }
}

/* ============================================================
   Impression — fiches papier
   ============================================================ */
@media print {
  :root { --paper: #fff; --card: #fff; }
  body { font-size: 12pt; background: #fff; color: #000; padding: 0; line-height: 1.5; }
  .course-head { border-color: #999; }
  .course-head .lesson-no { background: none; padding: 0; color: #444; }
  h1 { color: #000; }
  h2 { border-color: #999; }
  a { color: #000; text-decoration: underline; }
  sup.ref a { background: none; color: #000; }
  .box, .win, .quiz, .reveal, .dcard { break-inside: avoid; border-color: #999; background: #fff; box-shadow: none; }
  .win { background: #fff; }
  .win::after { display: none; }
  .quiz-opt { background: #fff; }
  .quiz-opt:hover { border-color: var(--rule); box-shadow: none; }
  .reveal-a { display: block !important; }   /* révèle les réponses à l'impression */
  .quiz-feedback { display: block !important; }
  .lesson-nav, .ask-teacher { display: revert; }
}
