/* ======================================================================
   THE FAMILY TREE (client/js/ui/family.js), maggie, 2026-09-30:
   "B on phone, C on desktop".
     - the roll (.ft-roll): one gilt stem, couples as rows joined by a
       lozenge, children indented beneath - the Relations tab at every
       width, and the expanded view on a wide screen;
     - the focus (.ft-phone): one person in a large arch with their people
       around them - the expanded view on a phone.
   Every face is the chat's gilt arch (.chat-frame / .chat-face from
   chat.css) in three sizes. The pennant at its foot is painted in the
   house's own colours (--hc, --hc2), set inline from houses.json; with none
   it falls back to the gilt. Inks are tokens, so both themes are right.
   ====================================================================== */

.ft-wrap {
  --ft-pewter: linear-gradient(160deg, #9a969e, #4a474e 55%, #77737c);
  --ft-band: #0b0a0d;
  --ft-stem: var(--accent-gold);
  --ft-stem-muted: color-mix(in srgb, var(--accent-gold) 45%, var(--text-muted));
  container-type: inline-size;
  font-family: var(--font-serif);
  color: var(--text-primary);
}

/* -- the leaf: the panel look of the manuscript (layout.css .panel-card) -- */
.ft-leaf {
  position: relative;
  background:
    var(--c-tl) top 3px left 3px / 26px no-repeat,
    var(--c-tr) top 3px right 3px / 26px no-repeat,
    var(--c-bl) bottom 3px left 3px / 26px no-repeat,
    var(--c-br) bottom 3px right 3px / 26px no-repeat,
    var(--grain),
    linear-gradient(180deg, var(--vellum-1), var(--vellum-2));
  border: 1px solid var(--gild-faint);
  border-radius: 2px;
  box-shadow:
    inset 0 0 0 4px var(--vellum-2),
    inset 0 0 0 5px color-mix(in srgb, var(--accent-gold) 12%, transparent),
    var(--vellum-shadow);
  padding: 1rem 1.05rem;
}
.ft-rubric {
  font-family: var(--font-display); font-variant: small-caps; letter-spacing: .1em;
  color: var(--accent-gold); font-size: var(--fs-text); font-weight: 500;
  padding-bottom: .4rem; margin: 0 0 .6rem;
  background: linear-gradient(90deg, var(--gild), var(--gild-faint) 70%, transparent) bottom / 100% 1px no-repeat;
}

/* -- the arch, in three sizes ------------------------------------------- */
.ft-arch { position: relative; display: inline-block; flex: none; z-index: 1; }
.ft-arch .chat-frame { display: block; flex: none; }
.ft-arch .chat-face { display: block; }
.ft-arch.s { margin-bottom: 7px; }
.ft-arch.s .chat-frame { width: 46px; padding: 2px; border-radius: 23px 23px 3px 3px; }
.ft-arch.s .chat-face { width: 42px; height: 56px; border-radius: 21px 21px 2px 2px; }
.ft-arch.l { margin-bottom: 14px; }
.ft-arch.l .chat-frame { width: 104px; padding: 4px; border-radius: 52px 52px 5px 5px; }
.ft-arch.l .chat-face { width: 96px; height: 128px; border-radius: 48px 48px 3px 3px; }
.ft-arch.xs { margin-bottom: 5px; }
.ft-arch.xs .chat-frame { width: 34px; padding: 2px; border-radius: 17px 17px 3px 3px; box-shadow: none; }
.ft-arch.xs .chat-face { width: 30px; height: 40px; border-radius: 15px 15px 2px 2px; }
/* the reader: a warm halo round the gilt */
.ft-p.me .ft-arch .chat-frame {
  box-shadow: 0 0 0 2px var(--bg-void), 0 0 0 3px var(--accent-gold),
    0 0 18px color-mix(in srgb, var(--accent-gold) 45%, transparent);
}
/* the dead: pewter for gold, the face gone to ash, a black mourning band */
.ft-p.dead .ft-arch .chat-frame { background: var(--ft-pewter); }
.ft-p.dead .ft-arch .chat-face { filter: grayscale(1) brightness(.72) contrast(.95); }
.ft-p.dead .ft-arch::after {
  content: ''; position: absolute; top: 9%; right: -3px; width: 42%; height: 12%;
  background: var(--ft-band); border-top: 1px solid #5a565e; border-bottom: 1px solid #5a565e;
  transform: rotate(38deg); transform-origin: right center;
}
.ft-p.dead .ft-arch.l::after { height: 10%; }
/* a guest (an in-law, kin who bears the other house, a ward): a thinner, cooler frame */
.ft-p.guest .ft-arch .chat-frame {
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--accent-gold) 45%, #999),
    color-mix(in srgb, var(--accent-gold) 30%, #222) 55%,
    color-mix(in srgb, var(--accent-gold) 50%, #777));
}

/* -- the house pennant at the foot of the arch -------------------------- */
.ft-pen {
  position: absolute; left: 50%; bottom: -8px; width: 12px; height: 15px; margin-left: -6px;
  background: linear-gradient(180deg, var(--hc, var(--accent-gold)) 0 64%, var(--hc2, var(--hc, var(--accent-gold))) 64%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  z-index: 2;
}
.ft-pen::before { /* gilt edge */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--accent-gold) 1.5px, transparent 1.5px, transparent calc(100% - 1.5px), var(--accent-gold) calc(100% - 1.5px));
  opacity: .9;
}
/* a bastard: the bend sinister across the house's colour */
.ft-p.bastard .ft-pen { background: linear-gradient(45deg, var(--hc, var(--accent-gold)) 38%, var(--ft-band) 38%, var(--ft-band) 62%, var(--hc, var(--accent-gold)) 62%); }
.ft-arch.xs .ft-pen { width: 10px; height: 12px; margin-left: -5px; bottom: -6px; }
.ft-arch.l .ft-pen { width: 22px; height: 28px; margin-left: -11px; bottom: -12px; }

/* -- the words under a face --------------------------------------------- */
.ft-nm { display: block; font-family: var(--font-display); font-variant: small-caps; letter-spacing: .04em; line-height: 1.08; color: var(--text-primary); font-size: 17px; }
.ft-sur { display: block; font-size: max(12px, .78em); color: var(--text-secondary); letter-spacing: .06em; }
.ft-p.dead .ft-nm, .ft-p.guest .ft-nm { color: var(--text-secondary); }
.ft-ln { font-family: var(--font-serif); font-style: italic; font-size: var(--fs-small); color: var(--accent-gold); line-height: 1.2; margin-top: 2px; }
.ft-p.dead .ft-ln { color: var(--text-muted); }
.ft-ln.rub { color: var(--rubric); }
.ft-role { display: block; font-family: var(--font-display); font-variant: small-caps; letter-spacing: .1em; font-size: var(--fs-fine); color: var(--text-muted); }

/* -- house chips with a pennant ----------------------------------------- */
.ft-chips { display: flex; flex-wrap: nowrap; gap: .4rem; overflow-x: auto; scrollbar-width: none; }
.ft-chip {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; padding: .3rem .75rem .3rem .55rem;
  font-family: var(--font-display); font-variant: small-caps; letter-spacing: .07em; font-size: 15px;
  border: 1px solid var(--gild-faint); border-radius: 0; color: var(--text-secondary); background: transparent;
  white-space: nowrap; cursor: pointer;
}
.ft-chip i { width: 11px; height: 14px; flex: none; background: linear-gradient(180deg, var(--hc, var(--accent-gold)) 0 64%, var(--hc2, var(--hc, var(--accent-gold))) 64%); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
.ft-chip b { font-weight: 400; color: var(--text-muted); font-variant-numeric: oldstyle-nums; }
.ft-chip.on { border-color: var(--accent-gold); color: var(--accent-gold); background: color-mix(in srgb, var(--accent-gold) 8%, transparent); }
/* A strip with chips scrolled out of sight fades on that edge, as the tab rows
   do (controls.css); the classes are kept by setupTabRows() in setup.js. */
.ft-chips::-webkit-scrollbar { display: none; }
.ft-chips.is-over-r {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 2.5rem), transparent);
          mask-image: linear-gradient(90deg, #000 calc(100% - 2.5rem), transparent);
}
.ft-chips.is-over-l {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 2.5rem);
          mask-image: linear-gradient(90deg, transparent, #000 2.5rem);
}
.ft-chips.is-over-l.is-over-r {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent);
}

/* -- the line of succession, with faces --------------------------------- */
.ft-holder { font-style: italic; color: var(--accent-gold); font-size: var(--fs-text); margin: -.2rem 0 .4rem; }
.ft-succ { list-style: none; margin: 0; padding: 0; }
.ft-succ li { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; border-bottom: 1px dotted var(--gild-faint); }
.ft-succ li:last-child { border-bottom: 0; }
.ft-succ .ft-n { width: 1.6rem; flex: none; font-family: var(--font-display); color: var(--accent-gold); font-variant-numeric: oldstyle-nums; font-size: 16px; }
.ft-succ .ft-sname { font-size: 16px; min-width: 0; }
.ft-succ .ft-pen { display: none; }
.ft-succ .ft-arch.xs { margin-bottom: 0; }

/* ======================================================================
   THE ROLL (design C)
   ====================================================================== */
.ft-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.ft-tools .ft-chips { flex: 1 1 auto; min-width: 0; }
.ft-expand { margin-left: auto; }
.ft-rollgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
@container (min-width: 820px) {
  .ft-rollgrid { grid-template-columns: minmax(0, 1fr) 300px; }
  .ft-rollgrid > .ft-side { position: sticky; top: 1rem; }
}
.ft-roll { min-width: 0; overflow-x: auto; }
.ft-page { padding: 1.3rem 1.6rem; }

.ft-who { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.ft-txt { min-width: 0; }
.ft-couple { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .2rem; }
.ft-knot { flex: none; width: 26px; height: 2px; background: var(--accent-gold); position: relative; margin: 0 .2rem; align-self: center; }
.ft-knot::after { content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; background: var(--accent-gold); transform: rotate(45deg); }
.ft-knot.faint { opacity: .45; }
.ft-wives { display: flex; flex-direction: column; gap: .45rem; }
.ft-wife { display: flex; align-items: center; }
.ft-wife .ft-nm { font-size: 15px; }

/* the stem: each child hangs off one vertical gilt line by a short tick */
.ft-issue { position: relative; margin: .2rem 0 0 22px; padding-left: 26px; }
.ft-issue::before { content: ''; position: absolute; left: 0; top: -.2rem; height: .2rem; width: 2px; background: var(--ft-stem); }
.ft-it { position: relative; padding: .5rem 0; }
.ft-it::after { content: ''; position: absolute; left: -26px; top: 0; bottom: 0; width: 2px; background: var(--ft-stem); }
.ft-it:last-child::after { bottom: auto; height: 38px; }
.ft-it::before { content: ''; position: absolute; left: -26px; top: 37px; width: 20px; height: 2px; background: var(--ft-stem); }
.ft-it.muted::before { background: var(--ft-stem-muted); }
.ft-it.bast::before { background: repeating-linear-gradient(90deg, var(--text-muted) 0 2px, transparent 2px 6px); }
.ft-by { display: flex; align-items: center; gap: .1rem; }
.ft-by .ft-knot { width: 18px; }
.ft-grp { margin-left: 12px; }
.ft-twins { display: flex; flex-wrap: wrap; gap: .4rem 1rem; position: relative; padding-left: 4px; }
.ft-twins::before { content: ''; position: absolute; left: -10px; top: 10px; bottom: 16px; width: 7px; border: 1.5px solid var(--accent-gold); border-right: 0; }
.ft-fleuron { display: flex; align-items: center; gap: .6rem; margin: .8rem 0; }
.ft-fleuron::before, .ft-fleuron::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gild)); }
.ft-fleuron::after { background: linear-gradient(90deg, var(--gild), transparent); }
.ft-fleuron span { width: 7px; height: 7px; background: var(--accent-gold); transform: rotate(45deg); display: inline-block; }
.ft-wards { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; }

/* ======================================================================
   THE EXPANDED VIEW: a page of its own over the game
   ====================================================================== */
.ft-pop {
  position: fixed; inset: 0; z-index: 9999; overflow-y: auto; overflow-x: hidden;
  background: var(--bg-void);
  -webkit-overflow-scrolling: touch;
}
.ft-bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem;
  border-bottom: 1px solid var(--gild-faint); background: var(--bg-void);
}
.ft-title { flex: 1; min-width: 0; font-family: var(--font-display); font-variant: small-caps; letter-spacing: .1em; color: var(--accent-gold); font-size: 20px; }
.ft-bar .btn { min-height: 40px; min-width: 40px; }
.ft-chiprow { padding: .6rem .75rem; border-bottom: 1px solid var(--gild-faint); }
.ft-desk .ft-chiprow { justify-content: center; flex-wrap: wrap; border-bottom: 0; }
.ft-desk .ft-body { max-width: 1180px; margin: 0 auto; padding: .5rem 1rem 2rem; }
.ft-desk .ft-title { text-align: center; font-size: 24px; }

/* -- the focus (design B), phones --------------------------------------- */
.ft-phone .ft-chiprow { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.ft-phone .ft-body { padding-bottom: 1.4rem; }
.ft-phone button.ft-p {
  display: block; padding: 0; margin: 0; border: 0; background: none; color: inherit;
  font: inherit; text-align: inherit; cursor: pointer; min-width: 0;
}
.ft-tile { display: flex; flex-direction: column; align-items: center; text-align: center; width: 96px; }
.ft-tile .ft-arch.s { margin-bottom: 11px; }
.ft-tile .ft-nm { font-size: 15px; }
.ft-tile .ft-ln { font-size: var(--fs-fine); }
.ft-tile .ft-role { margin-bottom: .3rem; }
.ft-band { padding: .9rem .9rem .6rem; }
.ft-band + .ft-band { border-top: 1px dotted var(--gild-faint); }
.ft-up { display: flex; justify-content: center; align-items: flex-start; gap: 1.3rem; }
.ft-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .7rem .6rem; }
.ft-focus { display: flex; align-items: flex-start; justify-content: center; gap: 1rem; padding: 1rem .9rem .9rem; }
.ft-me-t { width: 150px; }
.ft-me-t .ft-nm { font-size: 22px; }
.ft-me-t .ft-ln { font-size: var(--fs-text); }
.ft-spouses { display: flex; flex-direction: column; gap: .7rem; padding-top: .3rem; min-width: 0; }
.ft-sp { display: flex; align-items: center; gap: .55rem; text-align: left; }
.ft-sptxt { min-width: 0; }
.ft-sp .ft-nm { font-size: 15px; }
.ft-kidgrp { display: flex; align-items: flex-start; gap: .6rem; padding: .55rem 0; }
.ft-kidgrp + .ft-kidgrp { border-top: 1px dotted var(--gild-faint); }
.ft-kby { flex: 0 0 38px; padding-top: 18px; text-align: center; }
.ft-kids { flex: 1; display: flex; flex-wrap: wrap; align-items: flex-start; gap: .55rem .5rem; min-width: 0; }
.ft-kids .ft-tile { width: 88px; }
.ft-kids .ft-twins { flex-wrap: nowrap; gap: .5rem; padding: 10px 0 0; }
.ft-kids .ft-twins::before { top: 0; left: 44px; right: 44px; bottom: auto; width: auto; height: 9px; border: 1.5px solid var(--accent-gold); border-bottom: 0; }
.ft-phone .ft-side { margin: .6rem .6rem 1rem; }
.ft-phone .ft-side.ft-band { border-top: 1px solid var(--gild-faint); }

/* founders who are siblings: one stem joins them, no parent above it */
.ft-sibs { margin-left: 0; }
.ft-sibs::before { display: none; }
.ft-sibs > .ft-it:first-child::after { top: 37px; }
.ft-sibs > .ft-it:first-child:last-child::after { display: none; }
