/* ==========================================================================
   QORSEC — /outils/css/post-quantique.css
   Styles propres à l'outil « Inventaire cryptographique et préparation
   post-quantique ». S'appuie sur les jetons de /assets/css/site.css.
   Orange (--signal) = signalisation uniquement, jamais sur un bouton.
   ========================================================================== */

/* ------------------------------------------------------------ saisie */
.pq-org { margin-bottom: var(--s-4); }
.pq-tabs { margin-top: var(--s-2); }
.pq-tabs .tabs__panel { margin-top: var(--s-4); }
.pq-textarea { font-size: .8rem; line-height: 1.45; min-height: 170px; }
.pq-intro { margin: 0; color: var(--fg-muted); font-size: .95rem; }

.pq-drop {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: var(--paper-50);
  color: var(--fg-muted); transition: border-color var(--t-fast), background var(--t-fast);
}
.pq-drop > svg { width: 26px; height: 26px; flex: none; color: var(--cyan-700); }
.pq-drop__text { display: grid; gap: 2px; font-size: .86rem; min-width: 0; }
.pq-drop__text strong { color: var(--fg); font-size: .95rem; }
.pq-drop:hover, .pq-drop.is-over { border-color: var(--blue-600); background: rgba(29, 78, 216, .04); }
.pq-drop:focus-within { outline: 3px solid var(--focus, var(--blue-600)); outline-offset: 2px; border-color: var(--blue-600); }

.pq-files { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pq-files li {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 6px 4px 12px;
  border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); font-size: .84rem; font-weight: 600;
}
.pq-files__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pq-x {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--white);
  color: var(--fg-muted); font-size: 1.05rem; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.pq-x:hover { color: var(--fg); border-color: var(--border-strong); }

/* inventaire déclaratif */
.pq-uses { display: grid; gap: 10px; }
.pq-use {
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--white);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.pq-use.is-on { border-color: rgba(29, 78, 216, .45); box-shadow: 0 0 0 3px rgba(29, 78, 216, .08); }
.pq-use__head { display: flex; align-items: flex-start; gap: 10px; }
.pq-use__head input[type="checkbox"] { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--blue-600); }
.pq-use__head label { display: grid; gap: 1px; cursor: pointer; min-width: 0; }
.pq-use__title { font-weight: 700; color: var(--fg); }
.pq-use__hint { font-size: .84rem; color: var(--fg-muted); }
.pq-use__name {
  flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font: inherit; font-weight: 600; color: var(--fg); background: var(--white);
}
.pq-use__name:focus { outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 4px rgba(29, 78, 216, .15); }
.pq-use__fields { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; margin-top: 10px; padding-left: 28px; }
.pq-use__fields--3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); }
.pq-use__fields .field > span { font-size: .78rem; font-weight: 700; color: var(--fg-muted); }
.pq-use__fields select { font-size: .9rem; padding-top: 8px; padding-bottom: 8px; }
.pq-use:not(.is-on) .pq-use__fields { opacity: .72; }
@media (max-width: 640px) {
  .pq-use__fields, .pq-use__fields--3 { grid-template-columns: minmax(0, 1fr); padding-left: 0; }
}

/* ------------------------------------------------------------ rapport */
.pq-report-head h2 { font-size: 1.35rem; margin: 0 0 4px; }
.pq-scope { margin: 0 0 var(--s-4); font-size: .9rem; }
.pq-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: var(--s-5); }
/* rangées équilibrées : 4 chiffres (certificats seuls) = 4 colonnes, 6 chiffres = 3 + 3 */
@media (min-width: 641px) {
  .pq-kpis:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pq-kpis:has(> :nth-child(5)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.pq-kpi { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--r-md); background: var(--paper-50); border: 1px solid var(--border); }
.pq-kpi__value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--fg); font-variant-numeric: tabular-nums; }
.pq-kpi__label { font-size: .82rem; color: var(--fg-muted); line-height: 1.35; }
.pq-kpi--signal .pq-kpi__value { color: var(--signal); }
.pq-notices { margin-bottom: var(--s-5); }

.pq-block { margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--border); }
.pq-block:first-of-type { margin-top: 0; }
.pq-block > h3, .pq-block__head h3 { font-size: 1.15rem; margin: 0 0 var(--s-4); }
.pq-block__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: var(--s-4); }
.pq-block__head h3 { margin: 0; }
.pq-note { margin: 0; padding: 14px 16px; border-radius: var(--r-md); background: var(--paper-50); border: 1px dashed var(--border-strong); color: var(--fg-muted); font-size: .92rem; }

/* priorité (toujours avec son texte : l'information ne dépend pas de la couleur) */
.pq-prio {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .76rem; font-weight: 800; letter-spacing: .01em; white-space: nowrap;
  color: var(--pc); background: var(--pb); border: 1px solid var(--pd);
}
.pq-prio::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pq-prio--1 { --pc: var(--red-700); --pb: rgba(185, 28, 28, .08); --pd: rgba(185, 28, 28, .28); }
.pq-prio--2 { --pc: var(--orange-700); --pb: rgba(220, 94, 9, .09); --pd: rgba(184, 77, 6, .3); }
.pq-prio--3 { --pc: var(--cyan-700); --pb: rgba(14, 165, 233, .09); --pd: rgba(3, 105, 161, .28); }
.pq-prio--4 { --pc: var(--ink-500); --pb: rgba(74, 88, 115, .07); --pd: rgba(74, 88, 115, .28); }
.pq-prio--5 { --pc: var(--green-700); --pb: rgba(34, 197, 94, .09); --pd: rgba(21, 128, 61, .28); }

/* fiche certificat */
.pq-certs { display: grid; gap: var(--s-4); }
.pq-cert { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; background: var(--white); min-width: 0; }
.pq-cert__head { display: flex; gap: 14px; align-items: flex-start; }
.pq-cert__num {
  flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--navy-800); color: #fff; font-weight: 800; font-size: .9rem;
}
.pq-cert__id { min-width: 0; flex: 1; }
.pq-cert__id h4 { margin: 2px 0 8px; font-size: 1.05rem; overflow-wrap: anywhere; }
.pq-cert__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pq-dl { margin: 14px 0 6px; display: grid; gap: 0; border-top: 1px solid var(--border); }
.pq-dl__row { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-100, var(--border)); }
.pq-dl dt { font-size: .8rem; font-weight: 700; color: var(--fg-muted); }
.pq-dl dd { margin: 0; font-size: .9rem; color: var(--fg); min-width: 0; overflow-wrap: anywhere; }
.pq-dl__row { min-width: 0; }
/* la grille partagée .tool-main a une piste « auto » : une empreinte SHA-256 (chaîne sans
   coupure) l'élargissait sous la colonne latérale. Piste bornée pour cette page. */
.tool-main { grid-template-columns: minmax(0, 1fr); }
.pq-wrap { overflow-wrap: anywhere; word-break: break-word; }
.pq-small { font-size: .76rem !important; }
.pq-san { display: inline-block; margin: 0 4px 4px 0; padding: 1px 8px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); font-size: .82rem; }
.pq-link { color: var(--fg-muted); font-size: .85rem; }
.pq-cert__checks { margin-top: 4px; }
@media (max-width: 640px) {
  .pq-cert { padding: 14px; }
  .pq-dl__row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* tableau des usages : une fiche par usage, à toutes les largeurs (6 colonnes de texte ne tiennent
   pas dans la colonne du rapport). Le balisage reste un vrai tableau pour les lecteurs d'écran. */
.pq-table-wrap { border: 0; background: transparent; overflow: visible; box-shadow: none; }
.pq-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pq-table, .pq-table tbody { display: block; width: 100%; }
.pq-table tr {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.1fr) minmax(0, .7fr) minmax(0, .9fr);
  gap: 10px 20px; margin-bottom: 10px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--white);
}
.pq-table th, .pq-table td, .pq-table th[scope="row"] {
  display: block; padding: 0; border: 0; min-width: 0; background: transparent;
  font-size: .9rem; letter-spacing: normal; text-transform: none; white-space: normal; overflow-wrap: anywhere;
}
/* en-tête de ligne = nom de l'usage */
.pq-table th[scope="row"] { font-weight: 400; color: var(--fg-muted); }
.pq-table th[scope="row"] strong { display: block; color: var(--fg); font-weight: 700; font-size: .95rem; }
.pq-kind { display: block; font-size: .78rem; color: var(--fg-muted); }
.pq-table td::before {
  content: attr(data-label); display: block; margin-bottom: 2px;
  font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-subtle);
}
/* « Pourquoi » et « Cible recommandée » : sous la ligne principale, deux moitiés */
.pq-table td:nth-child(5) { grid-column: 1 / span 2; padding-top: 10px; border-top: 1px solid var(--border); color: var(--fg-muted); }
.pq-table td:nth-child(6) { grid-column: 3 / span 2; padding-top: 10px; border-top: 1px solid var(--border); color: var(--fg-muted); }
.pq-table tbody tr:hover td { background: transparent; }
@media (max-width: 640px) {
  .pq-table tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; padding: 12px 14px; }
  .pq-table th[scope="row"] { grid-column: 1 / -1; }
  .pq-table td:nth-child(5), .pq-table td:nth-child(6) { grid-column: 1 / -1; }
  .pq-table td:nth-child(6) { border-top: 0; padding-top: 0; }
}

/* feuille de route */
.pq-road { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.pq-road__phase { position: relative; padding: 0 0 var(--s-5) 30px; }
.pq-road__phase::before { content: ""; position: absolute; left: 8px; top: 10px; bottom: 0; width: 2px; background: var(--border); }
.pq-road__phase:last-child::before { display: none; }
.pq-road__phase::after {
  content: ""; position: absolute; left: 1px; top: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--white); border: 3px solid var(--pc, var(--ink-500));
}
.pq-road__phase--1 { --pc: var(--red-700); }
.pq-road__phase--2 { --pc: var(--orange-700); }
.pq-road__phase--3 { --pc: var(--cyan-700); }
.pq-road__phase--4 { --pc: var(--ink-500); }
.pq-road__phase--5 { --pc: var(--green-700); }
.pq-road__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pq-road__head h4 { margin: 0; font-size: 1.02rem; }
.pq-road__intro { margin: 4px 0 8px; font-size: .9rem; color: var(--fg-muted); }
.pq-road__list { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; }
.pq-road__list li { font-size: .92rem; color: var(--fg); overflow-wrap: anywhere; }
.pq-road__generic { color: var(--fg-muted) !important; }

/* ------------------------------------------------------------ « récolter maintenant » */
.pq-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; counter-reset: pq; }
.pq-step {
  position: relative; padding: 22px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border);
  counter-increment: pq;
}
.pq-step h3 { font-size: 1.12rem; margin: 10px 0 6px; }
.pq-step p { margin: 0; color: var(--fg-muted); font-size: .95rem; }
.pq-step__when {
  display: inline-flex; align-items: center; gap: 8px; font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--data);
}
.pq-step__when::before {
  content: counter(pq); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(14, 165, 233, .16); color: var(--data); font-size: .8rem; letter-spacing: 0;
}
.pq-step:nth-child(2) .pq-step__when { color: var(--signal); }
.pq-step:nth-child(2) .pq-step__when::before { background: rgba(220, 94, 9, .18); color: var(--signal); }
@media (min-width: 900px) {
  .pq-step:not(:last-child)::after {
    content: ""; position: absolute; right: -13px; top: 50%; width: 10px; height: 10px; z-index: 1;
    border-top: 2px solid var(--border-strong); border-right: 2px solid var(--border-strong); transform: translateY(-50%) rotate(45deg);
  }
}
@media (max-width: 899px) { .pq-steps { grid-template-columns: minmax(0, 1fr); } }
.pq-facts .card h3 { font-size: 1.05rem; margin-bottom: 8px; }

/* ------------------------------------------------------------ méthode */
.pq-method { align-items: start; gap: clamp(28px, 4vw, 56px); }
.pq-h { font-size: 1.12rem; margin: 0; }
.pq-method .pq-h { margin-bottom: 10px; }
.pq-method .pq-h:not(:first-child) { margin-top: var(--s-5); }
.pq-method p, .pq-limits li { color: var(--fg-muted); }
.pq-prio-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pq-prio-list li { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 10px; align-items: start; font-size: .93rem; color: var(--fg-muted); }
.pq-prio-list .pq-prio { justify-self: start; }
.pq-limits { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }
.pq-algo-table th[scope="row"] { white-space: normal; font-size: .86rem; letter-spacing: 0; text-transform: none; color: var(--fg); font-weight: 700; background: transparent; }
.pq-algo-table td { font-size: .88rem; }
.pq-code {
  margin: 10px 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--navy-900); color: #e6ecfa;
  font-family: var(--mono); font-size: .82rem; white-space: pre-wrap; word-break: break-all;
}
.pq-code code { background: none; border: 0; padding: 0; color: inherit; }
@media (max-width: 640px) {
  .pq-prio-list li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  /* tableau de classement : une fiche par famille au lieu d'un défilement horizontal tronqué */
  .table-wrap:has(> .pq-algo-table) { overflow: visible; }
  .pq-algo-table { display: flex; flex-direction: column; }
  .pq-algo-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .pq-algo-table tbody { display: block; }
  .pq-algo-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 14px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .pq-algo-table th[scope="row"] { grid-column: 1 / -1; padding: 0; border: 0; font-size: .95rem; }
  .pq-algo-table td { padding: 0; border: 0; overflow-wrap: anywhere; }
  .pq-algo-table td::before {
    content: "Face au quantique"; display: block; margin-bottom: 2px;
    font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-subtle);
  }
  .pq-algo-table td:nth-child(3)::before { content: "Aujourd\2019hui"; }
  :root[lang="en"] .pq-algo-table td:nth-child(2)::before { content: "Against quantum"; }
  :root[lang="en"] .pq-algo-table td:nth-child(3)::before { content: "Today"; }
  .pq-algo-table caption { display: block; order: 2; }
}

/* ------------------------------------------------------------ échéances */
.pq-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.pq-tl {
  display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 20px; padding: 20px 22px;
  border-radius: var(--r-lg); background: var(--white); border: 1px solid var(--border);
}
.pq-tl__date { font-weight: 800; color: var(--cyan-700); font-size: .95rem; padding-top: 2px; }
.pq-tl--ma .pq-tl__date { color: var(--navy-800); }
.pq-tl__body h3 { font-size: 1.08rem; margin: 0 0 6px; }
.pq-tl__body p { margin: 0 0 6px; color: var(--fg-muted); font-size: .95rem; }
.pq-tl__src { font-size: .86rem; }
.pq-tl__src a { font-weight: 700; }
@media (max-width: 640px) { .pq-tl { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 16px; } }

/* ------------------------------------------------------------ moteur Qorsec */
.pq-engine { align-items: start; }
@media (min-width: 980px) { .pq-engine { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); } }

/* ------------------------------------------------------------ mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  .pq-drop, .pq-use { transition: none; }
}

/* ------------------------------------------------------------ impression */
@media print {
  /* Une carte de certificat fait presque une page : on évite de couper ses sous-blocs, pas la carte entière
     (sinon chaque carte saute à la page suivante et laisse une demi-page vide). */
  .pq-kpi, .pq-road__phase, .pq-table tr, .pq-cert__head, .pq-dl__row, .pq-cert__checks > *, .pq-cert .check-row { break-inside: avoid; }
  .pq-certs { display: block; }
  .pq-certs > .pq-cert + .pq-cert { margin-top: 14px; }
  .pq-cert { break-inside: auto; }
  .pq-cert__head { break-after: avoid; }
  .pq-kpis { grid-template-columns: repeat(3, 1fr); }
  .pq-cert, .pq-kpi { border-color: #bbb; }
  .pq-cert__num { background: #10214b !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pq-prio { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pq-dl__row { grid-template-columns: 170px minmax(0, 1fr); }
  .pq-table-wrap { overflow: visible; }
}
