/* ==================================================================
   ARL BACKBONE — /resources/backbone
   Extends resources.css tokens. Scriptural foundation page.
   ================================================================== */

.page-head .backbone-jump {
  display: inline-flex;
  align-items: center;
  margin-top: 22px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  color: #1A1A1A;
  background: var(--accent);
  text-decoration: none;
  padding: 12px 20px;
  border-radius: 2px;
}
@media (max-width: 720px) {
  .page-head .backbone-jump {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 14px 18px;
  }
}
.page-head .backbone-jump:hover {
  background: var(--accent-hover);
}

#graph {
  scroll-margin-top: 72px;
}

.thesis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 8px;
}
@media (max-width: 720px) { .thesis-grid { grid-template-columns: 1fr; } }

.thesis-card {
  background: var(--bg-white);
  border: 1px solid rgba(0,0,0,0.12);
  padding: 26px 28px;
}
@media (max-width: 720px) { .thesis-card { padding: 22px 20px; } }
.thesis-card .t-label {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 8px;
}
.thesis-card .t-count {
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1;
  color: var(--accent);
  margin: 0 0 10px;
}
.thesis-card p {
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}

.phrase-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: flex-end;
  margin-bottom: 22px;
}
.phrase-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.phrase-toolbar select,
.phrase-toolbar input[type="search"] {
  font-family: var(--sans);
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid rgba(0,0,0,0.16);
  border-radius: 2px;
  background: var(--bg-white);
  color: var(--text-primary);
  min-width: 140px;
}
.phrase-toolbar input[type="search"] { min-width: 220px; flex: 1; }
@media (max-width: 720px) {
  .phrase-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .phrase-toolbar label { width: 100%; }
  .phrase-toolbar select,
  .phrase-toolbar input[type="search"] {
    width: 100%;
    min-width: 0;
  }
  .phrase-toolbar .genz-toggle { padding-bottom: 0; }
}
.phrase-toolbar .genz-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding-bottom: 9px;
}
.phrase-toolbar .genz-toggle input { width: 16px; height: 16px; accent-color: var(--primary); }

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
@media (max-width: 720px) {
  .filter-chips {
    margin-left: -2px;
    margin-right: -2px;
  }
}
.filter-chips button {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 12px;
  padding: 7px 14px;
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: 999px;
  background: var(--bg-white);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.filter-chips button:hover { border-color: var(--primary); color: var(--primary); }
.filter-chips button.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-on-dark);
}

.phrase-count {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0 0 16px;
}

.phrase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 860px) { .phrase-grid { grid-template-columns: 1fr; } }

.phrase-card {
  background: var(--bg-white);
  border: 1px solid rgba(0,0,0,0.12);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (max-width: 720px) { .phrase-card { padding: 20px 18px; } }
.phrase-card.is-hidden { display: none; }
.phrase-card .p-title {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.1;
  margin: 0;
  overflow-wrap: break-word;
}
@media (max-width: 720px) {
  .phrase-card .p-title { font-size: 22px; }
}
.phrase-card .p-ref {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.phrase-card .p-audience {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}
.phrase-card .p-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.45;
  color: var(--primary);
  margin: 0;
}
.phrase-card .p-genz {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  color: var(--text-secondary);
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.graph-section { padding-bottom: 48px; }
.graph-section .section-head em {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(17px, 2.2vw, 21px);
  line-height: 1.45;
  color: var(--primary);
  display: inline-block;
  margin-top: 4px;
}
.graph-section .graph-epigraph {
  margin-bottom: 14px;
}
.graph-section .graph-desc {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 40rem;
  margin: 0;
}
.graph-section .graph-scripture-ref {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.graph-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-ink);
  border: 1px solid rgba(196,151,59,0.22);
  height: min(72vh, 640px);
  min-height: 420px;
  overflow: hidden;
}
@media (max-width: 720px) {
  .graph-wrap {
    height: min(58vh, 480px);
    min-height: 300px;
  }
}
.graph-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}
.graph-wrap svg { display: block; width: 100%; height: 100%; }
.graph-wrap .link { stroke: rgba(196,151,59,0.5); stroke-width: 1.3px; }
.graph-wrap .node circle { stroke: rgba(245,242,237,0.85); stroke-width: 1.5px; cursor: grab; }
.graph-wrap .node circle:active { cursor: grabbing; }
.graph-wrap .diamond-facet {
  stroke: #C4973B;
  stroke-width: 2px;
  stroke-opacity: 0.7;
}
.graph-wrap .diamond-facet--soft { stroke-width: 1.5px; stroke-opacity: 0.45; }
.graph-wrap .corner-label {
  fill: #D4A94D;
  font-size: clamp(12px, 1.5vw, 16px);
  font-weight: 600;
  font-family: var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: rgba(15,31,24,0.75);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.graph-wrap .center-label {
  fill: rgba(245,242,237,0.72);
  font-size: clamp(10px, 1.1vw, 12px);
  font-weight: 600;
  font-family: var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: rgba(15,31,24,0.8);
  stroke-width: 3px;
}
.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 0;
}
@media (max-width: 720px) {
  .graph-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .graph-toolbar p { max-width: none; }
  .graph-toolbar .graph-actions {
    width: 100%;
  }
  .graph-toolbar .graph-actions .btn-secondary {
    flex: 1;
    text-align: center;
  }
}
.graph-toolbar p {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  max-width: 28rem;
}
.graph-toolbar .graph-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-secondary {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-white);
  border: 1px solid rgba(0,0,0,0.16);
  padding: 9px 16px;
  border-radius: 2px;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.graph-legend {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(15,31,24,0.92);
  border: 1px solid rgba(196,151,59,0.35);
  border-radius: 3px;
  padding: 12px 14px;
  z-index: 5;
  min-width: 150px;
}
@media (max-width: 720px) {
  .graph-legend {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    min-width: 0;
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
  }
  .graph-legend h3 {
    width: 100%;
    margin-bottom: 2px !important;
  }
  .graph-legend .legend-item {
    margin-bottom: 0;
    font-size: 10px;
  }
}
.graph-legend h3 {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.graph-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-family: var(--sans);
  font-size: 11px;
  color: rgba(245,242,237,0.85);
}
.graph-legend .legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.2);
}

.graph-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(380px, 100%);
  height: 100%;
  background: rgba(245,242,237,0.98);
  border-left: 2px solid var(--accent);
  transform: translateX(100%);
  transition: transform 0.28s ease;
  z-index: 20;
  overflow-y: auto;
  box-shadow: -8px 0 24px rgba(0,0,0,0.2);
}
.graph-panel.is-open { transform: translateX(0); }
.graph-panel-inner { padding: 24px 22px 40px; }
.graph-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px 8px;
}
.graph-panel h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.15;
  margin: 0 0 10px;
  padding: 0 32px 10px 0;
  border-bottom: 1px solid rgba(196,151,59,0.35);
  overflow-wrap: break-word;
}
@media (max-width: 720px) {
  .graph-panel h2 { font-size: 24px; }
  .graph-panel-inner { padding: 20px 18px 32px; }
}
.cat-badge {
  display: inline-block;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.graph-panel .field { margin-bottom: 14px; }
.graph-panel .field-label {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 3px;
}
.graph-panel .field-value {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.graph-wrap.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 100;
  height: 100vh !important;
  /* dvh tracks the visible viewport on iOS Safari, so the bottom of the
     graph is not hidden behind the browser toolbar */
  height: 100dvh !important;
  min-height: 0;
  max-height: none;
  border: none;
}
.graph-error {
  position: absolute;
  inset: auto 0 0 0;
  margin: 0;
  padding: 14px 18px;
  text-align: center;
  font-family: var(--sans);
  font-size: 14px;
  color: #F5F2ED;
  background: rgba(15, 31, 24, 0.92);
}
.graph-expand-bar {
  display: none;
  flex-shrink: 0;
  z-index: 6;
  padding: 14px 18px;
  background: rgba(15,31,24,0.98);
  border-bottom: 1px solid rgba(196,151,59,0.25);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.graph-wrap.is-expanded .graph-expand-bar { display: flex; }
.graph-expand-bar span {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-on-dark);
}
.graph-close-btn {
  color: var(--text-on-dark);
  background: rgba(245,242,237,0.08);
  border-color: rgba(245,242,237,0.2);
}
.graph-close-btn:hover {
  background: rgba(245,242,237,0.14);
  border-color: rgba(196,151,59,0.45);
  color: var(--text-on-dark);
}

/* Keyboard focus ring for verse nodes */
.graph-nodes .node:focus-visible { outline: none; }
.graph-nodes .node:focus-visible circle {
  stroke: #F5F2ED;
  stroke-width: 3px;
}
