/* Fandre family tree — inherits the fandre.com palette and type */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:   #C9A84C;
  --gold-l: #E8C97A;
  --dark:   #080604;
  --slate:  #1A1A2E;
  --ink:    #f3efe6;
  --dim:    rgba(255,255,255,0.45);
  --dimmer: rgba(255,255,255,0.22);
  --line:   rgba(255,255,255,0.09);
  --panel:  rgba(13,11,9,0.97);
  --row:    150px;   /* vertical distance between generations */
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--dark);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
/* class rules such as .modal{display:grid} outrank the UA [hidden] rule */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── shared backdrop ── */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px);
  background-size: 60px 60px;
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse 65% 55% at 50% 45%, rgba(201,168,76,0.08) 0%, transparent 70%);
}
#starfield { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.eyebrow {
  font-size: .7rem; font-weight: 500; letter-spacing: .3em;
  text-transform: uppercase; color: var(--gold);
}

/* ── gate ── */
.gate {
  position: relative; z-index: 2; height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem; padding: 2rem; text-align: center;
}
.gate.leaving { animation: gateOut .7s cubic-bezier(.6,0,.35,1) forwards; }
@keyframes gateOut { to { opacity: 0; transform: scale(1.06); filter: blur(6px); } }

.gate-inner { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.wordmark {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(3rem, 10vw, 7rem);
  letter-spacing: .07em; line-height: 1; margin-top: .3rem;
  background: linear-gradient(110deg, #fff 35%, var(--gold-l) 48%, #fff 60%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 5s ease-in-out infinite;
}
@keyframes shimmer { 0%,100% { background-position: 110% 0; } 50% { background-position: -10% 0; } }
.gate-sub { font-size: .8rem; letter-spacing: .12em; color: var(--dimmer); margin-bottom: 1.6rem; }

.gate-form { display: flex; gap: .5rem; align-items: stretch; }
#pass {
  width: min(340px, 70vw); padding: .85rem 1.1rem;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line);
  border-radius: 10px; outline: none; letter-spacing: .04em;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
#pass::placeholder { color: var(--dimmer); letter-spacing: .06em; }
#pass:focus {
  border-color: rgba(201,168,76,.55); background: rgba(255,255,255,0.06);
  box-shadow: 0 0 0 4px rgba(201,168,76,.09), 0 0 30px rgba(201,168,76,.10);
}
#gate-go {
  width: 52px; border: 1px solid rgba(201,168,76,.4); border-radius: 10px;
  background: rgba(201,168,76,.10); color: var(--gold-l); cursor: pointer;
  transition: background .25s, transform .25s, box-shadow .25s;
}
#gate-go:hover { background: rgba(201,168,76,.2); transform: translateX(3px); box-shadow: 0 0 24px rgba(201,168,76,.18); }
.go-arrow { font-size: 1.2rem; }

.gate-msg { margin-top: 1rem; font-size: .76rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dimmer); min-height: 1.2em; }
.gate-msg.err { color: #E4796B; }
.gate-msg.busy { color: var(--gold); }
.gate.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-9px);} 75% { transform: translateX(9px);} }

.remember { margin-top: 1.1rem; font-size: .72rem; color: var(--dimmer); display: flex; align-items: center; gap: .45rem; cursor: pointer; }
.remember input { accent-color: var(--gold); }
.gate-foot { position: absolute; bottom: 1.6rem; font-size: .68rem; color: rgba(255,255,255,0.16); max-width: 46ch; line-height: 1.6; }

/* ── app shell ── */
.app { position: relative; z-index: 2; height: 100vh; display: flex; flex-direction: column; }
.app.entering { animation: appIn .8s cubic-bezier(.2,.8,.25,1) both; }
@keyframes appIn { from { opacity: 0; transform: scale(.97); } }

.bar {
  display: flex; align-items: center; gap: 1.2rem; flex-shrink: 0;
  padding: .7rem 1.1rem; border-bottom: 1px solid var(--line);
  background: rgba(8,6,4,.6); backdrop-filter: blur(12px);
  /* backdrop-filter makes this a stacking context, trapping the search
     dropdown's z-index inside it. Without a z-index here the stage — a later
     sibling — paints over the dropdown and eats its clicks. */
  position: relative; z-index: 20;
}
.brand { text-decoration: none; display: flex; align-items: baseline; gap: .5rem; flex-shrink: 0; }
.brand-mark { font-family: 'Bebas Neue', sans-serif; font-size: 1.35rem; letter-spacing: .12em; color: var(--gold-l); }
.brand-sub  { font-size: .62rem; letter-spacing: .22em; text-transform: uppercase; color: var(--dimmer); }

.search-wrap { position: relative; flex: 1; max-width: 460px; margin-inline: auto; }
#search {
  width: 100%; padding: .5rem .9rem; padding-right: 2.2rem;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line);
  border-radius: 8px; outline: none; font-size: .85rem;
  transition: border-color .2s, background .2s;
}
#search::placeholder { color: var(--dimmer); }
#search:focus { border-color: rgba(201,168,76,.45); background: rgba(255,255,255,0.06); }
.search-wrap kbd {
  position: absolute; right: .55rem; top: 50%; transform: translateY(-50%);
  font-family: inherit; font-size: .62rem; color: var(--dimmer);
  border: 1px solid var(--line); border-radius: 4px; padding: .05rem .3rem; pointer-events: none;
}
#search:focus + kbd { opacity: 0; }

.results {
  position: absolute; top: calc(100% + .45rem); left: 0; right: 0; z-index: 30;
  max-height: 58vh; overflow-y: auto; border-radius: 10px;
  /* solid, not translucent: this floats over a moving starfield */
  background: #100e0b; border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0,0,0,.75);
}
.result {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  padding: .55rem .8rem; background: none; border: 0; cursor: pointer; text-align: left;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.result:last-child { border-bottom: 0; }
.result:hover, .result[aria-selected="true"] { background: rgba(201,168,76,.10); }
.result .rn { font-size: .85rem; }
.result .ry { margin-left: auto; font-size: .72rem; color: var(--dimmer); font-variant-numeric: tabular-nums; }
.result mark { background: none; color: var(--gold-l); }
.results-empty { padding: .9rem; font-size: .8rem; color: var(--dimmer); text-align: center; }

.bar-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.ghost {
  padding: .42rem .8rem; font-size: .74rem; letter-spacing: .05em;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line);
  border-radius: 7px; cursor: pointer; color: var(--dim);
  transition: color .2s, border-color .2s, background .2s;
}
.ghost:hover { color: var(--gold-l); border-color: rgba(201,168,76,.4); background: rgba(201,168,76,.08); }
.ghost.icon { width: 32px; padding: .42rem 0; }
a.ghost { text-decoration: none; display: inline-flex; align-items: center; }
.ghost[disabled] { opacity: .4; pointer-events: none; }

/* ── stage ── */
.stage { position: relative; flex: 1; overflow: hidden; }
#tree { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#tree.dragging { cursor: grabbing; }

.hint {
  position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%);
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255,255,255,.18); pointer-events: none;
  transition: opacity .6s;
}
.hint.gone { opacity: 0; }

.zoom { position: absolute; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .3rem; }
.zoom button {
  width: 32px; height: 32px; border-radius: 7px; cursor: pointer;
  background: rgba(14,12,10,.8); border: 1px solid var(--line); color: var(--dim);
  transition: color .2s, border-color .2s;
}
.zoom button:hover { color: var(--gold-l); border-color: rgba(201,168,76,.4); }

/* ── nodes ── */
.node { cursor: pointer; }
.node .plate {
  fill: rgba(20,17,13,.92); stroke: var(--line); stroke-width: 1;
  transition: stroke .3s, fill .3s;
}
.node .ring { fill: none; stroke-width: 1.5; opacity: .55; transition: opacity .3s, stroke-width .3s; }
.node .mono {
  font-family: 'Bebas Neue', sans-serif; font-size: 15px; letter-spacing: .06em;
  text-anchor: middle; dominant-baseline: central; fill: var(--gold-l);
}
.node .nm {
  font-size: 12.5px; font-weight: 500; fill: var(--ink);
  dominant-baseline: central;
}
.node .yr {
  font-size: 10.5px; fill: var(--dim); dominant-baseline: central;
  font-variant-numeric: tabular-nums;
}
.node .halo { fill: none; stroke: var(--gold); stroke-width: 2; opacity: 0; }

/* Faces decrypt asynchronously; the monogram holds the spot until one lands. */
.node .face {
  clip-path: circle(50%);
  opacity: 0;
  transition: opacity .5s ease;
}
.node .face.in { opacity: 1; }
.node .mono { transition: opacity .4s ease; }

.node:hover .plate { fill: rgba(32,27,19,.96); stroke: rgba(201,168,76,.55); }
.node:hover .ring  { opacity: 1; stroke-width: 2.2; }
.node.focus .plate { stroke: var(--gold); stroke-width: 1.8; fill: rgba(38,31,18,.96); }
.node.focus .halo  { opacity: .9; animation: pulse 2.6s ease-out infinite; }
@keyframes pulse {
  0%   { transform: scale(1);    opacity: .55; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}
.node.dim { opacity: .3; }
.node .dead-dot { fill: var(--dimmer); }

.link { fill: none; stroke-width: 1.6; }
.link.up   { stroke: url(#linkUp); }
.link.down { stroke: url(#linkDown); }
.link.spouse { stroke: rgba(201,168,76,.4); stroke-dasharray: 3 4; }
.link.lit { stroke: var(--gold); stroke-opacity: .9; filter: url(#glow); }

.genlabel {
  font-family: 'Bebas Neue', sans-serif; font-size: 11px; letter-spacing: .24em;
  fill: rgba(255,255,255,.14); text-anchor: middle;
}

/* ── detail panel ── */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(370px, 88vw); z-index: 25;
  background: var(--panel); backdrop-filter: blur(16px);
  border-left: 1px solid var(--line); padding: 1.6rem 1.5rem; overflow-y: auto;
  animation: slideIn .42s cubic-bezier(.2,.8,.25,1);
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }
.panel-close {
  position: absolute; top: .7rem; right: .8rem; width: 30px; height: 30px;
  font-size: 1.3rem; line-height: 1; background: none; border: 0;
  color: var(--dimmer); cursor: pointer; transition: color .2s;
}
.panel-close:hover { color: var(--gold-l); }

.p-mono {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  font-family: 'Bebas Neue', sans-serif; font-size: 25px; letter-spacing: .05em;
  border: 1.5px solid; margin-bottom: .9rem;
  background-size: cover; background-position: center top;
  transition: box-shadow .4s ease;
}
.p-mono.has-face { box-shadow: 0 6px 22px rgba(0,0,0,.55), 0 0 0 3px rgba(201,168,76,.13); }
.p-mono.has-face span { opacity: 0; }
.p-mono span { transition: opacity .4s ease; }

/* search-result avatar */
.rdot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: 'Bebas Neue', sans-serif; font-size: 11px; letter-spacing: .04em;
  background-size: cover; background-position: center top;
}
.rdot.has-face { color: transparent; }
.p-name { font-family: 'Bebas Neue', sans-serif; font-size: 1.85rem; letter-spacing: .04em; line-height: 1.05; }
.p-life { font-size: .78rem; color: var(--gold); letter-spacing: .1em; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.p-sec { margin-top: 1.4rem; }
.p-sec h3 {
  font-size: .62rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--dimmer); font-weight: 500; margin-bottom: .5rem;
}
.p-row { display: flex; gap: .6rem; font-size: .84rem; padding: .2rem 0; line-height: 1.5; }
.p-row .k { color: var(--dimmer); min-width: 52px; flex-shrink: 0; }
.p-note { font-size: .82rem; line-height: 1.65; color: var(--dim); white-space: pre-line; }
.p-alt {
  font-size: .78rem; line-height: 1.55; color: #D9B778;
  border-left: 2px solid rgba(201,168,76,.4); padding-left: .65rem; margin-top: .4rem;
}
.p-people { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  font-size: .78rem; padding: .25rem .6rem; border-radius: 20px; cursor: pointer;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--ink);
  transition: background .2s, border-color .2s, transform .2s;
}
.chip:hover { background: rgba(201,168,76,.12); border-color: rgba(201,168,76,.45); transform: translateY(-1px); }
.chip .cy { color: var(--dimmer); font-size: .72rem; margin-left: .3rem; font-variant-numeric: tabular-nums; }

/* ── legend ── */
.legend {
  position: absolute; left: 1rem; bottom: 1rem; display: flex; flex-wrap: wrap;
  gap: .3rem .75rem; max-width: 300px; pointer-events: none;
}
.legend span { font-size: .66rem; letter-spacing: .08em; color: var(--dimmer); display: flex; align-items: center; gap: .3rem; }
.legend i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ── modal ── */
.modal {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgba(4,3,2,.75); backdrop-filter: blur(6px); padding: 1.5rem;
  animation: fade .3s;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; max-width: 520px; max-height: 84vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 2rem 1.9rem;
}
.modal-card h2 {
  font-family: 'Bebas Neue', sans-serif; font-size: 1.25rem; letter-spacing: .1em;
  color: var(--gold-l); margin-bottom: .8rem;
}
.modal-card h2 + p, .modal-card p { font-size: .86rem; line-height: 1.7; color: var(--dim); margin-bottom: .7rem; }
.modal-card .p-sec + h2, .keys + h2 { margin-top: 1.6rem; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; font-size: .84rem; }
.keys dt { color: var(--gold-l); white-space: nowrap; }
.keys dd { color: var(--dim); }
kbd {
  font-family: inherit; font-size: .72rem; border: 1px solid var(--line);
  border-radius: 4px; padding: .05rem .32rem; color: var(--dim);
}

@media (max-width: 720px) {
  :root { --row: 128px; }
  .bar { flex-wrap: wrap; gap: .5rem; padding: .55rem .8rem; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .bar-actions { margin-left: auto; }
  .bar-actions .ghost:not(.icon) { padding: .38rem .55rem; font-size: .66rem; }
  .legend { display: none; }
  .hint { font-size: .6rem; bottom: .6rem; }

  /* A side panel would cover the whole phone; use a bottom sheet instead. */
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    max-height: 56%; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; padding: 1.2rem 1.15rem 1.6rem;
    animation: sheetIn .4s cubic-bezier(.2,.8,.25,1);
    box-shadow: 0 -20px 50px rgba(0,0,0,.6);
  }
  .panel::before {
    content: ""; position: absolute; top: .5rem; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.14);
  }
  .p-name { font-size: 1.5rem; }
  .zoom { bottom: auto; top: .7rem; }
}
@keyframes sheetIn { from { transform: translateY(100%); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
