/* ============================================================
   Transform Health — Taxonomy Explorer
   All selectors are namespaced under .th-taxonomy so the
   component can be dropped into a WordPress page without
   leaking styles.
   ============================================================ */

.th-taxonomy-shell {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #10233a;
  background: #ffffff;
  line-height: 1.5;
}

.th-taxonomy {
  --ink: #10233a;
  --ink-2: #4a5c73;
  --line: #dde4ec;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --accent: #0b6e6e;
  --focus: #f0a500;

  --tier1: #0b6e6e;
  --tier2: #7a4bbf;
  --tier3: #c2410c;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 35, 58, .06), 0 8px 24px rgba(16, 35, 58, .06);

  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  box-sizing: border-box;
}
.th-taxonomy *,
.th-taxonomy *::before,
.th-taxonomy *::after { box-sizing: border-box; }

/* ── Utilities ─────────────────────────────────────────── */
.th-taxonomy .sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.th-taxonomy :focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Header ────────────────────────────────────────────── */
.th-taxonomy .tax-header { margin-bottom: 24px; }
.th-taxonomy .tax-header h1 {
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  line-height: 1.2;
  margin: 0 0 10px;
}
.th-taxonomy .tax-intro {
  margin: 0;
  max-width: 68ch;
  color: var(--ink-2);
}

/* ── Search ────────────────────────────────────────────── */
.th-taxonomy .tax-search-wrap {
  position: relative;
  max-width: 720px;
  margin-bottom: 12px;
}
.th-taxonomy #tax-search {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.th-taxonomy #tax-search:focus { border-color: var(--accent); }

.th-taxonomy #tax-results {
  position: absolute;
  inset: calc(100% + 6px) 0 auto 0;
  z-index: 20;
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 420px;
  overflow-y: auto;
}
.th-taxonomy #tax-results:empty { display: none; }

.th-taxonomy .result {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  gap: 2px;
}
.th-taxonomy .result:hover,
.th-taxonomy .result.is-active { background: var(--surface-2); }
.th-taxonomy .result__name { font-weight: 600; color: var(--ink); }
.th-taxonomy .result__path { font-size: .8rem; color: var(--ink-2); }
.th-taxonomy .result__def  { font-size: .85rem; color: var(--ink-2); }
.th-taxonomy .result--empty {
  cursor: default;
  color: var(--ink-2);
  font-style: italic;
}
.th-taxonomy .result--empty:hover { background: none; }

/* ── Status ────────────────────────────────────────────── */
.th-taxonomy .tax-status {
  margin: 0 0 12px;
  min-height: 1.2em;
  font-size: .88rem;
  color: var(--ink-2);
}

/* ── Tag bar ───────────────────────────────────────────── */
.th-taxonomy .tax-tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin: 20px 0 28px;
}
.th-taxonomy .tag-group {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.th-taxonomy .tag-group legend {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-2);
  width: 100%;
  padding: 0 0 4px;
}
.th-taxonomy .tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: .82rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}
.th-taxonomy .tag-chip:has(input:checked) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.th-taxonomy .tag-chip input { accent-color: var(--accent); }
.th-taxonomy .tag-clear {
  background: none;
  border: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
}

/* ── Icicle overview ───────────────────────────────────── */
.th-taxonomy .tax-overview { margin: 0 0 28px; }
.th-taxonomy .icicle { position: relative; }
.th-taxonomy .icicle-rect {
  fill: var(--surface-2);
  stroke: var(--surface);
  stroke-width: 1;
  transition: opacity .15s ease;
}
.th-taxonomy .icicle-rect.lvl-1 { fill: color-mix(in srgb, var(--tier1) 22%, white); }
.th-taxonomy .icicle-rect.lvl-2 { fill: color-mix(in srgb, var(--tier2) 18%, white); }
.th-taxonomy .icicle-rect.lvl-3 { fill: color-mix(in srgb, var(--tier3) 14%, white); }
.th-taxonomy .icicle-rect.is-active   { fill: var(--accent); }
.th-taxonomy .icicle-rect.is-ancestor { stroke: var(--accent); stroke-width: 2; }
.th-taxonomy .icicle-rect.is-dimmed   { opacity: .18; }
.th-taxonomy .icicle-label { font-size: 11px; fill: var(--ink); }
.th-taxonomy .tax-overview figcaption {
  font-size: .78rem;
  color: var(--ink-2);
  margin-top: 6px;
}

.th-taxonomy .icicle-tip {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: .78rem;
  display: grid;
  gap: 2px;
  max-width: 280px;
}
.th-taxonomy .icicle-tip span { opacity: .75; }

/* ── Layout ────────────────────────────────────────────── */
.th-taxonomy .tax-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .th-taxonomy .tax-layout { grid-template-columns: 1fr; }
}

/* ── Columns ───────────────────────────────────────────── */
.th-taxonomy .tax-columns {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
  scroll-snap-type: x proximity;
}
.th-taxonomy .tax-col {
  list-style: none;
  margin: 0;
  padding: 0 0 0 10px;
  flex: 0 0 272px;
  scroll-snap-align: start;
  border-left: 3px solid var(--line);
}
.th-taxonomy .tax-col[data-depth="0"] { border-left-color: var(--tier1); }
.th-taxonomy .tax-col[data-depth="1"] { border-left-color: var(--tier2); }
.th-taxonomy .tax-col[data-depth="2"] { border-left-color: var(--tier3); }

.th-taxonomy .tax-item {
  display: grid;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color .12s ease, background .12s ease;
}
.th-taxonomy .tax-item:hover { border-color: var(--accent); }
.th-taxonomy .tax-item.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, white);
  box-shadow: inset 3px 0 0 var(--accent);
}
.th-taxonomy .tax-item.is-dimmed { opacity: .35; }
.th-taxonomy .tax-item__code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .72rem;
  color: var(--ink-2);
}
.th-taxonomy .tax-item__name { font-weight: 600; color: var(--ink); }
.th-taxonomy .tax-item__def {
  font-size: .82rem;
  color: var(--ink-2);
  line-height: 1.4;
}
.th-taxonomy .tax-item__count {
  justify-self: start;
  font-size: .7rem;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
}

/* ── Detail panel ──────────────────────────────────────── */
.th-taxonomy .tax-detail {
  position: sticky;
  top: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
@media (max-width: 900px) {
  .th-taxonomy .tax-detail { position: static; max-height: none; }
}

.th-taxonomy .breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  font-size: .78rem;
}
.th-taxonomy .breadcrumb li + li::before {
  content: "›";
  margin-right: 6px;
  color: var(--ink-2);
}
.th-taxonomy .breadcrumb button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.th-taxonomy .breadcrumb [aria-current="page"] { color: var(--ink-2); }

.th-taxonomy .detail-code {
  font-family: ui-monospace, monospace;
  font-size: .78rem;
  color: var(--ink-2);
  margin: 0 0 4px;
}
.th-taxonomy .tax-detail h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
  line-height: 1.25;
}
.th-taxonomy .detail-lede {
  margin: 0 0 16px;
  color: var(--ink-2);
  font-size: 1rem;
}

.th-taxonomy .detail-block { margin-top: 18px; }
.th-taxonomy .detail-block h3 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-2);
  margin: 0 0 6px;
}
.th-taxonomy .detail-block p {
  margin: 0 0 8px;
  line-height: 1.6;
}
.th-taxonomy .detail-block--boundary {
  border-left: 3px solid var(--focus);
  background: color-mix(in srgb, var(--focus) 8%, white);
  padding: 12px 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.th-taxonomy .detail-block--boundary h3 { color: #8a5a00; }

.th-taxonomy .tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.th-taxonomy .tag {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  font-size: .74rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.th-taxonomy .tag__cat {
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .65;
  font-size: .66rem;
}
.th-taxonomy .tag--teal   { background: #e6f4f4; border-color: #b8dede; }
.th-taxonomy .tag--amber  { background: #fdf3e0; border-color: #f0d9a8; }
.th-taxonomy .tag--violet { background: #f2ecfb; border-color: #d6c6f0; }

.th-taxonomy .detail-actions { margin-top: 22px; }
.th-taxonomy .btn-ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.th-taxonomy .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ── Motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .th-taxonomy *,
  .th-taxonomy *::before,
  .th-taxonomy *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}