/* Guru-Parampara Chart — vertical indented collapsible tree.
   Deliberately NOT a side-by-side org-chart: the real data is a chain up to
   25 generations deep with branches as wide as 8, so a horizontal layout
   would force thousands of pixels of width. An indented outline (like a
   file browser) scales to any depth in one column and needs no horizontal
   scrolling, even on a phone. */

.ptree-page { padding-bottom: 5rem; }

/* ---------- toolbar & legend ---------- */
.ptree-toolbar {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
  margin: 1rem 0;
}
.ptree-search-wrap {
  position: relative; flex: 1 1 52px; min-width: 220px;
  display: flex; align-items: center; gap: .55rem;
  background: #fff; border: 1px solid var(--ac-line); border-radius: 999px;
  padding: .6rem 1rem; box-shadow: var(--ac-shadow);
}
.ptree-search-wrap i { color: var(--ac-muted); }
.ptree-search { border: none; outline: none; flex: 1; font-size: .92rem; background: transparent; color: var(--ac-ink); }
.ptree-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--ac-line); border-radius: var(--ac-radius);
  box-shadow: var(--ac-shadow); max-height: 320px; overflow-y: auto;
}
.ptree-search-result {
  display: block; padding: .6rem .9rem; text-decoration: none; color: var(--ac-ink);
  font-size: .88rem; border-bottom: 1px solid var(--ac-line); cursor: pointer;
}
.ptree-search-result:last-child { border-bottom: none; }
.ptree-search-result:hover, .ptree-search-result.is-active { background: var(--ac-cream); }
.ptree-search-result small { display: block; color: var(--ac-muted); font-size: .78rem; }

.ptree-actions { display: flex; gap: .5rem; }
.ptree-btn {
  background: #fff; border: 1px solid var(--ac-line); color: var(--ac-dark);
  font-size: .82rem; font-weight: 600; padding: .55rem 1rem; border-radius: 999px;
  cursor: pointer; box-shadow: var(--ac-shadow); transition: transform .15s ease;
}
.ptree-btn:hover { transform: translateY(-1px); }

.ptree-legend {
  display: flex; flex-wrap: wrap; gap: .5rem 1.3rem; margin: .3rem 0 1.4rem;
  font-size: .78rem; color: var(--ac-muted);
}
.ptree-legend-item { display: inline-flex; align-items: center; gap: .45rem; }
.ptree-legend-item--note { flex-basis: 100%; font-style: italic; color: #a99f8c; }
.ptree-legend-swatch { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--ac-dark); }
.ptree-legend-swatch--dashed { border-top-style: dashed; border-top-color: #b8873a; }
.ptree-legend-swatch--root {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid #b8873a; color: #b8873a;
  display: inline-flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 800;
}
.ptree-legend-swatch--banner { width: 22px; height: 2px; background: repeating-linear-gradient(90deg, var(--ac-accent) 0 4px, transparent 4px 8px); }

/* ---------- tree structure ---------- */
/* Wide/deep branches scroll sideways inside their own box rather than ever
   pushing the page itself into horizontal scroll — same pattern this site
   already uses for wide tables (.ach-table-wrap). */
.ptree-forest {
  display: flex; flex-direction: column; gap: 2.2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.ptree, .ptree-children { list-style: none; margin: 0; padding: 0; }
.ptree-root { padding-left: 0; min-width: max-content; }
.ptree-children {
  position: relative;
  margin-left: 1.35rem;
  padding-left: 1.15rem;
  border-left: 2px solid var(--ac-line);
  transition: border-color .15s ease, border-width .15s ease;
}

/* Invisible hover/tap strip laid over the vertical guide line itself — deep,
   branchy stretches of the tree otherwise make it hard to tell which line
   belongs to which ancestor. Hovering (or tapping/focusing on touch and
   keyboard) highlights this one line and the node it descends from. */
.ptree-guide-hit {
  position: absolute; left: -1.15rem; top: 0; bottom: 0; width: 18px;
  cursor: pointer; outline: none;
}
/* Muted, depth-cycled guide-line colors — a passive cue so adjacent lines at
   different nesting depths stay distinguishable at a glance, not only on
   hover. Deliberately kept low-saturation and inside the site's existing
   warm palette rather than introducing new bright hues. */
.ptree-depth-0 { border-left-color: var(--ac-line); }
.ptree-depth-1 { border-left-color: #a9c9c4; }
.ptree-depth-2 { border-left-color: #d9c08c; }
.ptree-depth-3 { border-left-color: #d3a68c; }

.ptree-children.is-traced {
  border-left-color: var(--ac-accent);
  border-left-width: 3px;
}
.ptree-node.is-trace-source > .ptree-card-row > .ptree-card {
  box-shadow: 0 0 0 3px var(--ac-accent), var(--ac-shadow);
}
.ptree-node { position: relative; margin: .5rem 0; }
.ptree-children > .ptree-node:last-child { padding-bottom: 0; }

/* elbow connector: joins each node to the vertical guide line on its left */
.ptree-node::before {
  content: ''; position: absolute; left: -1.15rem; top: 1.15rem; width: 1.15rem;
  border-top: 2px solid var(--ac-line);
}
.ptree-root > .ptree-node::before { display: none; }
.ptree-node.is-disputed-edge::before { border-top-style: dashed; border-top-color: #b8873a; }
.ptree-node.is-origin::before { display: none; }

.ptree-card-row { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }

.ptree-toggle {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 1.5px solid var(--ac-dark); color: var(--ac-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; cursor: pointer; transition: background .15s ease, color .15s ease;
}
.ptree-toggle:hover { background: var(--ac-dark); color: #fff; }
.ptree-toggle--leaf { border: none; background: none; width: 8px; }

.ptree-card {
  display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ac-ink);
  background: #fff; border: 1px solid var(--ac-line); border-radius: 999px;
  padding: .35rem .95rem .35rem .35rem; box-shadow: var(--ac-shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.ptree-card:hover { transform: translateY(-1px); border-color: var(--ac-accent); }

.ptree-avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  background: var(--ac-cream-2); display: flex; align-items: center; justify-content: center;
}
.ptree-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ptree-avatar--placeholder { color: var(--ac-accent); font-size: 1.1rem; }

.ptree-text { display: flex; flex-direction: column; line-height: 1.25; }
.ptree-name { font-weight: 700; font-size: .92rem; color: var(--ac-dark); }
.ptree-epithet { font-size: .76rem; color: var(--ac-muted); }
.ptree-era { font-size: .72rem; color: #a99f8c; }

.ptree-count {
  font-size: .74rem; color: var(--ac-muted); background: var(--ac-cream);
  border-radius: 999px; padding: .2rem .6rem; white-space: nowrap;
}

/* ---------- gap / disputed markers ---------- */
.ptree-gap-marker {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #b8873a; color: #b8873a; background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800; cursor: help;
}
.ptree-root-note {
  margin: .35rem 0 .1rem 2.9rem; font-size: .78rem; color: var(--ac-muted);
  display: flex; align-items: flex-start; gap: .5rem; max-width: 42rem;
}
.ptree-root-note .ptree-gap-marker { margin-top: .05rem; }
.ptree-root-note-text { line-height: 1.5; }

/* ---------- sampradaya banners ---------- */
.ptree-banner-wrap { list-style: none; margin: 1.1rem 0 .6rem; }
.ptree-banner {
  display: flex; align-items: center; gap: .8rem; cursor: help;
}
.ptree-banner-line { flex: 1; height: 0; border-top: 2px dashed var(--ac-accent); }
.ptree-banner-label {
  flex: none; display: inline-flex; align-items: center; gap: .5rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ac-accent); background: var(--ac-cream-2); border-radius: 999px; padding: .4rem 1rem;
}

/* ---------- tooltip ---------- */
.ptree-tooltip {
  position: fixed; z-index: 100; max-width: 320px; background: var(--ac-dark); color: var(--ac-cream);
  font-size: .82rem; line-height: 1.55; padding: .7rem .9rem; border-radius: 10px;
  box-shadow: var(--ac-shadow); pointer-events: none;
}

/* ---------- search highlight ---------- */
.ptree-node.is-search-match > .ptree-card-row > .ptree-card { outline: 2px solid var(--ac-accent); outline-offset: 2px; }

/* ---------- mobile ---------- */
@media (max-width: 560px) {
  /* Tighter per-level indentation so a typical branch fits without any
     scrolling at all; .ptree-forest's overflow-x:auto (above) is the safety
     net for genuinely deep chains (this tree runs up to ~19 visible levels
     by default), so the page itself never has to grow sideways. */
  .ptree-children { margin-left: .5rem; padding-left: .5rem; }
  .ptree-node::before { left: -.5rem; width: .5rem; }
  .ptree-guide-hit { left: -.5rem; width: 12px; }
  .ptree-card { padding-right: .6rem; gap: .4rem; }
  .ptree-avatar { width: 32px; height: 32px; }
  .ptree-name { font-size: .85rem; }
  .ptree-epithet, .ptree-era { display: none; }
  .ptree-count { display: none; }
  .ptree-root-note { margin-left: 1.4rem; }
  .ptree-toolbar { flex-direction: column; align-items: stretch; }
}
