﻿/* ============================================================
   KALPY — Brief projet (console de cadrage à deux panneaux)
   Chargé uniquement par brief.html. Texte, filets et surfaces passent
   par les tokens de style.css / DESIGN.md. Seules exceptions assumées :
   les teintes translucides dérivées de l'accent (rgba 45,184,235) et du
   blanc, que le système ne déclare pas en variables.
   ============================================================ */

/* ---------- Hero de page : trois repères mono ---------- */
.brief-hero__meta {
  display: flex; flex-wrap: wrap; gap: 10px 28px;
  margin-top: clamp(20px, 2.4vw, 28px);
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.06em; color: var(--text);
}
.brief-hero__meta li { display: flex; align-items: baseline; gap: 8px; }
.brief-hero__meta span {
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em;
}
.brief-hero__meta a { border-bottom: 1px solid var(--line); transition: color 0.3s, border-color 0.3s; }
.brief-hero__meta a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Grille maîtresse ---------- */
/* .section--light rogne son débord ; ce rognage ferait de la section le
   conteneur de défilement de la fiche, qui ne collerait plus. Rien ne
   déborde ici, la section renonce donc au rognage. */
.brief.section--light { overflow: visible; }
.brief { padding-top: clamp(56px, 7vw, 96px); }
/* Filet renforcé du survol : le système ne déclare que `--line` au repos, et un
   blanc translucide disparaîtrait sur la colonne claire. Il suit donc le thème. */
.brief { --line-strong: rgba(255, 255, 255, 0.26); }
.brief.section--light { --line-strong: rgba(20, 18, 30, 0.32); }
.fiche { --line-strong: rgba(255, 255, 255, 0.26); }
.brief__grid {
  display: grid; grid-template-columns: 1.18fr 0.82fr;
  gap: clamp(36px, 4.5vw, 76px); align-items: start;
}

/* ============================================================
   Colonne des questions
   ============================================================ */
.bform { min-width: 0; }
.bform__trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Le <legend> est peint au-dessus de la boîte de contenu du fieldset : c'est lui,
   et non le padding du bloc, qui porte la respiration sous le filet de séparation. */
.bblock {
  border: none; min-width: 0; padding: 0;
  margin-top: clamp(38px, 4.6vw, 62px);
  border-top: 1px solid var(--line);
}
.bblock:first-of-type { border-top: none; margin-top: 0; }

.bblock__legend {
  display: block; width: 100%;
  padding: clamp(34px, 4vw, 52px) 0 0;
  margin-bottom: clamp(20px, 2.2vw, 28px);
}
.bblock:first-of-type .bblock__legend { padding-top: 0; }
.bblock__eyebrow {
  display: inline-flex; align-items: center; gap: 11px;
  font-family: var(--font-mono); font-weight: 500;
  font-size: var(--fs-label); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}
.bblock__dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent); flex-shrink: 0;
}
.bblock__title {
  display: block; margin-top: 12px;
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  font-size: clamp(1.7rem, 3.4vw, 2.6rem); line-height: 1; letter-spacing: 0.005em;
  color: var(--text);
}
.bblock__note {
  color: var(--muted); max-width: 58ch;
  margin-bottom: clamp(24px, 3vw, 34px);
  padding-left: 16px; border-left: 1px solid var(--line);
}

/* ---------- Champs ---------- */
.bgrid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(22px, 2.6vw, 32px);
}
.bgrid + .bgrid, .bgrid + .bfield, .bfield + .bgrid, .bfield--wide + .bfield--wide {
  margin-top: clamp(26px, 3vw, 38px);
}
.bfield { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.bfield--wide { grid-column: 1 / -1; }
.bgrid .bfield--wide { grid-column: 1 / -1; }

.bfield > label, .bfield__label {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.bfield__req { color: var(--accent); font-size: 1.1em; line-height: 0; }
.bfield__hint {
  color: var(--muted); font-size: 0.9rem; line-height: 1.55;
  max-width: 58ch; margin-top: -2px;
}

.bfield input[type="text"],
.bfield input[type="email"],
.bfield input[type="tel"],
.bfield input[type="url"],
.bfield textarea,
.bfield select {
  width: 100%; background: transparent; border: none;
  border-bottom: 1px solid var(--line); border-radius: 0;
  color: var(--text); font-family: var(--font-body); font-size: 1.02rem;
  padding: 11px 12px; outline: none;
  transition: border-color 0.35s var(--ease), background 0.35s var(--ease);
}
.bfield textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.bfield input:hover, .bfield textarea:hover, .bfield select:hover { border-bottom-color: var(--line-strong); }
.bfield input:focus, .bfield textarea:focus, .bfield select:focus {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}
.bfield input::placeholder, .bfield textarea::placeholder { color: var(--muted); opacity: 1; }
.bfield select { cursor: pointer; }
.bfield select option { background: var(--bg-soft); color: var(--text); }
.bfield input:user-invalid, .bfield textarea:user-invalid { border-bottom-color: var(--pink); }

/* ---------- Chips de choix (radio / checkbox) ---------- */
.bchips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 3px; }
.bchip { position: relative; display: inline-flex; cursor: pointer; }
.bchip input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; margin: 0; cursor: pointer;
}
.bchip span {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 100px;
  padding: 10px 20px;
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.06em;
  color: var(--muted); white-space: nowrap;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease),
              background 0.3s var(--ease), transform 0.3s var(--ease);
}
.bchip:hover span { color: var(--text); border-color: var(--line-strong); }
.bchip input:checked + span {
  background: var(--royal); border-color: transparent; color: #fff;
}
.bchip input:checked + span::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: #fff; flex-shrink: 0;
}
.bchip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.bchip:active span { transform: translateY(1px); }

/* ---------- Tuiles de périmètre (aiguillage) ---------- */
.btiles {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px; margin-top: 6px;
}
.btile { position: relative; display: flex; cursor: pointer; }
.btile input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
/* Case à cocher : carré adouci et coche tracée — jamais un disque, qui dirait « choix unique ». */
.btile__mark {
  position: absolute; top: clamp(16px, 1.8vw, 20px); left: clamp(16px, 1.8vw, 20px);
  width: 17px; height: 17px; border: 1px solid var(--line); border-radius: 6px;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.btile__mark::after {
  content: ""; position: absolute; left: 5px; top: 2px;
  width: 5px; height: 9px;
  border: solid var(--accent); border-width: 0 2px 2px 0;
  opacity: 0; transform: rotate(45deg) scale(0.5); transform-origin: center;
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease);
}
.btile__body {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(16px, 1.8vw, 20px);
  padding-left: calc(clamp(16px, 1.8vw, 20px) + 27px);
  width: 100%;
  transition: border-color 0.35s var(--ease), background 0.35s var(--ease);
}
.btile__title {
  font-family: var(--font-head); font-weight: 600; font-size: 1.02rem;
  color: var(--text); line-height: 1.25;
}
.btile__text { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.btile:hover .btile__body { border-color: var(--line-strong); }
.btile input:checked ~ .btile__body {
  border-color: rgba(45,184,235,0.5); background: rgba(45,184,235,0.05);
}
.btile input:checked ~ .btile__mark { border-color: var(--accent); background: rgba(45,184,235,0.12); }
.btile input:checked ~ .btile__mark::after { opacity: 1; transform: rotate(45deg) scale(1); }
.btile input:focus-visible ~ .btile__body { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Branches conditionnelles ---------- */
.bbranch-status {
  margin-top: 14px; min-height: 1.4em;
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.06em; color: var(--accent);
}
.bempty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: clamp(22px, 2.6vw, 30px);
  color: var(--muted); max-width: 58ch;
}
.bbranch {
  border: none; border-top: 1px solid var(--line);
  padding-top: clamp(26px, 3vw, 36px);
  margin-top: clamp(28px, 3.4vw, 42px);
}
.bbranch:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.bbranch[hidden] { display: none; }
.bbranch__legend {
  display: inline-flex; align-items: center; gap: 10px; padding: 0;
  font-family: var(--font-head); font-weight: 600; font-size: 1.1rem;
  color: var(--text); margin-bottom: clamp(20px, 2.4vw, 28px);
}
.bbranch__legend::before {
  content: ""; width: 22px; height: 1px; background: var(--accent); flex-shrink: 0;
}
.bbranch .bgrid + .bfield--wide, .bbranch .bfield--wide + .bgrid { margin-top: clamp(24px, 2.8vw, 34px); }
.bbranch.is-opening { animation: branchIn 0.55s var(--ease) both; }
@keyframes branchIn {
  from { opacity: 0; transform: translateY(10px); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* ---------- Consentement ---------- */
.bconsent {
  position: relative; display: grid; grid-template-columns: 19px 1fr;
  gap: 14px; align-items: start; cursor: pointer;
  margin-top: clamp(24px, 3vw, 34px);
  color: var(--muted); font-size: 0.9rem; line-height: 1.6; max-width: 60ch;
}
.bconsent input { position: absolute; width: 18px; height: 18px; opacity: 0; margin: 0; cursor: pointer; }
.bconsent__mark {
  width: 19px; height: 19px; margin-top: 3px; border-radius: 6px;
  border: 1px solid var(--line); position: relative;
  transition: border-color 0.3s var(--ease);
}
.bconsent__mark::after {
  content: ""; position: absolute; left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid var(--accent); border-width: 0 2px 2px 0;
  opacity: 0; transform: rotate(45deg) scale(0.5); transform-origin: center;
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease);
}
.bconsent input:checked ~ .bconsent__mark { border-color: var(--accent); background: rgba(45,184,235,0.12); }
.bconsent input:checked ~ .bconsent__mark::after { opacity: 1; transform: rotate(45deg) scale(1); }
.bconsent input:focus-visible ~ .bconsent__mark { outline: 2px solid var(--accent); outline-offset: 3px; }
.bconsent a { color: var(--text); border-bottom: 1px solid var(--line); }
.bconsent a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Pied de formulaire ---------- */
.bform__foot {
  margin-top: clamp(40px, 5vw, 66px); padding-top: clamp(30px, 3.6vw, 44px);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; flex-wrap: wrap; gap: 18px 26px;
}
.bform__submit[disabled] { opacity: 0.55; pointer-events: none; }
.bform__note { color: var(--muted); font-family: var(--font-mono); font-size: var(--fs-label); max-width: 40ch; }
.bform__status {
  flex-basis: 100%; font-family: var(--font-mono); font-size: var(--fs-label);
  color: var(--muted); min-height: 1em;
}
.bform__status.is-error { color: var(--pink); }
.bform__status.is-pending { color: var(--accent); }
/* La sortie se lit comme un lien, l'effacement comme un contrôle destructeur :
   deux gestes opposés ne portent pas le même habit ni le même bord d'écran. */
.bform__reset {
  flex-basis: 100%; display: flex; flex-wrap: wrap;
  gap: 12px 28px; justify-content: space-between; align-items: baseline;
}
.blink--quiet { border-bottom-color: transparent; opacity: 0.75; }
.blink--quiet:hover { color: var(--pink); border-bottom-color: var(--pink); opacity: 1; }
.bform__legendkey {
  color: var(--muted); font-size: 0.9rem; line-height: 1.55; max-width: 60ch;
  margin-bottom: clamp(30px, 3.6vw, 46px);
  padding-left: 16px; border-left: 1px solid var(--line);
}
.blink {
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em;
  color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 2px;
  transition: color 0.3s, border-color 0.3s;
}
.blink:hover { color: var(--text); border-color: var(--muted); }
.blink:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.blink.is-armed { color: var(--pink); border-color: var(--pink); }
.blink--accent { color: var(--accent); border-color: var(--accent); }
.fiche__toggle:focus-visible,
.fiche__index a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

/* ---------- Accusé d'envoi ---------- */
.bsent {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(30px, 4vw, 54px);
  display: flex; flex-direction: column; gap: 16px; align-items: flex-start;
  animation: branchIn 0.6s var(--ease) both;
}
.bsent__title {
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  font-size: var(--fs-display); line-height: 0.98; letter-spacing: 0.005em;
}
.bsent p { color: var(--muted); max-width: 54ch; }

/* ============================================================
   Fiche vivante
   ============================================================ */
/* La fiche reste un pupitre sombre au milieu de la section claire :
   on remplit dans la lumière, le livrable s'assemble dans le panneau.
   Elle redéclare les variables de thème pour toute sa descendance. */
.fiche {
  position: sticky; top: 104px;
  border: 1px solid rgba(255, 255, 255, 0.10); border-radius: var(--radius);
  background: #141030;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 140px); min-width: 0;
  overflow: hidden;
  box-shadow: var(--shadow-media);

  --text: #f2f1f8;
  --muted: #9791b5;
  --line: rgba(255, 255, 255, 0.10);
  --surface: #17123a;
}

.fiche__head {
  padding: clamp(20px, 2.2vw, 26px);
  border-bottom: 1px solid var(--line);
}
.fiche__headline { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.fiche__label {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.fiche__pct { font-family: var(--font-mono); font-size: 1.05rem; color: var(--text); }
.fiche__gauge {
  margin-top: 14px; height: 3px; border-radius: 100px;
  background: rgba(255,255,255,0.08); overflow: hidden;
}
/* Remplissage par transform : la largeur ne s'anime jamais (DESIGN.md). */
.fiche__gauge-fill {
  display: block; height: 100%; width: 100%;
  background: var(--grad);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.6s var(--ease);
}
.fiche__toggle { display: none; }

/* Le fondu du bas dit qu'il reste de la fiche sous le pli, là où une coupe nette
   ferait croire à une fin. */
.fiche__scroll {
  overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(18px, 2.2vw, 24px);
  scroll-behavior: smooth;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 44px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 calc(100% - 44px), transparent 100%);
}
.fiche__scroll.is-at-end {
  -webkit-mask-image: none; mask-image: none;
}
/* La glissière est le second indice, avec le fondu, qu'il reste de la fiche. */
.fiche__scroll { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.26) transparent; }
.fiche__scroll::-webkit-scrollbar { width: 6px; }
.fiche__scroll::-webkit-scrollbar-track { background: transparent; }
.fiche__scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.26); border-radius: 100px; }
.fiche__scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }

.fiche__row {
  position: relative; padding: 13px 0 13px 18px;
  border-bottom: 1px solid var(--line);
}
.fiche__row:last-child { border-bottom: none; }
.fiche__row::before {
  content: ""; position: absolute; left: 0; top: 19px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted); opacity: 0.4;
  transition: background 0.4s var(--ease), opacity 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.fiche__row.is-filled::before {
  background: var(--accent); opacity: 1; box-shadow: 0 0 8px var(--accent);
}
.fiche__row dt {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 5px;
}
.fiche__row dd {
  font-family: var(--font-head); font-weight: 500; font-size: 0.95rem;
  line-height: 1.45; color: var(--muted); word-break: break-word;
}
.fiche__row.is-filled dd { color: var(--text); }
.fiche__row[data-style="quote"].is-filled dd {
  font-family: var(--font-body); font-weight: 400; font-size: 0.9rem;
  color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.fiche__row .fiche__pair { display: flex; gap: 9px; align-items: baseline; }
.fiche__row .fiche__pair + .fiche__pair { margin-top: 5px; }
.fiche__row .fiche__pair em {
  flex: 0 0 auto; min-width: 76px;
  font-family: var(--font-mono); font-style: normal; font-size: 0.7rem;
  letter-spacing: 0.06em; color: var(--muted);
}
.fiche__row .fiche__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fiche__row .fiche__chips span {
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.06em;
  border: 1px solid var(--line); border-radius: 100px; padding: 4px 10px;
  color: var(--text);
}
.fiche__row.is-writing dd { animation: ficheWrite 0.5s var(--ease); }
@keyframes ficheWrite {
  from { opacity: 0; transform: translateY(6px); filter: blur(5px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

.fiche__index {
  margin-top: clamp(18px, 2vw, 24px); padding-top: clamp(16px, 2vw, 22px);
  border-top: 1px solid var(--line); list-style: none;
  display: flex; flex-direction: column; gap: 3px;
}
.fiche__index li { list-style: none; }
.fiche__index a {
  display: flex; align-items: center; gap: 10px; padding: 5px 0;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  transition: color 0.3s;
}
.fiche__index a:hover { color: var(--text); }
.fiche__index-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--muted); background: transparent;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
}
.fiche__index a.is-partial .fiche__index-dot { border-color: var(--accent); background: rgba(45,184,235,0.35); }
.fiche__index a.is-done .fiche__index-dot { border-color: var(--accent); background: var(--accent); }
.fiche__index a.is-done { color: var(--text); }

.fiche__foot {
  margin-top: clamp(16px, 2vw, 22px);
  color: var(--muted); font-size: 0.78rem; line-height: 1.55;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  .brief__grid { grid-template-columns: 1.05fr 0.95fr; gap: clamp(28px, 3.5vw, 48px); }
}

@media (max-width: 1024px) {
  .brief__grid { grid-template-columns: 1fr; gap: 0; }

  /* La fiche devient un pupitre ancré en bas d'écran. */
  .fiche {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    z-index: 780; border-radius: var(--radius) var(--radius) 0 0;
    border-left: none; border-right: none; border-bottom: none;
    background: var(--bg-soft);
    max-height: min(72vh, 560px);
    transform: translateY(calc(100% - var(--fiche-dock, 104px)));
    transition: transform 0.5s var(--ease);
    /* Seule ombre portée de la page : le pupitre flotte au-dessus du formulaire,
       il lui faut une pénombre de séparation là où un filet se perdrait. */
    box-shadow: 0 -30px 60px -36px rgba(0,0,0,0.7);
  }
  .fiche.is-open { transform: translateY(0); }
  .fiche__head { padding: 16px clamp(20px, 5vw, 32px); position: relative; }
  .fiche__toggle {
    display: flex; align-items: center; gap: 9px;
    margin-top: 12px;
    font-family: var(--font-mono); font-size: var(--fs-label);
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent);
  }
  .fiche__toggle i { transition: transform 0.4s var(--ease); font-size: 0.72rem; }
  .fiche.is-open .fiche__toggle i { transform: rotate(180deg); }
  .fiche__scroll { padding: 4px clamp(20px, 5vw, 32px) clamp(24px, 5vw, 32px); }
  .back-to-top { bottom: calc(var(--fiche-dock, 104px) + 20px); }
  /* Le pupitre déployé occupe l'écran : le bouton de remontée s'efface au lieu de flotter dessus. */
  body.is-fiche-open .back-to-top { opacity: 0; pointer-events: none; }
  .bform { padding-bottom: 32px; }
  .footer { padding-bottom: calc(var(--fiche-dock, 104px) + 12px); }
}

@media (max-width: 768px) {
  .bgrid { grid-template-columns: 1fr; }
  .btiles { grid-template-columns: 1fr; }
  .bform__foot { gap: 16px; }
  .bform__note { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bbranch.is-opening, .fiche__row.is-writing dd, .bsent { animation: none; }
  .fiche__scroll { scroll-behavior: auto; }
  .fiche, .fiche__gauge-fill, .btile__mark::after, .bconsent__mark::after { transition: none; }
}
