/* Butter UW Tree — inline component styles. All classes prefixed .uwt- */

.uwt-root {
  margin-top: 32px;
  font-family: inherit;
}

/* ============= TOOLBAR ============= */
.uwt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  border-bottom: none;
}
.uwt-search {
  flex: 1;
  min-width: 240px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--navy);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.uwt-search:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,63,235,0.08); }
.uwt-search::placeholder { color: var(--slate-2); }
.uwt-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.uwt-btn-ghost {
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.uwt-btn-ghost:hover { color: var(--navy); border-color: var(--navy); }

/* ============= PHASES ============= */
.uwt-phases {
  border: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  background: white;
  overflow: hidden;
}
.uwt-phase {
  border-bottom: 1px solid var(--line);
}
.uwt-phase:last-child { border-bottom: none; }
.uwt-phase.is-hit { background: rgba(255, 184, 0, 0.04); }

.uwt-phase-head {
  width: 100%;
  display: grid;
  grid-template-columns: 56px minmax(160px, 0.8fr) minmax(200px, 1.6fr) auto 24px;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  background: white;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}
.uwt-phase-head:hover { background: var(--bg-soft); }
.uwt-phase.is-open > .uwt-phase-head { background: var(--bg-soft); }

.uwt-phase-num {
  font-family: "SF Mono", Monaco, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--slate-2);
  text-transform: uppercase;
}
.uwt-phase-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.01em;
}
.uwt-phase-desc {
  font-size: 13.5px;
  color: var(--slate);
  line-height: 1.45;
}
.uwt-phase-meta {
  font-size: 11.5px;
  color: var(--slate-2);
  font-family: "SF Mono", Monaco, monospace;
  white-space: nowrap;
}
.uwt-phase-chev {
  color: var(--slate-2);
  font-size: 12px;
  transition: transform 0.2s;
}
.uwt-phase.is-open .uwt-phase-chev { transform: rotate(90deg); color: var(--navy); }

.uwt-phase-body {
  padding: 20px 24px 28px 24px;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  animation: uwt-slide-in 0.18s ease-out;
}
@keyframes uwt-slide-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.uwt-purpose {
  font-size: 14px;
  line-height: 1.55;
  color: var(--slate);
  max-width: 78ch;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--line);
  border-left: 3px solid var(--yellow);
  border-radius: 8px;
}

/* ============= HUB TABS (phase-3) ============= */
.uwt-hub-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}
.uwt-hub-tab {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all 0.15s;
}
.uwt-hub-tab:hover { border-color: var(--navy); }
.uwt-hub-tab.is-active {
  background: var(--navy);
  border-color: var(--navy);
}
.uwt-hub-tab.is-active .uwt-hub-tab-id,
.uwt-hub-tab.is-active .uwt-hub-tab-title,
.uwt-hub-tab.is-active .uwt-hub-tab-cite { color: white; }
.uwt-hub-tab-id {
  font-family: "SF Mono", Monaco, monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate-2);
}
.uwt-hub-tab-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.01em;
}
.uwt-hub-tab-cite {
  font-family: "SF Mono", Monaco, monospace;
  font-size: 11px;
  color: var(--slate);
}
.uwt-subphase-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
}

/* ============= BLOCKS (reqs / nodes / edges) ============= */
.uwt-block { margin-bottom: 22px; }
.uwt-block:last-child { margin-bottom: 0; }
.uwt-block-h {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--navy);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.uwt-block-meta {
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--slate-2);
  font-family: "SF Mono", Monaco, monospace;
  font-size: 11px;
}

/* requirements */
.uwt-reqs {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 6px;
}
.uwt-reqs li {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--slate);
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* nodes */
.uwt-nodes {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 4px;
}
.uwt-node-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all 0.12s;
}
.uwt-node-btn:hover { border-color: var(--navy); background: var(--yellow-soft); }
.uwt-node-id {
  font-family: "SF Mono", Monaco, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
}
.uwt-node-q {
  font-size: 13.5px;
  color: var(--slate);
  line-height: 1.45;
}
.uwt-node-cite {
  font-family: "SF Mono", Monaco, monospace;
  font-size: 11.5px;
  color: var(--blue);
  white-space: nowrap;
}

/* edges */
.uwt-edges {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 8px;
}
.uwt-edges li {
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.uwt-edge-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.uwt-edge-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--slate);
}

/* §-cite chip */
.uwt-cite {
  display: inline-block;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(46, 63, 235, 0.08);
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
}

/* ============= DETAIL PANEL ============= */
.uwt-detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 92vw);
  background: white;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(15, 26, 140, 0.08);
  transform: translateX(100%);
  transition: transform 0.22s ease-out;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.uwt-detail.is-open { transform: translateX(0); }
.uwt-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.uwt-detail-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate-2);
}
.uwt-detail-close {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 20px;
  color: var(--slate);
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.uwt-detail-close:hover { color: var(--navy); border-color: var(--navy); }

.uwt-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.uwt-detail-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate-2);
  margin-bottom: 6px;
}
.uwt-detail-id {
  font-family: "SF Mono", Monaco, monospace;
  font-size: 12px;
  color: var(--blue);
  font-weight: 600;
  margin-bottom: 8px;
}
.uwt-detail-q {
  font-size: 20px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin: 0 0 14px 0;
}
.uwt-detail-cite-row { margin-bottom: 16px; }
.uwt-detail-explain {
  font-size: 14px;
  line-height: 1.6;
  color: var(--slate);
  margin-bottom: 20px;
}
.uwt-detail-flow {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}
.uwt-flow-item {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  font-family: "SF Mono", Monaco, monospace;
}
.uwt-flow-item.pass {
  background: rgba(15, 138, 78, 0.06);
  border: 1px solid rgba(15, 138, 78, 0.2);
  color: var(--green);
}
.uwt-flow-item.fail {
  background: rgba(200, 54, 74, 0.05);
  border: 1px solid rgba(200, 54, 74, 0.2);
  color: var(--red);
}
.uwt-flow-l {
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-right: 6px;
}
.uwt-detail-term {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--slate);
}
.uwt-detail-term-h {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--navy);
  margin-bottom: 8px;
}

.uwt-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 140, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
  z-index: 99;
}
.uwt-detail.is-open + .uwt-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ============= MOBILE ============= */
@media (max-width: 720px) {
  .uwt-phase-head {
    grid-template-columns: 1fr 24px;
    grid-template-rows: auto auto auto;
    gap: 4px 0;
    padding: 16px 20px;
  }
  .uwt-phase-num { grid-column: 1; grid-row: 1; }
  .uwt-phase-title { grid-column: 1; grid-row: 2; }
  .uwt-phase-desc { grid-column: 1 / span 2; grid-row: 3; margin-top: 6px; }
  .uwt-phase-meta { display: none; }
  .uwt-phase-chev { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

  .uwt-phase-body { padding: 16px 18px 22px 18px; }
  .uwt-node-btn {
    grid-template-columns: 50px 1fr;
    grid-template-rows: auto auto;
    gap: 4px 12px;
  }
  .uwt-node-id { grid-column: 1; grid-row: 1 / span 2; }
  .uwt-node-q { grid-column: 2; grid-row: 1; }
  .uwt-node-cite { grid-column: 2; grid-row: 2; justify-self: start; }
}
