/* Tag tree and roots. The tree sits on the plain page; root cards are the only filled surface,
   and everything inside them is text: no inner fills, no borders. */
.tag-tree-block { margin-bottom: 26px; }
.tag-tree-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.tag-tree-head .note { font-size: 0.86rem; }
.tt-clear { border: 0; background: none; padding: 0; color: var(--subtle); font-weight: 800; cursor: pointer; }
.tt-clear:hover { color: var(--ink); }
.tt-clear[hidden] { display: none; }

/* Tag tree, TraceCite style: quiet text on the plain page, no boxes, no guide lines. Each theme has a tone
   its tags and roots inherit; rest is the tone faded toward the page, hover and picked are the full tone. */
.tag-tree { display: grid; gap: 2px; }
.tag-tree ul { list-style: none; margin: 0; padding: 0; }
.tag-tree ul ul { margin-inline-start: 10px; padding-inline-start: 6px; }
.tt-group { --tone: var(--k-built); }
.tt-group.tone-water { --tone: var(--k-water); }
.tt-group.tone-land { --tone: var(--k-land); }
.tt-group.tone-life { --tone: hsla(96, 40%, 40%, 1); }
.tt-group.tone-people { --tone: var(--k-people); }
.tt-group.tone-settlement { --tone: hsla(30, 38%, 44%, 1); }
.tt-group.tone-built { --tone: var(--k-built); }
.tt-group.tone-qualifier { --tone: hsla(var(--hue-primary), 10%, 46%, 1); }
.tt-group.tone-facet { --tone: hsla(var(--hue-primary), 14%, 40%, 1); }
:root[data-theme="dark"] .tt-group.tone-facet { --tone: hsla(var(--hue-primary), 14%, 72%, 1); }
.tt-divider { margin: 14px 0 4px; color: var(--faded); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.tt-picked { color: var(--map-accent); font-size: 0.74rem; }
:root[data-theme="dark"] .tt-group.tone-life { --tone: hsla(96, 40%, 62%, 1); }
:root[data-theme="dark"] .tt-group.tone-settlement { --tone: hsla(30, 46%, 66%, 1); }
:root[data-theme="dark"] .tt-group.tone-qualifier { --tone: hsla(var(--hue-primary), 12%, 66%, 1); }

.tt-row {
  --rest: color-mix(in oklab, var(--tone) 58%, var(--bg, var(--paper)));
  --on: color-mix(in oklab, var(--tone) 90%, var(--ink));
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 24px;
  padding-bottom: 3px;
}
.tt-group > li > .tt-row { min-height: 30px; }
.tt-row::after {
  content: "";
  position: absolute;
  left: 20px; right: 0; bottom: 1px; height: 2px;
  background: linear-gradient(90deg, color-mix(in oklab, var(--tone) 40%, transparent) var(--share), hsla(var(--hue-primary), 20%, 50%, 0.07) var(--share));
}
.tt-row:has(.tt-label.is-active)::after { background: linear-gradient(90deg, var(--tone) var(--share), hsla(var(--hue-primary), 20%, 50%, 0.07) var(--share)); }
.tt-toggle { width: 20px; height: 22px; border: 0; padding: 0; background: none; color: var(--rest); cursor: pointer; display: grid; place-items: center; }
.tt-toggle svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; transition: transform 160ms ease; }
.tt-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.tt-toggle.is-leaf { cursor: default; }
.tt-label {
  border: 0; padding: 0; background: none; text-align: left; cursor: pointer;
  color: var(--rest); font: inherit; font-size: 0.86rem; font-weight: 700; line-height: 1.25;
  padding-inline-start: 0; text-indent: 0; transition: color 160ms ease;
}
.tt-group > li > .tt-row .tt-label { font-size: 0.92rem; font-weight: 800; }
.tt-count { color: var(--faded); font-size: 0.74rem; font-weight: 700; font-variant-numeric: tabular-nums; padding-left: 8px; }
.tt-row:has(.tt-label:is(:hover, :focus-visible, .is-active)) :is(.tt-label, .tt-toggle) { color: var(--on); }
.tt-row:has(.tt-label.is-active) .tt-count { color: var(--on); }
.tt-label:focus-visible { outline: none; text-decoration: none; }
.tag-tree li.is-root .tt-label i { font-style: italic; }
.tag-tree li.is-empty > .tt-row { opacity: 0.45; }

/* rail header and the picked line */
.rail-head { margin-bottom: 8px; }
.rail-title { margin: 0; color: var(--subtle); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.rail-note { display: grid; grid-template-rows: 0fr; margin: 0; color: var(--subtle); font-size: 0.78rem; line-height: 1.4; transition: grid-template-rows 220ms ease, margin 220ms ease; overflow: hidden; }
.rail-note > span { min-height: 0; }
.rail-head:hover .rail-note, .rail-head:focus-within .rail-note { grid-template-rows: 1fr; margin-top: 6px; }
.picked { margin: 0 0 10px; color: var(--map-accent); font-size: 0.82rem; font-weight: 800; line-height: 1.35; }
.picked[hidden] { display: none; }
.picked .tt-clear { color: var(--map-accent); font-size: 1rem; line-height: 1; }

/* roots inside the detail panel */
.detail-roots { display: grid; gap: 14px; }
.root-row { display: grid; gap: 4px; }
.root-row p, .root-card p, .root-card h3 { margin: 0; }
.root-word { font-family: "Raleway", ui-sans-serif, system-ui, sans-serif; font-weight: 800; color: var(--ink); }
.root-gloss { color: var(--muted); }
.root-meta { color: var(--subtle); font-size: 0.86rem; line-height: 1.4; }
.root-path, .root-more {
  border: 0;
  padding: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}
.root-path:hover, .root-more:hover { color: var(--map-accent); }
.conf-high { color: var(--k-land); font-weight: 800; }
.conf-medium { color: var(--k-water); font-weight: 800; }
.conf-low { color: var(--map-accent); font-weight: 800; }

/* roots across the region */
.roots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.root-card {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 10px 28px var(--shadow-soft);
}
.root-card h3 { font-size: 1.05rem; line-height: 1.3; }
.root-counts { color: var(--muted); font-size: 0.9rem; }
.root-counts b { color: var(--ink); }
.root-examples { color: var(--subtle); font-size: 0.88rem; line-height: 1.45; }
.root-card .text-link { min-height: 26px; padding: 0; background: none; align-items: flex-start; line-height: 1.35; font-size: 0.84rem; }
.root-card .text-link i { margin-top: 0.2em; }
.roots-caveat { max-width: 72ch; }

/* a name's tags on its card: plain text inside the filled card, separated by dots */
.card-tags { display: flex; flex-wrap: wrap; gap: 2px 0; margin-top: 2px; font-size: 0.78rem; font-weight: 800; color: var(--faded); }
.card-tags span + span::before { content: "·"; margin: 0 6px; color: var(--faded); }
/* tags on cards: coloured text by theme family, as in TraceCite */
.card-tags span { color: color-mix(in oklab, var(--tone, var(--k-built)) 70%, var(--paper)); }
.card-tags .tone-water { --tone: var(--k-water); }
.card-tags .tone-land, .card-tags .tone-life { --tone: var(--k-land); }
.card-tags .tone-people { --tone: var(--k-people); }
.card-tags .tone-settlement { --tone: hsla(30, 38%, 44%, 1); }
.card-tags .tone-qualifier { --tone: hsla(var(--hue-primary), 10%, 46%, 1); }
.card-tags .is-on { color: var(--map-accent); }


/* facets as category bar lists (TraceCite): value, a 6px track, count. Picked values take the accent,
   the rest fade while any is picked. Plain text and hairline tracks, no fills behind them. */
.facets { display: grid; gap: 4px; margin-top: 18px; }
.facet-group { display: grid; gap: 4px; }
.facet-title { display: flex; align-items: center; gap: 6px; border: 0; padding: 4px 0; background: none; color: var(--ink); font: inherit; font-size: 0.84rem; font-weight: 800; cursor: pointer; text-align: left; }
.facet-title svg { width: 10px; height: 10px; fill: none; stroke: var(--faded); stroke-width: 1.4; stroke-linecap: round; transition: transform 160ms ease; }
.facet-title[aria-expanded="true"] svg { transform: rotate(90deg); }
.facet-title b { color: var(--map-accent); font-size: 0.74rem; }
.facet-list { display: grid; gap: 1px; padding-left: 16px; }
.facet {
  display: grid; grid-template-columns: minmax(0, 1fr) 54px 42px; align-items: center; gap: 8px;
  border: 0; padding: 3px 0; background: none; text-align: left; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 700; transition: color 160ms ease, opacity 160ms ease;
}
.facet-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--faded) var(--w), hsla(var(--hue-primary), 20%, 50%, 0.1) var(--w)); }
.facet-count { color: var(--faded); font-size: 0.74rem; font-variant-numeric: tabular-nums; text-align: right; }
.facet:hover { color: var(--ink); }
.facet.is-active { color: var(--map-accent); }
.facet.is-active .facet-track { background: linear-gradient(90deg, var(--map-accent) var(--w), hsla(var(--hue-primary), 20%, 50%, 0.1) var(--w)); }
.facet.is-active .facet-count { color: var(--map-accent); }
.facet.is-faded { opacity: 0.45; }
.facet-caption { margin: 0 0 6px 16px; color: var(--faded); font-size: 0.72rem; line-height: 1.35; }
.facet-caption:empty { display: none; }
.facet-clear { border: 0; padding: 0; background: none; color: var(--map-accent); font: inherit; font-weight: 800; cursor: pointer; }

/* region cards: same card, ring instead of a filled dot, and the meaning marked as a guess */
.name-card.is-region .name-text::before { background: none; box-shadow: inset 0 0 0 2px var(--c, var(--k-none)); }
.name-card .region-type { color: var(--faded); font-size: 0.74rem; font-weight: 800; white-space: nowrap; }
.name-card .guess { color: var(--k-people); font-weight: 800; font-size: 0.78rem; margin-right: 4px; }
.grid-more { margin-top: 14px; }
