/* From Adam to Christ — what belongs to this page alone. Base: /pages.css */

/* ---- reading type ----
   The prose here — the introduction, the notes, the events, the card — is set
   in a book face at a reading size; labels stay in the sans. Each script gets a
   face that has its letters: EB Garamond (Latin, Cyrillic), Noto Serif Georgian,
   Armenian and Hebrew, Noto Naskh Arabic, and the system's Song face for
   Chinese. The sizes differ because the faces do: Garamond is small on its body,
   Georgian large, and Georgian and Arabic want more room between the lines. */
:root {
    --read: 'EB Garamond', Georgia, serif;
    --read-size: 19.5px;
    --read-lh: 1.6;
    --soft: #dcd1b7;
    --chron-thumb: 64px;
}
:lang(ka) { --read: 'Noto Serif Georgian', serif; --read-size: 16.5px; --read-lh: 1.85; }
:lang(hy) { --serif: 'Noto Serif Armenian', serif; --read: 'Noto Serif Armenian', serif; --read-size: 17px; --read-lh: 1.8; }
:lang(he) { --serif: 'Noto Serif Hebrew', serif; --read: 'Noto Serif Hebrew', serif; --read-size: 18px; --read-lh: 1.75; }
:lang(ar) { --serif: 'Noto Naskh Arabic', serif; --read: 'Noto Naskh Arabic', serif; --read-size: 19px; --read-lh: 1.9; }
:lang(zh) { --serif: 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif; --read: var(--serif); --read-size: 17px; --read-lh: 1.9; }

/* ---- the head ---- */
.hero { padding: 22px 0 4px; }
.hero h1 {
    font: 700 clamp(36px, 6.4vw, 58px)/1.08 var(--serif);
    margin: 14px 0 20px; padding-bottom: .06em;
    background: linear-gradient(180deg, #fff4dc 20%, #e7c271 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
:lang(ka) .hero h1, :lang(hy) .hero h1, :lang(ar) .hero h1 { line-height: 1.25; }
.hero .intro {
    font: 400 calc(var(--read-size) + 1px)/var(--read-lh) var(--read);
    color: var(--soft); max-width: 35em; margin: 0;
}
.hero .count {
    display: inline-block; margin: 20px 0 0; padding: 6px 15px;
    border: 1px solid var(--border-strong); border-radius: 999px; background: var(--gold-soft);
    color: var(--gold); font: 600 13px/1.2 var(--sans); letter-spacing: .02em;
}

/* ---- the years band ---- */
.years {
    margin: 36px 0 0; padding: 24px 26px 22px;
    background: linear-gradient(180deg, rgba(255, 174, 0, .055), rgba(255, 174, 0, 0) 45%), var(--surface);
    border: 1px solid var(--border); border-radius: 20px;
}
.years h2 { font: 700 clamp(19px, 2.5vw, 23px)/1.3 var(--serif); margin: 8px 0 0; }
.years .note {
    font: 400 calc(var(--read-size) - 2.5px)/1.65 var(--read); color: var(--muted);
    margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--border);
}
.rail { margin: 26px 0 0; }
/* The rail is a diagram, not prose: time runs left to right in every language. */
.track { position: relative; height: 76px; direction: ltr; }
.scale span {
    position: absolute; top: 0; transform: translateX(-50%);
    font: 600 10.5px/1 'Inter', system-ui, sans-serif; color: var(--faint);
    letter-spacing: .04em; font-variant-numeric: tabular-nums;
}
.scale span::after {
    content: ''; position: absolute; left: 50%; top: 15px;
    width: 1px; height: 7px; background: rgba(255, 174, 0, .35);
}
.track .line {
    position: absolute; top: 27px; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, rgba(255, 174, 0, .45), var(--gold) 55%, rgba(255, 174, 0, .7));
}
.track .dot {
    position: absolute; top: 28px; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
    border-radius: 50%; background: var(--gold);
    box-shadow: 0 0 0 3px var(--surface), 0 0 12px rgba(255, 174, 0, .75);
}
.leaders { position: absolute; left: 0; top: 33px; width: 100%; height: 43px; overflow: visible; }
.leaders line { stroke: rgba(255, 174, 0, .42); stroke-width: 1; vector-effect: non-scaling-stroke; }

.miles {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); direction: ltr;
}
.miles li { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 5px; min-width: 0; }
[dir="rtl"] .miles li { direction: rtl; }
.miles img {
    width: 52px; height: 52px; object-fit: cover; border-radius: 50%; margin-bottom: 10px;
    border: 1px solid var(--border-strong); background: var(--surface2);
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(255, 174, 0, .22);
}
.miles b { font: 600 13px/1.35 var(--sans); color: var(--text); overflow-wrap: anywhere; }
.miles .am { font: 600 11.5px/1.45 var(--sans); color: var(--gold); margin-top: 4px; }
.miles .bc { font: 400 11.5px/1.45 var(--sans); color: var(--muted); }

/* ---- contents ---- */
.era-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0 0; }
.era-nav a {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 11px;
    border: 1px solid var(--border); border-radius: 999px; background: rgba(255, 255, 255, .015);
    color: var(--muted); font: 600 13px/1.2 var(--sans); transition: color .15s, border-color .15s, background .15s;
}
.era-nav a:hover, .era-nav a:focus-visible { color: var(--gold); border-color: var(--border-strong); background: var(--gold-soft); text-decoration: none; outline: none; }
.era-nav .rn { color: var(--gold); font: 700 11px/1 'Playfair Display', Georgia, serif; opacity: .85; }

/* ---- the eras and the grid of faces ---- */
.era, .chronology { scroll-margin-top: 76px; }
.era { margin: 58px 0 0; }
.era-head { display: flex; align-items: center; gap: 16px; }
.era-head::after {
    content: ''; flex: 1 1 40px; height: 1px; align-self: center;
    background: linear-gradient(90deg, var(--border-strong), transparent);
}
[dir="rtl"] .era-head::after { background: linear-gradient(270deg, var(--border-strong), transparent); }
.era-num {
    flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%;
    display: grid; place-items: center;
    border: 1px solid var(--border-strong); color: var(--gold);
    font: 700 15px/1 'Playfair Display', Georgia, serif;
    background: radial-gradient(circle at 50% 30%, rgba(255, 174, 0, .16), rgba(255, 174, 0, 0) 70%);
}
.era-titles { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; min-width: 0; }
.era h2 { font: 700 clamp(23px, 3.3vw, 29px)/1.25 var(--serif); margin: 0; }
.era-ref { font: 600 12.5px/1.3 var(--sans); color: var(--gold); letter-spacing: .02em; }
.era-note {
    font: 400 var(--read-size)/var(--read-lh) var(--read); color: var(--soft);
    max-width: 36em; margin: 14px 0 0;
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; margin-top: 22px; }
.face {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 9px 9px 12px; text-align: center; cursor: pointer; color: inherit;
    background: linear-gradient(180deg, #1b1813, #131210); border: 1px solid var(--border); border-radius: 16px;
    transition: border-color .2s, transform .2s, box-shadow .2s;
}
.face:hover, .face:focus-visible {
    border-color: rgba(255, 174, 0, .62); transform: translateY(-3px); outline: none;
    box-shadow: 0 14px 30px -14px rgba(0, 0, 0, .9), 0 0 0 1px rgba(255, 174, 0, .14);
}
.face .pic { position: relative; display: block; width: 100%; margin-bottom: 4px; }
.face img, .face .monogram {
    display: block; width: 100%; aspect-ratio: 1; object-fit: cover;
    border-radius: 11px; border: 1px solid rgba(255, 174, 0, .22); background: #0f0d09;
}
.face .n {
    position: absolute; bottom: 6px; inset-inline-start: 6px;
    min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
    display: grid; place-items: center;
    background: rgba(10, 9, 7, .8); border: 1px solid rgba(255, 174, 0, .35);
    color: var(--gold); font: 600 11px/1 'Inter', system-ui, sans-serif; font-style: normal; font-variant-numeric: tabular-nums;
}
.face b { font: 700 15px/1.25 var(--serif); }
.face .gen { color: var(--faint); font: 400 11.5px/1.3 var(--sans); min-height: 1.3em; }
.face .bar-life { width: 100%; height: 4px; margin-top: 3px; border-radius: 2px; background: rgba(255, 174, 0, .14); overflow: hidden; }
.face .bar-life span { display: block; height: 100%; background: var(--gold); opacity: .55; }
.face .bar-life span.begot { opacity: 1; }

/* No leaf of the Chronicle for this name (the second Cainan): his initial on a
   medallion of the Chronicle's own green, so it reads as a face of the book
   rather than a missing picture. */
.monogram, .face .monogram {
    position: relative; display: grid; place-items: center;
    background: radial-gradient(circle at 50% 38%, #93ad82 0%, #7c966e 48%, #556b49 100%);
    color: #f8e7b8; font: 600 46px/1 var(--serif); text-shadow: 0 1px 0 rgba(40, 30, 10, .45);
}
.monogram::before {
    content: ''; position: absolute; inset: 13%; border-radius: 50%;
    border: 1.5px solid rgba(248, 231, 184, .55); box-shadow: inset 0 0 0 5px rgba(60, 80, 50, .25);
}
.monogram span { position: relative; }

/* ---- the chronology ----
   Twenty-seven dated events, each with a picture: the portrait of the man it
   concerns, or a public-domain painting, engraving, manuscript or photograph.
   The pictures sit on the rail like beads; the rail is drawn on .chron, not
   per row, or it would break at every gap left by a filtered-out row. */
.chronology { margin: 66px 0 0; }
.chronology h2 { font: 700 clamp(23px, 3.3vw, 29px)/1.25 var(--serif); margin: 8px 0 0; }
.chronology .lede {
    font: 400 var(--read-size)/var(--read-lh) var(--read); color: var(--soft);
    max-width: 36em; margin: 12px 0 22px;
}

.chron-filter {
    width: 100%; max-width: 340px; margin: 0 0 12px; padding: 10px 14px 10px 38px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d7461' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px 50% / 15px;
    color: var(--text); border: 1px solid var(--border); border-radius: 12px;
    font: 400 14px var(--sans);
}
[dir="rtl"] .chron-filter { padding: 10px 38px 10px 14px; background-position: right 13px center; }
.chron-filter:focus { outline: none; border-color: var(--gold); }
.chron-filter::placeholder { color: var(--faint); }

.chron { position: relative; list-style: none; margin: 0; padding: 0; }
.chron::before {
    content: ''; position: absolute; inset-inline-start: calc(var(--chron-thumb) / 2 - 1px);
    top: 30px; bottom: 30px; width: 2px;
    background: linear-gradient(180deg, transparent, var(--border-strong) 3%, var(--border-strong) 97%, transparent);
}
.chron-row { position: relative; }

.chron-head {
    display: grid; grid-template-columns: var(--chron-thumb) minmax(0, 1fr) auto; align-items: center; gap: 18px;
    width: 100%; padding: 10px 4px 10px 0; background: none; border: 0; border-radius: 14px;
    text-align: start; color: inherit; font: inherit; cursor: pointer;
}
[dir="rtl"] .chron-head { padding: 10px 0 10px 4px; }
.chron-head .thumb {
    position: relative; width: var(--chron-thumb); height: var(--chron-thumb); object-fit: cover;
    border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface2);
    box-shadow: 0 0 0 5px var(--bg);
    transition: border-color .2s, transform .2s;
}
.chron-row.is-person .thumb { border-radius: 50%; }
.chron-head:hover .thumb, .chron-row.open .thumb { border-color: var(--gold); }
.chron-head:hover .chron-title { color: var(--gold); }
.chron-head:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; }
.chron-text { min-width: 0; }
.chron-when { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.chron-when .yr { font: 700 13px/1.35 var(--sans); color: var(--gold); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.chron-when .am { font: 400 12px/1.35 var(--sans); color: var(--faint); }
.chron-title { display: block; margin-top: 3px; font: 700 18px/1.3 var(--serif); transition: color .15s; }
.chron-caret {
    width: 9px; height: 9px; margin-inline-end: 8px;
    border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint);
    transform: rotate(45deg); transition: transform .18s, border-color .18s;
}
.chron-row.open .chron-caret { transform: rotate(-135deg); border-color: var(--gold); }

.chron-info { display: none; padding: 2px 0 22px calc(var(--chron-thumb) + 18px); }
[dir="rtl"] .chron-info { padding: 2px calc(var(--chron-thumb) + 18px) 22px 0; }
.chron-row.open .chron-info { display: block; animation: chron-in .28s ease both; }
@keyframes chron-in { from { opacity: 0; transform: translateY(-4px); } }
.chron-info p { font: 400 var(--read-size)/var(--read-lh) var(--read); color: var(--soft); max-width: 34em; margin: 0; }

.chron-fig { margin: 2px 0 16px; }
.chron-fig img {
    display: block; width: auto; height: auto; max-width: 100%; max-height: 400px;
    border-radius: 12px; border: 1px solid var(--border); background: var(--surface2);
    box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .9);
}
.chron-fig figcaption { margin-top: 9px; max-width: 46em; font: 400 12.5px/1.5 'Inter', system-ui, sans-serif; color: var(--faint); }
.chron-fig figcaption i { color: var(--muted); }
/* The credit is English, but on a right-to-left page it lines up under the
   picture's right edge like everything else. */
[dir="rtl"] .chron-fig figcaption { text-align: right; }
.chron-fig figcaption a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.chron-fig figcaption a:hover { color: var(--gold); }

.chron-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 14px; }
.chron-ref {
    padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px;
    color: var(--gold); font: 600 12.5px/1.2 var(--sans);
}
.chron-person {
    display: inline-flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px;
    background: var(--gold-soft); border: 1px solid var(--border-strong); border-radius: 999px;
    color: var(--gold); font: 600 13px/1.2 var(--sans); cursor: pointer;
}
[dir="rtl"] .chron-person { padding: 3px 3px 3px 12px; }
.chron-person img, .chron-person .monogram { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; font-size: 13px; }
.chron-person .monogram::before { display: none; }
.chron-person:hover { border-color: var(--gold); }
.chron-person .arr { display: inline-block; }
[dir="rtl"] .chron-person .arr { transform: scaleX(-1); }
.chron-empty { color: var(--faint); font-size: 14px; margin: 14px 0 0; }

/* ---- the foot ---- */
.credit { margin-top: 66px; padding-top: 22px; color: var(--muted); font-size: 13.5px; line-height: 1.65; }
.credit p { margin: 12px 0 0; max-width: 60em; }

/* ---- the card (shell in pages.css) ---- */
.overlay { padding: 28px 14px 60px; }
.sheet {
    position: relative; max-width: 680px; padding: 28px 30px 30px; border-radius: 22px;
    background: linear-gradient(180deg, #16130d 0%, #0c0b09 38%);
    box-shadow: 0 40px 100px -24px rgba(0, 0, 0, .85);
}
.sheet .close, [dir="rtl"] .sheet .close { float: none; position: absolute; top: 18px; inset-inline-end: 18px; }
.sheet-head { display: flex; align-items: flex-end; gap: 22px; padding-inline-end: 44px; }
.portrait { flex: 0 0 auto; width: 132px; margin: 0; }
.portrait img, .portrait .monogram {
    display: block; width: 132px; height: 132px; object-fit: cover;
    border-radius: 14px; border: 1px solid var(--border-strong);
}
.portrait .monogram { display: grid; font-size: 54px; }
.portrait figcaption { margin-top: 7px; font: 400 10.5px/1.35 var(--sans); color: var(--faint); }
.who { min-width: 0; padding-bottom: 26px; }
.sheet .gen { color: var(--gold); font: 600 12px/1.3 var(--sans); letter-spacing: .06em; }
.sheet h2 { font: 700 clamp(28px, 5vw, 38px)/1.12 var(--serif); margin: 6px 0 4px; }
.sheet .alt { color: var(--faint); font-size: 12.5px; }
.sheet .note { font: 400 calc(var(--read-size) + 1px)/var(--read-lh) var(--read); color: var(--text); margin: 22px 0 0; }

.life { margin: 24px 0 4px; }
.life .bar-life { height: 10px; border-radius: 5px; background: rgba(255, 174, 0, .14); overflow: hidden; }
.life .bar-life span { display: block; height: 100%; background: var(--gold); opacity: .5; }
.life .bar-life span.begot { opacity: 1; }
.life .legend span::before, .years-legend span::before {
    content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px;
    margin-inline-end: 6px; vertical-align: 1px; background: var(--gold);
}
.life .legend .key-total::before { opacity: .5; }
.years-legend { margin-top: 6px; }
.years-legend span::before { border-radius: 50%; background: var(--border-strong); }
.years-legend .site { color: var(--faint); }

.facts { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.facts li {
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 12px;
    padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.facts .num { color: var(--gold); font: 700 26px/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.facts .fact { display: flex; flex-direction: column; gap: 2px; font-size: 14px; line-height: 1.45; }
.facts .ref { color: var(--faint); font-size: 12px; }
.facts .check { color: var(--muted); font: italic 400 13.5px/1.45 var(--scripture); }

.event { margin-top: 14px; border-inline-start: 2px solid var(--gold); padding-block: 6px; padding-inline-start: 12px; }
.event b { display: block; }
.event i { color: var(--faint); font-style: normal; font-size: 12.5px; }
.sheet .onote { color: var(--faint); font-size: 13px; line-height: 1.55; margin: 12px 0 0; }
.sheet h3.sec { margin-top: 28px; }

.kin { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); }
.kin-btn {
    display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 14px 8px 8px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    color: inherit; text-align: start; cursor: pointer; transition: border-color .15s, background .15s;
}
[dir="rtl"] .kin-btn { padding: 8px 8px 8px 14px; }
.kin-btn:hover, .kin-btn:focus-visible { border-color: var(--gold); background: var(--surface2); outline: none; }
.kin-btn.next { grid-column: 2; flex-direction: row-reverse; text-align: end; }
[dir="rtl"] .kin-btn.next { padding: 8px 14px 8px 8px; }
[dir="rtl"] .kin-btn.prev { padding: 8px 8px 8px 14px; }
.kin-btn img, .kin-btn .monogram { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px; object-fit: cover; font-size: 20px; }
.kin-btn .monogram::before { inset: 10%; box-shadow: none; }
.kin-btn span { min-width: 0; }
.kin-btn small { display: block; color: var(--gold); font: 600 11px/1.3 var(--sans); letter-spacing: .04em; }
.kin-btn b { display: block; font: 700 15px/1.25 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- narrow screens ---- */
@media (max-width: 640px) {
    .years { padding: 20px 16px 18px; }
    /* The rail becomes a column: the line runs down through the portraits, and
       the gap above each milestone still grows with the years before it. */
    .track { display: none; }
    .rail { margin-top: 22px; }
    .miles { display: block; position: relative; direction: inherit; }
    .miles::before {
        content: ''; position: absolute; top: 26px; bottom: 26px; inset-inline-start: 25px; width: 2px;
        background: linear-gradient(180deg, rgba(255, 174, 0, .4), var(--gold), rgba(255, 174, 0, .55));
    }
    .miles li {
        display: grid; grid-template-columns: 52px minmax(0, 1fr); column-gap: 14px; align-items: center;
        text-align: start; padding: 0; margin-top: calc(12px + var(--gap) * 110px);
    }
    .miles li:first-child { margin-top: 0; }
    .miles img { grid-row: 1 / span 3; margin: 0; position: relative; }
    .miles b, .miles .am, .miles .bc { grid-column: 2; }
    .miles .am { margin-top: 2px; }

    .era { margin-top: 46px; }
    .era-head { gap: 12px; }
    .era-head::after { display: none; }
    .era-num { width: 38px; height: 38px; font-size: 13px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
    .face { padding: 7px 7px 10px; border-radius: 14px; }
    .face b { font-size: 14px; }

    :root { --chron-thumb: 52px; }
    .chron-head { gap: 14px; }
    .chron-title { font-size: 16.5px; }
    .chron-info, [dir="rtl"] .chron-info { padding-inline-start: 0; padding-inline-end: 0; }
    .chron-fig img { max-height: 320px; }

    .sheet { padding: 22px 18px 24px; border-radius: 18px; }
    .sheet .close, [dir="rtl"] .sheet .close { top: 12px; inset-inline-end: 12px; }
    .sheet-head { gap: 16px; padding-inline-end: 36px; }
    .portrait, .portrait img, .portrait .monogram { width: 96px; }
    .portrait img, .portrait .monogram { height: 96px; }
    .portrait .monogram { font-size: 40px; }
    .who { padding-bottom: 30px; }
    .kin { grid-template-columns: 1fr; }
    .kin-btn.next { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .face, .chron-head .thumb, .era-nav a, .kin-btn { transition: none; }
    .face:hover, .face:focus-visible { transform: none; }
    .chron-row.open .chron-info { animation: none; }
}
