/* The 科判 index (chuancheng/templates/wensi/kepan_index.html): every 本典
   with a tree, as cards on shelves. A long single-file list used to run to
   four screens; cards in a grid, a filter box and a strip of shelf links let
   a reader find one 本典 without scrolling past the other forty-five. Sits on
   catalogue_list.css and wensi_work.css for the crumbs and shelf heads. */

.kx-page {
  --kx-ink: #2d2822;
  --kx-muted: #7b7363;
  --kx-line: #e6e0cc;
  --kx-paper: #fffdf8;
  --kx-maroon: #4e0d0d;
  --kx-green: #4a7c59;
  color: var(--kx-ink);
  max-width: 1100px;
  padding-bottom: 40px;
}

/* Cards and shelves are flex and grid; keep the filter's [hidden] winning. */
.kx-page [hidden] {
  display: none !important;
}

.kx-head {
  margin: 4px 0 18px;
}

.kx-head__title {
  color: var(--kx-maroon);
  font-size: 1.7em;
  margin: 0 0 6px;
}

.kx-head__lede {
  color: var(--kx-muted);
  margin: 0 0 10px;
}

.kx-head__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.kx-head__stats span {
  background-color: #f3efe2;
  border-radius: 999px;
  color: var(--kx-muted);
  font-size: 0.88em;
  padding: 3px 12px;
}

.kx-head__stats b {
  color: var(--kx-maroon);
}

/* Search and shelf links, one line under the head. Not sticky: a search
   leaves a few cards at the top of the page, and the site's back-to-top
   button covers the rest. */
.kx-bar {
  border-bottom: 1px solid #d8d4c8;
  margin: 0 0 22px;
  padding: 0 0 14px;
}

.kx-search {
  align-items: center;
  background-color: #fff;
  border: 1px solid #d8ceb0;
  border-radius: 10px;
  display: flex;
  max-width: 360px;
  gap: 8px;
  padding: 0 12px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.kx-search:focus-within {
  border-color: var(--kx-green);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.kx-search__icon {
  fill: none;
  flex: none;
  height: 16px;
  stroke: var(--kx-muted);
  stroke-linecap: round;
  stroke-width: 2;
  width: 16px;
}

.kx-search input {
  background: transparent;
  border: 0;
  color: inherit;
  flex: 1;
  font-size: 1em;
  min-width: 0;
  outline: none;
  padding: 7px 0;
}

.kx-jump {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* 专业 on one line, 法类 on the next. */
.kx-jump__row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kx-jump__row::-webkit-scrollbar {
  display: none;
}

.kx-jump__lead {
  color: var(--kx-muted);
  flex: none;
  font-size: 0.8em;
  margin-right: 4px;
  min-width: 2.4em;
}

.kx-jump__chip {
  background-color: rgba(255, 255, 255, 0.6);
  border: 1px solid #d8d4c8;
  border-radius: 999px;
  color: var(--kx-ink);
  flex: none;
  font-size: 0.84em;
  padding: 2px 10px;
  text-decoration: none;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.kx-jump__chip:hover,
.kx-jump__chip:focus-visible {
  border-color: var(--kx-green);
  color: var(--kx-green);
  text-decoration: none;
}

.kx-jump__chip.is-empty {
  opacity: 0.35;
  pointer-events: none;
}

/* On a phone the shelves are one swipeable row, faded at the edge so it reads
   as more, not five lines of buttons. */
@media (max-width: 640px) {
  .kx-search {
    max-width: none;
  }

  .kx-jump__row {
    flex-wrap: nowrap;
    margin-right: -14px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    overflow-x: auto;
    padding: 2px 28px 2px 0;
    scrollbar-width: none;
  }
}

.kx-group + .kx-group {
  margin-top: 36px;
}

.kx-group__title {
  color: var(--kx-muted);
  font-size: 0.95em;
  font-weight: normal;
  letter-spacing: 0.08em;
  margin: 0 0 14px;
}

.kx-group__title small {
  font-size: 0.88em;
  letter-spacing: 0;
  margin-left: 8px;
  opacity: 0.8;
}

.kx-shelf {
  margin-bottom: 24px;
  scroll-margin-top: 70px;
}

/* Wide screens: the shelf name sits in its own column beside its cards, so a
   shelf of one 本典 costs one card's height, not a heading's as well. */
@media (min-width: 900px) {
  .kx-shelf {
    display: grid;
    gap: 0 20px;
    grid-template-columns: 9em 1fr;
  }

  .kx-shelf__head.wk-shelf__head {
    align-self: start;
    border-bottom: 0;
    border-top: 2px solid var(--kx-maroon);
    font-size: 1.05em;
    margin: 0;
    padding: 10px 0 0;
  }
}

.kx-shelf__head {
  border-bottom-width: 1px;
  margin-bottom: 12px;
}

.kx-shelf__head a {
  color: inherit;
}

.kx-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

/* One card per 本典; the whole card opens its own 科判, the other trees keep
   their own links above that. */
.kx-card {
  background-color: var(--kx-paper);
  border: 1px solid var(--kx-line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(60, 40, 10, 0.04);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 12px;
  position: relative;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.15s;
}

.kx-card:hover {
  border-color: #d8ceb0;
  box-shadow: 0 6px 18px rgba(60, 40, 10, 0.08);
  transform: translateY(-1px);
}

.kx-card:focus-within {
  border-color: var(--kx-green);
}

.kx-card__title {
  color: var(--kx-maroon);
  font-size: 1.08em;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}

.kx-card__title::after {
  border-radius: 12px;
  content: "";
  inset: 0;
  position: absolute;
}

.kx-card__title:hover,
.kx-card__title:focus {
  color: var(--kx-maroon);
  text-decoration: none;
}

.kx-card__title:focus-visible {
  outline: none;
}

.kx-card__sub {
  color: var(--kx-ink);
  font-size: 0.9em;
}

.kx-card__meta {
  color: var(--kx-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.84em;
  gap: 2px 0;
  margin: 0;
}

.kx-card__meta > span + span::before {
  content: "·";
  margin: 0 6px;
  opacity: 0.7;
}

.kx-card__where {
  color: var(--kx-muted);
  font-size: 0.84em;
  margin: 0;
}

.kx-card__more {
  border-top: 1px dashed var(--kx-line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  margin: 8px 0 0;
  padding: 10px 0 0;
}

.kx-card__more li {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kx-card__more a {
  color: var(--kx-green);
  font-size: 0.92em;
  position: relative;
  text-decoration: none;
  z-index: 1;
}

.kx-card__more a:hover {
  text-decoration: underline;
}

.kx-role {
  background-color: #e5ece4;
  border-radius: 4px;
  color: var(--kx-green);
  font-size: 0.78em;
  margin-right: 6px;
  padding: 0 5px;
  vertical-align: 1px;
}

.kx-role--peer {
  background-color: #f0ebdc;
  color: #7a6230;
}

.kx-card mark {
  background-color: var(--highlight-search);
  border-radius: 2px;
  color: inherit;
  padding: 0 1px;
}

.kx-none {
  color: var(--kx-muted);
  padding: 40px 0;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .kx-card,
  .kx-card:hover {
    transform: none;
    transition: none;
  }
}
