/* Outil « Héritage d'un terrain : parts de chacun en m² » (scripts/blocks/heritage.mjs, heritage-ui.js). */
.heritage-tool { max-width: 980px; }
.heritage-tool .ht-privacy { color: var(--muted); font-size: .95rem; margin-bottom: .6rem; }
.heritage-tool .ht-restored:empty { display: none; }
.heritage-tool .ht-restored { margin-bottom: 1rem; }
.ht-form { display: grid; gap: 1.6rem; min-width: 0; }
.heritage-tool .btn { white-space: normal; max-width: 100%; text-align: start; }
.ht-form .ht-fs { display: grid; gap: 1rem; min-width: 0; }
.ht-form .ht-fs > legend { font-size: 1.15rem; font-weight: 750; margin-bottom: .8rem; color: var(--text); }
.ht-form .ht-fs + .ht-fs { border-top: 1px solid var(--line); padding-top: 1.4rem; }
.ht-form .ht-group { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem 1rem; min-width: 0; }
.ht-form .ht-group > legend { padding-inline: .4rem; margin-bottom: .2rem; }
.ht-form .ht-field { display: grid; gap: .4rem; min-width: 0; align-content: start; }
.ht-form .ht-field > label { font-weight: 600; font-size: .92rem; }
.ht-form .ht-field .hint { margin: 0; }
.ht-form .ht-p { margin: 0; }
.ht-form .ht-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem; align-items: start; }
.ht-form .ht-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); gap: .8rem 1rem; align-items: end; }
.ht-form .ht-num input { max-width: 9rem; }
.ht-form [dir="ltr"] { text-align: start; }
[dir="rtl"] .ht-form input[dir="ltr"] { text-align: right; }
.ht-form input[aria-invalid="true"], .ht-form select[aria-invalid="true"] { border-color: #b3261e; border-width: 2px; }
.ht-err { margin: 0; color: #b3261e; font-size: .88rem; font-weight: 600; }
.ht-err::before { content: "⚠ "; }
:root[data-theme="dark"] .ht-err, :root[data-theme="dark"] .ht-errsum { color: #ffb4ab; }
:root[data-theme="dark"] .ht-form input[aria-invalid="true"] { border-color: #ffb4ab; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ht-err, :root:not([data-theme="light"]) .ht-errsum { color: #ffb4ab; }
  :root:not([data-theme="light"]) .ht-form input[aria-invalid="true"] { border-color: #ffb4ab; }
}
.ht-errsum { border: 2px solid currentColor; color: #b3261e; border-radius: 10px; padding: .8rem 1rem; font-weight: 650; }
.ht-errsum:focus { outline: 2px solid var(--copper); outline-offset: 2px; }
.ht-form .ht-chk { justify-self: start; border-radius: 14px; align-items: flex-start; }
.ht-form .ht-chk input { margin-top: .3rem; }
.ht-form .ht-checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.ht-pre-list { display: grid; gap: 1rem; }
.ht-pre-item { border: 1px dashed var(--input-line); border-radius: 12px; padding: .9rem 1rem 1rem; display: grid; gap: .9rem; min-width: 0; margin: 0; }
.ht-pre-item > legend { font-weight: 700; padding-inline: .4rem; }
.ht-pre-item .ht-sib { border: 0; padding: 0; margin: 0; min-width: 0; }
.ht-pre-item .ht-sib > legend { font-size: .9rem; margin-bottom: .5rem; }
.ht-form .ht-add, .ht-form .ht-del, .ht-form .ht-actions .btn { justify-self: start; cursor: pointer; font: inherit; font-weight: 650; }
.ht-form .btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.ht-form .btn.ghost:hover { border-color: var(--copper); }
.ht-actions { display: flex; flex-wrap: wrap; gap: .8rem; }
.ht-actions .btn:first-child { border: 0; }

/* Résultat : carte sombre, comme le convertisseur Lambert */
.ht-out:empty { display: none; }
.ht-out { margin-top: 2rem; display: grid; gap: 2rem; }
.ht-result { background: var(--ink); color: #eeecff; border-radius: 14px; padding: clamp(1.2rem, 1rem + 1.5vw, 2rem); min-width: 0; }
.ht-result h2 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); margin: 0 0 .3rem; color: #fff; }
.ht-result h2:focus { outline: none; }
.ht-result h2:focus-visible { outline: 2px solid var(--copper-l); outline-offset: 4px; }
.ht-result h3 { color: #fff; margin-top: 1.6rem; }
.ht-result .ht-date { color: rgba(236, 234, 255, .75); font-size: .9rem; }
.ht-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .8rem 1.4rem; margin: 1rem 0 1.4rem; }
.ht-sum dt { font-size: .82rem; color: rgba(236, 234, 255, .75); }
.ht-sum dd { margin: 0; font-family: var(--mono); font-size: 1.15rem; color: #fff; }
.ht-sum small, .ht-table small { display: block; font-size: .78rem; color: rgba(236, 234, 255, .75); font-family: var(--sans); margin-top: .15rem; }
.ht-scroll { overflow-x: auto; max-width: 100%; }
.ht-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ht-table th, .ht-table td { text-align: start; padding: .6rem .5rem; border-bottom: 1px solid rgba(233, 230, 255, .18); vertical-align: top; }
.ht-table thead th { font-size: .78rem; font-weight: 650; color: rgba(236, 234, 255, .8); }
.ht-table tbody th { font-weight: 650; color: #fff; }
.ht-table td bdi, .ht-sum bdi { font-family: var(--mono); white-space: nowrap; }
.ht-result .ht-round { font-size: .82rem; color: rgba(236, 234, 255, .75); margin: .8rem 0 0; }
.ht-list { padding-inline-start: 1.2rem; margin: 0; } .ht-list li { padding: .2rem 0; }
.ht-tools { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.4rem; }
.ht-tools .btn { cursor: pointer; font: inherit; font-weight: 650; background: transparent; color: #fff; border: 1px solid rgba(233, 230, 255, .4); }
.ht-tools .btn:hover { border-color: var(--copper-l); }
.ht-result :focus-visible { outline-color: var(--copper-l); }

/* Analyse du partage en nature */
.ht-analysis { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(1.2rem, 1rem + 1.5vw, 2rem); min-width: 0; }
.ht-analysis h2 { font-size: clamp(1.4rem, 1.2rem + 1vw, 1.9rem); }
.ht-analysis h3 { margin-top: 1.6rem; }
.ht-analysis .note { margin: 0 0 1rem; }
.ht-analysis .ht-table th, .ht-analysis .ht-table td { border-bottom-color: var(--line); }
.ht-analysis .ht-table thead th { color: var(--muted); }
.ht-analysis .ht-table tbody th { color: var(--text); }
.ht-verdict { font-weight: 650; padding: .8rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); }
.ht-verdict > span, .ht-badge > span { font-weight: 800; }
.ht-verdict.ok > span, .ht-badge.ok { color: var(--g-text); }
.ht-verdict.ko > span, .ht-badge.ko { color: var(--copper-ink); }
.ht-badge { font-weight: 650; white-space: nowrap; }
.ht-groups { padding-inline-start: 1.2rem; }
.ht-analysis .ht-rule { font-weight: 600; }
.ht-disc { border-top: 1px solid var(--line); margin-top: 1.6rem; padding-top: 1.2rem; font-size: .92rem; color: var(--muted); }
.ht-disc strong { color: var(--text); }
.ht-devis { margin-top: 1.6rem; padding: 1.2rem; border-radius: 12px; background: var(--sand); }
.ht-devis .btn { margin-top: .4rem; }
.ht-analysis a:not(.btn) { color: var(--g-text); }

/* Écrans étroits : tableaux en cartes */
@media (max-width: 720px) {
  .ht-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ht-table, .ht-table tbody, .ht-table tr, .ht-table th, .ht-table td { display: block; width: 100%; }
  .ht-table tr { border-bottom: 1px solid rgba(233, 230, 255, .25); padding: .6rem 0; }
  .ht-analysis .ht-table tr { border-bottom-color: var(--line); }
  .ht-table th, .ht-table td { border: 0; padding: .2rem 0; }
  .ht-table td:empty { display: none; }
  .ht-table td::before { content: attr(data-label); display: block; font-size: .75rem; opacity: .8; font-family: var(--sans); }
  .ht-table tbody th { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) { .heritage-tool * { scroll-behavior: auto; } }

/* Impression : seulement le résultat et l'analyse */
.ht-print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }
  .top, .foot, .page-head, .skip, main > section:not(.ht-sec), .ht-box, .ht-privacy, .ht-restored, .ht-tools, .ht-devis, .listen-bar, .a11y { display: none !important; }
  .ht-sec { padding: 0 !important; }
  .ht-sec .wrap { width: 100%; }
  .heritage-tool { max-width: none; }
  .ht-out { margin: 0; display: block; }
  .ht-result, .ht-analysis { background: #fff !important; color: #000 !important; border: 1px solid #999; border-radius: 0; padding: 0 0 8mm; border-width: 0 0 1px; }
  .ht-result *, .ht-analysis * { color: #000 !important; }
  .ht-sum small, .ht-table small, .ht-result .ht-date, .ht-result .ht-round { color: #333 !important; }
  .ht-table th, .ht-table td { border-bottom: 1px solid #bbb !important; }
  .ht-table tr { break-inside: avoid; }
  .ht-analysis { break-before: auto; margin-top: 6mm; }
  .ht-analysis .note, .ht-verdict { background: #fff !important; border: 1px solid #999; }
  a { text-decoration: none; }
  .ht-print-only { display: block; }
  .ht-ptitle { font-size: 13pt; font-weight: 700; margin: 0 0 2mm; }
}
