/* ==========================================================================
   Segurado Pereira family archive
   Aesthetic: an engraved archive plate. Parchment ground, iron-gall ink,
   oxidized register red, letterpress rules, typewritten catalogue codes.
   ========================================================================== */

:root {
  --paper:       #efe6d6;
  --paper-deep:  #e4d8c1;
  --paper-card:  #f8f2e6;
  --paper-sunk:  #e9dfcb;

  --ink:         #201709;
  --ink-soft:    #4b3d2a;
  --ink-faint:   #6d5c43;

  /* Longest comfortable line for continuous reading. */
  --measure: 68ch;

  --rule:        #cdbb9d;
  --rule-soft:   #dccdb2;

  --red:         #8c2f22;
  --red-bright:  #a83a29;
  --ochre:       #a87c2c;   /* rules and borders */
  --ochre-text:  #7f5b1e;   /* the same accent, dark enough to read */
  --teal:        #35544d;
  --void:        #14100c;

  --display: 'Fraunces', Georgia, serif;
  --body:    'Newsreader', Georgia, serif;
  --mono:    'Courier Prime', 'Courier New', monospace;

  --shadow-card: 0 1px 0 rgba(255,253,247,.7) inset,
                 0 2px 4px rgba(60,44,24,.07),
                 0 12px 28px -18px rgba(60,44,24,.5);
  --shadow-lift: 0 1px 0 rgba(255,253,247,.8) inset,
                 0 4px 10px rgba(60,44,24,.1),
                 0 22px 44px -24px rgba(60,44,24,.55);

  --bar-h: 60px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(120% 80% at 12% -10%, rgba(255,252,244,.85), transparent 60%),
    radial-gradient(90% 70% at 92% 4%, rgba(215,196,163,.5), transparent 55%);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17.5px;
  line-height: 1.68;
  font-variation-settings: 'opsz' 16;
  overflow-x: hidden;
}

/* Paper grain, sits above the ground and below the content. */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: .38; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: .18em; }
a:hover { text-decoration-color: var(--red); }

button { font: inherit; color: inherit; cursor: pointer; }

.mono { font-family: var(--mono); font-size: .86em; letter-spacing: -.01em; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: 'SOFT' 28, 'WONK' 1, 'opsz' 120;
  line-height: 1.08;
  margin: 0;
  letter-spacing: -.012em;
}

::selection { background: rgba(140,47,34,.18); }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */

.masthead {
  position: sticky; top: 0; z-index: 40;
  height: var(--bar-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 clamp(16px, 4vw, 44px);
  background: rgba(239,230,214,.86);
  backdrop-filter: blur(9px) saturate(1.1);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(255,253,247,.7);
}

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; margin-right: auto; }
.brand-mark svg { width: 22px; height: 22px; stroke: var(--red); stroke-width: 1.7; fill: var(--ink); }
.brand-text { display: flex; flex-direction: column; line-height: 1.06; }
.brand-text b {
  font-family: var(--display); font-weight: 600; font-size: 16.5px;
  font-variation-settings: 'SOFT' 20, 'WONK' 1, 'opsz' 40;
  letter-spacing: .005em;
}
.brand-text i {
  font-family: var(--mono); font-style: normal; font-size: 9.5px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-faint);
  margin-top: 2px;
}

.nav { display: flex; gap: 26px; }
.nav a {
  position: relative; text-decoration: none;
  font-size: 13px; letter-spacing: .11em; text-transform: uppercase;
  font-family: var(--mono); color: var(--ink-soft);
  padding: 4px 0; transition: color .18s var(--ease);
}
.nav a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: 0;
  height: 1.5px; background: var(--red); transition: right .28s var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after, .nav a.active::after { right: 0; }
.nav a.active { color: var(--red); }

.lang-switch { display: flex; align-items: center; gap: 1px; margin-left: 26px; flex: none; }
.lang-switch button {
  border: 1px solid var(--rule); background: transparent; color: var(--ink-faint);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em;
  padding: 5px 9px; transition: .2s var(--ease);
}
.lang-switch button:first-child { border-right-width: 0; }
.lang-switch button:hover { color: var(--ink); border-color: var(--ink-faint); }
.lang-switch button.active {
  background: var(--ink); border-color: var(--ink); color: var(--paper-card);
}
.lang-switch button.active:hover { background: var(--red); border-color: var(--red); color: var(--paper-card); }

.nav-toggle { display: none; background: none; border: 0; padding: 8px; }
.nav-toggle span { display: block; width: 21px; height: 1.5px; background: var(--ink); margin: 4px 0; transition: .25s var(--ease); }

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */

main { position: relative; z-index: 2; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 44px); }
.wrap-narrow { max-width: 760px; }

.loading {
  min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 18px;
  color: var(--ink-faint); font-family: var(--mono); font-size: 12px;
  letter-spacing: .22em; text-transform: uppercase;
}
.loading-rule { width: 90px; height: 1px; background: var(--rule); position: relative; overflow: hidden; }
.loading-rule::after {
  content: ''; position: absolute; inset: 0; width: 34%; background: var(--red);
  animation: sweep 1.15s var(--ease) infinite;
}
@keyframes sweep { from { transform: translateX(-110%); } to { transform: translateX(320%); } }

.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .24em;
  text-transform: uppercase; color: var(--red);
  display: flex; align-items: center; gap: 12px;
}
.eyebrow::after { content: ''; flex: 1; height: 1px; background: var(--rule); }

.rule-double { border: 0; border-top: 1px solid var(--rule); box-shadow: 0 3px 0 -2px var(--rule); margin: 0; }

/* --------------------------------------------------------------------------
   Home: the title plate
   -------------------------------------------------------------------------- */

.plate { padding: clamp(48px, 9vw, 104px) 0 clamp(40px, 6vw, 72px); position: relative; }

.plate::before {
  content: ''; position: absolute; inset: clamp(20px,4vw,40px) 0 auto;
  height: 1px; background: var(--rule); opacity: .0;
}

.plate-inner { position: relative; }

.plate h1 {
  font-size: clamp(46px, 11.5vw, 132px);
  font-weight: 500;
  font-variation-settings: 'SOFT' 40, 'WONK' 1, 'opsz' 144;
  line-height: .86; letter-spacing: -.03em;
  margin: 18px 0 0;
}
.plate h1 span { display: block; }
.plate h1 .l2 { padding-left: clamp(0px, 8vw, 118px); color: var(--red); }

.plate-sub {
  font-size: clamp(17px, 2.1vw, 21px);
  color: var(--ink-soft); max-width: 33ch; margin: 30px 0 0;
  font-variation-settings: 'opsz' 20;
}

.plate-stats {
  display: flex; flex-wrap: wrap; gap: clamp(20px, 4vw, 52px);
  margin-top: clamp(36px, 5vw, 60px); padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.stat b {
  display: block; font-family: var(--display); font-weight: 500;
  font-size: clamp(30px, 4.4vw, 46px); line-height: 1;
  font-variation-settings: 'SOFT' 34, 'WONK' 1, 'opsz' 90;
}
.stat span {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .19em;
  text-transform: uppercase; color: var(--ink-faint); display: block; margin-top: 8px;
}

.plate-cta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: clamp(34px, 5vw, 52px); }

.btn {
  display: inline-flex; align-items: center; gap: 11px;
  padding: 13px 24px; border: 1px solid var(--ink); border-radius: 2px;
  background: var(--ink); color: var(--paper-card);
  font-family: var(--mono); font-size: 12px; letter-spacing: .15em; text-transform: uppercase;
  text-decoration: none; transition: .22s var(--ease);
  box-shadow: 0 8px 18px -12px rgba(34,25,15,.9);
}
.btn:hover { background: var(--red); border-color: var(--red); transform: translateY(-1px); }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); box-shadow: none; }
.btn-ghost:hover { background: transparent; color: var(--red); border-color: var(--red); }

.btn-small { padding: 9px 16px; font-size: 11px; }

/* Ornamental pedigree engraving behind the plate */
.plate-ornament {
  position: absolute; top: 50%; right: -4%; transform: translateY(-52%);
  width: min(46vw, 520px); opacity: .13; pointer-events: none; z-index: -1;
}
.plate-ornament path, .plate-ornament line { stroke: var(--ink); fill: none; stroke-width: 1; }
.plate-ornament circle { fill: var(--ink); }

/* Featured strip */
.strip { padding: clamp(40px, 6vw, 76px) 0; border-top: 1px solid var(--rule); }
.strip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.strip-head h2 { font-size: clamp(24px, 3vw, 34px); font-weight: 500; }
.strip-head a { font-family: var(--mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); text-decoration: none; white-space: nowrap; }
.strip-head a:hover { color: var(--red); }

.card-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: clamp(14px, 2vw, 24px); }

/* Research note block, styled like a typed slip pinned to the page */
.slip {
  background: var(--paper-card); border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--ochre);
  padding: clamp(20px, 3vw, 32px); box-shadow: var(--shadow-card);
  font-family: var(--mono); font-size: 13px; line-height: 1.9;
  white-space: pre-wrap; color: var(--ink-soft); overflow-x: auto;
  max-height: 340px; overflow: hidden; position: relative;
  transition: max-height .5s var(--ease);
}
.slip.open { max-height: 4000px; }
.slip::after {
  content: ''; position: absolute; inset: auto 0 0; height: 110px;
  background: linear-gradient(transparent, var(--paper-card));
  transition: opacity .3s;
}
.slip.open::after { opacity: 0; }
.slip-toggle { margin-top: 12px; }

/* --------------------------------------------------------------------------
   Document cards
   -------------------------------------------------------------------------- */

.doc {
  display: block; text-decoration: none; background: var(--paper-card);
  border: 1px solid var(--rule-soft); padding: 9px 9px 0;
  box-shadow: var(--shadow-card); transition: .28s var(--ease);
  cursor: zoom-in; text-align: left; width: 100%; font: inherit;
}
.doc:hover { transform: translateY(-3px) rotate(-.35deg); box-shadow: var(--shadow-lift); border-color: var(--rule); }
.doc-frame { aspect-ratio: 3 / 4; overflow: hidden; background: var(--paper-sunk); position: relative; }
.doc-frame img { width: 100%; height: 100%; object-fit: cover; filter: contrast(1.03) sepia(.07); }
.doc-frame::after {
  content: ''; position: absolute; inset: 0;
  box-shadow: inset 0 0 30px rgba(60,44,24,.18);
}
.doc-cap { padding: 11px 3px 13px; }
.doc-cap p { margin: 0; font-size: 13.5px; line-height: 1.4; }
.doc-cap span { display: block; margin-top: 7px; font-family: var(--mono); font-size: 11px; letter-spacing: .07em; color: var(--ink-faint); overflow-wrap: anywhere; }

/* --------------------------------------------------------------------------
   Tree chart
   -------------------------------------------------------------------------- */

.tree-view { position: relative; height: calc(100dvh - var(--bar-h)); overflow: hidden; background:
  radial-gradient(80% 60% at 50% 40%, rgba(255,252,245,.7), transparent 70%); }

#chart { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#chart.dragging { cursor: grabbing; }

.link { fill: none; stroke: var(--rule); stroke-width: 1.25; }
.link-focus { stroke: var(--red); stroke-width: 1.6; }
.link-couple { stroke: var(--red); stroke-width: 1.3; stroke-dasharray: 5 3; opacity: .75; }
.union-mark { fill: var(--red); }

.node { cursor: pointer; }
.node-box {
  fill: var(--paper-card); stroke: var(--rule); stroke-width: 1;
  transition: fill .2s var(--ease), stroke .2s var(--ease);
}
.node:hover .node-box { stroke: var(--ink-soft); fill: #fdf8ee; }
.node-sex { stroke-width: 2.5; }
.node-sex-m { stroke: var(--teal); }
.node-sex-f { stroke: var(--red); }
.node-sex-u { stroke: var(--ink-faint); }

.node-name {
  font-family: var(--display); font-size: 14.5px; font-weight: 600;
  font-variation-settings: 'SOFT' 20, 'WONK' 0, 'opsz' 30;
  fill: var(--ink);
}
.node-dates { font-family: var(--mono); font-size: 10.5px; fill: var(--ink-faint); letter-spacing: .04em; }
.node-docs { font-family: var(--mono); font-size: 10px; fill: var(--ochre-text); letter-spacing: .06em; }

.node-focus .node-box { fill: #fffaf0; stroke: var(--ink); stroke-width: 1.6; }
.node-focus .node-name { fill: var(--ink); }
.focus-ring { fill: none; stroke: var(--red); stroke-width: 1; stroke-dasharray: 3 4; opacity: .55; }

.node-open { cursor: pointer; }
/* Invisible, and larger than the glyph so a finger has something to hit. */
.node-open .node-open-hit { fill: transparent; stroke: none; }
.node-open .node-open-face {
  fill: var(--paper-sunk); stroke: var(--rule); stroke-width: 1;
  transition: fill .16s var(--ease), stroke .16s var(--ease);
}
.node-open-glyph { stroke: var(--ink-soft); stroke-width: 1.6; transition: stroke .16s var(--ease); }
.node-open:hover .node-open-face,
.node-open:focus-visible .node-open-face { fill: var(--ink); stroke: var(--ink); }
.node-open:hover .node-open-glyph, .node-open:focus-visible .node-open-glyph { stroke: var(--paper-card); }
.node-open:focus-visible { outline: none; }

.node-more { fill: var(--paper-card); stroke: var(--rule); stroke-width: 1; }
.node-more-glyph { stroke: var(--ink-soft); stroke-width: 1.4; fill: none; }
.node:hover .node-more { stroke: var(--red); }
.node:hover .node-more-glyph { stroke: var(--red); }

.chart-controls {
  position: absolute; right: clamp(12px, 3vw, 26px); bottom: clamp(12px, 3vw, 26px);
  display: flex; flex-direction: column; gap: 1px; background: var(--rule);
  border: 1px solid var(--rule); box-shadow: var(--shadow-card);
}
.chart-controls button {
  width: 38px; height: 38px; border: 0; background: var(--paper-card);
  display: grid; place-content: center; font-size: 17px; line-height: 1;
  transition: background .18s;
}
.chart-controls button:hover { background: #fff9ee; color: var(--red); }

.chart-card {
  position: absolute; left: clamp(12px, 3vw, 26px); top: clamp(12px, 3vw, 26px);
  width: min(310px, calc(100vw - 24px));
  background: rgba(248,242,230,.94); backdrop-filter: blur(6px);
  border: 1px solid var(--rule); box-shadow: var(--shadow-card);
  padding: 18px 20px 20px;
}
.chart-card .eyebrow { margin-bottom: 10px; }
.chart-card h2 { font-size: 25px; font-weight: 500; line-height: 1.05; }
.chart-card .lifespan { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); margin: 8px 0 0; letter-spacing: .06em; }
.chart-card .place { font-size: 14px; color: var(--ink-soft); margin: 10px 0 0; }
.chart-card .actions { display: flex; gap: 9px; margin-top: 16px; flex-wrap: wrap; align-items: center; }

.depth {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--rule-soft);
}
.depth-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-faint); line-height: 1.4;
}
.depth-stepper { display: flex; align-items: center; gap: 1px; flex: none; }
.depth-stepper b {
  font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--ink);
  min-width: 26px; text-align: center; border-block: 1px solid var(--rule);
  padding: 4px 0; background: var(--paper);
}
.depth-stepper button {
  width: 26px; height: 26px; padding: 0; line-height: 1; font-size: 14px;
  border: 1px solid var(--rule); background: var(--paper-card); color: var(--ink);
  transition: .18s var(--ease);
}
.depth-stepper button:hover:not(:disabled) { background: var(--ink); border-color: var(--ink); color: var(--paper-card); }
.depth-stepper button:disabled { color: var(--rule); cursor: default; }

.view-switch { display: flex; gap: 1px; margin-bottom: 15px; }
.view-switch button {
  flex: 1; padding: 7px 6px; border: 1px solid var(--rule); background: var(--paper-card);
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); transition: .18s var(--ease);
}
.view-switch button:first-child { border-right-width: 0; }
.view-switch button:hover { color: var(--ink); }
.view-switch button.active { background: var(--ink); border-color: var(--ink); color: var(--paper-card); }

/* Menu shown when a person in the chart is clicked */
.node-pop {
  position: absolute; z-index: 20; width: 250px;
  background: var(--paper-card); border: 1px solid var(--ink-faint);
  box-shadow: 0 18px 40px -20px rgba(60,44,24,.75), 0 2px 6px rgba(60,44,24,.12);
  padding: 15px 17px 16px;
  animation: pop .2s var(--ease);
}
.node-pop[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.pop-name {
  margin: 0; font-family: var(--display); font-size: 17px; font-weight: 600;
  font-variation-settings: 'SOFT' 20, 'WONK' 0, 'opsz' 30; line-height: 1.22;
}
.pop-life { margin: 5px 0 0; font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); letter-spacing: .06em; }
.pop-hint {
  margin: 12px 0 10px; padding-top: 11px; border-top: 1px solid var(--rule-soft);
  font-size: 13px; color: var(--ink-soft);
}
.pop-actions { display: flex; flex-direction: column; gap: 7px; }
.pop-actions .btn { justify-content: center; width: 100%; }

.chart-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-faint);
  background: rgba(239,230,214,.8); padding: 7px 15px; border: 1px solid var(--rule-soft);
  pointer-events: none; transition: opacity .5s; text-align: center;
}
.chart-hint.hide { opacity: 0; }

.legend {
  position: absolute; right: clamp(12px, 3vw, 26px); top: clamp(12px, 3vw, 26px);
  display: flex; gap: 16px; font-family: var(--mono); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint);
  background: rgba(239,230,214,.8); padding: 8px 13px; border: 1px solid var(--rule-soft);
}
.legend i { display: inline-block; width: 13px; height: 2.5px; margin-right: 6px; vertical-align: middle; }

/* --------------------------------------------------------------------------
   Person page
   -------------------------------------------------------------------------- */

.person { padding: clamp(28px, 5vw, 56px) 0 clamp(60px, 9vw, 110px); }

.person-grid { display: grid; grid-template-columns: 290px 1fr; gap: clamp(28px, 5vw, 68px); align-items: start; }

.person-rail { position: sticky; top: calc(var(--bar-h) + 26px); }

.person-name {
  font-size: clamp(34px, 5.2vw, 56px); font-weight: 500; line-height: .95;
  font-variation-settings: 'SOFT' 36, 'WONK' 1, 'opsz' 110;
  letter-spacing: -.022em;
}
.person-name em { font-style: normal; color: var(--red); display: block; }
.person-lifespan {
  font-family: var(--mono); font-size: 13px; letter-spacing: .13em;
  color: var(--ink-faint); margin: 16px 0 0;
}
.person-nick { font-size: 15px; color: var(--ink-soft); font-style: italic; margin: 6px 0 0; }

.rail-block { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--rule); }
.rail-block h3 {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .21em;
  text-transform: uppercase; color: var(--ink-faint); font-weight: 400; margin-bottom: 12px;
}
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-list li { margin-bottom: 9px; line-height: 1.35; }
.rail-list a { text-decoration: none; border-bottom: 1px solid var(--rule); transition: .18s; }
.rail-list a:hover { border-color: var(--red); color: var(--red); }
.yrs { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); margin-left: 7px; white-space: nowrap; }

.person-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }

/* Events as register entries */
.entry { position: relative; padding: 0 0 34px 30px; border-left: 1px solid var(--rule); }
.entry:last-child { border-left-color: transparent; padding-bottom: 6px; }
.entry::before {
  content: ''; position: absolute; left: -4.5px; top: 9px;
  width: 8px; height: 8px; background: var(--paper); border: 1.5px solid var(--red);
  border-radius: 50%;
}
.entry-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.entry-label {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  font-variation-settings: 'SOFT' 22, 'WONK' 0, 'opsz' 40;
}
.entry-date { font-family: var(--mono); font-size: 12.5px; color: var(--red); letter-spacing: .06em; }
.entry-place { color: var(--ink-soft); margin: 6px 0 0; font-size: 16px; max-width: var(--measure); }
.entry-detail { margin: 6px 0 0; font-size: 16px; max-width: var(--measure); }

.citation {
  margin-top: 15px; padding: 15px 18px; background: var(--paper-sunk);
  border: 1px solid var(--rule-soft); font-size: 15px;
  max-width: var(--measure);
}
.citation-title { margin: 0; line-height: 1.45; }
.citation-title a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.citation-title a:hover { color: var(--red); border-color: var(--red); }
.citation-page { margin: 7px 0 0; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); line-height: 1.65; overflow-wrap: anywhere; }
.citation-thumbs { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; }
.citation-thumbs button {
  width: 56px; height: 68px; padding: 0; border: 1px solid var(--rule);
  background: var(--paper-card); overflow: hidden; cursor: zoom-in; transition: .2s var(--ease);
}
.citation-thumbs button:hover { transform: translateY(-2px); border-color: var(--red); }
.citation-thumbs img { width: 100%; height: 100%; object-fit: cover; filter: sepia(.08); }

.note-block {
  margin: 16px 0 0; padding: 18px 22px; background: var(--paper-card);
  border: 1px solid var(--rule-soft); border-left: 3px solid var(--rule);
  white-space: pre-wrap; font-size: 16px; line-height: 1.75; color: var(--ink-soft);
  max-width: var(--measure); overflow-wrap: break-word;
}

/* Catalogue entry for a record the archive has not digitised */
.catalog {
  margin-top: 16px; padding: 18px 22px 20px; max-width: var(--measure);
  background: repeating-linear-gradient(
    -45deg, transparent, transparent 9px,
    rgba(168,124,44,.045) 9px, rgba(168,124,44,.045) 18px), var(--paper-card);
  border: 1px solid var(--rule-soft); border-left: 3px solid var(--ochre);
}
.catalog-tag {
  margin: 0 0 10px; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ochre-text);
}
.catalog h4 {
  font-size: 17.5px; font-weight: 600; line-height: 1.3;
  font-variation-settings: 'SOFT' 20, 'WONK' 0, 'opsz' 30;
}
.catalog-dates { margin: 6px 0 0; font-family: var(--mono); font-size: 11px; color: var(--red); letter-spacing: .06em; }
.catalog-desc {
  margin: 12px 0 0; font-size: 15.5px; line-height: 1.72; color: var(--ink-soft);
  white-space: pre-wrap; max-width: var(--measure); overflow-wrap: break-word;
}
.catalog-ref { margin: 9px 0 0; font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); line-height: 1.7; overflow-wrap: anywhere; }

.section-lead { color: var(--ink-soft); max-width: var(--measure); margin: -8px 0 22px; font-size: 16px; }

.section { margin-top: clamp(40px, 6vw, 66px); }
.section > h2 {
  font-size: clamp(22px, 2.8vw, 30px); font-weight: 500; margin-bottom: 22px;
  padding-bottom: 12px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
}
.section > h2 small { font-family: var(--mono); font-size: 11px; letter-spacing: .15em; color: var(--ink-faint); text-transform: uppercase; font-weight: 400; }

/* --------------------------------------------------------------------------
   Index pages
   -------------------------------------------------------------------------- */

.page-head { padding: clamp(34px, 5vw, 62px) 0 clamp(22px, 3vw, 34px); }
.page-head h1 { font-size: clamp(38px, 6vw, 70px); font-weight: 500; margin-top: 16px; letter-spacing: -.025em; }
.page-head p { color: var(--ink-soft); max-width: var(--measure); margin: 16px 0 0; }

.search {
  display: flex; align-items: center; gap: 12px; margin: 30px 0 0;
  border-bottom: 1.5px solid var(--ink); padding-bottom: 9px;
}
.search input {
  flex: 1; border: 0; background: transparent; font-family: var(--display);
  font-size: clamp(19px, 2.6vw, 26px); font-weight: 500; color: var(--ink);
  font-variation-settings: 'SOFT' 24, 'WONK' 1, 'opsz' 40;
  padding: 0; min-width: 0;
}
.search input:focus { outline: none; }
.search input::placeholder { color: var(--ink-faint); opacity: .6; }
.search svg { width: 19px; height: 19px; stroke: var(--ink-soft); fill: none; stroke-width: 1.6; flex: none; }
.search-count { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); letter-spacing: .1em; white-space: nowrap; }

.index-group { margin-top: clamp(30px, 4vw, 48px); }
.index-letter {
  font-family: var(--display); font-size: 13px; letter-spacing: .3em;
  text-transform: uppercase; color: var(--red); font-weight: 600;
  padding-bottom: 8px; border-bottom: 1px solid var(--rule); margin-bottom: 4px;
}

.index-row {
  display: flex; align-items: baseline; gap: 10px; padding: 11px 2px;
  border-bottom: 1px solid var(--rule-soft); text-decoration: none;
  transition: background .18s var(--ease), padding-left .18s var(--ease);
}
.index-row:hover { background: rgba(255,252,244,.75); padding-left: 10px; }
.index-row-name { font-size: 18px; font-family: var(--display); font-weight: 500; font-variation-settings: 'SOFT' 22, 'opsz' 30; }
.index-row:hover .index-row-name { color: var(--red); }
.index-row-lead { flex: 1; border-bottom: 1px dotted var(--rule); transform: translateY(-4px); min-width: 20px; }
.index-row-meta { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); letter-spacing: .06em; white-space: nowrap; }
.index-row-docs { font-family: var(--mono); font-size: 11px; color: var(--ochre-text); letter-spacing: .08em; white-space: nowrap; }

.empty { padding: 60px 0; text-align: center; color: var(--ink-faint); font-family: var(--mono); font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; }

/* Sources */
.source-item { padding: 24px 0; border-bottom: 1px solid var(--rule-soft); display: grid; grid-template-columns: auto 1fr; gap: 22px; }
.source-num { font-family: var(--mono); font-size: 11px; color: var(--red); letter-spacing: .1em; padding-top: 6px; }
.source-item h3 { font-size: 20px; font-weight: 500; line-height: 1.25; }
.source-meta { margin: 9px 0 0; font-size: 15.5px; color: var(--ink-soft); }
.source-ref {
  margin: 8px 0 0; font-family: var(--mono); font-size: 12px; color: var(--ink-faint);
  line-height: 1.75; overflow-wrap: anywhere; white-space: pre-wrap; max-width: var(--measure);
}
.source-people { margin: 14px 0 0; font-size: 15px; line-height: 1.75; max-width: var(--measure); }
.source-people a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.source-people a:hover { color: var(--red); border-color: var(--red); }

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */

.lightbox {
  position: fixed; inset: 0; z-index: 100; background: var(--void);
  display: flex; align-items: center; justify-content: center;
  animation: fade .28s var(--ease);
}
.lightbox[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.lb-stage { position: absolute; inset: 0 0 78px; overflow: hidden; cursor: grab; touch-action: none; }
.lb-stage.dragging { cursor: grabbing; }
.lb-stage img {
  position: absolute; top: 50%; left: 50%; max-width: none;
  transform-origin: 0 0; user-select: none; -webkit-user-drag: none;
  box-shadow: 0 30px 90px -30px rgba(0,0,0,.9);
}

.lb-close, .lb-nav {
  position: absolute; z-index: 3; background: rgba(240,232,216,.1); border: 1px solid rgba(240,232,216,.22);
  color: #efe6d6; backdrop-filter: blur(5px); transition: .2s var(--ease);
}
.lb-close { top: 18px; right: 18px; width: 42px; height: 42px; font-size: 24px; line-height: 1; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 72px; font-size: 27px; line-height: 1; }
.lb-prev { left: 16px; } .lb-next { right: 16px; }
.lb-close:hover, .lb-nav:hover { background: rgba(240,232,216,.22); border-color: rgba(240,232,216,.5); }
.lb-nav[hidden] { display: none; }

.lb-bar {
  position: absolute; inset: auto 0 0; height: 78px; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 clamp(16px, 3vw, 28px);
  background: rgba(20,16,12,.94); border-top: 1px solid rgba(240,232,216,.16);
  color: #e8dcc6;
}
.lb-meta { min-width: 0; }
.lb-title { margin: 0; font-family: var(--display); font-size: 16px; font-weight: 500; font-variation-settings: 'SOFT' 20, 'opsz' 30; line-height: 1.3; }
.lb-ref { margin: 4px 0 0; color: #9d8c72; font-size: 10.5px; letter-spacing: .07em; overflow-wrap: anywhere; }
.lb-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.lb-tools button {
  width: 34px; height: 34px; background: rgba(240,232,216,.09);
  border: 1px solid rgba(240,232,216,.2); color: #e8dcc6; font-size: 17px; line-height: 1;
}
.lb-tools button:hover { background: rgba(240,232,216,.2); }
.lb-zoom { min-width: 46px; text-align: center; color: #9d8c72; font-size: 11px; }
.lb-tools a {
  padding: 8px 14px; border: 1px solid rgba(240,232,216,.24); text-decoration: none;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase;
  color: #e8dcc6; transition: .2s;
}
.lb-tools a:hover { background: rgba(240,232,216,.16); }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.foot {
  border-top: 1px solid var(--rule); margin-top: clamp(50px, 8vw, 90px);
  padding: 34px 0 46px; color: var(--ink-faint);
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; line-height: 1.9;
}
.foot a { color: var(--ink-soft); }

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */

.reveal { opacity: 0; transform: translateY(14px); animation: rise .68s var(--ease) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
.d1 { animation-delay: .06s; } .d2 { animation-delay: .13s; }
.d3 { animation-delay: .2s; }  .d4 { animation-delay: .28s; }
.d5 { animation-delay: .36s; } .d6 { animation-delay: .45s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Tablet: the rail no longer has room beside the record, and the chart card
   competes with the tree. */
@media (max-width: 1024px) {
  :root { --measure: 62ch; }
  .wrap { max-width: 820px; }
}

@media (max-width: 900px) {
  .person-grid { grid-template-columns: 1fr; gap: 30px; }
  .person-rail {
    position: static;
    padding-bottom: 26px; border-bottom: 1px solid var(--rule);
  }
  .person-name { font-size: clamp(30px, 7vw, 44px); }
  .rail-block { margin-top: 22px; padding-top: 16px; }
  .legend { display: none; }
  .card-row { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 760px) {
  :root { --measure: 100%; --bar-h: 56px; }
  body { font-size: 17px; }

  .nav {
    position: fixed; inset: var(--bar-h) 0 auto; flex-direction: column; gap: 0;
    background: var(--paper-card); border-bottom: 1px solid var(--rule);
    padding: 8px clamp(16px, 4vw, 44px) 18px; transform: translateY(-120%);
    transition: transform .32s var(--ease); box-shadow: 0 18px 30px -24px rgba(60,44,24,.7);
  }
  .nav.open { transform: none; }
  .nav a { padding: 15px 0; border-bottom: 1px solid var(--rule-soft); font-size: 15px; }
  .nav a::after { display: none; }
  .nav-toggle { display: block; }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }
  .lang-switch { margin-left: auto; margin-right: 4px; }
  .brand-text i { display: none; }

  .plate h1 .l2 { padding-left: 0; }
  .plate-ornament { display: none; }
  .plate-stats { gap: 22px 30px; }
  .plate-cta .btn { flex: 1 1 100%; justify-content: center; }

  /* Reading blocks get their padding back on a narrow screen. */
  .note-block, .catalog { padding: 15px 16px; }
  .citation { padding: 13px 14px; }
  .catalog-desc, .source-ref, .slip { font-size: 14.5px; }
  .entry { padding-left: 20px; }
  .section > h2 { flex-direction: column; align-items: flex-start; gap: 4px; }

  .index-row { flex-wrap: wrap; gap: 4px 10px; padding: 13px 2px; }
  .index-row-lead { display: none; }
  .index-row-name { flex: 1 1 100%; font-size: 17px; }

  .source-item { grid-template-columns: 1fr; gap: 6px; }
  .card-row { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

  .chart-card { width: calc(100vw - 20px); left: 10px; padding: 11px 13px 13px; }
  .chart-card h2 { font-size: 17px; }
  .chart-card .eyebrow, .chart-card .place { display: none; }
  .chart-card .lifespan { margin-top: 4px; }
  .chart-card .actions { margin-top: 10px; }
  .chart-hint { display: none; }
  .chart-controls button { width: 44px; height: 44px; }
  .view-switch button { padding: 9px 6px; }
  .depth-stepper button { width: 32px; height: 32px; }

  .node-pop { width: min(260px, calc(100vw - 24px)); }

  /* The viewer bar stacks, so the plate keeps as much height as possible. */
  .lb-bar { height: auto; padding: 11px 14px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .lb-stage { inset: 0 0 112px; }
  .lb-tools { width: 100%; justify-content: space-between; }
  .lb-nav { width: 40px; height: 64px; }
  .lb-close { top: 12px; right: 12px; width: 44px; height: 44px; }
  .lb-title { font-size: 15px; }
}

@media (max-width: 420px) {
  .plate-stats { gap: 18px 24px; }
  .stat b { font-size: 30px; }
  .card-row { grid-template-columns: repeat(2, 1fr); }
  .doc-cap p { font-size: 12.5px; }
}

/* Touch devices: give the controls a proper target size. */
@media (hover: none) {
  .pop-actions .btn { min-height: 46px; font-size: 12px; }
  .node-pop { padding: 16px 18px 18px; }
  .chart-controls button { width: 46px; height: 46px; }
  .lb-tools button { width: 40px; height: 40px; }
  .citation-thumbs button { width: 64px; height: 78px; }
}

@media print {
  .masthead, .chart-controls, .nav, .grain, .lightbox { display: none !important; }
  body { background: #fff; }
}
