/* ==========================================================================
   Mallinder Clan — Responsive Heritage & Family-Tree Design System
   Mobile-first layout with comfortable desktop reading proportions,
   warm archival parchment tones, Yorkshire forest-green & antique-brass
   accents, and harmonious compatibility across Bootstrap 5.3.3 & 4.x pages.
   ========================================================================== */

:root {
    /* Archival Heritage Palette */
    --heritage-bg: #f7f3eb;              /* Warm archival parchment canvas */
    --heritage-surface: #fffdf9;         /* Crisp archival paper card */
    --heritage-surface-alt: #f0e9dc;     /* Warm linen tint for callouts & panels */
    --heritage-ink: #27211b;             /* Deep warm charcoal-sepia prose */
    --heritage-muted: #625648;           /* Warm umber for captions & metadata */
    --heritage-primary: #2d4a3e;         /* Classic Yorkshire heritage forest green */
    --heritage-primary-hover: #20372e;   /* Deeper forest hover */
    --heritage-primary-soft: #e6efe9;    /* Soft sage tint for badges & active states */
    --heritage-accent: #8e6b3e;          /* Antique brass / sepia gold */
    --heritage-border: #dcd2c1;          /* Delicate linen hairline */
    --heritage-shadow: 0 2px 12px rgba(39, 33, 27, 0.055);
    --heritage-shadow-hover: 0 8px 24px rgba(39, 33, 27, 0.09);

    /* Typography */
    --heritage-font-serif: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
    --heritage-font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Responsive Layout Tokens */
    --heritage-max-width: 980px;         /* Balanced desktop card frame — comfortable natural prose width */
    --heritage-radius: 10px;
}

/* --- Global Base & Overflow Protection (Mobile-First) --- */
html {
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    background-color: var(--heritage-bg);
    background-image: radial-gradient(rgba(142, 107, 62, 0.045) 1px, transparent 0);
    background-size: 28px 28px;
    color: var(--heritage-ink);
    font-family: var(--heritage-font-sans);
    font-size: 1.0625rem;
    line-height: 1.66;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
}

/* Comfortable desktop reading scale proportional to archival clippings and 980px cards */
@media (min-width: 992px) {
    body {
        font-size: 1.125rem;
        line-height: 1.68;
    }
}

/* Prevent wide links, URLs, or images from causing mobile horizontal overflow */
img, video, iframe, svg {
    max-width: 100%;
}

a {
    color: var(--heritage-primary);
    text-decoration-color: rgba(45, 74, 62, 0.35);
    text-underline-offset: 0.18em;
    transition: color 0.18s ease, text-decoration-color 0.18s ease;
}

a:hover {
    color: var(--heritage-primary-hover);
    text-decoration-color: var(--heritage-accent);
}

/* --- Heritage Editorial Headings --- */
h1, h2, h3, h4, h5 {
    font-family: var(--heritage-font-serif);
    color: var(--heritage-primary);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

h1 {
    font-size: clamp(1.7rem, 3.2vw, 2.35rem);
    font-weight: 700;
}

h2 {
    font-size: clamp(1.38rem, 2.4vw, 1.85rem);
    font-weight: 700;
    margin-bottom: 0.85rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--heritage-border);
}

h3 {
    font-size: clamp(1.18rem, 1.8vw, 1.45rem);
    font-weight: 700;
    margin-top: 1.25rem;
    margin-bottom: 0.65rem;
}

h4 {
    font-size: clamp(1.08rem, 1.5vw, 1.3rem);
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--heritage-primary);
}

/* Give full-width card section headings (e.g. Birth, Marriage, Children, Death) a crisp archival underline */
.col-12 > h4,
.col-md-12 > h4 {
    padding-bottom: 0.45rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--heritage-border);
}

.col-12 > h4 small,
.col-md-12 > h4 small,
.col-12 > h3 small {
    display: inline-block;
    font-family: var(--heritage-font-sans);
    font-size: 0.96rem;
    font-weight: 400;
    color: #52463a !important;
    margin-left: 0.45rem;
}

/* Legible archival captions & newspaper/source citations directly beneath clipping images */
p:has(> img) + p.text-center,
img.img-thumbnail + p.text-center,
figcaption {
    font-size: 0.98rem;
    font-style: italic;
    font-weight: 600;
    color: #4c4034;
    margin-top: -0.4rem;
    margin-bottom: 1.4rem;
}

@media (min-width: 992px) {
    .col-12 > h4 small,
    .col-md-12 > h4 small,
    .col-12 > h3 small {
        font-size: 1rem;
    }

    p:has(> img) + p.text-center,
    img.img-thumbnail + p.text-center,
    figcaption {
        font-size: 1.02rem;
    }
}

p {
    margin-bottom: 1.05rem;
    overflow-wrap: break-word;
}

.lead {
    font-size: clamp(1.125rem, 1.5vw, 1.28rem);
    line-height: 1.68;
    color: var(--heritage-ink);
}

/* --- Heritage Navigation Bar (Sticky-Top, Mobile-First) --- */
nav.navbar {
    background: rgba(255, 253, 249, 0.96) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 2px solid var(--heritage-border);
    box-shadow: 0 2px 10px rgba(39, 33, 27, 0.05);
    padding: 0.55rem 0;
}

nav.navbar > .container,
nav.navbar > .container-fluid {
    max-width: var(--heritage-max-width);
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

nav.navbar .navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.15rem 0;
    text-decoration: none;
}

nav.navbar .navbar-brand img {
    max-height: 44px;
    width: auto;
    height: auto;
}

.heritage-brand-subtitle {
    display: none;
    font-family: var(--heritage-font-serif);
    font-size: 0.88rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--heritage-accent);
    border-left: 1px solid var(--heritage-border);
    padding-left: 0.65rem;
}

@media (min-width: 576px) {
    .heritage-brand-subtitle {
        display: inline-block;
    }
}

nav.navbar .navbar-toggler {
    border-color: var(--heritage-border);
    padding: 0.45rem 0.65rem;
    min-width: 44px;
    min-height: 44px;
}

nav.navbar .nav-link {
    color: var(--heritage-ink) !important;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.62rem 0.9rem !important;
    border-radius: 6px;
    transition: background-color 0.16s ease, color 0.16s ease;
}

nav.navbar .nav-link:hover,
nav.navbar .nav-link:focus,
nav.navbar .nav-item.active > .nav-link {
    color: var(--heritage-primary) !important;
    background-color: var(--heritage-primary-soft);
}

nav.navbar .dropdown-menu {
    background-color: var(--heritage-surface);
    border: 1px solid var(--heritage-border);
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(39, 33, 27, 0.1);
    padding: 0.45rem;
}

nav.navbar .dropdown-item {
    color: var(--heritage-ink);
    font-size: 0.98rem;
    padding: 0.56rem 0.95rem;
    border-radius: 5px;
}

nav.navbar .dropdown-item:hover,
nav.navbar .dropdown-item:focus {
    background-color: var(--heritage-primary-soft);
    color: var(--heritage-primary);
}

.heritage-nav-login {
    border: 1px solid var(--heritage-border);
    background-color: var(--heritage-surface-alt);
    margin-top: 0.35rem;
}

@media (min-width: 992px) {
    nav.navbar .nav-link {
        font-size: 1.04rem;
        padding: 0.62rem 1rem !important;
    }

    .heritage-nav-login {
        margin-top: 0;
        margin-left: 0.45rem;
    }
}

/* --- Main Content Containers: Constrained Desktop Reading Frame --- */
body > .container-fluid.padding {
    max-width: var(--heritage-max-width);
    margin: 1.25rem auto;
    padding: 1.15rem 1rem;
    background-color: var(--heritage-surface);
    border: 1px solid var(--heritage-border);
    border-radius: var(--heritage-radius);
    box-shadow: var(--heritage-shadow);
}

/* Hide legacy empty black spacer strip without deleting markup */
body > .container-fluid.padding.bg-black.py-2:empty {
    display: none;
}

@media (min-width: 768px) {
    body > .container-fluid.padding {
        margin: 1.6rem auto;
        padding: 1.85rem 2.15rem;
    }
}

@media (min-width: 1200px) {
    body > .container-fluid.padding {
        padding: 2.15rem 2.6rem;
    }
}

/* Balanced Grid Gutters, Natural Full-Card Prose Width & Clean Vertical Rhythm */
body > .container-fluid.padding .row.padding {
    align-items: flex-start;
    row-gap: 1.15rem;
    --bs-gutter-x: 1.75rem;
}

/* Generous breathing room between consecutive rows inside a card (e.g. image row -> caption/text row) */
body > .container-fluid.padding .row.padding + .row.padding {
    margin-top: 1.15rem;
}

/* Let card copy fill the natural, balanced card width (~860px inner width) without lopsided right gaps */
body > .container-fluid.padding .col-12 > p,
body > .container-fluid.padding .col-12 > ol,
body > .container-fluid.padding .col-12 > ul,
body > .container-fluid.padding .col-md-12 > p,
body > .container-fluid.padding .col-md-12 > ol,
body > .container-fluid.padding .col-md-12 > ul {
    max-width: 100%;
}

/* Remove redundant bottom margin on the last paragraph inside a card */
body > .container-fluid.padding .row.padding:last-of-type .col-12 > p:last-child,
body > .container-fluid.padding .row.padding:last-of-type .col-md-12 > p:last-child,
body > .container-fluid.padding .row.padding:last-of-type .col-md-7 > p:last-child {
    margin-bottom: 0.25rem;
}

/* On narrow mobile screens, let col-3 / col-6 / col-3 centered portrait rows use full width cleanly */
@media (max-width: 575.98px) {
    body > .container-fluid.padding .row.padding > .col-3:empty {
        display: none;
    }

    body > .container-fluid.padding .row.padding > .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* --- Biography & Narrative Cards: Clean Stacking (< 992px) + Editorial Float-Wrap (>= 992px) ---
   Targets only side-by-side image + prose rows (col-md-5/7, col-md-4/8, col-md-3/9)
   excluding homepage/subsite teaser cards (a.btn), YouTube iframe rows, and data tables. */
@media (max-width: 991.98px) {
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-5,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-7,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-4,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-8,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-3,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-9 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
    }
}

@media (min-width: 992px) {
    /* Switch qualifying image+prose rows from rigid flex columns to a self-clearing float context */
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)),
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table)),
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) {
        display: flow-root;
        margin-left: 0;
        margin-right: 0;
    }

    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table))::after,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table))::after,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table))::after {
        content: "";
        display: table;
        clear: both;
    }

    /* Float portrait/illustration column on the left with balanced margins */
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-5 {
        float: left;
        width: 38%;
        max-width: 340px;
        margin: 0.25rem 2rem 1.25rem 0;
        padding: 0;
    }

    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-4,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-3 {
        float: left;
        width: 30%;
        max-width: 280px;
        margin: 0.25rem 2rem 1.25rem 0;
        padding: 0;
    }

    /* Keep floated portraits crisp and proportionate */
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-5 .img-thumbnail,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-4 .img-thumbnail,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-3 .img-thumbnail {
        width: 100%;
        max-height: 440px;
        margin: 0;
    }

    /* Unwrap sibling prose column so headings/audio sit beside the portrait and paragraphs wrap cleanly below it */
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-7,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-8,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-9 {
        display: contents;
    }

    /* Headings and lists establish a BFC so bottom rules and list bullets never overlap the floated portrait */
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-7 > h2,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-7 > h3,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-7 > h4,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-7 > ol,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-5 img):has(> .col-md-7):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-7 > ul,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-8 > h2,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-4 img):has(> .col-md-8):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-8 > h4,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-9 > h2,
    body > .container-fluid.padding:not(.heritage-ancestor-card) > .row.padding:has(> .col-md-3 img):has(> .col-md-9):not(:has(a.btn)):not(:has(iframe)):not(:has(table)) > .col-md-9 > h4 {
        overflow: hidden;
    }
}

/* Comfortable spacing for multi-item historical lists */
body > .container-fluid.padding ol,
body > .container-fluid.padding ul {
    padding-left: 1.35rem;
}

body > .container-fluid.padding li {
    margin-bottom: 0.55rem;
}

/* --- Heritage Hero Banner & Paternal Lineage Jump Strip (index.html) --- */
.heritage-hero {
    background: linear-gradient(180deg, #fffdf9 0%, #f4ede0 100%) !important;
    border-top: 4px solid var(--heritage-primary) !important;
    text-align: center;
}

.heritage-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--heritage-font-sans);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--heritage-accent);
    background-color: var(--heritage-surface-alt);
    border: 1px solid var(--heritage-border);
    border-radius: 999px;
    padding: 0.28rem 0.85rem;
    margin-bottom: 0.85rem;
}

.heritage-hero-title {
    margin-bottom: 0.75rem;
    border-bottom: none;
    padding-bottom: 0;
}

.heritage-hero .lead {
    max-width: 62ch;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 1.25rem;
}

/* Compact Generation Quick-Jump Strip on Homepage */
.heritage-lineage-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--heritage-border);
}

.heritage-lineage-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.36rem 0.75rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--heritage-primary);
    background-color: var(--heritage-surface);
    border: 1px solid var(--heritage-border);
    border-radius: 999px;
    text-decoration: none;
    transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.heritage-lineage-pill:hover {
    background-color: var(--heritage-primary);
    border-color: var(--heritage-primary);
    color: #fffdf9;
    transform: translateY(-1px);
    text-decoration: none;
}

.heritage-lineage-dates {
    font-weight: 400;
    opacity: 0.82;
    font-size: 0.82rem;
}

/* --- Ancestor Generation Cards (Homepage & Lineage Sections) --- */
.heritage-ancestor-card {
    position: relative;
    border-left: 4px solid var(--heritage-accent) !important;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.heritage-ancestor-card:hover {
    box-shadow: var(--heritage-shadow-hover);
}

.heritage-gen-tag {
    display: inline-block;
    font-family: var(--heritage-font-sans);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--heritage-accent);
    background-color: var(--heritage-surface-alt);
    border: 1px solid var(--heritage-border);
    border-radius: 4px;
    padding: 0.18rem 0.55rem;
    margin-bottom: 0.55rem;
}

/* --- Responsive Video Presentation (Constrained on Wide Desktops) --- */
.heritage-video-section {
    background-color: var(--heritage-surface-alt) !important;
}

.heritage-video-frame,
body > .container-fluid.padding > .ratio.ratio-16x9,
body > .ratio.ratio-16x9 {
    max-width: 860px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    background-color: #161412;
    box-shadow: 0 8px 24px rgba(22, 20, 18, 0.18);
    border: 1px solid rgba(142, 107, 62, 0.35);
}

.heritage-video-frame video,
.ratio.ratio-16x9 video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* --- Archival Photograph & Historical Document Framing --- */
.img-thumbnail {
    background-color: #fffdf9;
    border: 1px solid var(--heritage-border);
    padding: 0.42rem;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(39, 33, 27, 0.08);
    max-height: 520px;
    width: auto;
    object-fit: contain;
    margin-top: 0.25rem;
    margin-bottom: 1rem;
}

/* Keep side-by-side desktop portraits flush with adjacent biography text */
@media (min-width: 768px) {
    .col-md-5 .img-thumbnail,
    .col-md-4 .img-thumbnail,
    .col-md-3 .img-thumbnail {
        margin-bottom: 0;
    }
}

/* Allow full-column scanned certificates & maps to remain crisp without excessive desktop height */
.col-12 .img-thumbnail,
.col-md-12 .img-thumbnail {
    max-height: 640px;
}

/* --- Buttons (Heritage Forest Primary) --- */
.btn-primary {
    background-color: var(--heritage-primary);
    border-color: var(--heritage-primary);
    color: #fffdf9;
    font-weight: 600;
    padding: 0.55rem 1.2rem;
    min-height: 42px;
    border-radius: 6px;
    letter-spacing: 0.01em;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--heritage-primary-hover);
    border-color: var(--heritage-primary-hover);
    color: #fffdf9;
    transform: translateY(-1px);
}

/* --- Ornamental Heritage Section Dividers --- */
hr.my-4 {
    border: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--heritage-border) 18%,
        var(--heritage-accent) 50%,
        var(--heritage-border) 82%,
        transparent 100%
    );
    opacity: 0.85;
    margin: 1.5rem 0 !important;
    overflow: visible;
    position: relative;
}

/* Hide redundant bottom hr inside already-bordered heritage cards */
body > .container-fluid.padding > hr.my-4:last-child {
    display: none;
}

/* --- Audio Narration Player Enhancement (Ancestor Pages) --- */
#audio-button {
    background-color: var(--heritage-primary);
    border-color: var(--heritage-primary);
    min-width: 56px;
    min-height: 56px;
}

#audio-button:hover {
    background-color: var(--heritage-primary-hover);
    border-color: var(--heritage-primary-hover);
}

#seek-slider.form-range::-webkit-slider-thumb {
    background-color: var(--heritage-primary) !important;
}

#seek-slider.form-range::-moz-range-thumb {
    background-color: var(--heritage-primary) !important;
}

/* Frame the audio controls when present inside biography columns */
.col-md-7 > .my-3.d-flex.align-items-center,
.col-12 > .my-3.d-flex.align-items-center {
    background-color: var(--heritage-surface-alt);
    border: 1px solid var(--heritage-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem !important;
}

.col-md-7 > .d-flex.align-items-center.mt-2,
.col-12 > .d-flex.align-items-center.mt-2 {
    background-color: var(--heritage-surface-alt);
    border: 1px solid var(--heritage-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-bottom: 1.25rem;
}

/* --- Historical Record Tables (Responsive, Zero Mobile Overflow) --- */
.heritage-table-wrap {
    margin: 1.15rem 0;
    border: 1px solid var(--heritage-border);
    border-radius: 8px;
    background-color: var(--heritage-surface);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.heritage-table-wrap > table.table,
table.table {
    margin-bottom: 0;
    font-size: 0.98rem;
    color: var(--heritage-ink);
}

@media (min-width: 992px) {
    .heritage-table-wrap > table.table,
    table.table {
        font-size: 1.02rem;
    }
}

table.table thead,
table.table thead.table-dark,
table.table thead.thead-dark {
    background-color: var(--heritage-primary);
    color: #fffdf9;
}

table.table thead th {
    background-color: var(--heritage-primary) !important;
    color: #fffdf9 !important;
    font-family: var(--heritage-font-serif);
    font-weight: 700;
    font-size: 0.94rem;
    border-bottom: 2px solid var(--heritage-accent);
    white-space: nowrap;
    padding: 0.68rem 0.8rem;
}

table.table tbody th,
table.table tbody td {
    padding: 0.58rem 0.75rem;
    border-color: var(--heritage-border);
    vertical-align: top;
}

table.table-striped tbody tr:nth-of-type(odd) > * {
    background-color: rgba(240, 233, 220, 0.55);
}

/* Archival key-value record sheet (e.g. William Mallinder marriage licence) */
.heritage-record-table tbody th {
    width: 38%;
    max-width: 240px;
    background-color: var(--heritage-surface-alt);
    color: var(--heritage-primary);
    font-weight: 700;
}

/* --- Heritage Site Footer --- */
footer {
    margin-top: 2.5rem;
    background-color: #23352d;
    border-top: 3px solid var(--heritage-accent);
    color: #f3ede1;
}

footer > .container-fluid.padding {
    max-width: var(--heritage-max-width);
    margin: 0 auto;
    padding: 1.65rem 1.25rem;
    background: transparent;
    border: 0;
    box-shadow: none;
}

footer p.bg-secondary {
    background-color: transparent !important;
    color: #f3ede1 !important;
    font-family: var(--heritage-font-serif);
    font-style: italic;
    font-size: 0.98rem;
    line-height: 1.65;
    max-width: 64ch;
    margin: 0 auto !important;
    padding: 0.25rem 0 !important;
}

/* --- Chatbot Widget Heritage Harmonization --- */
#chatbot-container #chat-bubble,
#chatbot-container #chat-window > .bg-primary,
#chatbot-container #send-btn,
#chatbot-container .bubble-user {
    background-color: var(--heritage-primary) !important;
    border-color: var(--heritage-primary) !important;
}

#chatbot-container #chat-bubble:hover,
#chatbot-container #send-btn:hover {
    background-color: var(--heritage-primary-hover) !important;
    border-color: var(--heritage-primary-hover) !important;
}
