/* ==========================================================================
   NavTree styles.

   The caret is a CSS border triangle rather than a glyph. A glyph depends on
   a font that may fail to load, leaving the user with an invisible hit area;
   a border triangle always renders. Direction is a single class on a single
   element -- .is-open -- so it cannot disagree with the state that decides
   whether children are shown.
   ========================================================================== */

.nt-tree {
  --nt-indent: 14px;
  --nt-caret-size: 7px;
  --nt-row-h: 30px;
  --nt-hover: #1e293b;
  --nt-active: #22304a;

  font-size: 13px;
  line-height: var(--nt-row-h);
  user-select: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.nt-row {
  display: flex;
  align-items: center;
  min-height: var(--nt-row-h);
  padding-right: 8px;
  white-space: nowrap;
  cursor: default;
  color: var(--fg);
  border-left: 2px solid transparent;
}

.nt-row:hover { background: var(--nt-hover); }
.nt-row:focus-visible { outline: 2px solid var(--acc); outline-offset: -2px; }
.nt-row.is-selected {
  background: var(--nt-active);
  border-left-color: var(--acc);
}
.nt-row.is-selected .nt-label { color: #fff; font-weight: 600; }

/* -- caret -------------------------------------------------------------
   Two separate boxes, not one element rotated. A rotation is cheaper to
   animate but interpolates through a diagonal and briefly points at
   nothing; a discrete swap is never ambiguous, and "which way is it
   pointing" must be answerable at every instant. */
.nt-caret {
  flex: 0 0 auto;
  width: calc(var(--nt-caret-size) * 2);
  height: calc(var(--nt-caret-size) * 2);
  margin-right: 4px;
  position: relative;
  cursor: pointer;
  /* Widen the pointer target without widening the glyph: an 7px triangle is
     below the comfortable click size, and a miss here reads as "the nav is
     broken" rather than "you were 2px off". */
  background: transparent;
}

.nt-caret::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-style: solid;
  transition: transform 90ms ease;
}

/* collapsed -> points right */
.nt-caret::after {
  border-width: var(--nt-caret-size) 0 var(--nt-caret-size) var(--nt-caret-size);
  border-color: transparent transparent transparent var(--dim);
  transform: translate(-65%, -50%);
}

/* expanded -> points down */
.nt-caret.is-open::after {
  border-width: var(--nt-caret-size) var(--nt-caret-size) 0 var(--nt-caret-size);
  border-color: var(--acc2) transparent transparent transparent;
  transform: translate(-50%, -65%);
}

.nt-caret:hover::after { border-left-color: var(--acc2); }
.nt-caret.is-open:hover::after { border-top-color: var(--acc2); }

/* A leaf has nothing to expand, so it gets a spacer of the same width and
   the label stays aligned across the whole tree. */
.nt-caret.is-leaf {
  cursor: default;
  pointer-events: none;
}

.nt-label {
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

.nt-label:hover { color: var(--acc2); }

/* -- shell ------------------------------------------------------------- */
.nt-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.nt-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
}

.nt-head .nt-title {
  flex: 1 1 auto;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim2);
  font-weight: 600;
}

.nt-btn {
  font: inherit;
  font-size: 11px;
  line-height: 1;
  color: var(--dim);
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: 5px;
  padding: 5px 7px;
  cursor: pointer;
}
.nt-btn:hover { color: var(--fg); border-color: var(--acc); }

.nt-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 0; }

.nt-meta {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--dim2);
  line-height: 1.5;
}

.nt-layout { display: flex; align-items: stretch; min-height: 0; }
.nt-layout > .nt-panel { width: 268px; flex: 0 0 268px; }
.nt-layout > .nt-content { flex: 1 1 auto; min-width: 0; overflow-y: auto; }

@media (max-width: 900px) {
  .nt-layout { flex-direction: column; }
  .nt-layout > .nt-panel { width: 100%; flex: 0 0 auto; max-height: 40vh; }
}

/* -- module detail ----------------------------------------------------- */
.nt-detail { padding: 18px 22px; }
.nt-detail h3 { font-size: 17px; margin-bottom: 4px; }
.nt-detail .nt-path { color: var(--dim2); font-size: 12px; margin-bottom: 14px; }
.nt-detail .nt-sum { color: var(--dim); margin-bottom: 14px; max-width: 70ch; }
.nt-detail dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; font-size: 13px; }
.nt-detail dt { color: var(--dim2); }
.nt-detail dd { color: var(--fg); word-break: break-all; }
.nt-caps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.nt-cap {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--card2);
  border: 1px solid var(--line2);
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.nt-kids { margin-top: 16px; }
.nt-kids h4 { font-size: 12px; color: var(--dim2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.nt-kid {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
}
.nt-kid:hover { border-color: var(--acc); }
.nt-kid small { display: block; color: var(--dim2); font-size: 11px; margin-top: 2px; }
