/* Sevrage — bases partagées (tuteur, espace parent, atelier). Les couleurs sont dans palette.css, chargée avant. */

/* Hanken Grotesk (licence SIL OFL, fonts/HankenGrotesk-OFL.txt), servie par l'application : aucune requête vers un
   service de polices. Sous-ensemble latin ; les symboles mathématiques absents (√, π, ≤, ², …) viennent de la police
   système. Le repli « Fallback » (Arial ajustée aux mêmes métriques) évite que les lignes bougent au chargement. */
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/HankenGrotesk-Latin.woff2") format("woff2");
  unicode-range: U+0020-007E, U+00A0-00B1, U+00B4-00B8, U+00BA-017E, U+2013-2015, U+2018-201A, U+201C-201E, U+2020-2023, U+2025-2026, U+2030-2031, U+2039-203A, U+2044, U+20AC, U+2190, U+2192, U+2212;
}

@font-face {
  font-family: "Hanken Grotesk Fallback";
  src: local("Arial");
  size-adjust: 99.82%;
  ascent-override: 100.18%;
  descent-override: 30.35%;
  line-gap-override: 0%;
  unicode-range: U+0020-007E, U+00A0-00B1, U+00B4-00B8, U+00BA-017E, U+2013-2015, U+2018-201A, U+201C-201E, U+2020-2023, U+2025-2026, U+2030-2031, U+2039-203A, U+2044, U+20AC, U+2190, U+2192, U+2212;
}

:root {
  --radius: 14px;
  --font: "Hanken Grotesk", "Hanken Grotesk Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Plus de titres à empattements : une seule famille, comme la référence. */
  --serif: var(--font);
}

* {
  box-sizing: border-box;
}

/* Un élément masqué le reste, même si sa classe lui donne un display (les bandeaux d'erreur vides, par exemple). */
[hidden] {
  display: none !important;
}

/* Lu par les lecteurs d'écran, invisible à l'écran. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--c-page);
  color: var(--c-ink);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ol,
ul {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.boot {
  padding: 48px;
  color: var(--ink-2);
}

/* --- Mise en page */

.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 16px;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--c-action);
}

.brand h1 {
  font: 600 22px/1 var(--serif);
  letter-spacing: -0.01em;
}

.domain-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.domain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.domain-item:hover {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.domain-item[aria-current="true"] {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.main {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 36px clamp(16px, 4vw, 48px) 96px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Petits éléments */

.muted {
  color: var(--ink-2);
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--ink-2)) 13%, transparent);
  color: var(--c, var(--ink-2));
}

.lvl-5 { --c: var(--lvl-5); }
.lvl-4 { --c: var(--lvl-4); }
.lvl-3 { --c: var(--lvl-3); }
.lvl-2 { --c: var(--lvl-2); }
.lvl-1 { --c: var(--lvl-1); }
.lvl-0 { --c: var(--lvl-0); }

.badge.grad { --c: var(--accent); }
.badge.help { --c: var(--warn); }

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.banner.demo {
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 14px;
}

.banner.error {
  background: var(--bad-soft);
  color: var(--bad);
}

.banner .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.banner strong {
  display: block;
}

/* --- Boutons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--c-control-border);
  border-radius: 12px;
  background: var(--c-surface);
  color: var(--c-ink);
  font-weight: 600;
  line-height: 1.2;
}

.btn:hover:not(:disabled) {
  border-color: var(--c-ink);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not(:disabled) {
  background: var(--c-action-hover);
  border-color: var(--c-action-hover);
}

.btn.warn {
  color: var(--warn);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.link {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn.link:hover:not(:disabled) {
  color: var(--ink);
}

/* --- En-tête de domaine, échelle, stats */

.domain-head h2 {
  font: 600 30px/1.15 var(--serif);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.domain-head p {
  margin-top: 6px;
  max-width: 62ch;
}

.ladder {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.ladder > li {
  display: flex;
}

.rung {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-2);
  text-align: center;
}

.rung .n {
  font: 600 20px/1 var(--serif);
}

.rung .t {
  font-size: 11px;
  line-height: 1.2;
}

.rung.passed {
  background: color-mix(in srgb, var(--c) 8%, var(--surface));
  border-color: transparent;
  color: var(--c);
}

.rung.current {
  background: var(--c);
  border-color: var(--c);
  color: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.rung:disabled {
  cursor: default;
}

.ladder-caption {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.ladder-caption strong {
  font-size: 17px;
}

.level-confirm {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.stat .v {
  font: 600 24px/1.2 var(--serif);
}

.stat .l {
  font-size: 12px;
  color: var(--ink-2);
}

/* --- Zone de saisie */

.composer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer label {
  font-weight: 600;
}

.composer textarea,
.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-control-border);
  border-radius: 12px;
  background: var(--c-surface);
  resize: vertical;
  line-height: 1.5;
}

.composer textarea:focus,
.field input[type="text"]:focus,
.field textarea:focus {
  outline: 2px solid var(--c-focus);
  outline-offset: 0;
  border-color: transparent;
}

.composer .row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.composer .row .spacer {
  flex: 1;
}

.hint {
  font-size: 14px;
  color: var(--ink-2);
}

.task-brief {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}

.task-brief p {
  margin-top: 2px;
  white-space: pre-wrap;
}

.working {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
  .rung.current {
    transform: none;
  }
}

/* --- Fil des relectures */

.feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.feed > h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  font-size: 14px;
}

.card-head .push {
  margin-left: auto;
}

.card .brief {
  font-weight: 600;
  white-space: pre-wrap;
}

details.attempt summary {
  cursor: pointer;
  color: var(--ink-2);
  font-size: 14px;
}

.block {
  white-space: pre-wrap;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}

.block.ref {
  background: var(--accent-soft);
}

.result {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.verdict {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.verdict strong {
  font: 600 24px/1.2 var(--serif);
}

.verdict.solide strong { color: var(--lvl-0); }
.verdict.correct strong { color: var(--lvl-3); }
.verdict.a_revoir strong { color: var(--bad); }

.section-title {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.bullets {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bullets li {
  position: relative;
  padding-left: 18px;
}

.bullets li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--lvl-1);
  font-weight: 700;
}

.issues {
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: issue;
}

.issues li {
  position: relative;
  padding-left: 30px;
  counter-increment: issue;
}

.issues li::before {
  content: counter(issue);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
}

.issues .fix {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
}

.hintq {
  padding: 14px 16px;
  border-left: 3px solid var(--lvl-1);
  background: var(--surface-2);
  border-radius: 0 12px 12px 0;
  font: italic 500 18px/1.45 var(--serif);
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--ink-2);
  text-align: center;
}

/* --- Accueil et création de domaine */

.welcome h2,
.form-panel h2 {
  font: 600 32px/1.15 var(--serif);
  letter-spacing: -0.01em;
}

.welcome .lead {
  margin-top: 8px;
  font-size: 18px;
  color: var(--ink-2);
  max-width: 54ch;
}

.steps {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 12px 14px 12px 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 14px;
  border: 1px solid var(--c-control-border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
}

.chip:hover:not(:disabled) {
  border-color: var(--c-action);
  color: var(--c-action);
}

.form-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label,
.field > .label {
  font-weight: 600;
}

.level-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.level-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.level-option:has(input:checked) {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 8%, var(--surface));
}

.level-option input {
  margin-top: 4px;
  accent-color: var(--accent);
}

.level-option .name {
  font-weight: 600;
}

.level-option .desc {
  font-size: 13px;
  color: var(--ink-2);
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* --- Petits écrans : la barre latérale devient un bandeau */

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .domain-list {
    flex-direction: row;
    flex: 1 1 100%;
    order: 3;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .domain-item {
    width: auto;
    white-space: nowrap;
    border-color: var(--line);
    background: var(--surface);
  }

  .sidebar-foot {
    display: none;
  }

  .main {
    padding-top: 24px;
  }

  .rung .t {
    display: none;
  }

  .stats {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .level-picker {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stat .v {
    font-size: 20px;
  }
  .composer {
    padding: 14px;
  }
}
