:root {
    --paper: #f6ecd1;
    --paper-soft: #fff8e8;
    --ink: #3f2a18;
    --muted: #75604c;
    --line: #d7bb83;
    --accent: #8a3f2f;
    --accent-strong: #683022;
    --green: #35665a;
    --shadow: 0 18px 45px rgba(65, 39, 15, 0.16);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 104px;
}

body {
    margin: 0;
    color: var(--ink);
    font: 16px/1.65 Georgia, "Times New Roman", serif;
    background:
        linear-gradient(rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.58)),
        url("../../images/bg.jpg") repeat;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    color: var(--accent-strong);
    text-decoration: underline;
}

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

button,
input,
textarea {
    font: inherit;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.skip-link,
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link:focus {
    width: auto;
    height: auto;
    clip: auto;
    left: 16px;
    top: 16px;
    z-index: 100;
    padding: 10px 14px;
    color: #fff;
    background: var(--accent);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(138, 63, 47, 0.2);
    background: rgba(255, 248, 232, 0.94);
    backdrop-filter: blur(10px);
}

.header-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 24px;
    min-height: 82px;
}

.brand {
    display: inline-grid;
    line-height: 1;
    color: var(--ink);
}

.brand:hover {
    text-decoration: none;
}

.brand-script {
    font-family: "Brush Script MT", "Segoe Script", cursive;
    font-size: clamp(2rem, 4vw, 3rem);
    white-space: nowrap;
}

.brand-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

.main-nav {
    justify-self: end;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.main-nav a {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 7px 11px;
    border-radius: var(--radius);
    color: var(--ink);
    font-size: 0.95rem;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
    color: #fff;
    text-decoration: none;
    background: var(--accent);
}

.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper-soft);
}

.nav-toggle span:not(.sr-only) {
    display: block;
    width: 20px;
    height: 2px;
    margin: 4px auto;
    background: var(--ink);
}

.page-hero {
    padding: 42px 0 34px;
    background:
        linear-gradient(120deg, rgba(246, 236, 209, 0.95), rgba(255, 248, 232, 0.8)),
        url("../../images/back.jpg") center top / 900px auto no-repeat;
    border-bottom: 1px solid rgba(138, 63, 47, 0.16);
}

.page-hero .shell {
    display: grid;
    grid-template-columns: 1fr minmax(280px, 440px);
    align-items: end;
    gap: 26px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(2.2rem, 5vw, 4.6rem);
    line-height: 1.02;
    font-weight: 500;
}

h2 {
    line-height: 1.25;
    font-size: clamp(1.35rem, 2.3vw, 1.8rem);
}

.home-section {
    padding: 52px 0 62px;
}

.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
    align-items: center;
    gap: 42px;
}

.home-copy p:not(.eyebrow) {
    max-width: 620px;
    color: var(--muted);
    font-size: 1.14rem;
}

.frame-figure {
    margin: 0;
    padding: clamp(12px, 2vw, 18px);
    border: 1px solid rgba(138, 63, 47, 0.18);
    border-radius: var(--radius);
    background: rgba(255, 248, 232, 0.72);
    box-shadow: var(--shadow);
}

.frame-figure img {
    width: 100%;
    aspect-ratio: 457 / 339;
    object-fit: cover;
    border-radius: 4px;
}

.search-form {
    display: flex;
    gap: 8px;
    width: min(100%, 580px);
    margin: 24px 0 18px;
}

.search-form.compact {
    justify-self: end;
    margin: 0;
}

.search-form.wide {
    width: 100%;
    max-width: none;
}

.search-form input,
.contact-form input,
.contact-form textarea,
.admin-field {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: rgba(255, 252, 241, 0.94);
}

.search-form input {
    min-height: 44px;
    padding: 0 14px;
}

.search-form button,
.contact-form button,
.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius);
    padding: 0 18px;
    color: #fff;
    background: var(--green);
    cursor: pointer;
    white-space: nowrap;
}

.button {
    background: rgba(53, 102, 90, 0.12);
    color: var(--green);
    border: 1px solid rgba(53, 102, 90, 0.32);
}

.button.primary,
.search-form button:hover,
.contact-form button:hover {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stats-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    margin: 42px 0;
    overflow: hidden;
    border: 1px solid rgba(138, 63, 47, 0.18);
    border-radius: var(--radius);
    background: rgba(138, 63, 47, 0.18);
}

.stats-strip div {
    padding: 18px;
    background: rgba(255, 248, 232, 0.82);
}

.stats-strip strong {
    display: block;
    font-size: 2rem;
    line-height: 1;
}

.stats-strip span {
    color: var(--muted);
    font-size: 0.9rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.feature,
.text-panel,
.contact-card,
.photo-card {
    border: 1px solid rgba(138, 63, 47, 0.18);
    border-radius: var(--radius);
    background: rgba(255, 248, 232, 0.84);
    box-shadow: 0 10px 28px rgba(65, 39, 15, 0.08);
}

.feature {
    display: block;
    min-height: 160px;
    padding: 22px;
    color: var(--ink);
}

.feature:hover {
    text-decoration: none;
    border-color: rgba(138, 63, 47, 0.48);
}

.feature span {
    display: block;
    margin-bottom: 12px;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}

.feature p {
    margin: 0;
    color: var(--muted);
}

.content-section {
    padding: 38px 0 62px;
}

.text-panel {
    padding: clamp(20px, 4vw, 42px);
}

.section-intro {
    color: var(--muted);
    font-size: 1.05rem;
}

.name-group {
    padding: 24px 0;
    border-top: 1px solid rgba(138, 63, 47, 0.18);
}

.name-group:first-of-type {
    border-top: 0;
}

.person-list {
    columns: 2 260px;
    padding-left: 22px;
}

.person-list li {
    break-inside: avoid;
    margin: 0 0 8px;
}

.surname-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.surname-grid a {
    display: grid;
    min-height: 86px;
    align-content: center;
    gap: 4px;
    padding: 14px;
    border: 1px solid rgba(138, 63, 47, 0.18);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.3);
}

.surname-grid a:hover {
    text-decoration: none;
    background: rgba(53, 102, 90, 0.08);
}

.surname-grid span,
.person-surname,
.photo-card small {
    color: var(--muted);
    font-size: 0.92rem;
}

.person-entry {
    padding: 24px 0;
    border-top: 1px solid rgba(138, 63, 47, 0.18);
    scroll-margin-top: 104px;
}

.person-entry:first-child {
    border-top: 0;
}

.person-entry h2 {
    margin-bottom: 2px;
}

.life-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 12px;
    color: var(--muted);
    font-size: 0.95rem;
}

.life-facts span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 2px 9px;
    border: 1px solid rgba(138, 63, 47, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.34);
}

.compact-text {
    max-width: 78ch;
}

.back-link {
    color: var(--muted);
}

.rich-text {
    overflow-wrap: anywhere;
}

.rich-text img,
.rich-text table {
    max-width: 100%;
}

.rich-text table {
    display: block;
    overflow-x: auto;
}

.content-block + .content-block {
    margin-top: 34px;
    padding-top: 28px;
    border-top: 1px solid rgba(138, 63, 47, 0.18);
}

.descendants-auto {
    margin-bottom: 34px;
    padding-bottom: 28px;
    border-bottom: 1px solid rgba(138, 63, 47, 0.18);
}

.descendant-tree,
.descendant-tree ol {
    list-style: none;
    margin: 0;
    padding-left: 0;
}

.descendant-tree ol {
    margin-left: 28px;
    padding-left: 18px;
    border-left: 1px solid rgba(138, 63, 47, 0.18);
}

.descendant-tree li {
    margin-top: 12px;
}

.descendant-person {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid rgba(138, 63, 47, 0.14);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.26);
}

.descendant-number {
    min-width: 48px;
    padding: 4px 8px;
    border-radius: var(--radius);
    color: #fff;
    text-align: center;
    background: var(--green);
    font-size: 0.9rem;
}

.descendant-person h3 {
    margin: 0 0 2px;
    font-size: 1.08rem;
    line-height: 1.25;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.photo-card {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.photo-card > a {
    display: grid;
    place-items: center;
    background: rgba(53, 102, 90, 0.08);
}

.photo-card img,
.missing-photo {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: rgba(53, 102, 90, 0.1);
}

.photo-card h2 {
    margin-bottom: 8px;
    font-size: 1.08rem;
}

.photo-card div:last-child {
    padding: 16px;
}

.missing-photo {
    display: grid;
    place-items: center;
    color: var(--muted);
}

.contact-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: 22px;
}

.contact-form {
    display: grid;
    gap: 14px;
}

.contact-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.contact-form input,
.contact-form textarea {
    padding: 10px 12px;
}

.honeypot {
    position: absolute;
    left: -100vw;
}

.contact-card {
    padding: 24px;
}

.notice {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: var(--radius);
}

.notice.success {
    color: #174d37;
    background: #dff3e7;
}

.notice.error {
    color: #6d2018;
    background: #f5ddd8;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
}

.pagination a,
.pagination span,
.pagination strong {
    min-width: 38px;
    min-height: 38px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(138, 63, 47, 0.22);
    border-radius: var(--radius);
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.34);
}

.pagination strong {
    color: #fff;
    background: var(--accent);
}

mark {
    padding: 0 2px;
    color: inherit;
    background: #ffe083;
}

.site-footer {
    padding: 26px 0;
    color: var(--muted);
    border-top: 1px solid rgba(138, 63, 47, 0.18);
    background: rgba(255, 248, 232, 0.82);
}

.footer-grid {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.footer-grid p {
    margin: 0;
}

.footer-grid nav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: minmax(44px, 1fr) minmax(0, auto) minmax(44px, 1fr);
    grid-template-rows: 1fr auto;
    align-items: center;
    justify-items: center;
    padding: 28px;
    background: rgba(18, 12, 8, 0.86);
}

.lightbox[hidden] {
    display: none;
}

.lightbox img {
    grid-column: 2;
    max-height: min(78vh, 900px);
    max-width: min(86vw, 1200px);
    width: auto;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.lightbox p {
    grid-column: 1 / -1;
    max-width: min(90vw, 780px);
    margin: 14px 0 0;
    color: #fff8e8;
    text-align: center;
}

.lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: var(--radius);
    color: #fff;
    background: transparent;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-prev,
.lightbox-next {
    width: 48px;
    height: 64px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: var(--radius);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    font-size: 2.4rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-prev {
    grid-column: 1;
}

.lightbox-next {
    grid-column: 3;
}

.lightbox-prev:disabled,
.lightbox-next:disabled {
    opacity: 0.35;
    cursor: default;
}

pre {
    overflow-x: auto;
    padding: 14px;
    background: rgba(255, 255, 255, 0.45);
}

@media (max-width: 860px) {
    .header-grid {
        grid-template-columns: 1fr auto;
    }

    .nav-toggle {
        display: block;
    }

    .main-nav {
        grid-column: 1 / -1;
        display: none;
        justify-self: stretch;
        padding-bottom: 16px;
    }

    .main-nav.open {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .main-nav a {
        justify-content: center;
        background: rgba(255, 255, 255, 0.42);
    }

    .page-hero .shell,
    .home-hero,
    .contact-layout {
        grid-template-columns: 1fr;
    }

    .frame-figure {
        order: -1;
    }

    .search-form.compact {
        justify-self: stretch;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .shell {
        width: min(100% - 22px, 1120px);
    }

    html {
        scroll-padding-top: 92px;
    }

    .brand-script {
        font-size: 1.9rem;
    }

    .header-grid {
        min-height: 74px;
    }

    .home-section,
    .content-section {
        padding: 24px 0 42px;
    }

    .page-hero {
        padding: 26px 0;
    }

    .search-form {
        display: flex;
        gap: 8px;
    }

    .search-form input {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
    }

    .search-form button {
        flex: 0 0 auto;
        width: auto;
        padding-inline: 14px;
    }

    .hero-actions .button {
        width: 100%;
    }

    .stats-strip {
        grid-template-columns: 1fr;
    }

    .main-nav.open {
        grid-template-columns: 1fr;
    }

    .text-panel,
    .contact-card {
        padding: 18px;
    }

    .person-entry {
        scroll-margin-top: 92px;
    }

    .descendant-tree ol {
        margin-left: 10px;
        padding-left: 12px;
    }

    .descendant-person {
        grid-template-columns: 1fr;
    }

    .descendant-number {
        width: max-content;
    }

    .lightbox {
        grid-template-columns: 48px minmax(0, 1fr) 48px;
        padding: 18px 10px;
    }

    .lightbox img {
        max-width: calc(100vw - 116px);
    }
}
