/* ==========================================================================
   QORSEC — Analyseur d'en-têtes de courriel (/outils/en-tetes-email.html)
   Styles propres à l'outil. S'appuie sur les jetons de /assets/css/site.css.
   ========================================================================== */

/* ---------------------------------------------------------------- saisie */
.eh-input {
  font-family: var(--mono);
  font-size: .82rem !important;
  line-height: 1.5;
  min-height: 260px !important;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 4;
}
.eh-actions { gap: 8px; }
.eh-file-btn { position: relative; cursor: pointer; }
.eh-file-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.eh-howto { margin-top: var(--s-5); }
.eh-steps { display: grid; gap: 14px; margin: 0; }
.eh-steps dt { font-weight: 800; color: var(--fg); font-size: .95rem; }
.eh-steps dd { margin: 2px 0 0; font-size: .93rem; }
.eh-howto__note { margin-top: 14px; font-size: .88rem; color: var(--fg-subtle); }
kbd {
  display: inline-block; padding: 0 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px; background: var(--surface-2); font-size: .8em; line-height: 1.5;
}

/* La colonne de .tool-main est une grille : sans min-width:0, un long en-tête (Received,
   DKIM…) imposait sa largeur minimale et le bloc résultat débordait à 390 px (744 px de large). */
.tool-main > *, #tool-results, #eh-report, #tool-output { min-width: 0; }

/* ---------------------------------------------------------------- verdict */
.eh-sample {
  margin: 0 0 14px; padding: 8px 12px; border-radius: var(--r-sm);
  background: rgba(14, 165, 233, .08); border: 1px dashed rgba(3, 105, 161, .35);
  color: var(--cyan-700); font-size: .85rem; font-weight: 600;
}
.eh-verdict {
  --v: var(--ink-500); --v-bg: var(--paper-50);
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: start;
  padding: 20px 22px; border-radius: var(--r-lg); border: 1px solid var(--border);
  border-left: 5px solid var(--v); background: var(--v-bg);
}
.eh-verdict--high { --v: var(--red-700); --v-bg: #fdf1f1; }
.eh-verdict--moderate { --v: var(--orange-700); --v-bg: #fff6ef; }
.eh-verdict--low { --v: var(--green-700); --v-bg: #f0faf3; }
.eh-verdict--limited { --v: var(--ink-500); --v-bg: var(--paper-50); }
.eh-verdict__title { font-size: 1.35rem; margin: 0 0 6px; color: var(--v); letter-spacing: -.02em; }
.eh-verdict p { margin: 0 0 8px; color: var(--ink-700); font-size: .95rem; }
.eh-verdict .eh-caveat { margin: 0; font-size: .82rem; color: var(--fg-subtle); }
.eh-meter { display: grid; grid-template-rows: repeat(3, 14px); gap: 5px; width: 48px; padding-top: 6px; }
.eh-meter__seg { border-radius: 4px; background: var(--line-200); }
.eh-meter__seg:nth-child(1) { order: 3; } .eh-meter__seg:nth-child(2) { order: 2; } .eh-meter__seg:nth-child(3) { order: 1; }
.eh-meter__seg.is-on { background: var(--v); }
.eh-meta { margin: 12px 0 0; font-size: .8rem; color: var(--fg-subtle); }

/* ---------------------------------------------------------------- blocs */
.eh-block { padding-top: 22px; margin-top: 22px; border-top: 1px solid var(--border); }
.eh-block > h3 { font-size: 1.12rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.eh-count {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border); font-size: .78rem; font-weight: 800; color: var(--fg-muted);
}
.eh-sub { font-size: .95rem; margin: 18px 0 8px; }
.eh-note { font-size: .84rem; color: var(--fg-muted); overflow-wrap: anywhere; }
p.eh-note { margin: 0 0 10px; }
.eh-pos { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.eh-pos li { position: relative; padding-left: 26px; font-size: .93rem; }
.eh-pos li::before {
  content: "✓"; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: .7rem; font-weight: 800; color: #fff; background: var(--green-700);
}
.eh-block .check-row { padding: 12px 0; }

/* niveau de gravité (toujours un texte, jamais la seule couleur) */
.eh-sev {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill); font-size: .74rem; font-weight: 800;
  letter-spacing: .02em; white-space: nowrap; border: 1px solid currentColor;
}
.eh-sev--high { color: var(--red-700); background: #fdeeee; }
.eh-sev--medium { color: var(--orange-700); background: #fff4ec; }
.eh-sev--low { color: var(--ink-700); background: var(--surface-2); border-color: var(--border-strong); }
.eh-sev--info { color: var(--cyan-700); background: rgba(14, 165, 233, .07); border-color: rgba(3, 105, 161, .3); }

/* liste clé / valeur */
.eh-kv { margin: 0; display: grid; }
.eh-kv__row { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 4px 18px; padding: 10px 0; border-bottom: 1px solid var(--line-100); }
.eh-kv__row:last-child { border-bottom: 0; }
.eh-kv dt { font-size: .86rem; font-weight: 700; color: var(--fg-muted); }
.eh-kv dd { margin: 0; font-size: .93rem; overflow-wrap: anywhere; min-width: 0; }
.eh-kv code, .eh-block code, .eh-table code { font-size: .84em; overflow-wrap: anywhere; word-break: break-word; }
.eh-org { font-size: .8rem; color: var(--fg-subtle); white-space: nowrap; }

/* résultats SPF / DKIM / DMARC */
.eh-res {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill); font-size: .78rem; font-weight: 800; white-space: nowrap;
  border: 1px solid currentColor;
}
.eh-res--ok { color: var(--green-700); background: #ecf9f0; }
.eh-res--bad { color: var(--red-700); background: #fdeeee; }
.eh-res--warn { color: var(--orange-700); background: #fff4ec; }
.eh-res--muted { color: var(--ink-500); background: var(--surface-2); }
.eh-table td { font-size: .88rem; }
.eh-table .eh-val { min-width: 220px; overflow-wrap: anywhere; }
/* hors colonne de détail : un domaine ou un code n'est coupé qu'en dernier recours (sinon la colonne s'écrase) */
.eh-table td:not(.eh-val) code { overflow-wrap: break-word; word-break: normal; }
.eh-align { margin: 12px 0 0; padding: 10px 14px; border-radius: var(--r-sm); font-size: .9rem; background: var(--surface-2); border: 1px solid var(--border); }
.eh-align--pass { border-left: 4px solid var(--green-700); }
.eh-align--fail { border-left: 4px solid var(--red-700); }
.eh-align--unknown { border-left: 4px solid var(--ink-400); }
.eh-list { margin: 0; padding-left: 1.1em; display: grid; gap: 8px; font-size: .9rem; }
.eh-ip { font-size: .84em; }
.eh-chip { font-size: .72rem; padding: 1px 8px; vertical-align: 1px; }
.eh-tag { display: inline-block; margin: 0 4px 6px 0; padding: 2px 8px; border-radius: var(--r-xs); background: var(--surface-2); border: 1px solid var(--border); }
.eh-uri { display: inline-block; max-width: 100%; }

/* ---------------------------------------------------------------- frise des relais */
.eh-hops { list-style: none; margin: 14px 0 0; padding: 0; position: relative; }
.eh-hop { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding-bottom: 14px; }
.eh-hop::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: 0; width: 2px; background: var(--line-200); }
.eh-hop:last-child { padding-bottom: 0; }
.eh-hop:last-child::before { display: none; }
.eh-hop__num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .88rem;
  background: var(--white); color: var(--navy-800); border: 2px solid var(--cyan-500); position: relative; z-index: 1;
}
.eh-hop__card { min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.eh-hop__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 6px; }
.eh-hop__time { font-family: var(--mono); font-size: .82rem; font-weight: 700; color: var(--navy-800); margin-right: 4px; }
.eh-hop__line { font-size: .9rem; margin: 3px 0; overflow-wrap: anywhere; }
.eh-hop__k { display: inline-block; min-width: 2.6em; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-subtle); }
.eh-hop__meta { margin-top: 6px; font-size: .8rem; color: var(--fg-muted); overflow-wrap: anywhere; }

/* tous les en-têtes */
.eh-all { margin-top: 22px; }
.eh-export-note { margin: 10px 0 0; font-size: .8rem; color: var(--fg-subtle); }

/* méthode */
.eh-method .card__kicker {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(14, 165, 233, .1); color: var(--cyan-700); font-weight: 800;
}
.eh-method .card p { font-size: .93rem; }

/* ---------------------------------------------------------------- petits écrans */
@media (max-width: 640px) {
  .eh-input { min-height: 200px !important; }
  .eh-actions .btn { flex: 1 1 auto; }
  .eh-verdict { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px; }
  .eh-meter { grid-template-rows: none; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 180px; padding-top: 0; }
  .eh-meter__seg { height: 10px; }
  .eh-meter__seg:nth-child(n) { order: 0; }
  .eh-kv__row { grid-template-columns: minmax(0, 1fr); }
  .eh-hop { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
  .eh-hop__num { width: 28px; height: 28px; font-size: .8rem; }
  .eh-hop::before { left: 13px; top: 28px; }
  .eh-block .check-row { grid-template-columns: 22px minmax(0, 1fr); }
  .eh-block .check-row > .eh-sev { grid-column: 2; justify-self: start; }
  /* tableaux en fiches empilées : chaque cellule porte son intitulé (data-label, posé par le JS) */
  .eh-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .eh-table, .eh-table tbody, .eh-table tr, .eh-table td { display: block; width: 100%; }
  .eh-table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .eh-table tr:last-child { border-bottom: 0; }
  .eh-table td { border-bottom: 0; padding: 4px 14px; min-width: 0; }
  .eh-table td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-subtle);
  }
  .eh-table td.num[data-label] { text-align: left; }
  .eh-table td:empty { display: none; }
  .eh-table .eh-val { min-width: 0; }
  .eh-table td:not(.eh-val) code { overflow-wrap: anywhere; }
}

/* ---------------------------------------------------------------- mouvement réduit */
@media (prefers-reduced-motion: no-preference) {
  .eh-meter__seg { transition: background-color .35s ease; }
}

/* ---------------------------------------------------------------- impression */
@media print {
  .eh-verdict { break-inside: avoid; }
  .eh-hop, .eh-kv__row, .eh-block .check-row { break-inside: avoid; }
  .eh-block { break-inside: auto; }
  .tool-results { break-inside: auto !important; }
  .eh-meter__seg.is-on { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .eh-sev, .eh-res, .eh-pos li::before, .eh-hop__num { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .eh-all summary::after { display: none; }
  .eh-table .eh-val { min-width: 0; }
  .eh-table td:not(.eh-val) code { overflow-wrap: anywhere; }
}

/* titre : ne jamais couper « en-têtes » au trait d'union */
.eh-nowrap { white-space: nowrap; }
