/* Главная: шкала лет под картой (одна на карту и матрицу), народы и легенда над матрицей, цвет ячеек.
   Разметку ставит home-matrix.js. Стили грузятся только на главной. */

/* у тактики на главной - только название, без числа техник */
.dc-mx-count { display: none !important; }
.dc-mx-h { min-height: 60px !important; justify-content: center !important; }

/* красный карты; у части - бледная заливка и рамка полной силы, чтобы три состояния различались и формой */
.cx, .dc-mx-wrap { --cx-red: #c2301f; --cx-line: #8a1a10; --cx-dot: #c2301f; --cx-part-line: #c2301f; --cx-pale: color-mix(in srgb, #c2301f 13%, var(--c-body)); }
:root[data-theme=dark] .cx, :root[data-theme=dark] .dc-mx-wrap { --cx-red: #ad2619; --cx-line: #ea4f35; --cx-dot: #f47c66; --cx-part-line: #ea4f35; --cx-pale: color-mix(in srgb, #ea4f35 18%, var(--c-body)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .cx, :root:not([data-theme=light]) .dc-mx-wrap { --cx-red: #ad2619; --cx-line: #ea4f35; --cx-dot: #f47c66; --cx-part-line: #ea4f35; --cx-pale: color-mix(in srgb, #ea4f35 18%, var(--c-body)); } }
.cx { margin: 20px 0 0; display: grid; gap: 20px; }
.cx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* народы: флажки, можно выбрать несколько; последний не снимается */
.cx-peoples { display: flex; flex-wrap: wrap; gap: 8px; }
.cx .cx-p { display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px 0 12px; border: 1px solid var(--dc-cell, var(--dc-rule)); border-radius: 4px; background: none; font: 15px/20px "Roboto-Regular", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--c-body-on); cursor: pointer; }
.cx .cx-p[aria-pressed=true] { color: var(--c-body-on-emph); }
.cx-ck { position: relative; width: 16px; height: 16px; box-sizing: border-box; border: 1.5px solid var(--dc-muted); border-radius: 3px; }
.cx-p[aria-pressed=true] .cx-ck { border-color: var(--dc-accent); background: var(--dc-accent); }
.cx-p[aria-pressed=true] .cx-ck::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* точки народов: левая - нохчи, правая - украинцы */
.cx-d { display: inline-flex; gap: 4px; }
.cx-d i { width: 8px; height: 8px; border-radius: 50%; box-sizing: border-box; border: 1.5px solid currentColor; }
.cx-d i.on { background: currentColor; }
.cx-d i.off { visibility: hidden; }
.cx-p .cx-d, .cx-key .cx-d { color: var(--cx-dot); }

/* годы */
.cx-time { display: grid; gap: 10px; }
.cx-yrs { margin: 0; font: 500 17px/24px "Roboto-Medium", system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; color: var(--c-body-on-emph); }
.cx-yrs span { margin-left: 8px; font: 15px/20px "Roboto-Regular", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--dc-muted); }
.cx-track { position: relative; height: 24px; margin: 0 10px; }
.cx-track::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--dc-muted) 80%, var(--c-body)); }
.cx-tick { position: absolute; top: 6px; width: 1px; height: 12px; background: var(--dc-cell, var(--dc-rule)); }
.cx-fill { position: absolute; top: 10px; height: 4px; background: var(--dc-accent); }
.cx-th { position: absolute; top: 2px; width: 20px; height: 20px; margin-left: -10px; box-sizing: border-box; border: 2px solid var(--dc-accent); border-radius: 50%; background: var(--c-body); }
.cx-th::before { content: ""; position: absolute; inset: -12px; }
.cx-bands { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0 10px; }
.cx .cx-b { display: grid; align-content: start; gap: 2px; padding: 8px 8px 0; border: 0; border-left: 1px solid var(--dc-cell, var(--dc-rule)); background: none; text-align: left; font: 13px/18px "Roboto-Regular", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--dc-muted); cursor: pointer; }
.cx .cx-b:last-child { border-right: 1px solid var(--dc-cell, var(--dc-rule)); }
.cx-b b { font-weight: 400; color: var(--c-body-on); }
.cx-b small { font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; }
.cx .cx-b.in b { color: var(--c-body-on-emph); }
.cx .cx-b.in { box-shadow: inset 0 2px 0 var(--dc-accent); }

/* легенда - прямо над матрицей */
.dc-home-mx .cx .cx-key, .dc-home-mx .cx .cx-yrs { max-width: none; }
.cx-key { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0; font-size: 13px; line-height: 20px; color: var(--c-body-on); }
.cx-key > span { display: inline-flex; align-items: center; gap: 8px; }
.cx-k { width: 14px; height: 14px; box-sizing: border-box; }
.cx-k-all { background: var(--cx-red); box-shadow: inset 0 0 0 1px var(--cx-line); }
.cx-k-part { background: var(--cx-pale); box-shadow: inset 0 0 0 1px var(--cx-part-line); }
.cx-k-none { box-shadow: inset 0 0 0 1px var(--dc-muted); }
/* кнопка сортировки - последний пункт легенды: ставит ячейки в порядке легенды; бледная, пока порядок уже верный.
   Стоит у правого края ряда: место не зависит от числа пунктов легенды, и кнопка не читается подписью соседнего пункта.
   Размер один на всех экранах; на сенсорном экране область нажатия шире и выше самой кнопки: кнопка 32 px с рамкой, область 46 px */
.cx-key { align-items: center; }
.cx .cx-sort { position: relative; height: 32px; margin: 4px 0 4px auto; padding: 0 12px; border: 1px solid var(--dc-muted); border-radius: 4px; background: none; font: 15px/20px "Roboto-Regular", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--c-body-on-emph); cursor: pointer; }
.cx .cx-sort:hover { border-color: var(--c-body-on-emph); background: color-mix(in srgb, var(--c-body-on) 8%, transparent); }
.cx .cx-sort[aria-disabled=true] { border-color: var(--dc-cell, var(--dc-rule)); background: none; color: var(--dc-muted); cursor: default; }
@media (pointer: coarse) { .cx .cx-sort::before { content: ""; position: absolute; inset: -7px -5px; } }

/* ячейки: точки на постоянном месте в правом верхнем углу, текст их не обтекает - матрица не прыгает */
.dc .dc-mx-wrap .dc-mx-t, .dc .dc-mx-wrap .dc-mx-sub a { padding-right: 34px; }
.dc .dc-mx-wrap .cx-all { z-index: 1; background: var(--cx-red); border-color: var(--cx-line); color: #fff; }
.dc .dc-mx-wrap .cx-part { z-index: 1; background: var(--cx-pale); border-color: var(--cx-part-line); color: var(--c-body-on-emph); }
.dc .dc-mx-wrap .cx-none { color: var(--dc-muted); }
.dc-mx-wrap .cx-d { position: absolute; right: 8px; top: 12px; }
.dc-mx-sub .cx-d { top: 11px; }
.dc-mx-wrap .cx-all .cx-d { color: #fff; }
/* стрелка подтехник - цветом текста ячейки: на красной - белая, у техники без текста в базе - бледная */
.dc .dc-mx-row:has(> .cx-none) .dc-mx-tog { color: var(--dc-muted); }
.dc .dc-mx-row:has(> .cx-all) .dc-mx-tog { color: #fff; }
.dc .dc-mx-row:has(> .cx-all) .dc-mx-tog:hover { background: rgb(255 255 255 / .16); }
.dc-mx-wrap .cx-part .cx-d { color: var(--cx-dot); }
@media (max-width: 1023px) { .dc-mx-wrap .cx-d, .dc-mx-sub .cx-d { top: 50%; margin-top: -4px; } }

@media (max-width: 719px) {
  .cx .cx-p { gap: 8px; padding: 0 10px; }
  .cx .cx-b { padding: 6px 2px 0 4px; }
  .cx-b b { font-size: 12px; line-height: 16px; hyphens: manual; }
  /* браузер без словаря переносов (Chromium без словаря языка) рвёт длинное слово без дефиса, а не выпускает за колонку */
  .cx-b .cx-hy { hyphens: auto; overflow-wrap: anywhere; }
  .cx-b small { display: none; }
  .cx-key { gap: 4px 16px; }
}
@media (max-width: 389px) {
  .cx-peoples { gap: 6px; } .cx .cx-p { padding: 0 8px; }
}

/* у карты заголовок, как у матрицы */
.home-h { align-self: stretch; margin: 0 0 -8px; font: 500 22px/28px "Roboto-Medium", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--c-body-on-emph); }
/* вступление над картой: два абзаца, под ними экскурсия и почта; раздел карты отделён от него отступом */
.home-lead + .home-lead { margin-top: 12px; }
.home-text + .home-h { margin-top: 16px; }
@media (min-width: 1024px) { .home-text + .home-h { margin-top: 24px; } }
.cx-th { touch-action: none; cursor: grab; z-index: 1; }
.cx-th:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--c-body), 0 0 0 4px var(--dc-accent); }
.cx-th.on-top { z-index: 2; }
.cx-track { cursor: pointer; }
/* строка над шкалой: тексты не сжимаются и не обрезаются; не помещается - «карта на…» уходит строкой ниже.
   Отступы полями, не gap: WebKit (Safari и Chrome на iPhone) не считает gap в ширине строки и обрезал годы */
.cx-row { display: flex; flex-wrap: wrap; align-items: center; row-gap: 6px; }
.cx-row > * { flex: none; margin-right: 12px; }
.cx-row > :last-child { margin-right: 0; }

/* одна шкала лет: под картой, вместо ряда лет; подписей шагов нет */
.emp .emp-tabs, .emp .emp-more, .emp .emp-text { display: none !important; }
.cx-slot { margin-top: 16px; }
.cx.cx-tl { margin: 0; }
.cx-tl .cx-time, .cx-tl .cx-row { min-width: 0; }
/* ширина кнопки задана и свойством width: WebKit считает ширину строки по содержимому кнопки (значок 16 px), а не по flex-basis;
   без неё строка выходила на 16 px уже, и в прилипшей шкале левая ручка наезжала на последнюю цифру года */
.cx-tl .emp-play { flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid var(--dc-cell, var(--dc-rule)); border-radius: 4px; }
.cx-tl .cx-yrs { max-width: none; white-space: nowrap; }
/* даты карты - риски под линией, ниже ручек; дата, на которой стоит карта, - красная риска, та же метка у слов «карта на» */
.cx-tl .cx-track { height: 34px; }
.cx-m { position: absolute; top: 25px; width: 2px; height: 6px; margin-left: -1px; background: var(--dc-muted); border-radius: 1px; }
.cx-m::before { content: ""; position: absolute; inset: -6px -4px; }
.cx-now { position: absolute; top: 24px; width: 3px; height: 10px; margin-left: -1.5px; background: var(--cx-dot); border-radius: 1px; pointer-events: none; }
.cx-mapat { white-space: nowrap; font: 15px/20px "Roboto-Regular", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--dc-muted); font-variant-numeric: tabular-nums; }
.cx-mapat::before { content: ""; display: inline-block; width: 3px; height: 10px; margin-right: 6px; vertical-align: -1px; background: var(--cx-dot); border-radius: 1px; }
/* прилипшая шкала: во всю ширину окна под шапкой, пока читатель в матрице; полос в ней нет */
.cx-tl.cx-stuck { position: fixed; z-index: 15; left: 0; right: 0; box-sizing: border-box; padding-top: 8px; padding-bottom: 10px; background: var(--c-body); box-shadow: 0 1px 0 var(--dc-cell, var(--dc-rule)); }
.cx-tl.cx-stuck .cx-time { gap: 6px; }
.cx-tl.cx-stuck .cx-bands { display: none; }
@media (max-width: 719px) {
  .cx-tl .cx-yrs span { display: none; }
  .cx-tl.cx-stuck.cx-has-band .cx-yrs span { display: inline; font-size: 13px; }
  .cx-tl.cx-stuck.cx-has-band .cx-mapat { display: none; }
  .cx-tl.cx-stuck .emp-play { position: relative; height: 32px; flex-basis: 32px; width: 32px; }
  .cx-tl.cx-stuck .emp-play::after { content: ""; position: absolute; inset: -6px; }
}
.dc-mx-hd { top: calc(var(--cx-top, 52px) + var(--cx-stuck-h, 0px)) !important; }
/* телефон и низкое окно (телефон боком): над ячейками матрицы - как можно меньше.
   Прилипшая шкала - одной строкой: кнопка, годы, линия; «карта на» не нужна - карта за кадром.
   Шапка тактик - без лишних отступов, названия в две строки */
@media (max-width: 719px), (max-height: 500px) {
  .cx-tl.cx-stuck { padding-top: 6px; padding-bottom: 6px; }
  .cx-tl.cx-stuck .cx-time { display: flex; align-items: flex-start; gap: 0; }
  .cx-tl.cx-stuck .cx-row { flex: none; flex-wrap: nowrap; }
  .cx-tl.cx-stuck .cx-mapat { display: none; }
  /* годы и кнопка - во всю свою ширину, линия бегунка забирает остаток */
  .cx-tl.cx-stuck .cx-track { flex: 1 1 0; min-width: 96px; height: 30px; margin-top: 4px; }
  .cx-tl.cx-stuck .emp-play { position: relative; height: 32px; flex-basis: 32px; width: 32px; }
  .cx-tl.cx-stuck .emp-play::after { content: ""; position: absolute; inset: -6px; }
  .dc-mx-h { padding: 4px 4px 3px !important; min-height: 0 !important; }
  .dc-mx-name { line-height: 16px !important; }
}
/* телефон боком: шкала у нижнего края окна, пока на экране карта */
.cx-tl.cx-stuck.cx-bot { top: auto; bottom: 0; box-shadow: 0 -1px 0 var(--dc-cell, var(--dc-rule)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
/* узкий телефон: имени полосы в строке нет места - промежуток видно по ручкам и годам */
@media (max-width: 719px) { .cx-tl.cx-stuck.cx-has-band .cx-yrs span { display: none; } }
/* подпись полосы не шире своей колонки: иначе она растягивается по длинному слову и слово не переносится */
.cx-b b { min-width: 0; }
