/* ============================================================
   root-to-branch.css
   All styles scoped to the Root to Branch tree widget.
   Loaded only on family-history.html.
   Page-level styles live in family-history.css.
   ============================================================ */

/* ── VIEWPORT ───────────────────────────────────────────────── */
#tree-scroll { width: 100%; height: 72vh; overflow: hidden; position: relative; background: linear-gradient(to bottom, #f3ece6 0%, #f7f2ed 48%, #faf8f5 100%); border: 1px solid #E4D8D2; border-radius: 4px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.55), inset 0 -20px 60px rgba(122, 74, 58, 0.03); }
#tree-svg-wrap { position: absolute; top: 0; left: 0; transform-origin: 0 0; z-index: 1; }
#tree-connectors { position: absolute; top: 0; left: 0; width: 4000px; height: 2500px; pointer-events: none; z-index: 0; overflow: visible; }
#tree-connectors line,
#tree-connectors path { stroke: #A6757E; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 0 rgba(255,255,255,0.24)); animation: rtbConnectorPulse 4.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
#tree-connectors .rtb-connector-trunk { stroke: #955C69; stroke-width: 2.8; opacity: 0.99; animation-duration: 3.6s; }
#tree-connectors .rtb-connector-branch { stroke: #A6757E; stroke-width: 2.45; opacity: 0.96; animation-duration: 4.4s; }

@keyframes rtbConnectorPulse {
  0%, 100% {
    opacity: 0.76;
    stroke: #955C69;
    filter: drop-shadow(0 1px 0 rgba(255,255,255,0.22)) drop-shadow(0 0 0 rgba(214, 112, 148, 0));
  }
  50% {
    opacity: 1;
    stroke: #E57FA7;
    filter: drop-shadow(0 1px 0 rgba(255,255,255,0.44)) drop-shadow(0 0 12px rgba(214, 112, 148, 0.58));
  }
}

#tree-root { position: absolute; top: 0; left: 0; width: 4000px; height: 2500px; }

/* ── NODES ──────────────────────────────────────────────────── */
.node { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; z-index: 1; }
.node-content { display: flex; flex-direction: column; align-items: center; position: relative; z-index: 10; }

/* ── CHEVRONS ───────────────────────────────────────────────── */
.chevron-btn { background: rgba(242, 224, 217, 0.9); border: 1.5px solid #C8A391; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; margin: 0 0 5px 0; border-radius: 50%; transition: all 0.3s ease; color: #8B7355; box-shadow: 0 2px 5px rgba(0,0,0,0.08); position: relative; z-index: 15; padding: 0; }
.chevron-glyph { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; line-height: 1; transform: rotate(-90deg) translateX(0.5px); transform-origin: 50% 50%; transition: transform 0.4s ease, color 0.3s ease; color: #7A4A3A; font-size: 13px; }
.chevron-btn.expanded { background: rgba(180, 140, 120, 0.95); border-color: #8B6650; }
.chevron-btn.expanded .chevron-glyph { transform: rotate(90deg) translateX(-0.5px); color: #4A2A1A; }

/* ── CARDS ──────────────────────────────────────────────────── */
.person-card { width: 340px; height: 155px; min-height: 155px; max-height: 155px; background: linear-gradient(180deg, #FFFDFC 0%, #FBF7F3 100%); border: 1px solid #E3D8CF; border-radius: 8px; padding: 10px 12px 8px 10px; box-shadow: 0 4px 14px rgba(44, 36, 32, 0.07), inset 0 1px 0 rgba(255,255,255,0.7); cursor: pointer; transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease; position: relative; border-left: 3px solid #C4806A; display: flex; flex-direction: column; overflow: hidden; box-sizing: border-box; }
.person-card::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 6px;
  pointer-events: none;
  border: 1px solid rgba(196, 128, 106, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.45),
    inset 0 -1px 0 rgba(140, 96, 78, 0.06);
}

.person-card::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.78;
  background:
    radial-gradient(circle at 50% 8px, rgba(196, 128, 106, 0.24) 0 1.6px, transparent 1.8px),
    linear-gradient(rgba(196, 128, 106, 0.18), rgba(196, 128, 106, 0.18)) center 10px / 54px 1.15px no-repeat,
    radial-gradient(circle at calc(50% - 30px) 10px, rgba(196, 128, 106, 0.16) 0 0.9px, transparent 1.1px),
    radial-gradient(circle at calc(50% + 30px) 10px, rgba(196, 128, 106, 0.16) 0 0.9px, transparent 1.1px),
    radial-gradient(circle at 50% calc(100% - 12px), rgba(196, 128, 106, 0.22) 0 1.8px, transparent 2px),
    linear-gradient(rgba(196, 128, 106, 0.18), rgba(196, 128, 106, 0.18)) center calc(100% - 14px) / 50px 1.3px no-repeat,
    radial-gradient(circle at calc(50% - 28px) calc(100% - 14px), rgba(196, 128, 106, 0.16) 0 1px, transparent 1.2px),
    radial-gradient(circle at calc(50% + 28px) calc(100% - 14px), rgba(196, 128, 106, 0.16) 0 1px, transparent 1.2px);
  background-repeat: no-repeat;
}

.person-card:has(.bio-btn)::after {
  background:
    radial-gradient(circle at 50% 8px, rgba(196, 128, 106, 0.24) 0 1.6px, transparent 1.8px),
    linear-gradient(rgba(196, 128, 106, 0.18), rgba(196, 128, 106, 0.18)) center 10px / 54px 1.15px no-repeat,
    radial-gradient(circle at calc(50% - 30px) 10px, rgba(196, 128, 106, 0.16) 0 0.9px, transparent 1.1px),
    radial-gradient(circle at calc(50% + 30px) 10px, rgba(196, 128, 106, 0.16) 0 0.9px, transparent 1.1px),
    radial-gradient(circle at 50% calc(100% - 12px), rgba(196, 128, 106, 0.20) 0 1.5px, transparent 1.7px),
    linear-gradient(rgba(196, 128, 106, 0.15), rgba(196, 128, 106, 0.15)) center calc(100% - 14px) / 34px 1.1px no-repeat,
    radial-gradient(circle at calc(50% - 20px) calc(100% - 14px), rgba(196, 128, 106, 0.14) 0 0.9px, transparent 1.1px),
    radial-gradient(circle at calc(50% + 20px) calc(100% - 14px), rgba(196, 128, 106, 0.14) 0 0.9px, transparent 1.1px);
  background-repeat: no-repeat;
}

/* Viewport Note Popover base styling */
.rtb-viewport-note-popover {
  position: absolute;
  width: min(188px, calc(100% - 24px));
  transform: translate(calc(-100% - 24px), -50%);
  padding: 8px 10px 8px;
  border: 1px solid #D8CCE3;
  border-radius: 10px;
  background: rgba(254, 251, 255, 0.92);
  box-shadow: 0 8px 18px rgba(44, 36, 32, 0.10);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease-out;
  will-change: opacity;
}

.rtb-viewport-note-popover.is-open {
  opacity: 1;
  pointer-events: none;
  transform: translate(calc(-100% - 24px), -50%);
  transition: opacity 0.14s ease-out;
}

.rtb-viewport-note-popover.is-closing {
  opacity: 0;
  pointer-events: none;
  transform: translate(calc(-100% - 24px), -50%);
  transition: opacity 0.34s ease-out;
}
.rtb-viewport-note-popover__title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  color: #5D456F;
  margin-bottom: 4px;
  min-height: 14px;
  white-space: nowrap;
  overflow: hidden;
}
.rtb-viewport-note-popover__body {
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  line-height: 1.35;
  color: #5A4A44;
  padding-right: 0;
  min-height: 28px;
  overflow: hidden;
}
.person-card.placeholder { background: linear-gradient(180deg, #F6F3F0 0%, #F1ECE7 100%); border-color: #D8D0C8; border-left-color: #B8B0A8; opacity: 0.85; }
.person-card.placeholder h3 { color: #8A8078; font-style: italic; }

.person-card.boerne {
  background: linear-gradient(180deg, #F3F7F2 0%, #EDF2EC 100%);
  border-color: #D2DDD1;
  border-left-color: #7F9F7B;
  box-shadow:
    0 4px 14px rgba(44, 36, 32, 0.07),
    inset 0 1px 0 rgba(255,255,255,0.70),
    inset 0 0 0 999px rgba(127, 159, 123, 0.045);
}

.person-card.root-node {
  border-width: 1px;
  border-left-width: 4px;
  box-shadow:
    0 8px 24px rgba(44, 36, 32, 0.14),
    0 0 0 1px rgba(214, 143, 167, 0.20),
    inset 0 1px 0 rgba(255,255,255,0.86),
    inset 0 0 0 1px rgba(214, 143, 167, 0.18);
}

.person-card.boerne.root-node {
  background:
    linear-gradient(180deg, rgba(248, 252, 246, 0.99) 0%, rgba(239, 245, 237, 0.99) 100%),
    radial-gradient(circle at 18% 12%, rgba(228, 178, 197, 0.30) 0%, transparent 42%),
    radial-gradient(circle at 82% 18%, rgba(214, 143, 167, 0.22) 0%, transparent 38%);
  border-color: #D6DFD4;
  border-left-color: #7F9F7B;
  box-shadow:
    0 10px 26px rgba(44, 36, 32, 0.15),
    0 0 0 1px rgba(214, 143, 167, 0.22),
    inset 0 1px 0 rgba(255,255,255,0.86),
    inset 0 0 0 1px rgba(214, 143, 167, 0.20),
    inset 0 0 0 999px rgba(127, 159, 123, 0.04);
}

.placeholder-text { font-size: 13px; color: #9A9088; font-style: italic; }

.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; width: 100%; position: relative; min-height: 38px; padding: 0 4px; }
.person-card h3 { margin: 0; font-size: 15px; color: #2C2420; font-weight: 600; line-height: 1.3; flex: 1; font-family: 'Libre Baskerville', Georgia, serif; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; line-clamp: 2; -webkit-line-clamp: 2; -webkit-box-orient: vertical; padding-right: 70px; text-shadow: 0 1px 0 rgba(255,255,255,0.45); }

.military-badges { position: absolute; top: -1px; right: -1px; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; z-index: 10; }
.badge-row { display: flex; gap: 2px; justify-content: flex-end; flex-wrap: wrap; max-width: 132px; }
.badge-row svg { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.16)); }

.card-body { display: flex; flex-direction: column; gap: 7px; flex: 1; justify-content: center; padding: 0 4px; }
.card-dates-row { display: flex; align-items: center; justify-content: flex-start; width: 100%; overflow: visible; }

.card-note-row { display: flex; align-items: center; justify-content: flex-start; width: 100%; margin-top: -1px; padding-left: 4px; overflow: visible; }
.viewport-note-btn {
  position: relative;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  flex: 0 0 auto;
  border: 1px solid rgba(139, 111, 168, 0.45);
  border-radius: 50%;
  background: rgba(248, 243, 251, 0.98);
  color: #7A5D96;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  padding: 0;
  margin-left: 0;
  z-index: 2;
}

.viewport-note-btn svg {
  width: 9px;
  height: 9px;
  display: block;
}
.viewport-note-btn:hover {
  background: rgba(243, 235, 249, 0.98);
  border-color: #8B6FA8;
  color: #684B84;
}
.card-relation-row { display: flex; align-items: center; justify-content: flex-end; width: 100%; }

.person-card .dates { font-size: 13px; color: #5A4A3A; font-family: 'EB Garamond', Georgia, serif; font-style: italic; letter-spacing: 0.02em; margin: 0; white-space: nowrap; padding-left: 4px; display: flex; align-items: center; gap: 4px; flex: 0 0 auto; min-width: 0; }
.date-chip { display: inline-flex; align-items: center; padding: 2px 8px; background: rgba(196, 128, 106, 0.08); border: 1px solid rgba(196, 128, 106, 0.12); border-radius: 10px; font-size: 12px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.4); }
.date-chip.deceased { background: rgba(139, 115, 85, 0.18); color: #5C4E43; font-style: normal; font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: 0.55px; font-family: 'Jost', sans-serif; border: 1px solid rgba(139, 115, 85, 0.16); box-shadow: inset 0 1px 0 rgba(255,255,255,0.22); }
.date-sep { font-size: 12px; color: #9A8078; padding: 0 3px; font-family: "EB Garamond", serif; font-style: normal; line-height: 1; align-self: center; display: inline-flex; }

.person-card .relation { font-size: 11px; color: #7A6050; font-family: 'Jost', sans-serif; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin: 0; padding: 5px 14px; background: linear-gradient(135deg, rgba(196, 128, 106, 0.14), rgba(196, 128, 106, 0.08)); border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid rgba(196, 128, 106, 0.25); white-space: normal; text-align: center; line-height: 1.3; max-width: 220px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.35); }
.relation-heart { width: 11px; height: 11px; fill: #D06060; animation: heartbeat 2.2s ease-in-out infinite; }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } 45% { transform: scale(1.15); } }

.card-footer { margin-top: auto; padding-top: 7px; border-top: 1px solid rgba(196, 128, 106, 0.18); display: flex; justify-content: flex-start; align-items: center; min-height: 24px; }
.bio-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px; background: linear-gradient(135deg, #F5E6E0, #EAD0C5); border: 1.5px solid #C4806A; border-radius: 18px; font-family: 'Jost', sans-serif; font-size: 10px; font-weight: 700; color: #7A3F2D; cursor: pointer; transition: all 0.2s ease; text-transform: uppercase; letter-spacing: 0.9px; box-shadow: 0 2px 4px rgba(196, 128, 106, 0.2), inset 0 1px 0 rgba(255,255,255,0.35); min-width: 120px; justify-content: center; }
.bio-btn:hover { background: linear-gradient(135deg, #EAD0C5, #E0C0B0); border-color: #A65D3D; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(196, 128, 106, 0.28), inset 0 1px 0 rgba(255,255,255,0.35); }

.person-card:hover {
  transform: translateY(-2px);
  border-color: #D6C6BB;
  box-shadow:
    0 10px 24px rgba(44, 36, 32, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.78);
}

.person-card.boerne:hover {
  border-color: #C8D6C6;
  border-left-color: #7F9F7B;
  box-shadow:
    0 10px 24px rgba(44, 36, 32, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.76),
    inset 0 0 0 999px rgba(127, 159, 123, 0.055);
}

.person-card.boerne.root-node:hover {
  border-color: #D6DFD4;
  border-left-color: #7F9F7B;
  box-shadow:
    0 12px 28px rgba(44, 36, 32, 0.16),
    0 0 0 1px rgba(214, 143, 167, 0.24),
    inset 0 1px 0 rgba(255,255,255,0.88),
    inset 0 0 0 1px rgba(214, 143, 167, 0.22),
    inset 0 0 0 999px rgba(127, 159, 123, 0.045);
}

/* ── CONTROLS BANNER ────────────────────────────────────────── */
.tree-controls-banner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 0 auto 16px;
  padding: 8px 14px 9px;
  background: linear-gradient(135deg, #FDF9F6 0%, #F8F2ED 100%);
  border: 1px solid #E4D8D2;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  gap: 10px;
  width: min(100%, 760px);
}

.controls-zoom-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.controls-nav-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 0;
}

.controls-nav-group > .controls-nav-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: auto;
}

.zoom-label { font-family: 'Jost', sans-serif; font-size: 10px; font-weight: 600; color: #9A8070; letter-spacing: 0.3px; text-align: center; }
.controls-label { font-family: 'Jost', sans-serif; font-size: 10px; font-weight: 600; color: #9A8070; letter-spacing: 0.3px; text-align: center; }

.zoom-controls-wrapper {
  display: flex;
  align-items: center;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.zoom-btn { width: 28px; height: 28px; border: 1px solid #D8C8C0; background: #FEFCFA; border-radius: 5px; font-size: 14px; font-weight: 600; cursor: pointer; color: #5A4A44; display: flex; align-items: center; justify-content: center; transition: all 0.15s ease; flex-shrink: 0; }
.zoom-btn:hover { border-color: #C4806A; color: #C4806A; background: #FDF8F5; }
.zoom-btn:active { transform: scale(0.95); }
.zoom-pct { width: 52px; height: 28px; border: 1px solid #D8C8C0; border-radius: 5px; background: #FEFCFA; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #5A4A44; font-family: 'Jost', sans-serif; text-align: center; cursor: text; transition: border-color 0.15s ease; flex-shrink: 0; }
.zoom-pct:hover { border-color: #C4806A; }
.zoom-pct:focus { outline: none; border-color: #C4806A; background: #FFF; }

.controls-divider {
  width: 1px;
  height: 34px;
  background: linear-gradient(to bottom, transparent, #D8C8C0 20%, #D8C8C0 80%, transparent);
  margin: 0 2px;
  flex-shrink: 0;
}

.controls-action-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: linear-gradient(135deg, #F5E6E0, #EAD0C5); border: 1.5px solid #C4806A; border-radius: 8px; font-family: 'Jost', sans-serif; font-size: 12px; font-weight: 600; color: #7A3F2D; cursor: pointer; transition: all 0.2s ease; white-space: nowrap; flex-shrink: 0; }
.controls-action-btn:hover { background: linear-gradient(135deg, #EAD0C5, #E0C0B0); border-color: #A65D3D; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(196, 128, 106, 0.25); }
.controls-action-btn.secondary { background: #F8F2ED; border-color: #D8C8C0; color: #7A6B5A; }
.controls-action-btn.secondary:hover { background: #F2E8E0; border-color: #C8B8B0; color: #5A4A44; }

@media (min-width: 769px) {
  .tree-controls-banner {
    display: grid;
    grid-template-columns: auto 1px auto;
    align-items: end;
    justify-content: center;
    column-gap: 18px;
  }

  .controls-zoom-group {
    grid-column: 1;
    justify-self: center;
    display: grid;
    grid-template-rows: auto auto;
    row-gap: 5px;
    align-content: end;
    justify-items: center;
  }

  .controls-divider {
    grid-column: 2;
    align-self: end;
    justify-self: center;
    height: 34px;
    margin: 0 0 1px 0;
  }

  .controls-nav-group {
    grid-column: 3;
    justify-self: center;
    display: grid;
    grid-template-columns: max-content minmax(220px, 240px);
    grid-template-areas:
      'navlabel searchlabel'
      'buttons  search';
    column-gap: 12px;
    row-gap: 0;
    align-items: end;
  }

  .controls-label {
    display: none;
  }

  .controls-nav-group > .controls-nav-buttons {
    grid-area: buttons;
    justify-content: center;
    width: auto;
    align-self: end;
    margin-top: 0;
    flex-wrap: nowrap;
  }

  .zoom-label {
    min-height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 0 0 2px 0;
    line-height: 1;
  }

  .rtb-search-overlay--inline {
    grid-area: search;
    width: 100%;
    min-width: 220px;
    max-height: none;
    opacity: 1;
    overflow: visible;
    margin: 0;
    position: relative;
    align-self: end;
    padding-top: 0;
    z-index: 60;
  }

  .rtb-search-overlay--inline::before {
    content: 'Search';
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 10px;
    margin: 0 0 3px 0;
    font-family: 'Jost', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #9A8070;
    letter-spacing: 0.3px;
    text-align: center;
    line-height: 1;
  }

  .controls-nav-group::before {
    content: 'Navigate';
    grid-area: navlabel;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3px;
    margin: 0;
    font-family: 'Jost', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #9A8070;
    letter-spacing: 0.3px;
    text-align: center;
    line-height: 1;
  }

  .controls-nav-group::after {
    content: '';
    display: none;
  }

  .rtb-search-overlay--inline .rtb-search-inner {
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
  }

  .rtb-search-overlay--inline .rtb-search-input {
    height: 30px;
    margin: 0 0 3px 0;
  }

  .rtb-search-overlay--inline .rtb-search-close,
  .rtb-search-overlay--inline .rtb-search-status {
    display: none;
  }

  .rtb-search-overlay--inline .rtb-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    margin: 0;
    background: #FEFCFA;
    border: 1px solid #E4D8D2;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    z-index: 60;
  }
}

@media (max-width: 768px) {
  .tree-controls-banner {
    width: 100%;
    display: flex;
    padding: 8px 12px 10px;
    gap: 8px;
  }

  .controls-nav-group > .controls-nav-buttons {
    justify-content: center;
  }
}

@media (max-width: 500px) {
  .controls-action-btn { padding: 6px 10px; font-size: 11px; }
  .controls-divider { margin: 0 2px; }
}

/* ── BOOK MODAL ─────────────────────────────────────────────── */
.book-modal-overlay { display: flex; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(45, 40, 35, 0.5); backdrop-filter: blur(8px); z-index: 2000; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.6s ease, visibility 0s linear 0.6s; align-items: center; justify-content: center; perspective: 2000px; }
.book-modal-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.6s ease, visibility 0s linear 0s; }
.book-modal-overlay.closing { transition: opacity 0.4s ease, visibility 0s linear 0.4s; }
.open-book { width: 700px; max-width: 92vw; height: 460px; max-height: 80vh; position: relative; transform-style: preserve-3d; transform: rotateY(-90deg) scale(0.85); transition: transform 0.9s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease; opacity: 0; background: linear-gradient(to right, #8B4513 0%, #A0522D 2.5%, #FDF8F0 2.5%, #FDF8F0 97.5%, #8B4513 97.5%, #A0522D 100%); border-radius: 8px 12px 12px 8px; box-shadow: 0 25px 80px rgba(0,0,0,0.4), 0 10px 30px rgba(0,0,0,0.3), inset 0 0 60px rgba(0,0,0,0.08); display: flex; overflow: hidden; }
.book-modal-overlay.active .open-book { transform: rotateY(0deg) scale(1); opacity: 1; }
.book-spine { position: absolute; left: 50%; top: 0; bottom: 0; width: 32px; transform: translateX(-50%); background: linear-gradient(to right, rgba(0,0,0,0.15), rgba(255,255,255,0.08) 20%, rgba(0,0,0,0.08) 50%, rgba(255,255,255,0.08) 80%, rgba(0,0,0,0.15)); z-index: 20; box-shadow: inset 2px 0 4px rgba(0,0,0,0.15), inset -2px 0 4px rgba(0,0,0,0.15); }
.book-spine::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; transform: translateX(-50%); background: linear-gradient(to bottom, transparent 2%, #C4806A 2%, #C4806A 98%, transparent 98%); opacity: 0.7; }
.book-left { flex: 1; padding: 24px 20px 20px 20px; display: flex; flex-direction: column; align-items: center; background: #FAF8F5; position: relative; overflow-y: auto; margin-right: 16px; }
.book-header { font-family: 'EB Garamond', serif; font-size: 22px; font-weight: 600; color: #2C2420; margin: 0 0 10px 0; line-height: 1.2; width: 100%; text-align: center; flex-shrink: 0; position: relative; padding-bottom: 12px; padding-right: 16px; }
.book-header::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 150px; height: 2.5px; background: linear-gradient(to right, transparent, #C4806A 15%, #C4806A 85%, transparent); }
#book-dates {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 14px;
  font-style: italic;
  color: #8B7355;
  text-align: center;
  margin: -2px 0 10px 0;
  line-height: 1.2;
  flex-shrink: 0;
  padding-right: 16px;
}
.book-photo-container { display: flex; flex-direction: column; align-items: center; margin: 12px 0 14px 0; flex-shrink: 0; padding-right: 16px; }
.book-photo-placeholder { width: 130px; height: 130px; border-radius: 4px; background: #F5F0EB; border: 2px dashed #C4B8AC; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8B7355; font-size: 12px; font-style: italic; font-family: 'EB Garamond', serif; position: relative; overflow: hidden; }
.book-photo-placeholder img { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; }
.book-photo-placeholder .silhouette { width: 50px; height: 50px; fill: #C4B8AC; margin-bottom: 6px; }
.book-photo-caption { font-size: 13px; color: #8B7355; font-style: italic; font-family: 'EB Garamond', Georgia, serif; text-align: center; margin-top: 8px; }
.book-bullets { list-style: none; padding: 0; margin: 0; width: 100%; text-align: left; padding-right: 16px; }
.book-bullets li { padding: 8px 0 8px 20px; color: #5A4A44; font-size: 14px; font-family: 'EB Garamond', Georgia, serif; line-height: 1.4; position: relative; border-bottom: 1px solid #E8E2DC; }
.book-bullets li::before { content: ''; position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; background: #C4806A; border-radius: 50%; }
.book-right { flex: 1.2; padding: 0; background: #FDF8F0; background-image: linear-gradient(#E8E0D5 1px, transparent 1px); background-size: 100% 26px; background-position: 0 13px; line-height: 26px; overflow-y: auto; overflow-x: hidden; position: relative; }
.book-right::before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 8px; background: linear-gradient(to right, transparent, rgba(253,248,240,0.5)); z-index: 2; pointer-events: none; }
.book-right-content { font-size: 15px; color: #3A3028; min-height: 100%; white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; overflow-x: hidden; padding: 16px 24px 24px 24px; line-height: 26px; font-family: 'EB Garamond', serif; }
.bio-link { color: #C4806A; text-decoration: underline; text-underline-offset: 2px; transition: color 0.2s; }
.bio-link:hover { color: #A65D3D; }
.bio-cite { font-size: 0.75em; text-decoration: none; color: #9A8070; font-family: "Jost", sans-serif; font-weight: 600; padding: 0 1px; }
.bio-cite:hover { color: #C4806A; }

.book-close { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: none; background: #C4806A; border-radius: 50%; cursor: pointer; font-size: 14px; font-weight: bold; line-height: 1; color: #FFF; z-index: 30; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.book-close:hover { background: #A65D3D; transform: scale(1.1) rotate(90deg); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .person-card { width: 280px !important; height: 145px !important; min-height: 145px; max-height: 145px; }
  .person-card h3 { font-size: 14px; padding-right: 50px; }
  .open-book { width: 95vw; height: 380px; }
  .book-left { padding: 20px 14px 16px 14px; margin-right: 10px; }
  .book-header { font-size: 18px; padding-right: 10px; }
  .book-photo-container { padding-right: 10px; }
  .book-photo-placeholder { width: 100px; height: 100px; }
  #tree-scroll { height: 65vh; }
}
@media (max-width: 480px) {
  .person-card { width: 240px !important; }
  .chevron-btn { width: 28px; height: 28px; font-size: 11px; }
  .badge-row svg { width: 20px; height: 20px; }
}

/* ── SEARCH OVERLAY ─────────────────────────────────────────── */
/* Append to root-to-branch.css */

.rtb-search-overlay {
  position: relative;
  z-index: 50;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.23, 1, 0.32, 1),
              opacity    0.25s ease;
  opacity: 0;
  margin: 0 auto 0;
  width: 100%;
  min-width: 0;
}

.rtb-search-overlay--open {
  max-height: 420px;
  opacity: 1;
  margin-bottom: 12px;
}

.rtb-search-inner {
  position: relative;
  padding: 10px 14px 12px;
  background: linear-gradient(to bottom, #f5f0eb 0%, #faf9f6 100%);
  border: 1px solid #E4D8D2;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.rtb-search-input {
  width: 100%;
  height: 36px;
  border: 1px solid #D8C8C0;
  border-radius: 8px;
  background: #FEFCFA;
  padding: 0 36px 0 12px;
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  color: #2C2420;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.rtb-search-input:focus { border-color: #C4806A; }

.rtb-search-input::placeholder {
  color: #B0A09A;
  font-style: italic;
  font-size: 12px;
}

/* hide browser search clear button */
.rtb-search-input::-webkit-search-cancel-button { display: none; }

.rtb-search-close {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 28px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 18px;
  color: #9A8070;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.rtb-search-close:hover { color: #C4806A; }

@media (min-width: 769px) {
  .rtb-search-overlay:not(.rtb-search-overlay--inline) {
    width: min(100%, 820px);
  }

  .controls-nav-group > .rtb-search-overlay--inline {
    width: 100%;
  }
}

@media (min-width: 769px) {
  .rtb-search-overlay--open {
    margin-top: -6px;
  }

  .rtb-search-inner {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }
}

.rtb-search-status {
  font-family: 'Jost', sans-serif;
  font-size: 11px;
  color: #9A8070;
  font-style: italic;
  margin-top: 6px;
  min-height: 16px;
  padding: 0 2px;
}

.rtb-search-results {
  list-style: none;
  padding: 0;
  margin: 4px 0 0 0;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.rtb-search-result {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(196, 128, 106, 0.1);
}

.rtb-search-result:last-child { border-bottom: none; }

.rtb-search-result:hover { background: rgba(196, 128, 106, 0.08); }

.rtb-search-result:active { background: rgba(196, 128, 106, 0.15); }

.rtb-search-result-name {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: #2C2420;
  flex-shrink: 0;
}

.rtb-search-result-placeholder { color: #8A8078; font-style: italic; font-weight: 400; }

.rtb-search-result-sub {
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  color: #9A8070;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── SEARCH HIGHLIGHT (card pulse after navigation) ──────────── */
@keyframes rtb-search-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(196, 128, 106, 0.7); }
  40%  { box-shadow: 0 0 0 10px rgba(196, 128, 106, 0.2); }
  70%  { box-shadow: 0 0 0 16px rgba(196, 128, 106, 0.05); }
  100% { box-shadow: 0 0 0 0   rgba(196, 128, 106, 0); }
}

.rtb-search-highlight {
  animation: rtb-search-pulse 2.4s ease-out forwards;
  border-color: #C4806A !important;
}

/* ── FLOATING ACTION BUTTONS (search + fullscreen) ────────────
   Positioned inside #tree-scroll bottom-right.
   Fade with nav-fade on interaction via .rtb-fab-group.
   ──────────────────────────────────────────────────────────── */
.rtb-fab-group {
  position: absolute;
  bottom: 28px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
  pointer-events: auto;
}

.rtb-fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(196, 128, 106, 0.4);
  background: rgba(253, 249, 246, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #7A3F2D;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  padding: 0;
}

.rtb-fab:hover {
  background: rgba(245, 230, 224, 0.96);
  border-color: #C4806A;
  transform: scale(1.08);
}

.rtb-fab:active { transform: scale(0.95); }

.rtb-fab.active {
  background: linear-gradient(135deg, #F5E6E0, #EAD0C5);
  border-color: #C4806A;
  box-shadow: 0 3px 10px rgba(196, 128, 106, 0.3);
}

/* Fade FABs during pan/zoom -- mirrors nav-fade behavior */
.rtb-fab-group.faded {
  opacity: 0.2;
  pointer-events: none;
}

/* ── PSEUDO-FULLSCREEN (iOS fallback) ─────────────────────────
   Applied when native fullscreen API is unavailable.
   ──────────────────────────────────────────────────────────── */
#tree-scroll.rtb-pseudo-fullscreen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  height: 100dvh !important;
  width: 100vw !important;
  z-index: 1000;
  border-radius: 0;
  border: none;
  isolation: isolate;
}

/* ── FULLSCREEN CONTROL BAR ───────────────────────────────────
   Injected inside #tree-scroll when pseudo-fullscreen is active.
   ──────────────────────────────────────────────────────────── */
.rtb-fs-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1010;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: fit-content;
  max-width: calc(100% - 20px);
  padding: 8px 54px 8px 14px;
  background: rgba(250, 248, 245, 0.96);
  border: 1px solid #E4D8D2;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-sizing: border-box;
  pointer-events: auto;
}

.rtb-fs-bar-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.rtb-fs-bar-group--zoom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.rtb-fs-bar-group--nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
}

.rtb-fs-btn {
  height: 30px;
  padding: 0 10px;
  border: 1px solid #D8C8C0;
  border-radius: 6px;
  background: rgba(254, 252, 250, 0.9);
  color: #5A4A44;
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.rtb-fs-btn:hover { border-color: #C4806A; color: #7A3F2D; background: #FDF8F5; }
.rtb-fs-btn--close:hover,
.rtb-fs-close-native:hover {
  transform: scale(1.1) rotate(90deg);
}
.rtb-fs-btn:active { transform: scale(0.96); }

.rtb-fs-btn--primary {
  background: linear-gradient(135deg, #F5E6E0, #EAD0C5);
  border-color: #C4806A;
  color: #7A3F2D;
}
.rtb-fs-btn--close {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  line-height: 1;
  border-radius: 50%;
  background: #C4806A;
  border-color: #C4806A;
  color: white;
  flex-shrink: 0;
  margin: 0;
}

.rtb-fs-btn--close,
.rtb-fs-close-native {
  transition: all 0.2s ease;
}

.rtb-fs-close-native {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
  background: #C4806A;
  border: 1px solid #C4806A;
  color: white;
  z-index: 1012;
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
}

.rtb-fs-close-native:hover {
  background: #A65D3D;
  border-color: #A65D3D;
  color: white;
}

.rtb-fs-zoom-pct {
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #5A4A44;
  min-width: 38px;
  text-align: center;
}

/* Search overlay repositioned inside fullscreen viewport */
.rtb-search-overlay--in-fs {
  position: absolute;
  top: 64px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  z-index: 1009;
  max-height: none !important;
  margin: 0 !important;
  width: min(calc(100% - 20px), 760px);
  isolation: isolate;
  pointer-events: auto;
}

.rtb-search-overlay--in-fs .rtb-search-inner {
  position: relative;
  z-index: 1;
  transform: translateZ(0);
}

.book-modal-overlay--in-fs {
  position: absolute;
  inset: 0;
  z-index: 2000;
}

.rtb-search-overlay--in-fs.rtb-search-overlay--open {
  max-height: 360px !important;
}

/* ── LANDSCAPE PSEUDO-FULLSCREEN FIXES ───────────────────────
   In landscape, viewport is shorter -- adjust FAB position.
   Raise stacking context to ensure visibility.
   ──────────────────────────────────────────────────────────── */
@media (orientation: landscape) {
  #tree-scroll.rtb-pseudo-fullscreen .rtb-fab-group {
    bottom: 12px;
    right: 12px;
    z-index: 1010;
  }
  #tree-scroll.rtb-pseudo-fullscreen .rtb-fs-bar {
    z-index: 1010;
  }
}

/* Always ensure FABs are above canvas in pseudo-fullscreen */
#tree-scroll.rtb-pseudo-fullscreen .rtb-fab-group {
  position: absolute;
  bottom: 24px;
  right: 14px;
  display: flex !important;
  visibility: visible !important;
  opacity: 1;
  z-index: 1010;
  pointer-events: auto;
}

#tree-scroll.rtb-pseudo-fullscreen .rtb-fs-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  z-index: 1010;
  display: flex !important;
  visibility: visible !important;
  max-width: calc(100% - 20px);
}


/* Search dropdown visibility fixes for inline desktop/landscape mode */
.tree-controls-banner,
.controls-nav-group,
.controls-nav-buttons,
.rtb-search-overlay,
.rtb-search-overlay--inline,
.rtb-search-inner {
  overflow: visible;
}

.rtb-search-overlay--inline {
  position: relative;
  z-index: 250;
}

.rtb-search-overlay--inline .rtb-search-inner {
  position: relative;
  z-index: 1;
}

.rtb-search-overlay--inline .rtb-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 260;
}