/* ═══ §32 ТЕПЛОВЫЕ КАРТЫ · v6 · lumen-heat.js (LM.heat) ═══════════════════════
   Классы lm-heat6* — чтобы не пересечься с .lm-heat / .lm-cal / .lm-cohort из lumen-viz.
   Рампы считаются от токенов в OKLCH относительным цветом:
     oklch(from var(--c) L calc(c * k) h) — оттенок токена сохраняется точно,
     светлота задаётся ступенями, хрома чуть гасится на концах.
   Ступени подобраны под валидатор dataviz (--ordinal, 06.09.2026): монотонная L,
   ΔL ≥ .06 между соседями, крайняя ступень ≥ 2:1 к поверхности, один оттенок.
     светлая · seq: L .78 → .39 (6 ступеней)   · плечо div: .78 → .54 (3)
     тёмная  · seq: L .43 → .78 (от поверхности к свету) · плечо div: .44 → .66
   Расходящаяся: --cold ↔ нейтраль (--chart-empty) ↔ --warm.
   Текст в ячейке носит токены текста (--ink / --surface по светлоте заливки),
   никогда цвет ряда. Зазор 2 px — gap сетки, сквозь него видна поверхность.
   Подключение: отдельной <link> после lumen.css (в v6 сольётся в lumen.css §32). */

.lm-heat6{--c:var(--lm-emph);--cn:var(--cold);--cw:var(--warm);
  --lm-heat6-h:28px;--lm-heat6-min:24px;--lm-heat6-fs:11.5px;--lm-heat6-r:4px;--lm-heat6-hh:72px;
  --lm-heat6-l1:.78;--lm-heat6-l2:.71;--lm-heat6-l3:.64;--lm-heat6-l4:.57;--lm-heat6-l5:.48;--lm-heat6-l6:.39;
  --lm-heat6-k1:.55;--lm-heat6-k2:.7;--lm-heat6-k3:.85;--lm-heat6-k4:1;--lm-heat6-k5:.9;--lm-heat6-k6:.75;
  --lm-heat6-d1:.78;--lm-heat6-d2:.66;--lm-heat6-d3:.54;
  --lm-heat6-dn1:.6;--lm-heat6-dn2:.9;--lm-heat6-dn3:.8;
  --lm-heat6-dw1:.6;--lm-heat6-dw2:.85;--lm-heat6-dw3:.7;
  position:relative;min-width:0;max-width:100%;contain:inline-size;font-size:var(--lm-heat6-fs);color:var(--ink)}  /* contain: min-content таблицы близнеца не раздувает плавающую карточку */
html[data-theme="dark"] .lm-heat6{
  --lm-heat6-l1:.43;--lm-heat6-l2:.50;--lm-heat6-l3:.57;--lm-heat6-l4:.64;--lm-heat6-l5:.71;--lm-heat6-l6:.78;
  --lm-heat6-k1:.6;--lm-heat6-k2:.8;--lm-heat6-k3:1;--lm-heat6-k4:1;--lm-heat6-k5:.85;--lm-heat6-k6:.7;
  --lm-heat6-d1:.44;--lm-heat6-d2:.55;--lm-heat6-d3:.66;
  --lm-heat6-dn1:.6;--lm-heat6-dn2:.8;--lm-heat6-dn3:1;
  --lm-heat6-dw1:.45;--lm-heat6-dw2:.6;--lm-heat6-dw3:.85}

/* ── ступени: одна для ячеек и для плашек легенды. Пустая клетка — --chart-empty; ступень перебивает её (специфичность выше) ── */
.lm-heat6 .cell:not([data-step]){background:var(--chart-empty)}
.lm-heat6 [data-step]{color:var(--ink)}
.lm-heat6 [data-step="1"]{background:oklch(from var(--c) var(--lm-heat6-l1) calc(c * var(--lm-heat6-k1)) h)}
.lm-heat6 [data-step="2"]{background:oklch(from var(--c) var(--lm-heat6-l2) calc(c * var(--lm-heat6-k2)) h)}
.lm-heat6 [data-step="3"]{background:oklch(from var(--c) var(--lm-heat6-l3) calc(c * var(--lm-heat6-k3)) h)}
.lm-heat6 [data-step="4"]{background:oklch(from var(--c) var(--lm-heat6-l4) calc(c * var(--lm-heat6-k4)) h);color:var(--surface)}
.lm-heat6 [data-step="5"]{background:oklch(from var(--c) var(--lm-heat6-l5) calc(c * var(--lm-heat6-k5)) h);color:var(--surface)}
.lm-heat6 [data-step="6"]{background:oklch(from var(--c) var(--lm-heat6-l6) calc(c * var(--lm-heat6-k6)) h);color:var(--surface)}
.lm-heat6.div [data-step="1"]{background:oklch(from var(--cw) var(--lm-heat6-d1) calc(c * var(--lm-heat6-dw1)) h);color:var(--ink)}
.lm-heat6.div [data-step="2"]{background:oklch(from var(--cw) var(--lm-heat6-d2) calc(c * var(--lm-heat6-dw2)) h);color:var(--ink)}
.lm-heat6.div [data-step="3"]{background:oklch(from var(--cw) var(--lm-heat6-d3) calc(c * var(--lm-heat6-dw3)) h);color:var(--surface)}
.lm-heat6.div [data-step="-1"]{background:oklch(from var(--cn) var(--lm-heat6-d1) calc(c * var(--lm-heat6-dn1)) h);color:var(--ink)}
.lm-heat6.div [data-step="-2"]{background:oklch(from var(--cn) var(--lm-heat6-d2) calc(c * var(--lm-heat6-dn2)) h);color:var(--ink)}
.lm-heat6.div [data-step="-3"]{background:oklch(from var(--cn) var(--lm-heat6-d3) calc(c * var(--lm-heat6-dn3)) h);color:var(--surface)}
/* запасной путь для браузеров без относительного цвета: те же ступени смесью в sRGB */
@supports not (color: oklch(from red l c h)){
  .lm-heat6 [data-step="1"]{background:color-mix(in srgb,var(--c) 30%,var(--surface))}
  .lm-heat6 [data-step="2"]{background:color-mix(in srgb,var(--c) 45%,var(--surface))}
  .lm-heat6 [data-step="3"]{background:color-mix(in srgb,var(--c) 62%,var(--surface))}
  .lm-heat6 [data-step="4"]{background:color-mix(in srgb,var(--c) 80%,var(--surface))}
  .lm-heat6 [data-step="5"]{background:var(--c)}
  .lm-heat6 [data-step="6"]{background:color-mix(in srgb,var(--c) 75%,var(--ink))}
  .lm-heat6.div [data-step="1"]{background:color-mix(in srgb,var(--cw) 40%,var(--surface))}
  .lm-heat6.div [data-step="2"]{background:color-mix(in srgb,var(--cw) 75%,var(--surface))}
  .lm-heat6.div [data-step="3"]{background:color-mix(in srgb,var(--cw) 80%,var(--ink))}
  .lm-heat6.div [data-step="-1"]{background:color-mix(in srgb,var(--cn) 40%,var(--surface))}
  .lm-heat6.div [data-step="-2"]{background:color-mix(in srgb,var(--cn) 75%,var(--surface))}
  .lm-heat6.div [data-step="-3"]{background:color-mix(in srgb,var(--cn) 80%,var(--ink))}}

/* ── шапка: факт-заголовок + кнопка «таблица» ── */
.lm-heat6-hd{display:flex;align-items:flex-start;gap:10px;margin-bottom:10px;min-width:0}
.lm-heat6-hd .t{flex:1;min-width:0}
.lm-heat6-hd h4{margin:0;font-size:14px;font-weight:600;letter-spacing:-.015em;color:var(--ink);line-height:1.3;text-wrap:balance}
.lm-heat6-hd .sub{font-size:var(--lm-small);color:var(--ink-4);margin-top:2px;line-height:1.35;text-wrap:pretty}
.lm-heat6-hd .lm-btn{flex:none}

/* ── сетка ── */
.lm-heat6-wrap{overflow-x:auto;overscroll-behavior-x:contain;min-width:0;max-width:100%;padding-bottom:2px}
.lm-heat6-grid{display:grid;gap:2px;align-items:stretch;min-width:0}
.lm-heat6-grid.diag{padding-right:52px;padding-top:2px}
.lm-heat6 .ch{display:flex;align-items:flex-end;justify-content:center;min-width:0;padding:0 1px 4px;font-size:var(--lm-micro);color:var(--ink-4);line-height:1.2;text-align:center}
.lm-heat6 .ch>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lm-heat6 .ch small{display:block;font-size:var(--lm-micro);color:var(--ink-5);font-variant-numeric:tabular-nums}
.lm-heat6 .ch.corner{justify-content:flex-start;text-align:left;padding-right:8px}
.lm-heat6-grid.diag .ch:not(.corner){height:var(--lm-heat6-hh);position:relative;overflow:visible;justify-content:flex-start;padding:0}
.lm-heat6-grid.diag .ch:not(.corner)>span{position:absolute;left:50%;bottom:6px;width:max-content;max-width:150px;transform-origin:0 100%;transform:rotate(-52deg);overflow:hidden}
.lm-heat6-grid.diag .ch small{display:inline;margin-left:4px}
.lm-heat6 .mh{grid-row:1;display:flex;align-items:flex-end;gap:4px;min-width:0;padding:0 2px 3px;font-size:var(--lm-micro);color:var(--ink-4);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums}
.lm-heat6 .mh b{font-weight:var(--w-semibold);color:var(--ink-3)}
.lm-heat6 .rh{display:flex;align-items:center;justify-content:flex-end;gap:6px;padding:0 8px 0 0;min-height:var(--lm-heat6-h);font-size:var(--lm-small);color:var(--ink-3);white-space:nowrap;max-width:200px;min-width:0}
.lm-heat6 .rh>span{overflow:hidden;text-overflow:ellipsis;min-width:0}
.lm-heat6 .rh small{color:var(--ink-4);font-size:var(--lm-micro);font-variant-numeric:tabular-nums;flex:none}
.lm-heat6 .rh.off{color:var(--ink-4)}
.lm-heat6 .cell{position:relative;display:flex;align-items:center;justify-content:center;min-width:0;height:var(--lm-heat6-h);border-radius:var(--lm-heat6-r);font-variant-numeric:tabular-nums;font-size:var(--lm-heat6-fs);line-height:1;overflow:hidden;cursor:default}
.lm-heat6 .cell>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 3px}
.lm-heat6.dense .cell:not(.tot)>span{display:none}
.lm-heat6 .cell.zero{color:var(--ink-4)}
.lm-heat6 .cell.na{background:repeating-linear-gradient(45deg,transparent 0 4px,var(--border-2) 4px 5px);color:var(--ink-4)}
.lm-heat6 .cell.off{background-image:repeating-linear-gradient(135deg,transparent 0 3px,color-mix(in srgb,var(--ink) 9%,transparent) 3px 4px)}
.lm-heat6 .cell.weak{background:var(--chart-empty);color:var(--ink-4)}
/* §37: порог и «сегодня» отмечаются НЕ жирной рамкой, а засечкой в углу и волосяным кольцом
   цвета поверхности — заливка остаётся единственным носителем величины (см. DESIGN_SYSTEM §37) */
.lm-heat6 .cell.over{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--surface) 65%,transparent)}
.lm-heat6 .cell.over::after{content:'';position:absolute;top:0;right:0;width:0;height:0;border-top:6px solid color-mix(in srgb,var(--ink) 55%,transparent);border-left:6px solid transparent;border-top-right-radius:2px;pointer-events:none}
.lm-heat6 .cell.today{box-shadow:inset 0 0 0 1px var(--ink-4)}
.lm-heat6 .cell.today::before{content:'';position:absolute;left:50%;bottom:2px;width:10px;height:2px;border-radius:var(--sp-fig-r,3px);transform:translateX(-50%);background:var(--ink-3);pointer-events:none}
.lm-heat6 .cell.future{background:transparent;box-shadow:inset 0 0 0 1px var(--border-2)}
.lm-heat6 .cell.out{visibility:hidden}
.lm-heat6 .cell.tot{background:transparent;color:var(--ink-3);font-weight:var(--w-semibold);justify-content:flex-end}
.lm-heat6 .cell.tot>span{padding-right:2px}
@media (hover:hover){.lm-heat6 .cell:not(.tot):not(.out):hover{filter:brightness(.92)} .lm-heat6 .cell.na:hover,.lm-heat6 .cell.future:hover{filter:none;box-shadow:inset 0 0 0 1px var(--border-3)}}
.lm-heat6 .cell.lm-on{filter:brightness(.9)}

/* ── календарь: квадратные клетки 13 px (o.square → колонки фиксированной ширины), без подписей ── */
.lm-heat6.cal{--lm-heat6-h:13px;--lm-heat6-min:13px;--lm-heat6-r:2px}
.lm-heat6-grid.months .ch{grid-row:2}
.lm-heat6.cal .rh{font-size:var(--lm-micro);padding-right:6px}
.lm-heat6.cal .cell.today{box-shadow:inset 0 0 0 1px var(--ink-4)}
.lm-heat6.cal .cell.off{background-image:none}
.lm-heat6.cal .cell.off:not([data-step]){background:color-mix(in srgb,var(--chart-empty) 55%,transparent)}
.lm-heat6.cal .cell.tot{font-size:var(--lm-micro)}

/* ── легенда: шкала с min/max, порог с автором, «нет данных», источник ── */
.lm-heat6-lg{display:flex;flex-wrap:wrap;align-items:center;gap:6px 14px;margin-top:10px;font-size:var(--lm-micro);color:var(--ink-4);min-width:0;line-height:1.35}
.lm-heat6-lg .sc{display:inline-flex;align-items:center;gap:2px;flex:none}
.lm-heat6-lg .sc i{display:block;width:16px;height:10px;border-radius:var(--sp-fig-r,3px);cursor:default} .lm-heat6-lg .sc i:not([data-step]){background:var(--chart-empty)} /* легенда красится теми же [data-step], что и клетки */
.lm-heat6-lg .sc i.mid{background:var(--chart-empty);box-shadow:inset 0 0 0 1px var(--border-3)}
.lm-heat6-lg .sc span{margin:0 4px;font-variant-numeric:tabular-nums;color:var(--ink-3)}
.lm-heat6-lg .it{display:inline-flex;align-items:center;gap:5px;flex:none}
.lm-heat6-lg .it i{display:block;width:12px;height:12px;border-radius:var(--sp-fig-r,3px);background:var(--chart-empty)}
.lm-heat6-lg .it i.na{background:repeating-linear-gradient(45deg,transparent 0 4px,var(--border-2) 4px 5px)}
.lm-heat6-lg .it i.off{background-image:repeating-linear-gradient(135deg,transparent 0 3px,color-mix(in srgb,var(--ink) 12%,transparent) 3px 4px)}
.lm-heat6-lg .it i.over{background:transparent;box-shadow:inset 0 0 0 1px var(--border-3);position:relative;overflow:hidden} .lm-heat6-lg .it i.over::after{content:'';position:absolute;top:0;right:0;width:0;height:0;border-top:5px solid color-mix(in srgb,var(--ink) 55%,transparent);border-left:5px solid transparent}
.lm-heat6-lg .it i.today{background:transparent;box-shadow:inset 0 0 0 1px var(--ink-4)}
.lm-heat6-lg .it i.future{background:transparent;box-shadow:inset 0 0 0 1px var(--border-3)}
.lm-heat6-lg .it i.weak{background:var(--chart-empty)}
.lm-heat6-lg .thr{display:inline-flex;align-items:center;gap:5px;color:var(--ink-3)}
.lm-heat6-lg .thr i{display:block;position:relative;width:12px;height:12px;border-radius:var(--sp-fig-r,3px);box-shadow:inset 0 0 0 1px var(--border-3);flex:none;overflow:hidden} .lm-heat6-lg .thr i::after{content:'';position:absolute;top:0;right:0;width:0;height:0;border-top:5px solid color-mix(in srgb,var(--ink) 55%,transparent);border-left:5px solid transparent}
.lm-heat6-lg .thr.none{color:var(--ink-4)}
.lm-heat6-lg .src{margin-left:auto;color:var(--ink-4);font-family:var(--font-mono);font-size:var(--lm-micro);white-space:nowrap}
.lm-heat6-note{margin-top:6px;font-size:var(--lm-micro);color:var(--ink-4);line-height:1.4;text-wrap:pretty}

/* ── близнец ── */
.lm-heat6-twin{margin-top:10px}
.lm-heat6-twin[hidden]{display:none}
.lm-heat6.twin-only .lm-heat6-wrap,.lm-heat6.twin-only .lm-heat6-lg{display:none}
.lm-heat6.twin-only .lm-heat6-twin{margin-top:0}
.lm-heat6-twin .lm-table td.na{color:var(--ink-4)}
.lm-heat6-twin .lm-table tr.avg td{color:var(--ink-3);font-style:normal;border-top:1px solid var(--border-3)}

/* ── загрузка: скелет в форме будущей сетки ── */
.lm-heat6-skel{display:grid;gap:2px}
.lm-heat6-skel .lm-skel{height:var(--lm-heat6-h);border-radius:var(--lm-heat6-r)}

/* ── четыре состояния внутри формы: остаются тем же блоком ── */
.lm-heat6>.lm-state{min-height:160px}

/* ── ТВ / показ: крупнее ячейки и подписи ── */
html[data-preset="тв"] .lm-heat6{--lm-heat6-h:36px;--lm-heat6-fs:14px}
html[data-preset="тв"] .lm-heat6 .rh,html[data-preset="тв"] .lm-heat6 .ch{font-size:13px}
@media print{.lm-heat6 .cell{print-color-adjust:exact;-webkit-print-color-adjust:exact} .lm-heat6-twin{display:block!important}}
