/* ============================================================
   lore-family-tree.css  –  Tree-of-life styling
   Sons        → cool blue cards
   Daughters   → warm rose cards
   Ruler       → gold halo + crown
   Spouse box  → distinct lavender accent below the card
   Layout      → horizontally scrollable, responsive on mobile
   ============================================================ */

/* ──────────────────────────────────────────────────────────
   Local colour palette (extends global tokens in style.css)
   ────────────────────────────────────────────────────────── */
.lore-content {
  --ftree-male:        #6fa8dc;
  --ftree-male-soft:   rgba(111, 168, 220, 0.18);
  --ftree-male-glow:   rgba(111, 168, 220, 0.35);
  --ftree-female:      #d68bb6;
  --ftree-female-soft: rgba(214, 139, 182, 0.18);
  --ftree-female-glow: rgba(214, 139, 182, 0.35);
  --ftree-ruler:       var(--gold);
  --ftree-ruler-light: var(--gold-light);
  --ftree-ruler-glow:  rgba(232, 196, 74, 0.35);
  --ftree-spouse:      #c8a2e6;          /* lavender — distinct from male/female */
  --ftree-spouse-soft: rgba(200, 162, 230, 0.12);
  --ftree-line:        rgba(180, 153, 109, 0.35);
  --ftree-line-strong: rgba(232, 196, 74, 0.85);
}

/* ──────────────────────────────────────────────────────────
   Branch sections
   ────────────────────────────────────────────────────────── */
.ftree-branch {
  margin: 0 0 2.6rem;
  padding: 1rem 0 0.4rem;
  border-top: 1px solid rgba(201, 162, 39, 0.15);
}
.ftree-branch:first-of-type { border-top: none; padding-top: 0; }

.ftree-branch__title {
  font-family: 'Cinzel', serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--gold-light);
  margin: 0 0 0.25rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--gold);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.ftree-branch__title::before {
  content: '✦';
  color: var(--gold);
  font-size: 0.85em;
  opacity: 0.85;
}
.ftree-branch__subtitle {
  font-family: 'Crimson Text', serif;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin: 0 0 0.45rem;
}
.ftree-branch__connection {
  font-family: 'Crimson Text', serif;
  font-size: 0.82rem;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.06);
  border-left: 3px solid var(--gold);
  padding: 0.4rem 0.75rem;
  margin: 0 0 0.9rem;
  border-radius: 0 4px 4px 0;
}
.ftree-branch__connection a { color: var(--gold-light); text-decoration: underline; }
.ftree-branch__connection a:hover { color: var(--gold); }

/* ──────────────────────────────────────────────────────────
   Scroll wrapper — keeps wide trees usable on every screen
   ────────────────────────────────────────────────────────── */
.ftree-scroll {
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
  padding: 0.4rem 0 0.7rem;
  /* Gold-tinted scrollbar so it blends with the parchment look */
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}
.ftree-scroll::-webkit-scrollbar { height: 8px; }
.ftree-scroll::-webkit-scrollbar-track { background: transparent; }
.ftree-scroll::-webkit-scrollbar-thumb {
  background: rgba(201, 162, 39, 0.25);
  border-radius: 4px;
}
.ftree-scroll::-webkit-scrollbar-thumb:hover { background: rgba(201, 162, 39, 0.45); }

.ftree-scroll__inner {
  display: inline-flex;        /* shrink-to-fit so very wide trees scroll */
  flex-direction: column;
  align-items: center;
  min-width: 100%;
  padding: 0.5rem 0.8rem 0.3rem;
}

/* ──────────────────────────────────────────────────────────
   Person card  (the trunk node of the tree)
   ────────────────────────────────────────────────────────── */
.ftree-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  align-items: center;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-card) 0%, #15151f 100%);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 0.45rem 0.85rem 0.5rem;
  cursor: pointer;
  min-width: 138px;
  max-width: 220px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  outline: none;
}
.ftree-card:hover,
.ftree-card:focus-visible {
  transform: translateY(-3px) scale(1.04);
  border-color: var(--gold-light);
  background:
    linear-gradient(180deg, rgba(232, 196, 74, 0.08) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-card) 0%, #1b1a26 100%);
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--gold-light),
    0 0 18px rgba(232, 196, 74, 0.35);
  z-index: 5;
}

.ftree-card__name {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1.15;
  white-space: normal;
}
.ftree-card__name a { color: inherit; text-decoration: none; }
.ftree-card__name a:hover { color: var(--gold); text-decoration: underline; }

.ftree-card__epithet {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.1;
}
.ftree-card__title-tag {
  font-family: 'Crimson Text', serif;
  font-size: 0.68rem;
  color: var(--gold);
  font-style: italic;
  margin-top: 0.1rem;
}

/* Crown badge (rulers only) */
.ftree-card__crown {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--bg-deep);
  background: radial-gradient(circle, var(--gold-light) 0%, var(--gold) 75%);
  border: 1px solid var(--gold-light);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--ftree-ruler-glow);
  pointer-events: none;
}

/* Compact meta row inside the card */
.ftree-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  margin-top: 0.15rem;
  font-family: 'Crimson Text', serif;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.ftree-meta__item {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  white-space: nowrap;
}
.ftree-meta__item .lore-icon {
  width: 0.78rem;
  height: 0.78rem;
  color: var(--text-muted);
}
.ftree-meta__item--reign { color: var(--gold); }
.ftree-meta__item--reign .lore-icon { color: var(--gold); }

/* ── Gender-tinted variants ── */
.ftree-card--male {
  border-color: rgba(111, 168, 220, 0.55);
  background:
    linear-gradient(180deg, rgba(111, 168, 220, 0.08) 0%, transparent 80%),
    linear-gradient(180deg, var(--bg-card) 0%, #15151f 100%);
  box-shadow: inset 0 0 0 1px rgba(111, 168, 220, 0.08);
}
.ftree-card--male .ftree-card__name        { color: #d6e6f5; }
.ftree-card--male:hover,
.ftree-card--male:focus-visible {
  border-color: var(--ftree-male);
  background:
    linear-gradient(180deg, rgba(111, 168, 220, 0.16) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-card) 0%, #181925 100%);
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--ftree-male),
    0 0 18px var(--ftree-male-glow);
}

.ftree-card--female {
  border-color: rgba(214, 139, 182, 0.55);
  background:
    linear-gradient(180deg, rgba(214, 139, 182, 0.08) 0%, transparent 80%),
    linear-gradient(180deg, var(--bg-card) 0%, #15151f 100%);
  box-shadow: inset 0 0 0 1px rgba(214, 139, 182, 0.08);
}
.ftree-card--female .ftree-card__name      { color: #f4dce8; }
.ftree-card--female:hover,
.ftree-card--female:focus-visible {
  border-color: var(--ftree-female);
  background:
    linear-gradient(180deg, rgba(214, 139, 182, 0.18) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-card) 0%, #1d1925 100%);
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--ftree-female),
    0 0 18px var(--ftree-female-glow);
}

/* Ruler — gold halo overrides the base/gender border but keeps the tint */
.ftree-card--ruler {
  border-color: var(--gold);
  box-shadow:
    inset 0 0 0 1px rgba(232, 196, 74, 0.18),
    0 0 14px rgba(212, 175, 55, 0.18);
  padding-top: 0.7rem;        /* room for the crown badge */
}
.ftree-card--ruler .ftree-card__name { color: var(--gold-light); }
.ftree-card--ruler:hover,
.ftree-card--ruler:focus-visible {
  border-color: var(--gold-light);
  background:
    linear-gradient(180deg, rgba(232, 196, 74, 0.18) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-card) 0%, #1d1b22 100%);
  box-shadow:
    inset 0 0 0 1px rgba(232, 196, 74, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.65),
    0 0 0 1px var(--gold-light),
    0 0 26px rgba(232, 196, 74, 0.55);
}
.ftree-card--ruler:hover .ftree-card__crown,
.ftree-card--ruler:focus-visible .ftree-card__crown {
  box-shadow: 0 0 14px var(--ftree-ruler-glow), 0 0 26px var(--ftree-ruler-glow);
  transform: translateX(-50%) scale(1.1);
}

/* When a spouse box hangs below — flatten the bottom of the card */
.ftree-card--has-spouses {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-style: dashed;
}

/* ──────────────────────────────────────────────────────────
   Spouse box  (one or more wives/husbands listed under a card)
   ────────────────────────────────────────────────────────── */
.ftree-unit {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}
.ftree-spouses {
  background:
    linear-gradient(180deg, var(--ftree-spouse-soft) 0%, transparent 100%),
    var(--bg-deep);
  border: 1px solid var(--border-dim);
  border-top: none;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  padding: 0.22rem 0.55rem 0.28rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 138px;
  max-width: 220px;
  margin: 0 auto;
}
.ftree-spouses--ruler { border-color: var(--gold); }
.ftree-spouses--from-male   { border-color: rgba(111, 168, 220, 0.55); border-top: none; }
.ftree-spouses--from-female { border-color: rgba(214, 139, 182, 0.55); border-top: none; }
.ftree-spouses--ruler.ftree-spouses--from-male,
.ftree-spouses--ruler.ftree-spouses--from-female { border-color: var(--gold); }

.ftree-spouse-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.35rem;
  margin: 0 -0.25rem;
  border-radius: 4px;
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 0.74rem;
  color: var(--ftree-spouse);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ftree-spouse-chip__symbol {
  color: var(--gold-light);
  font-size: 0.85rem;
  font-style: normal;
  flex-shrink: 0;
}
.ftree-spouse-chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.ftree-spouse-chip:hover {
  color: #f0d9fa;
  background: rgba(200, 162, 230, 0.18);
  transform: translateX(2px);
}
.ftree-spouse-chip:hover .ftree-spouse-chip__symbol { color: var(--gold-light); }

/* Non-clickable: this spouse has no dynasty entry, so we visually demote it.
   Muted brown-grey, no italic-link cue, dotted symbol — the user instantly
   sees "this isn't a link" before even hovering. */
.ftree-spouse-chip--no-click {
  cursor: default;
  color: var(--text-dim);
  font-style: italic;
  opacity: 0.78;
}
.ftree-spouse-chip--no-click .ftree-spouse-chip__symbol {
  color: var(--text-dim);
  opacity: 0.7;
}
.ftree-spouse-chip--no-click:hover {
  color: var(--text-dim);
  background: transparent;
  transform: none;
}
.ftree-spouse-chip--no-click:hover .ftree-spouse-chip__symbol {
  color: var(--text-dim);
}

/* If we know the spouse's gender, tint the chip name accordingly so it stays
   visually consistent with the rest of the tree. */
.ftree-spouse-chip--female { color: #ecc6db; }
.ftree-spouse-chip--female:hover {
  color: #fbe4ee;
  background: rgba(214, 139, 182, 0.22);
}
.ftree-spouse-chip--male   { color: #b9d4ee; }
.ftree-spouse-chip--male:hover {
  color: #e3eef9;
  background: rgba(111, 168, 220, 0.22);
}

/* ──────────────────────────────────────────────────────────
   Tree connectors
   ────────────────────────────────────────────────────────── */
.ftree-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

/* Vertical stem from a unit down to its children junction */
.ftree-stem {
  width: 2px;
  height: 1.4rem;
  background: var(--ftree-line);
  flex-shrink: 0;
}
.ftree-stem--main {
  width: 3px;
  background: var(--ftree-line-strong);
  box-shadow: 0 0 4px var(--ftree-ruler-glow);
}

/* Children row — horizontal */
.ftree-children {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  padding-top: 1.1rem;
  gap: 0.1rem;
}
.ftree-children--single { padding-top: 0; }   /* no extra gap if there's one child */

/* Each child slot — draws part of the horizontal bar via ::before */
.ftree-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 0.45rem;
  min-width: 0;
}
.ftree-child::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-top: 2px solid var(--ftree-line);
}
.ftree-child:first-child::before { left: 50%; }
.ftree-child:last-child::before  { right: 50%; }
.ftree-child:only-child::before  { display: none; }

/* Vertical drop from horizontal bar down to the child's unit */
.ftree-child::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 1.1rem;
  background: var(--ftree-line);
  transform: translateX(-50%);
}
.ftree-child:only-child::after { height: 0; }

/* Ruler-bearing child — gold connectors */
.ftree-child--main::before {
  border-top-color: var(--ftree-line-strong);
  border-top-width: 3px;
}
.ftree-child--main::after {
  background: var(--ftree-line-strong);
  width: 3px;
  box-shadow: 0 0 4px var(--ftree-ruler-glow);
}

/* Push the child unit/subtree below the drop line */
.ftree-child > .ftree-unit { margin-top: 1.1rem; }
.ftree-child > .ftree-tree { margin-top: 1.1rem; }
.ftree-child:only-child > .ftree-unit,
.ftree-child:only-child > .ftree-tree { margin-top: 0; }

/* ── Centered-main row: compact siblings around a single ruler-child ──
   Phantom slots pad the row so the main is exactly centred under the
   parent's stem. Connector edges are driven by --first-visible /
   --last-visible classes (NOT :first-child / :last-child) because the
   visible edges may be inset behind invisible phantoms. */
.ftree-children--centered-main .ftree-child--phantom {
  min-width: 138px;
  visibility: hidden;
  pointer-events: none;
}
.ftree-children--centered-main .ftree-child--phantom::before,
.ftree-children--centered-main .ftree-child--phantom::after { display: none; }

.ftree-children--centered-main .ftree-child--first-visible::before { left: 50%; }
.ftree-children--centered-main .ftree-child--last-visible::before  { right: 50%; }
.ftree-children--centered-main
  .ftree-child--first-visible.ftree-child--last-visible::before { display: none; }

@media (max-width: 760px) {
  .ftree-children--centered-main .ftree-child--phantom { min-width: 122px; }
}
@media (max-width: 480px) {
  .ftree-children--centered-main .ftree-child--phantom { min-width: 108px; }
}

/* ──────────────────────────────────────────────────────────
   Gap markers, indirect notes, orphans
   ────────────────────────────────────────────────────────── */
.ftree-gap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  justify-content: center;
}
.ftree-gap__dots {
  font-size: 1.4rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  line-height: 1;
}
.ftree-gap__note {
  font-family: 'Crimson Text', serif;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.ftree-indirect {
  font-family: 'Crimson Text', serif;
  font-size: 0.74rem;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.06);
  border: 1px dashed rgba(212, 175, 55, 0.3);
  border-radius: 4px;
  padding: 0.25rem 0.7rem;
  margin: 0.5rem auto 0.4rem;
  display: table;
  text-align: center;
}

.ftree-orphans {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  padding-top: 0.6rem;
}
.ftree-orphans .ftree-unit { flex: 0 0 auto; }

/* ──────────────────────────────────────────────────────────
   Branch nav (jump links)
   ────────────────────────────────────────────────────────── */
.ftree-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.ftree-nav__link {
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  padding: 0.32rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  color: var(--gold-light);
  text-decoration: none;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.ftree-nav__link:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212, 175, 55, 0.06);
}

/* ──────────────────────────────────────────────────────────
   Responsive — keep the tree readable on phones / tablets
   ────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .ftree-branch__title    { font-size: 1.05rem; }
  .ftree-branch__subtitle { font-size: 0.8rem; }
  .ftree-card             { min-width: 122px; max-width: 180px; padding: 0.4rem 0.65rem 0.45rem; }
  .ftree-card--ruler      { padding-top: 0.65rem; }
  .ftree-card__name       { font-size: 0.78rem; }
  .ftree-card__epithet    { font-size: 0.68rem; }
  .ftree-meta             { font-size: 0.66rem; }
  .ftree-spouses          { min-width: 122px; max-width: 180px; padding: 0.18rem 0.45rem 0.22rem; }
  .ftree-spouse-chip      { font-size: 0.7rem; }
  .ftree-children         { padding-top: 0.95rem; }
  .ftree-child            { padding: 0 0.3rem; }
  .ftree-stem             { height: 1.1rem; }
  .ftree-child::after     { height: 0.95rem; }
}

@media (max-width: 480px) {
  .ftree-card             { min-width: 108px; max-width: 160px; padding: 0.35rem 0.5rem 0.4rem; }
  .ftree-card__name       { font-size: 0.74rem; }
  .ftree-card__epithet    { font-size: 0.64rem; }
  .ftree-meta             { gap: 0.3rem; font-size: 0.62rem; }
  .ftree-spouses          { min-width: 108px; max-width: 160px; }
  .ftree-spouse-chip      { font-size: 0.66rem; }
  .ftree-card__crown      { width: 18px; height: 18px; line-height: 18px; font-size: 0.7rem; top: -8px; }
  .ftree-nav__link        { font-size: 0.72rem; padding: 0.28rem 0.65rem; }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .ftree-card,
  .ftree-card:hover,
  .ftree-card:focus-visible {
    transform: none;
    transition: none;
  }
  .ftree-spouse-chip:hover { transform: none; }
}

/* ──────────────────────────────────────────────────────────
   Floating sticky horizontal scrollbar
   Always glued to the bottom of the viewport whenever a tree
   branch is in view, so the user never has to scroll all the
   way down before they can drag the tree sideways.
   ────────────────────────────────────────────────────────── */
.ftree-floating-scrollbar {
  position: fixed;
  bottom: 14px;
  height: 16px;
  z-index: 90;
  display: none;
  align-items: center;
  padding: 0 3px;
  border-radius: 9px;
  background: rgba(13, 13, 26, 0.86);
  border: 1px solid rgba(201, 162, 39, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.ftree-floating-scrollbar.is-visible {
  display: flex;
  opacity: 1;
}
.ftree-floating-scrollbar__thumb {
  height: 9px;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
  border-radius: 5px;
  cursor: grab;
  transition: filter 0.15s ease;
  box-shadow: 0 0 6px rgba(232, 196, 74, 0.45);
  flex-shrink: 0;
}
.ftree-floating-scrollbar__thumb:hover { filter: brightness(1.15); }
.ftree-floating-scrollbar.is-dragging .ftree-floating-scrollbar__thumb {
  filter: brightness(1.25);
  cursor: grabbing;
}

/* Floating label above the scrollbar that names the active branch */
.ftree-floating-scrollbar__label {
  position: fixed;
  bottom: 36px;
  z-index: 91;
  padding: 0.3rem 0.7rem;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--gold-light);
  background: rgba(13, 13, 26, 0.86);
  border: 1px solid rgba(201, 162, 39, 0.4);
  border-radius: 5px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.18s ease;
  display: none;
}
.ftree-floating-scrollbar__label.is-visible {
  display: block;
  opacity: 1;
}
.ftree-floating-scrollbar__label::before {
  content: '⇆ ';
  color: var(--gold);
  margin-right: 0.2rem;
}

/* Pan-mode cursor while the user is middle-click-dragging a branch */
.ftree-scroll--panning,
.ftree-scroll--panning * { cursor: grabbing !important; }
body.ftree-panning { cursor: grabbing; }

/* ──────────────────────────────────────────────────────────
   Persistent detail panel — page stays interactive
   The right-side modal opens as before but we drop the dim
   backdrop and the click-out-to-close behaviour. The user
   dismisses it via × or Escape; meanwhile the rest of the
   page (tree, sidebar, scrollbar) stays fully clickable.
   ────────────────────────────────────────────────────────── */
body.ftree-modal-open .lore-modal-backdrop {
  background: transparent;
  pointer-events: none;
}

/* On wide screens we shift the whole .lore-layout (which is normally
   max-width:1200 margin:0 auto) toward the left so its right edge sits
   flush against the panel's left edge. Padding on .lore-content alone
   wouldn't move the box — it only shrinks the inner area, leaving a
   dark stripe of "outer margin" between the tree and the panel. */
.lore-layout { transition: margin-right 0.28s ease, margin-left 0.28s ease; }
@media (min-width: 1180px) {
  body.ftree-modal-open .lore-layout {
    margin-right: min(480px, 90vw);
    margin-left: auto;
  }
}

/* ──────────────────────────────────────────────────────────
   Modal: ruler detail link + clean spouse list
   ────────────────────────────────────────────────────────── */
.ftree-modal__detail-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0.4rem 0 0.9rem;
  padding: 0.55rem 0.9rem;
  font-family: 'Cinzel', serif;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  color: var(--gold-light);
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.18) 0%, rgba(201, 162, 39, 0.06) 100%);
  border: 1px solid var(--gold);
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.ftree-modal__detail-link:hover,
.ftree-modal__detail-link:focus-visible {
  background: linear-gradient(90deg, rgba(232, 196, 74, 0.28) 0%, rgba(201, 162, 39, 0.12) 100%);
  color: var(--gold-light);
  transform: translateX(2px);
  box-shadow: 0 4px 14px rgba(201, 162, 39, 0.25);
}
.ftree-modal__detail-link-arrow {
  font-size: 1.05rem;
  transition: transform 0.18s ease;
}
.ftree-modal__detail-link:hover .ftree-modal__detail-link-arrow { transform: translateX(4px); }

/* Spouse rows inside the modal — properly aligned, multi-line safe */
.ftree-modal__spouses {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.ftree-modal__spouse-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 0.3rem 0.55rem;
  padding: 0.35rem 0.55rem;
  background: rgba(200, 162, 230, 0.06);
  border-left: 2px solid rgba(200, 162, 230, 0.4);
  border-radius: 0 4px 4px 0;
}
.ftree-modal__spouse-symbol {
  color: var(--gold-light);
  font-size: 1rem;
  line-height: 1;
}
.ftree-modal__spouse-name {
  font-family: 'Cinzel', serif;
  font-size: 0.86rem;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  border-bottom: 1px dashed rgba(232, 196, 74, 0.35);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ftree-modal__spouse-name:hover {
  color: var(--gold-light);
  border-bottom-color: var(--gold-light);
}
.ftree-modal__spouse-name--plain {
  cursor: default;
  border-bottom: 1px dashed transparent;
  color: var(--text-dim);
  font-style: italic;
  font-weight: 400;
  opacity: 0.85;
}
.ftree-modal__spouse-name--plain:hover {
  color: var(--text-dim);
  border-bottom-color: transparent;
}
.ftree-modal__spouse-year {
  font-family: 'Crimson Text', serif;
  font-size: 0.78rem;
  color: var(--gold);
  white-space: nowrap;
}
.ftree-modal__spouse-note {
  grid-column: 1 / -1;
  font-family: 'Crimson Text', serif;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
}
@media (max-width: 480px) {
  .ftree-modal__spouse-row {
    grid-template-columns: auto 1fr;
  }
  .ftree-modal__spouse-year {
    grid-column: 2;
  }
}
