/* Ton espace de thèse — the questionnaire page. Paper and ink, one cool accent for progress;
   gold only when something needs her attention, brick only for a failure (Adrien's colour rule). */
:root {
  --ground: #f6f4ef;
  --paper: #fffefb;
  --ink: #1c2327;
  --muted: #56626a;
  --line: #d8d4cb;
  --line-strong: #7f8a90;
  --accent: #23716a;
  --accent-soft: #e2efec;
  --attention: #7d5f17;
  --attention-soft: #f6eedb;
  --failure: #a23e3b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, sans-serif;
  --radius: 10px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #11181c;
    --paper: #172025;
    --ink: #e5e9ea;
    --muted: #9ca8ae;
    --line: #2a353b;
    --line-strong: #6b787e;
    --accent: #4fb3a8;
    --accent-soft: #1b3533;
    --attention: #c9a554;
    --attention-soft: #2e2817;
    --failure: #cf6a6a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 1rem 8rem;
}
@media (min-width: 64rem) {
  .shell { grid-template-columns: 15rem minmax(0, 44rem); gap: 4rem; justify-content: center; padding-top: 1rem; }
  /* Sign-in and state screens have no thread: one centred column. */
  .shell:has(> .fil[hidden]) { grid-template-columns: minmax(0, 36rem); }
}

/* ---- Header -------------------------------------------------------------------------------- */
.intro { padding: 3.5rem 0 1.5rem; max-width: 40rem; }
.kicker { margin: 0 0 .75rem; font-size: .8125rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 {
  margin: 0 0 1.25rem;
  font: 400 clamp(2.1rem, 6vw, 3rem)/1.08 var(--serif);
  letter-spacing: -.01em;
}
.intro p { margin: 0 0 .9rem; color: var(--muted); }
.intro p:first-of-type { color: var(--ink); font-size: 1.125rem; }
.promise {
  display: flex; gap: .75rem; align-items: flex-start;
  margin-top: 1.5rem; padding: .9rem 1rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: .9375rem; color: var(--muted);
}
.promise svg { flex: none; margin-top: .2rem; color: var(--accent); }

/* ---- Sections and questions ---------------------------------------------------------------- */
.part { padding-top: 2.75rem; }
.part-head { display: flex; align-items: baseline; gap: .9rem; margin: 0 0 1.25rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.part-letter { font: 400 1.75rem/1 var(--serif); color: var(--accent); min-width: 1.5ch; }
.part-head h2 { margin: 0; font: 400 1.6rem/1.2 var(--serif); }

.q {
  margin: 0 0 1rem; padding: 1.25rem 1.25rem 1.1rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.q:focus-within { border-color: var(--line-strong); box-shadow: 0 1px 0 var(--line), 0 8px 24px -16px rgb(0 0 0 / .25); }
.q.revealed { animation: reveal .45s var(--ease) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(-6px); } }
.q.needed { border-color: var(--attention); background: linear-gradient(var(--attention-soft), var(--attention-soft)) padding-box; }
fieldset.q { min-width: 0; }
.q-label { display: block; padding: 0; margin: 0 0 .85rem; font-weight: 600; line-height: 1.45; }
/* A legend sits on the fieldset's border unless floated; floating keeps the card layout whole. */
legend.q-label { float: left; width: 100%; }
legend.q-label + * { clear: both; }
.q-id { display: inline-block; min-width: 2.2rem; font: 500 .8125rem/1 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.q-req { margin-left: .4rem; font-size: .8125rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.q.needed .q-req { color: var(--attention); }

.choices { display: grid; gap: .45rem; }
.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; transition: background .2s var(--ease), border-color .2s var(--ease);
}
.choice span::before {
  content: ""; flex: none; width: 1.1rem; height: 1.1rem; margin-top: .22rem;
  border: 1.5px solid var(--line-strong); border-radius: 50%;
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.choice input[type="checkbox"] + span::before { border-radius: 4px; }
.choice:hover span { border-color: var(--line-strong); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.choice input[type="radio"]:checked + span::before { border-color: var(--accent); box-shadow: inset 0 0 0 .22rem var(--paper), inset 0 0 0 1rem var(--accent); }
.choice input[type="checkbox"]:checked + span::before {
  border-color: var(--accent); background: var(--accent) center/.8rem no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6 9.6 3.4' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.choice input:disabled + span { cursor: default; }
.other { width: calc(100% - 2.35rem); margin: 0 0 .1rem 2.35rem; }

textarea {
  display: block; width: 100%; min-height: 3.2rem; resize: none; overflow: hidden;
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--ground); line-height: 1.55;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
textarea:focus { border-color: var(--accent); background: var(--paper); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea::placeholder { color: var(--muted); opacity: .8; }

/* ---- End of the questionnaire -------------------------------------------------------------- */
.finish { margin-top: 3rem; padding: 1.75rem 1.5rem; border-top: 2px solid var(--ink); }
.finish h2 { margin: 0 0 .5rem; font: 400 1.6rem/1.2 var(--serif); }
.finish p { margin: 0 0 1rem; color: var(--muted); }
.finish .missing { color: var(--attention); }
.finish .missing a { color: inherit; }
.primary, .quiet {
  border: 0; border-radius: 999px; padding: .8rem 1.5rem; cursor: pointer; font-weight: 600;
  transition: transform .15s var(--ease), background .2s var(--ease);
}
.primary { background: var(--ink); color: var(--paper); }
.primary:hover { transform: translateY(-1px); }
.primary:active { transform: none; }
.primary[disabled] { opacity: .55; cursor: progress; transform: none; }
.quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.error { color: var(--failure); }

/* ---- Read-only, thanks and other states ---------------------------------------------------- */
.state { padding: 5rem 0; max-width: 34rem; color: var(--muted); }
.state h1 { color: var(--ink); }
.thanks { margin: 2rem 0 0; padding: 1.5rem; background: var(--accent-soft); border-radius: var(--radius); }
.thanks h2 { margin: 0 0 .4rem; font: 400 1.5rem/1.2 var(--serif); }
.thanks p { margin: 0; }
.readonly .q { background: transparent; }

/* ---- Sign-in ------------------------------------------------------------------------------- */
.signin { padding-top: 6rem; }
.signin > p:not(.kicker) { font-size: 1.125rem; }
.signin-form { margin-top: 2rem; }
.signin-form label { display: block; margin-bottom: .5rem; font-weight: 600; color: var(--ink); }
.signin-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.signin-row input {
  flex: 1 1 16rem; min-width: 0; padding: .8rem 1rem; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--paper); transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.signin-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.signin-message { min-height: 1.6em; margin: .75rem 0 0; font-size: .9375rem; }
.signin .thanks { margin-top: 0; color: var(--ink); }

/* ---- Le fil: the thread in the margin, one knot per part ----------------------------------- */
.fil { display: none; }
@media (min-width: 64rem) {
  .fil { display: block; position: sticky; top: 0; align-self: start; height: 100vh; padding: 4.5rem 0 2rem; }
  .fil ol { position: relative; list-style: none; margin: 0; padding: 0; }
  .fil ol::before { content: ""; position: absolute; left: .69rem; top: .8rem; bottom: .8rem; width: 1px; background: var(--line); }
  .fil .thread { position: absolute; left: .69rem; top: .8rem; width: 1px; height: 0; background: var(--accent); transition: height .7s var(--ease); }
  .fil li { position: relative; }
  .fil a {
    display: flex; align-items: center; gap: .85rem; padding: .42rem 0;
    color: var(--muted); text-decoration: none; font-size: .9375rem; line-height: 1.25;
    transition: color .2s var(--ease);
  }
  .fil a:hover, .fil a[aria-current="true"] { color: var(--ink); }
  .knot {
    --p: 0; position: relative; flex: none; width: 1.4rem; height: 1.4rem; border-radius: 50%;
    background: conic-gradient(var(--accent) calc(var(--p) * 1turn), var(--line) 0);
    transition: --p .6s var(--ease);
  }
  .knot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--ground); transition: inset .4s var(--ease), background .4s var(--ease); }
  .fil a[aria-current="true"] .knot::after { inset: 4px; }
  .fil li.done .knot::after { inset: 5px; background: var(--accent); }
  .fil li.done a { color: var(--ink); }
  .fil .fil-save { margin: 1.75rem 0 0 2.25rem; font-size: .8125rem; color: var(--muted); }
}
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }

/* ---- Mobile bar ---------------------------------------------------------------------------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); font-size: .875rem;
}
.bar-progress { position: absolute; left: 0; right: 0; top: -1px; height: 2px; }
.bar-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s var(--ease); }
.bar-where { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save { margin: 0; color: var(--muted); white-space: nowrap; }
.save.offline { color: var(--attention); }
@media (min-width: 64rem) { .bar { display: none !important; } }

/* ---- Dialog -------------------------------------------------------------------------------- */
.confirm { max-width: 28rem; padding: 1.75rem; border: 0; border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px -30px rgb(0 0 0 / .5); }
.confirm::backdrop { background: rgb(10 16 20 / .45); backdrop-filter: blur(2px); }
.confirm h2 { margin: 0 0 .6rem; font: 400 1.5rem/1.2 var(--serif); }
.confirm p { margin: 0 0 1.5rem; color: var(--muted); }
.confirm-actions { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; }

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