/* ---- tree-table layout ---- */
:root {
  --tt-indent: 10px;
  --tt-line: #bba992;  /* #999; */
  --tt-leftm:  7px;
  --first-row-topm: 6px;
}
.tree-table {
  display: grid;
  /* tree_table.js narrows the first two tracks (fitColumns); this is the fallback until it runs */
  grid-template-columns: minmax(min-content, max-content) minmax(min-content, max-content) minmax(min-content, 1fr);
  font-size: 14px;
  line-height: 1.4;
  width: 100%;
  max-width: 100%;
}
.lg_form > .translit {
    font-size: 103%;
    padding-right: 4px;
}
.tree-row, .tree-head { display: contents; }

.tree-row > span {
  align-self: stretch;
  white-space: normal;          /* long meanings and language names wrap */
  font-size: 112%;
  min-height: 1.9em;
}

.tree-row[data-row="0"] > .tree-cell {
  margin-top: var(--first-row-topm);
}
.tree-row[data-row="0"] > .form,
.tree-row[data-row="0"] > .senses {
  padding-top: var(--first-row-topm);
}

.tree-cell { 
	display: flex; align-items: stretch; 	
}
.lg_form {
  padding-right:1em;
}

/* rails span the full (possibly wrapped) row height.
   Rails, connectors and toggles get their size from width, not flex-basis: Firefox leaves
   flex-basis out of a flex row's min-/max-content, so column 1 would be sized without the indents */
.rail { position: relative; 
	flex: none; width: var(--tt-indent); 
	margin-left: var(--tt-leftm); 
}

.rail.v::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: -12px;
  border-left: 1px solid var(--tt-line);
}

/* connector: horizontal stroke pinned to the FIRST line, not the cell middle,
   so wrapped rows keep the tree readable; the tee's vertical still runs full height */
.conn { position: relative; flex: none; width: var(--tt-indent); margin-left: var(--tt-leftm); }
.conn::before {
  content: ""; position: absolute; left: 0; top: -9px;
  border-left: 1px solid var(--tt-line);
}
.conn.tee::before { bottom: -12px; }
.conn.ell::before { height: 0.75em; }

/* horizontal stroke — non-borrowings */
.conn:not(.borrow)::after {
  content: ""; position: absolute; left: 0; right: -2px; top: 0.7em;
  border-top: 1px solid var(--tt-line);
  transform: scaleY(1.7);
}
/* borrowing: arrow instead of stroke */
.conn.borrow::after {
  /* content: "🡒";   🠆  */
  content: "🡒"; 
  position: absolute;
  left: 0px;
  top: 2px;                          /* tune: aligns the glyph with the 0.7em stroke line */
  font-size: 12px;
  line-height: 1.4;
  color: #807362; /* #bba992 */ /* #777 */
  transform: scale(1.2, 1);
  -webkit-transform: scale(1.2, 1);
}
.toggle, .tog-spacer {
  flex: none; width: 1em; text-align: center; font-size: 0.6em;
  color: var(--tt-line); 
  user-select: none;
  margin-left: -14px;
  z-index: 30;
}
.tog-spacer {
  align-self: flex-start;
  margin-top: 0.3em;
  background: white;
}
.toggle {
  cursor: pointer;
  position: relative;          /* anchor for the ::after descender */
  align-self: stretch;         /* full row height so the descender can reach the bottom */
  margin-top: 0.5em;          /* replaces margin-top: keeps the glyph on the first line */
  background: transparent;     /* full-height box must not blank out rails behind it */
}
.toggle:hover { color: #111; }

/* white backdrop only behind the glyph, not the full-height box */
.toggle::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1.7em;               /* one glyph line incl. the 0.3em padding */
  background: white;
  z-index: -3;
}

/* descender: bridges a wrapped parent row down to its first child.
   Zero-height on single-line rows (top ≥ row height). */
.toggle::after {
  content: "";
  position: absolute;
  top: 18px;                  /* 0.3em padding + one line; at font-size 0.7em ≈ first-line bottom */
  bottom: 0;
  left: 50%;                   /* the child's rail is directly below the glyph center */
  border-left: 1px solid var(--tt-line);
}

/* collapsed parent: no children below, no descender */
.tree-row.collapsed .toggle::after { display: none; }

/* the child's rail sits one slot (indent + leftm) right of the parent's connector */
/*.conn + .toggle::after { left: calc(var(--tt-indent) + var(--tt-leftm) + 5px); }
*.tree-cell > .toggle:first-child::after { left: calc(var(--tt-indent) + var(--tt-leftm) + 5px); } */
.conn + .toggle::after,
.tree-cell > .toggle:first-child::after {
  left: calc(var(--tt-indent) + var(--tt-leftm) + 4px);
		top: 16px;
		bottom: -12px;
}
/* root row: no connector; toggle sits at 3px, children's rail at leftm */
/*.tree-cell > .toggle:first-child::after { left: calc(var(--tt-leftm) - 3px); } */

/* language column: wraps, capped so very long p- names break instead of pushing columns */
.tree-table .lang { 
  margin-left: 9px; 
  /* max-width: 13em; */ 
  align-self: flex-start; 
  background-color: #ffffff54; 
  z-index: 40; 
  font-family: "Arial narrow", Calibri, "Segoe UI Semilight", sans-serif;
  font-weight: bold;
  padding-top: 3px;
  padding-right: 0.6em;
    /* font-style: normal; */
}
.tree-row.has-children > .tree-cell > .lg_name {
  margin-left: 16px; 
  text-indent: -6px;
}

.tree-cell .lg_name a { 
	color: #5e492d;
}
/* prevent extra descender for wrapped lines to run into language names
.tree-table .lang {
  padding-left: calc(var(--tt-indent) + var(--tt-leftm));
  text-indent: calc(6px - var(--tt-indent) - var(--tt-leftm));
  max-width: 13em;
} */
/* ---- the few colors tab3's CSS can't deliver to spans ---- */
.tree-head .th {
  background-color: #794906;
  color: #fff;
  padding: 4px 5px 3px 8px;
  font-weight: 600;
  font-variant: small-caps;
}
.tree-head .tf { background-color: #794906; padding: 0 4px 4px; }
.tree-head .tf input.tableFilter {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.tree-table .form {
  background-color: #cbfac5;     /* tab3's td:nth-child(2) green — td selector can't reach spans */
  padding: 0px 9px;
  cursor: pointer;
}
.tree-table .senses { padding: 0 8px 5px 10px; }

/* ---- reconstructed languages ---- */
.tree-row.proto { opacity: 0.55; filter: grayscale(0.8); }

/* ---- rows kept only because they have children while a filter is active ---- */
.tree-row.filtered-out { opacity: 0.4; }

/* ---- glossed-only toggle switch (in the title line) ---- */
.tree-switch {
  display: inline-block;
  position: relative;
  width: 34px; height: 18px;
  margin-left: 10px;
  vertical-align: text-bottom;
  cursor: pointer;
}
.tree-switch input { opacity: 0; width: 0; height: 0; }
.tree-slider {
  position: absolute; inset: 0;
  background-color: #ccc;
  border-radius: 9px;
  transition: background-color 0.15s;
}
.tree-slider::before {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  left: 2px; top: 2px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s;
}
.tree-switch input:checked + .tree-slider { background-color: #794906; }
.tree-switch input:checked + .tree-slider::before { transform: translateX(16px); }

details.tree-fold > summary.table_title {
	text-align: right;
    margin-right: 4%;
}
h3.table_title {
    font-size: 102%;
}
span.form.lg_form > a > img.icon {
    float: right;
    max-width: none;   /* .icon's fit-content shrinks not-yet-loaded icons, which skews the measured column widths */
}
/* a clicked form: its meanings stay highlighted on the graph until the next click (graph_script.js) */
.tree-table .form.pinned {
	background-color: var(--hilite);    /* see :root in tables.css */
	box-shadow: inset 0 0 0 1px var(--hilite-dark);
	border-radius: 6px;
	padding: 2px 5px;
}
/* the language clicked on the map, until the next click */
.tree-table .tree-row.highlighted > .form {
	background-color: #55aa4a;
    color: white;
}

@media(max-width:990px){
	.conn.borrow::after {
		content: "⇒"; 
		color: var(--tt-line); 
		left: 1px;
		right: 3px;
	}	
	.conn:not(.borrow)::after {
		left: 0px;
		right: 6px;
    }
	div.tree-table > .tree-row.has-children > .tree-cell > .lg_name {
	  margin-left: 22px; 
	  text-indent: -6px;
	}
	.rail {
		width: 2px;
		margin-left: 4px; 
	}
	.conn {
		width: 19px; 
		margin-left: 4px;
	}
	.conn + .toggle::after, .tree-cell > .toggle:first-child::after {
		left: 9px;
	}
	/* connector: horizontal stroke pinned to the FIRST line, not the cell middle,
	   so wrapped rows keep the tree readable; the tee's vertical still runs full height *//* 
	.conn { position: relative; flex: 0 0 var(--tt-indent); margin-left: var(--tt-leftm); } */
	.conn::before {
	  content: ""; position: absolute; left: 0; top: -9px;
	  border-left: 1px solid var(--tt-line);
	}
	.conn.tee::before { 
		bottom: -12px; 
	}
	.conn.ell::before { height: 0.75em; }
	.toggle:hover { 
		color: var(--tt-line); 
	}
	.toggle::before {
    left: 0px;
    right: 1px;
    }
	.toggle, .tog-spacer {	
		width: 8px;
		margin-left: -22px;
	}
	.tree-table .lang {
		margin-left: 13px;
	}
}
