/* Каталог «Техкарты по предметам и классам» и посадочные страницы предмета,
   класса и пары предмет×класс. Карточки, ссылки-плитки и строки — из
   cabinet.css; здесь только раскладка строк каталога и списков. */

/* Строка предмета: название слева, номера классов справа */
.tk-subject-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.tk-subject-row__grades {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tk-subject-row__note {
  text-align: right;
  text-wrap: pretty;
}

/* Строка с подписью вместо номеров: название в одну строку, переносится подпись */
.tk-subject-row--note > .tk-strong {
  white-space: nowrap;
}

/* Вступление посадочной страницы: лид, кнопки, подпись */
.tk-intro {
  display: grid;
  gap: 16px;
  justify-items: start;
}

/* Темы уроков: название + кнопка «создать по этой теме» */
.tk-topics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.tk-topic {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  font: var(--t-small);
  color: var(--ink);
}

.tk-topic__title {
  flex: 1 1 260px;
  min-width: 0;
  text-wrap: pretty;
}

/* Список учебников */
.tk-umk {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.tk-umk li {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font: var(--t-small);
}

/* Остальные этапы — в <details>, кнопка-summary исчезает, когда таблица раскрыта.
   min-width: 0 — раскрытая таблица листается внутри своей прокрутки и не расширяет сетку .tk-stack
   вместе со страницей (#138) */
.tk-details {
  min-width: 0;
}

.tk-details summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
}

.tk-details summary::-webkit-details-marker {
  display: none;
}

.tk-details[open] summary {
  display: none;
}

@media (max-width: 1023px) {
  .tk-subject-row {
    flex-wrap: wrap;
  }

  .tk-subject-row__grades {
    justify-content: flex-start;
  }

  .tk-subject-row__note {
    text-align: left;
  }
}

/* ---------- Хаб «Техкарты по предметам» (seo/hub.html) */
.cat-section {
  display: grid;
  gap: 16px;
}

/* Плитки «Чаще всего ищут»: предмет и класс, справа шеврон в голубом кружке */
.cat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.cat-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px 14px 20px;
  border-radius: var(--r-16);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  text-decoration: none;
  transition: box-shadow var(--duration-fast) var(--ease-standard);
}

.cat-tile:hover {
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-card-hover);
}

.cat-tile__text {
  flex: 1;
  min-width: 0;
  display: grid;
}

.cat-tile__title {
  font: 600 16px/24px var(--font-sans);
}

.cat-tile__sub {
  font: var(--t-small);
  color: var(--text-2);
}

.cat-tile__go {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-tint);
  color: var(--link);
  transition:
    background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.cat-tile:hover .cat-tile__go {
  background: var(--primary);
  color: var(--on-primary);
}

/* Таблица «предмет × класс»: над номерами классов — ступени школы со
   скобкой-линией, строка подсвечивается при наведении, чтобы глаз не
   терял предмет; пустая ячейка — точка */
.cat-matrix-card {
  gap: 20px;
  padding: 32px;
}

/* fixed — одиннадцать колонок классов равной ширины, предмету треть */
.cat-matrix {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.cat-matrix__subject-col {
  width: 30%;
}

.cat-matrix__stages th {
  position: relative;
  padding: 0 4px 10px;
  font: 500 14px/20px var(--font-sans);
  color: var(--text-2);
  text-align: center;
  white-space: nowrap;
}

.cat-matrix__stages th::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 4px;
  height: 2px;
  border-radius: 1px;
  background: var(--line-strong);
}

.cat-matrix__grades th {
  padding: 4px 2px 12px;
  border-bottom: 1px solid var(--line);
  font: 600 14px/20px var(--font-sans);
  color: var(--text-2);
  text-align: center;
}

.cat-matrix__grades th:first-child {
  padding-left: 12px;
  text-align: left;
}

.cat-matrix tbody th {
  padding: 6px 12px;
  border-radius: var(--r-8) 0 0 var(--r-8);
  font: 500 16px/24px var(--font-sans);
  text-align: left;
}

.cat-matrix tbody th a {
  color: var(--ink);
  text-decoration: none;
}

/* Отдельные ссылки («Все темы и пример…», предмет в таблице) — цель нажатия не ниже 24 px: отступ у строчной
   ссылки не сдвигает строки и не меняет вида (techkarta-back#149). Только ссылка одна в абзаце: в строке из
   нескольких ссылок через « · » при переносе отступы соседних строк перекрывались бы */
.tk-small > a:only-child,
.cat-matrix tbody th a {
  padding-block: 4px;
}

.cat-matrix tbody th a:hover {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.cat-matrix td {
  padding: 4px 2px;
  text-align: center;
}

.cat-matrix td:last-child {
  border-radius: 0 var(--r-8) var(--r-8) 0;
}

.cat-matrix tbody tr:hover > * {
  background: var(--surface-2);
}

.cat-cell {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-8);
  background: var(--primary-tint);
  box-shadow: inset 0 0 0 1px var(--primary-edge);
  color: var(--link);
  font: 600 14px/20px var(--font-sans);
  text-decoration: none;
  vertical-align: middle;
  transition:
    background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

a.cat-cell:hover {
  background: var(--primary);
  box-shadow: none;
  color: var(--on-primary);
  text-decoration: none;
}

.cat-cell--none {
  background: none;
  box-shadow: none;
}

.cat-cell--none::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--line-strong);
}

/* Плитки классов: крупный номер, под ним «класс»; на широком экране все 11 в ряд */
.cat-grades {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 12px;
}

.cat-grade {
  display: grid;
  justify-items: center;
  padding: 14px 4px;
  border-radius: var(--r-16);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  text-decoration: none;
  transition: box-shadow var(--duration-fast) var(--ease-standard);
}

.cat-grade:hover {
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-card-hover);
}

.cat-grade__num {
  font: 700 28px/36px var(--font-sans);
  font-variant-numeric: tabular-nums;
  color: var(--link);
}

.cat-grade__label {
  font: var(--t-small);
  color: var(--text-2);
}

@media (min-width: 1280px) {
  .cat-grades {
    grid-template-columns: repeat(11, minmax(0, 1fr));
  }
}

/* Призыв в конце — голубая плашка с картинкой техкарты */
.cat-cta {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 28px 32px;
  border: 1px solid var(--primary-edge);
  border-radius: var(--r-16);
  background: var(--band);
}

.cat-cta__art {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  color: var(--link);
}

.cat-cta__text {
  flex: 1;
  margin: 0;
  font: 500 18px/28px var(--font-sans);
  color: var(--ink);
  text-wrap: pretty;
}

.cat-cta .tk-btn {
  flex-shrink: 0;
}

/* Телефон: популярное — в две колонки без шеврона; строки таблицы —
   карточки «предмет и номера классов», пустых ячеек нет */
@media (max-width: 767px) {
  .cat-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .cat-tile {
    min-height: 64px;
    padding: 12px 14px;
  }

  .cat-tile__go {
    display: none;
  }

  .cat-matrix-card {
    padding: 20px;
  }

  .cat-matrix,
  .cat-matrix tbody,
  .cat-matrix tr,
  .cat-matrix th,
  .cat-matrix td {
    display: block;
  }

  .cat-matrix thead {
    display: none;
  }

  .cat-matrix tbody tr {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
  }

  .cat-matrix tbody tr + tr {
    border-top: 1px solid var(--line);
  }

  .cat-matrix tbody tr:hover > * {
    background: none;
  }

  .cat-matrix tbody th {
    flex: 1 0 100%;
    padding: 0;
  }

  .cat-matrix td {
    padding: 0;
  }

  .cat-matrix td.is-empty {
    display: none;
  }

  .cat-cta {
    flex-direction: column;
    align-items: stretch;
    padding: 24px 20px;
  }

  .cat-cta__art {
    width: 48px;
    height: 48px;
  }
}
