/* Graph reader surface: proposition panel, review badges, and ladder controls. */

.prop-ref {
  position: relative;
  top: -1px;
  margin-left: 2px;
  color: var(--links, #6e1f1f);
  font-size: 11px;
  line-height: 1;
  vertical-align: super;
}

.prop-ref[tabindex] {
  cursor: pointer;
}

.prop-ref:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--links, #6e1f1f);
  outline-offset: 3px;
}

.graph-panel[hidden] {
  display: none;
}

.graph-panel {
  --graph-mark-plate: var(--bg, #fff);
  position: fixed;
  /* Above mdbook's sidebar and sidebar toggle; at mobile width this is the
     full-cover sheet, so no navigation chrome may paint through it. */
  z-index: 1000;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 420px;
  max-width: calc(100vw - 32px);
  overflow: auto;
  /* Keep wheel/touch scrolling inside the panel from chaining to the page. */
  overscroll-behavior: contain;
  border: 1px solid var(--table-border-color, #c9b894);
  border-radius: 6px;
  background: var(--bg, #fff);
  color: var(--fg, #1a1612);
  /* Slide in from the right, the mirror of the chapter TOC's slide. */
  transform: translateX(calc(100% + 16px));
  transition: transform 300ms ease;
}

.graph-panel--open {
  transform: none;
}

.graph-panel--reading {
  width: min(820px, calc(100vw - 32px));
}

.graph-panel-loading .panel-pointer {
  cursor: progress;
  opacity: 0.68;
}

@media (prefers-reduced-motion: reduce) {
  .graph-panel {
    transition: none;
  }
}

.bartley-light .graph-panel {
  box-shadow: 0 10px 30px rgba(26, 22, 18, 0.18);
}

.bartley-dark .graph-panel {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.graph-panel-header {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--table-border-color, #c9b894);
  background: var(--bg, #fff);
}

.graph-panel-title {
  flex: 1 1 auto;
  margin: 0;
  color: var(--fg, #1a1612);
  font-size: 18px;
  font-weight: 500;
  line-height: 24px;
  overflow-wrap: anywhere;
}

.graph-panel-back,
.graph-panel-close {
  /* Both controls take the same square frame and centre a drawn icon in it.
     They used to be text glyphs sized 20px and 18px, which gave them different
     frame widths (38 vs 32) and left the close glyph 2.6px low — punctuation
     has no cap height for the theme's metric overrides to reference. */
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--rule, #c9b894);
  border-radius: 4px;
  background: transparent;
  color: var(--fg, #1a1612);
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
}

.graph-control-icon {
  display: block;
  width: 16px;
  height: 16px;
}

.graph-panel-back[hidden] {
  display: none;
}

.graph-panel-back:hover,
.graph-panel-back:focus-visible,
.graph-panel-close:hover,
.graph-panel-close:focus-visible {
  border-color: var(--links, #6e1f1f);
  color: var(--links, #6e1f1f);
}

.graph-panel-body {
  padding: 16px;
}

.graph-panel-body section + section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--rule, #c9b894);
}

.graph-panel-hop-title {
  margin: 0 0 8px;
  color: var(--fg, #1a1612);
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
}

.panel-proposition-text,
.panel-edge-rationale {
  margin: 0 0 8px;
}

.graph-panel .panel-theory {
  display: block;
}

.graph-panel .panel-theory-objective {
  margin: 0 0 8px;
}

.graph-panel .panel-theory-ladder {
  display: inline-block;
  margin-top: 8px;
  color: var(--links, #6e1f1f);
}

.graph-panel .panel-theory-ladder:focus-visible {
  outline: 2px solid var(--links, #6e1f1f);
  outline-offset: 2px;
}

.graph-panel-meta {
  margin: 6px 0;
  color: var(--whisper, #6e6354);
  font-size: 12px;
  line-height: 17px;
}

.graph-badges,
.ladder-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.graph-badges {
  margin-top: 8px;
}

.ladder-badges {
  margin: 8px 0 10px;
}

.graph-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--rule, #c9b894);
  border-radius: 999px;
  color: var(--whisper, #6e6354);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
}

.panel-edge {
  margin-top: 12px;
  padding: 12px;
  border-left: 3px solid var(--rule, #c9b894);
  background: var(--surface, #f5f5f5);
}

.panel-edge--contradicts {
  border-left-color: var(--links, #6e1f1f);
}

.panel-edge-relation {
  margin: 0;
  color: var(--fg, #1a1612);
  font-size: 14px;
  font-weight: 600;
  line-height: 19px;
}

.panel-edge--contradicts .panel-edge-relation {
  color: var(--links, #6e1f1f);
}

.panel-passage,
.panel-source {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule, #c9b894);
}

.panel-quote-context {
  color: var(--whisper, #6e6354);
  line-height: 22px;
}

.panel-quote-exact {
  color: var(--fg, #1a1612);
}

.panel-quote-prefix::after,
.panel-quote-exact::after {
  content: " ";
}

.panel-source-title {
  margin-bottom: 4px;
  font-weight: 600;
}

.panel-source-primary {
  display: inline-block;
  margin: 2px 0 6px;
  padding: 2px 7px;
  border: 1px solid var(--rule, #c9b894);
  border-radius: 999px;
  color: var(--whisper, #6e6354);
  font-size: 11px;
  line-height: 15px;
}

.panel-source-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.panel-pointer-row {
  min-width: 0;
}

.panel-pointer-label {
  display: block;
  margin-bottom: 2px;
  color: var(--whisper, #6e6354);
  font-size: 12px;
}

.panel-pointer {
  display: block;
  padding: 5px 6px;
  border: 1px solid var(--rule, #c9b894);
  border-radius: 3px;
  background: var(--surface, #f5f5f5);
  color: var(--fg, #1a1612);
  font-size: 11px;
  line-height: 16px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.panel-pointer:hover,
.panel-pointer:focus-visible {
  border-color: var(--links, #6e1f1f);
  color: var(--links, #6e1f1f);
  outline-offset: 2px;
}

.graph-withheld {
  color: var(--whisper, #6e6354);
  font-size: 12px;
  font-style: italic;
}

/* Drawer relation neighborhood and subject-normalized relation rows. */
.graph-panel .panel-neighborhood {
  display: block;
  margin-top: 12px;
  position: relative;
}

.graph-panel .panel-neighborhood-svg {
  display: block;
  width: 100%;
  height: auto;
}

.graph-panel .panel-neighborhood-label {
  fill: var(--fg, #1a1612);
  font-size: 9px;
  paint-order: stroke fill;
  pointer-events: none;
  stroke: var(--bg, #fff);
  stroke-linejoin: round;
  stroke-width: 3px;
  text-anchor: middle;
}

.graph-panel .panel-neighborhood-label-relation {
  fill: var(--whisper, #6e6354);
  font-size: 8px;
}

.graph-panel .panel-neighborhood-tooltip {
  position: absolute;
  z-index: 2;
  max-width: 260px;
  padding: 6px 9px;
  border: 1px solid var(--table-border-color, #c9b894);
  border-radius: 4px;
  background: var(--bg, #fff);
  color: var(--fg, #1a1612);
  font-size: 12px;
  line-height: 1.25;
  pointer-events: none;
}

.graph-panel .panel-neighborhood-tooltip[hidden] {
  display: none;
}

.graph-panel .panel-neighborhood-tooltip strong,
.graph-panel .panel-neighborhood-tooltip span {
  display: block;
}

.graph-panel .panel-neighborhood-tooltip span {
  margin-top: 2px;
  color: var(--whisper, #6e6354);
  font-size: 11px;
}

.graph-panel .panel-neighborhood .graph-layer-node:not([role]) {
  cursor: default;
}

.graph-panel .panel-neighborhood .panel-neighborhood-hub-ring {
  fill: none;
  stroke: var(--whisper, #6e6354);
  stroke-dasharray: 2 2;
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}

.graph-panel .panel-neighborhood .graph-layer-edge {
  stroke-opacity: 0.45;
}

.graph-panel .panel-neighborhood .graph-layer-node.dimmed > .graph-layer-mark--ring {
  fill-opacity: 0.15;
}

.graph-panel .panel-neighborhood .graph-layer-node.dimmed > .graph-node-mark {
  opacity: 0.15;
}

.graph-panel .panel-neighborhood .graph-layer-node.graph-relation-linked > .graph-layer-mark--accent {
  stroke: var(--links, #6e1f1f);
  stroke-width: 5px;
  vector-effect: non-scaling-stroke;
}

.graph-panel .panel-neighborhood .graph-layer-node.graph-relation-linked > .graph-node-icon > g > * {
  stroke: var(--links, #6e1f1f);
  stroke-width: 2.5px;
}

.graph-panel .panel-neighborhood .graph-layer-node.graph-relation-linked:focus-visible > .graph-layer-mark--accent {
  outline: none;
  stroke: var(--links, #6e1f1f);
  stroke-width: calc(var(--graph-accent-stroke-width, 3.5px) * 2);
  vector-effect: non-scaling-stroke;
}

.graph-panel .panel-neighborhood .graph-layer-node.graph-relation-linked:focus-visible > .graph-node-icon > g > * {
  outline: none;
  stroke: var(--links, #6e1f1f);
  stroke-width: var(--graph-accent-stroke-width, 3.5px);
}

.graph-panel .panel-neighborhood .graph-layer-node:focus-visible > .graph-layer-mark--accent {
  outline: none;
  stroke: var(--links, #6e1f1f);
  stroke-width: calc(var(--graph-accent-stroke-width, 3.5px) * 2);
  vector-effect: non-scaling-stroke;
}

.graph-panel .panel-neighborhood .graph-layer-node:focus-visible > .graph-node-icon > g > * {
  outline: none;
  stroke: var(--links, #6e1f1f);
  stroke-width: var(--graph-accent-stroke-width, 3.5px);
}

.graph-panel .panel-neighborhood .graph-layer-node.graph-relation-linked.dimmed > .graph-layer-mark--accent {
  stroke-opacity: 1;
}

.graph-panel .panel-neighborhood .graph-layer-node.graph-relation-linked.dimmed > .graph-layer-mark--ring {
  fill-opacity: 1;
}

.graph-panel .panel-relations-list {
  display: grid;
  row-gap: 6px;
}

.graph-panel .panel-relation-line {
  margin: 0;
}

.graph-panel .panel-relation-label {
  color: var(--whisper, #6e6354);
}

.graph-panel button.panel-relation-counterpart {
  padding: 0;
  border: 0;
  background: none;
  color: var(--links, #6e1f1f);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.graph-panel a.panel-relation-counterpart {
  color: var(--links, #6e1f1f);
}

.graph-panel div.panel-relation-counterpart {
  color: var(--fg, #1a1612);
  cursor: auto;
}

.graph-panel .panel-relation-counterpart.graph-relation-linked {
  border-radius: 2px;
  box-shadow: 0 0 0 2px var(--links, #6e1f1f);
}

/* The actionable relation rows carry the drawer's themed focus ring, matching the
   neighborhood spokes above and the panel's other interactive surfaces. The button
   reset below clears padding/border/background but never `outline`, so omitting this
   left the UA default ring — functional, but visibly off-theme in the one place the
   keyboard user lands most. */
.graph-panel .panel-relation-counterpart:focus-visible {
  outline: 2px solid var(--links, #6e1f1f);
  outline-offset: 2px;
}

.graph-panel .panel-relation--withheld .panel-relation-counterpart {
  color: var(--whisper, #6e6354);
  font-size: 12px;
  font-style: italic;
}

.prop-ref.graph-prop-linked {
  border-radius: 2px;
  outline: 2px solid var(--links, #6e1f1f);
  outline-offset: 3px;
}

.timeline-mark.graph-prop-linked .timeline-mark-shape {
  stroke: var(--links, #6e1f1f);
  stroke-width: 3px;
}

.ladder-rung--dead .ladder-statement,
.ladder-rung--dead .ladder-burden,
.ladder-rung--dead .ladder-rules,
.ladder-rung--dead .ladder-disconnect {
  color: var(--whisper, #6e6354);
}

.ladder-rung--dead .ladder-statement {
  opacity: 0.72;
}

.ladder-disconnect {
  display: grid;
  row-gap: 4px;
}

.ladder-disconnect > * {
  display: block;
}

.ladder-badge--dead {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 7px;
  border: 1px solid var(--rule, #c9b894);
  border-radius: 999px;
  color: var(--whisper, #6e6354);
  font-size: 11px;
  line-height: 15px;
}

.ladder-hide-dead .ladder-rung--dead {
  display: none;
}

.ladder-rung[data-divergence="sanctioned"]::after {
  display: block;
  margin-top: 5px;
  color: var(--whisper, #6e6354);
  content: "authored " attr(data-authored-status) " · computed " attr(data-computed-status);
  font-size: 12px;
  line-height: 17px;
}

.ladder-dead-toggle {
  margin: 0 0 12px;
  padding: 5px 10px;
  border: 1px solid var(--rule, #c9b894);
  border-radius: 4px;
  background: transparent;
  color: var(--whisper, #6e6354);
  font-family: inherit;
  font-size: 12px;
  line-height: 17px;
  cursor: pointer;
}

.ladder-dead-toggle[aria-pressed="true"] {
  background: var(--surface, #f5f5f5);
  color: var(--fg, #1a1612);
}

.ladder-dead-toggle:hover,
.ladder-dead-toggle:focus-visible {
  border-color: var(--links, #6e1f1f);
  color: var(--links, #6e1f1f);
}

@media (max-width: 768px) {
  /* Full-cover sheet: content-height bottom sheets left a variable gap above
     the panel; match the wide rendition's always-full-height behavior. */
  .graph-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    border: 0;
    border-radius: 0;
    transform: translateX(100%);
  }

  .graph-panel--reading {
    width: 100%;
  }

  .graph-panel--open {
    transform: none;
  }

  .graph-panel-header,
  .graph-panel-body {
    padding-right: 14px;
    padding-left: 14px;
  }
}

@media print {
  .graph-panel,
  .graph-panel-back,
  .ladder-dead-toggle {
    display: none;
  }
}
