/* Static article directories. Shared shell, typography and width stay unchanged. */
.directory-content {
  min-width: 0;
}

.directory-overview {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 22px;
  color: #777d89;
  font-size: 13px;
  line-height: 1.6;
}

.directory-overview strong {
  color: #191c26;
  font-weight: 650;
}

.directory-overview > span {
  color: #b4a9c8;
}

.directory-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 30px;
}

.directory-index a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 13px;
  border: 1px solid #ddd6e9;
  border-radius: 12px;
  background: #ffffff7a;
  color: #665277;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.directory-index a:hover {
  background: #fff;
  border-color: #b99ade;
  color: #7143cb;
}

.directory-index a > span {
  flex: none;
  color: #9d87b1;
  font-size: 10px;
}

/* Native details expose every root on initial load; names navigate separately from the toggle. */
.tree-map {
  display: grid;
  gap: 18px;
}

.tree-root {
  min-width: 0;
  border: 1px solid #fff;
  border-radius: 26px;
  background: #fff;
  overflow: hidden;
}

.tree-root > summary {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 15px;
  padding: 28px 30px;
  cursor: default;
  list-style: none;
  /* This is a toggle, not editable text. Keep native focus and keyboard activation. */
  -webkit-user-select: none;
  user-select: none;
  caret-color: transparent;
}

.tree-root > summary::-webkit-details-marker {
  display: none;
}

.tree-root > summary:hover {
  background: #faf8fe;
}

.tree-root-marker {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: #905bff;
  box-shadow: 0 0 0 5px #905bff0e;
}

.tree-root-title {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -.5px;
  overflow-wrap: anywhere;
}

.tree-root-count {
  min-width: 34px;
  padding: 3px 8px;
  border-radius: 8px;
  background: #f1ebfd;
  color: #8155bd;
  font: 400 11px/20px "IBM Plex Mono", monospace;
  text-align: center;
}

.directory-chevron {
  justify-self: center;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid #8d73b2;
  border-bottom: 1.5px solid #8d73b2;
  transform: rotate(-45deg);
}

.tree-root[open] > summary .directory-chevron {
  transform: rotate(45deg) translate(-2px, -2px);
}

.tree-root > .tree-children {
  margin: 0 30px 30px 36px;
}

.tree-children {
  list-style: none;
  margin: 10px 0 8px 5px;
  padding: 0 0 0 26px;
  border-left: 1px solid #e6deef;
}

.tree-node {
  position: relative;
  min-width: 0;
  padding: 7px 0;
}

.tree-node::before {
  position: absolute;
  top: 19px;
  left: -26px;
  width: 17px;
  height: 1px;
  background: #e6deef;
  content: "";
}

.tree-node-label {
  display: block;
  color: #68707e;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.tree-node--branch > .tree-node-label {
  color: #30283c;
  font-size: 15px;
  font-weight: 600;
}

/* Keep the original resting colors; only interactive states underline the name. */
.tree-root-title,.tree-node-label { text-decoration: none; text-underline-offset: 4px; cursor: pointer; }
.tree-root-title { color: inherit; }
.tree-map a:is(:hover,:focus-visible) { color: #7542c8; text-decoration: underline; }
.tree-map a:active { color: #6c3cdd; text-decoration: underline; }
.tree-map a:focus-visible { outline: 2px solid #905bff; outline-offset: 3px; border-radius: 2px; }
.tree-toggle {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  caret-color: transparent;
}
.tree-toggle:hover { background: #905bff12; }
.tree-toggle:active { background: #905bff22; }
.tree-toggle:focus-visible { outline: 2px solid #905bff; outline-offset: 2px; }
.tree-toggle .directory-chevron { pointer-events: none; }

/* Alphabetical catalogue; only existing selected-article memberships expand. */
.tag-alphabet {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
}

.tag-alphabet a {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #ddd6e9;
  border-radius: 10px;
  background: #ffffff80;
  color: #795996;
  font-size: 14px;
}

.tag-alphabet a:hover {
  color: #fff;
  background: #8450eb;
  border-color: #8450eb;
}

.tag-catalog-note {
  max-width: 720px;
  margin-bottom: 27px;
  color: #8c8198;
  font-size: 12px;
  line-height: 1.65;
}

.tag-catalog {
  padding: 8px 30px;
  border: 1px solid #fff;
  border-radius: 26px;
  background: #fff;
}

.tag-letter-group {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 30px;
  padding: 25px 0;
}

.tag-letter-group + .tag-letter-group {
  border-top: 1px solid #eeeaf4;
}

.tag-letter-group h2 {
  color: #a17ccf;
  font-size: 32px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: -.5px;
}

.tag-letter-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 8px 26px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag-letter-list > li {
  min-width: 0;
}

.tag-entry-static,
.tag-entry > summary {
  padding: 10px 0;
  color: #525966;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.tag-entry-static {
  display: block;
}

.tag-entry > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 12px;
  align-items: center;
  gap: 10px;
  list-style: none;
  cursor: pointer;
  color: #7143b1;
}

.tag-entry > summary::-webkit-details-marker {
  display: none;
}

.tag-entry > summary:hover {
  color: #985ffa;
}

.tag-entry-count {
  padding: 1px 6px;
  min-width: 24px;
  text-align: center;
  background: #f2edfb;
  border-radius: 6px;
  color: #9a78ba;
  font: 400 10px/19px "IBM Plex Mono", monospace;
}

.tag-entry[open] .directory-chevron {
  transform: rotate(45deg) translate(-2px, -2px);
}

.tag-entry-articles {
  list-style: none;
  margin: 2px 0 8px;
  padding: 0 0 0 12px;
  border-left: 1px solid #dfd2f0;
}

.tag-entry-articles li {
  color: #7c7584;
  font-size: 12px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.tag-entry-articles li + li {
  margin-top: 10px;
}

@media(max-width:800px) {
  .tree-root > summary {
    padding: 24px;
  }

  .tree-root > .tree-children {
    margin-left: 30px;
    margin-right: 24px;
    margin-bottom: 24px;
  }

  .tag-letter-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media(max-width:520px) {
  .directory-overview {
    gap: 6px 10px;
    font-size: 12px;
  }

  .directory-index {
    gap: 7px;
    margin-bottom: 24px;
  }

  .directory-index a {
    padding: 9px 11px;
    font-size: 11px;
  }

  .tree-root {
    border-radius: 22px;
  }

  .tree-root > summary {
    grid-template-columns: 10px minmax(0, 1fr) auto 12px;
    gap: 10px;
    padding: 21px 18px;
  }

  .tree-root-marker {
    width: 9px;
    height: 9px;
    border-radius: 3px;
  }

  .tree-root-title {
    font-size: 18px;
    line-height: 1.45;
    letter-spacing: -.3px;
  }

  .tree-root-count {
    min-width: 27px;
    padding: 1px 5px;
    font-size: 9px;
  }

  .tree-root > .tree-children {
    margin: 0 17px 22px 22px;
  }

  .tree-children {
    padding-left: 15px;
    margin-left: 2px;
  }

  .tree-node::before {
    left: -15px;
    width: 9px;
    top: 18px;
  }

  .tree-node-label {
    font-size: 12px;
    line-height: 1.65;
  }

  .tree-node--branch > .tree-node-label {
    font-size: 13px;
  }

  .tag-catalog {
    padding: 3px 18px;
    border-radius: 22px;
  }

  .tag-letter-group {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 14px;
    padding: 20px 0;
  }

  .tag-letter-group h2 {
    font-size: 27px;
  }

  .tag-entry-static,
  .tag-entry > summary {
    font-size: 13px;
  }

  .tag-alphabet a {
    width: 33px;
    height: 33px;
    font-size: 12px;
  }
}

@media(prefers-reduced-motion:reduce) {
  .directory-index a {
    transition: none;
  }
}
