/* File: wwwroot/css/site.css
   IsaFamilyTree theme. Colours, radius and spacing are tokens; layout uses logical properties
   (inline-start / inline-end) so the same rules serve English (LTR) and Arabic (RTL). */
:root {
    --ft-surface: #FBF8F3;
    --ft-card: #FFFFFF;
    --ft-border: #E7DFD3;
    --ft-ink: #2B2622;
    --ft-ink-soft: #6B6259;
    --ft-primary: #1F5F57;
    --ft-primary-dark: #17483F;
    --ft-accent: #B5653A;
    --ft-radius: 12px;
    --ft-space: 4px;
    --bs-primary: #1F5F57;
    --bs-primary-rgb: 31, 95, 87;
    --bs-link-color: #1F5F57;
    --bs-link-hover-color: #17483F;
    --bs-body-bg: var(--ft-surface);
    --bs-body-color: var(--ft-ink);
}

html[lang="ar"] body { font-family: 'Noto Naskh Arabic', 'Segoe UI', Tahoma, serif; line-height: 1.8; }
body { background: var(--ft-surface); color: var(--ft-ink); font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }

.btn-primary { --bs-btn-bg: var(--ft-primary); --bs-btn-border-color: var(--ft-primary); --bs-btn-hover-bg: var(--ft-primary-dark); --bs-btn-hover-border-color: var(--ft-primary-dark); --bs-btn-active-bg: var(--ft-primary-dark); --bs-btn-active-border-color: var(--ft-primary-dark); }
.btn-outline-secondary { --bs-btn-color: var(--ft-ink-soft); --bs-btn-border-color: var(--ft-border); }
.btn-pill { border-radius: 999px; padding-block: calc(var(--ft-space) * 2.5); font-weight: 600; }
.btn-google { background: #fff; border: 1px solid var(--ft-border); color: var(--ft-ink); border-radius: 999px; padding-block: calc(var(--ft-space) * 2.5); font-weight: 600; }
.btn-google:hover { background: #F4EFE7; color: var(--ft-ink); }
.btn-google .fa-google { color: #DB4437; margin-inline-end: 8px; }
:focus-visible { outline: 3px solid var(--ft-accent); outline-offset: 2px; }
.skip-link { position: absolute; inset-inline-start: -9999px; top: 0; background: var(--ft-primary); color: #fff; padding: 8px 16px; z-index: 2000; }
.skip-link:focus { inset-inline-start: 0; }

/* Header */
.site-header { background: var(--ft-card); border-block-end: 1px solid var(--ft-border); position: sticky; top: 0; z-index: 1030; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { color: var(--ft-primary); font-weight: 700; font-size: 1.2rem; text-decoration: none; display: inline-flex; gap: 8px; align-items: center; }
.main-nav { gap: 24px; align-items: center; }
.main-nav a { color: var(--ft-ink); text-decoration: none; font-weight: 500; }
.main-nav a:hover { color: var(--ft-primary); }
.nav-soon { color: var(--ft-ink-soft); opacity: .7; cursor: default; }
.main-nav-mobile { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-block-start: 1px solid var(--ft-border); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { display: inline-flex; gap: 6px; align-items: center; color: var(--ft-ink-soft); font-size: .9rem; }
.lang-switch { margin: 0; }

.page-content { flex: 1; padding-block: calc(var(--ft-space) * 8); max-width: 1280px; }
.page-title { font-size: 1.6rem; font-weight: 700; margin-block-end: 20px; }
.site-footer { border-block-start: 1px solid var(--ft-border); padding-block: 16px; color: var(--ft-ink-soft); font-size: .85rem; text-align: center; }

/* Cards and home */
.widget-card { background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); padding: 20px; }
.section-spacer { margin-block-start: 32px; }
.section-title { font-size: 1.15rem; font-weight: 700; margin-block-end: 12px; }
.hero { padding: 32px; border-radius: var(--ft-radius); background: linear-gradient(135deg, #1F5F57 0%, #2C7A6F 100%); color: #FBF8F3; }
.hero-eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; opacity: .85; margin: 0 0 8px; }
.hero-title { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; margin: 0 0 8px; }
.hero-lead { max-width: 60ch; margin: 0; opacity: .92; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.feature-card { display: flex; flex-direction: column; gap: 8px; }
.feature-icon { width: 44px; height: 44px; border-radius: 12px; background: #F1E6D8; color: var(--ft-accent); display: grid; place-items: center; font-size: 1.2rem; }
.feature-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.feature-text { color: var(--ft-ink-soft); margin: 0; flex: 1; }
.badge-soon { align-self: flex-start; background: #F1E6D8; color: var(--ft-accent); border-radius: 999px; padding: 2px 12px; font-size: .78rem; font-weight: 600; }

/* Sign-in and error pages */
.account-body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle at top, #F3EADC 0%, var(--ft-surface) 60%); }
.account-lang { position: absolute; inset-block-start: 16px; inset-inline-end: 16px; }
.account-shell { width: 100%; max-width: 440px; }
.account-card { background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: 16px; padding: 32px; box-shadow: 0 8px 30px rgba(43, 38, 34, .06); }
.account-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--ft-primary); color: #FBF8F3; display: grid; place-items: center; font-size: 1.5rem; margin: 0 auto 16px; }
.account-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin: 0 0 4px; }
.account-subtitle { text-align: center; color: var(--ft-ink-soft); margin-block-end: 24px; }
.account-divider { display: flex; align-items: center; gap: 12px; color: var(--ft-ink-soft); margin-block: 20px; font-size: .85rem; }
.account-divider::before, .account-divider::after { content: ""; flex: 1; border-block-start: 1px solid var(--ft-border); }
.account-switch { text-align: center; margin: 20px 0 0; color: var(--ft-ink-soft); }
.error-code { font-size: 4rem; font-weight: 800; color: var(--ft-accent); line-height: 1; margin-block-end: 8px; }

/* Admin */
.admin-tabs { margin-block-end: 16px; }
.admin-tabs .nav-link { color: var(--ft-ink-soft); }
.admin-tabs .nav-link.active { color: var(--ft-primary); font-weight: 600; }
.admin-panels .table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ft-ink-soft); white-space: nowrap; }
.role-select { min-width: 150px; }

@media (max-width: 575.98px) {
    .account-card { padding: 24px 20px; }
    .page-content { padding-block: 20px; }
    .hero { padding: 24px 20px; }
}

/* People: list, cards and profile */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.person-card, .mini-person { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ft-ink); }
.person-card { background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); padding: 12px 14px; transition: border-color .15s, box-shadow .15s; }
.person-card:hover { border-color: var(--ft-primary); box-shadow: 0 4px 14px rgba(31, 95, 87, .1); color: var(--ft-ink); }
.mini-person { padding: 4px 0; }
.mini-person:hover .mini-name { color: var(--ft-primary); text-decoration: underline; }
.mini-icon { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 1rem; background: #EFE9DF; color: var(--ft-ink-soft); }
.mini-icon.gender-M, .profile-avatar.gender-M { background: #E3EEF2; color: #2F6B82; }
.mini-icon.gender-F, .profile-avatar.gender-F { background: #F6E6DE; color: var(--ft-accent); }
.mini-text { display: flex; flex-direction: column; min-width: 0; }
.mini-name { font-weight: 600; overflow-wrap: anywhere; }
.mini-dates { font-size: .82rem; color: var(--ft-ink-soft); }

.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.profile-avatar { flex: 0 0 auto; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; background: #EFE9DF; color: var(--ft-ink-soft); }
.profile-title { flex: 1 1 260px; min-width: 0; }
.profile-other-name { font-size: 1.15rem; color: var(--ft-ink-soft); }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.relation-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.relation-list > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.relation-meta { display: inline-flex; align-items: center; gap: 6px; }
.union-block { border: 1px solid var(--ft-border); border-radius: var(--ft-radius); padding: 12px 14px; margin-block-start: 12px; background: #FDFBF8; }
.detail-list dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ft-ink-soft); margin-block-start: 12px; }
.detail-list dt:first-child { margin-block-start: 0; }
.detail-list dd { margin: 2px 0 0; overflow-wrap: anywhere; }

/* ---- Phase 3: interactive tree ---- */
.tree-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; margin-bottom: 12px; }
.tree-search { position: relative; flex: 1 1 260px; min-width: 200px; max-width: 420px; }
.tree-search-results { position: absolute; inset-inline: 0; top: calc(100% + 4px); background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: 10px; box-shadow: 0 10px 28px rgba(43, 38, 34, .16); z-index: 30; margin: 0; padding: 4px; max-height: 320px; overflow: auto; }
.tree-hit { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; background: none; border: 0; border-radius: 8px; padding: 8px 10px; color: var(--ft-ink); }
.tree-hit:hover, .tree-hit:focus-visible { background: #F4EFE7; }
.tree-hit small { margin-inline-start: auto; }
.tree-hit-none { padding: 8px 10px; color: var(--ft-ink-soft); }
.tree-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.tree-select { width: auto; max-width: 210px; }
.tree-buttons { display: flex; gap: 6px; margin-inline-start: auto; }

.tree-stage { position: relative; height: calc(100vh - 250px); min-height: 440px; border: 1px solid var(--ft-border); border-radius: var(--ft-radius); background: radial-gradient(circle at 1px 1px, #E2D9CB 1px, transparent 0) 0 0 / 24px 24px, #FDFBF7; overflow: hidden; }
.tree-stage:fullscreen { height: 100vh; border-radius: 0; }
.tree-stage-fixed { position: fixed; inset: 0; height: auto; z-index: 1500; border-radius: 0; }
.tree-viewport { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; outline-offset: -3px; }
.tree-viewport.is-panning { cursor: grabbing; }
.tree-world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; will-change: transform; }
.tree-edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.tree-cards { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.tree-edge { fill: none; stroke: #8B7F72; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.tree-edge.dashed { stroke-dasharray: 6 5; }
.tree-edge.cross { stroke: #C4B6A3; stroke-width: 1.2; stroke-dasharray: 2 5; }
.tree-path-line { fill: none; stroke: var(--ft-accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: .75; vector-effect: non-scaling-stroke; }

.tree-card { position: absolute; box-sizing: border-box; background: var(--ft-card); border: 1.5px solid var(--ft-border); border-radius: 14px; box-shadow: 0 2px 8px rgba(43, 38, 34, .08); cursor: pointer; display: flex; align-items: center; padding: 8px 10px; transition: opacity .15s, box-shadow .15s, border-color .15s; }
.tree-card:hover { box-shadow: 0 6px 18px rgba(43, 38, 34, .16); }
.tree-card.gender-M { border-inline-start: 5px solid #4F8FA8; }
.tree-card.gender-F { border-inline-start: 5px solid #D08B6B; }
.tree-card.gender-U { border-inline-start: 5px solid #B9AFA3; }
.tree-card.deceased { background: #F6F2EC; }
.tree-card.placeholder { border-style: dashed; background: #FFFDF8; }
.tree-card.is-selected { border-color: var(--ft-primary); box-shadow: 0 0 0 3px rgba(31, 95, 87, .25), 0 8px 22px rgba(43, 38, 34, .18); z-index: 3; }
.tree-card.rel-parent { box-shadow: 0 0 0 3px rgba(181, 101, 58, .35); }
.tree-card.rel-child { box-shadow: 0 0 0 3px rgba(31, 95, 87, .22); }
.tree-card.rel-spouse { box-shadow: 0 0 0 3px rgba(190, 70, 110, .30); }
.tree-card.on-path { box-shadow: 0 0 0 4px rgba(181, 101, 58, .55); z-index: 2; }
.has-selection .tree-card:not(.hl):not(.on-path) { opacity: .5; }
.tc-body { display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%; }
.tc-avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #EFE9DF; color: var(--ft-ink-soft); font-size: 16px; }
.gender-M .tc-avatar { background: #E3EEF2; color: #2F6B82; }
.gender-F .tc-avatar { background: #F6E6DE; color: var(--ft-accent); }
.tc-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.tc-name { font-weight: 600; font-size: .9rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tc-dates { font-size: .75rem; color: var(--ft-ink-soft); white-space: nowrap; }
.tc-cross { font-size: .65rem; opacity: .7; }
.tc-btn { position: absolute; width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 1.5px solid var(--ft-border); background: #fff; color: var(--ft-ink-soft); font-size: 11px; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(43, 38, 34, .15); cursor: pointer; z-index: 4; }
.tc-btn:hover { background: var(--ft-primary); color: #fff; border-color: var(--ft-primary); }
.tc-up { top: -13px; left: calc(50% - 12px); }
.tc-down { bottom: -13px; left: calc(50% - 12px); }
.tc-fold { bottom: -9px; inset-inline-end: -9px; width: 18px; height: 18px; font-size: 9px; opacity: 0; transition: opacity .15s; }
.tree-card:hover .tc-fold, .tree-card:focus-within .tc-fold, .tree-card.is-selected .tc-fold { opacity: 1; }
.union-badge { position: absolute; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 1.5px solid var(--ft-border); font-size: 10px; z-index: 1; }
.union-badge.u-current { color: #C0476E; }
.union-badge.u-ended { color: #8B7F72; }
.union-badge.u-widowed { color: #8B7F72; }

.tree-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--ft-ink-soft); text-align: center; padding: 24px; }
.tree-empty .fa-sitemap { font-size: 3rem; opacity: .4; }
.tree-loading { position: absolute; inset-block-start: 12px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: 999px; padding: 4px 16px; font-size: .85rem; color: var(--ft-ink-soft); box-shadow: 0 2px 8px rgba(43, 38, 34, .12); z-index: 20; }
.tree-loading.d-none { display: none !important; }
.tree-toast { position: absolute; inset-block-start: 12px; inset-inline: 12px; margin-inline: auto; width: fit-content; max-width: calc(100% - 24px); background: var(--ft-ink); color: #fff; border-radius: 10px; padding: 8px 16px; font-size: .9rem; z-index: 25; }

.tree-panel { position: absolute; inset-block-end: 12px; inset-inline-end: 12px; width: 330px; max-width: calc(100% - 24px); max-height: 70%; overflow: auto; background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); box-shadow: 0 10px 30px rgba(43, 38, 34, .2); padding: 16px; z-index: 15; }
.tree-panel-close { position: absolute; inset-block-start: 10px; inset-inline-end: 10px; }
.tree-avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: #EFE9DF; color: var(--ft-ink-soft); font-size: 22px; }
.tree-avatar.gender-M { background: #E3EEF2; color: #2F6B82; }
.tree-avatar.gender-F { background: #F6E6DE; color: var(--ft-accent); }
.tp-name { overflow-wrap: anywhere; }
.min-w-0 { min-width: 0; }
.tp-relatives { margin-top: 12px; }
.tp-group { margin-bottom: 8px; }
.tp-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ft-ink-soft); margin-bottom: 4px; }
.tp-chip { display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 6px 0; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--ft-border); background: #FBF8F3; color: var(--ft-ink); font-size: .8rem; }
html[dir="rtl"] .tp-chip { margin: 0 0 6px 6px; }
.tp-chip:hover { border-color: var(--ft-primary); color: var(--ft-primary); }
.tp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.tree-legend { position: absolute; inset-block-end: 12px; inset-inline-start: 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; max-width: 60%; background: rgba(255, 255, 255, .88); border: 1px solid var(--ft-border); border-radius: 10px; padding: 6px 12px; font-size: .75rem; color: var(--ft-ink-soft); z-index: 10; pointer-events: none; }
.tree-legend .lg-line { display: inline-block; width: 22px; height: 0; border-top: 2px solid #8B7F72; vertical-align: middle; margin-inline-end: 4px; }
.tree-legend .lg-line.dashed { border-top-style: dashed; }
.tree-legend .lg-heart { color: #C0476E; }
.tree-legend .lg-broken { color: #8B7F72; }

@media (max-width: 767.98px) {
    .tree-stage { height: calc(100vh - 340px); min-height: 380px; }
    .tree-legend { display: none; }
    .tree-panel { inset-inline: 8px; inset-block-end: 8px; width: auto; max-height: 55%; }
    .tree-buttons { margin-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) { .tree-card { transition: none; } }

/* ===== Phase 4: profiles, directory, branches, global search ===== */
.profile-photo { flex: 0 0 auto; width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid var(--ft-card); box-shadow: 0 0 0 1px var(--ft-border); background: #EFE9DF; }
.profile-tabs { border-bottom-color: var(--ft-border); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
.profile-tabs .nav-link { color: var(--ft-ink-soft); }
.profile-tabs .nav-link.active { color: var(--ft-primary); font-weight: 600; border-color: var(--ft-border) var(--ft-border) var(--ft-surface); background: var(--ft-surface); }
.contact-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--ft-border); }
.contact-list li:last-child { border-bottom: 0; }
.contact-list i { width: 18px; text-align: center; color: var(--ft-ink-soft); }
.life-story { white-space: pre-line; line-height: 1.8; }

.branch-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 500; color: var(--branch-colour, var(--ft-primary)); background: color-mix(in srgb, var(--branch-colour, #1F5F57) 12%, #fff); border: 1px solid color-mix(in srgb, var(--branch-colour, #1F5F57) 35%, #fff); }
.branch-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--branch-colour, var(--ft-primary)); }
.branch-dot-lg { width: 44px; height: 44px; }
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; align-items: start; }
.branch-card { border-inline-start: 6px solid var(--branch-colour, var(--ft-primary)); padding: 14px 16px; }
.branch-card-main { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ft-ink); }
.branch-card-text { display: flex; flex-direction: column; }
.branch-name { font-weight: 600; }
.branch-members { font-size: .85rem; color: var(--ft-ink-soft); }
.branch-children { margin-top: 12px; display: grid; gap: 8px; }
.branch-children .branch-card { padding: 8px 12px; box-shadow: none; background: var(--ft-surface); }

.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.dir-card { background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, box-shadow .15s; }
.dir-card:hover { border-color: var(--ft-primary); box-shadow: 0 4px 14px rgba(31, 95, 87, .1); }
.dir-card-main { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ft-ink); }
.dir-card-text { display: flex; flex-direction: column; min-width: 0; }
.dir-name { font-weight: 600; overflow-wrap: anywhere; }
.dir-other, .dir-dates { font-size: .85rem; color: var(--ft-ink-soft); }
.dir-card-avatar { flex: none; width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.dir-avatar { display: grid; place-items: center; background: #EFE9DF; color: var(--ft-ink-soft); font-size: 1.3rem; }
.dir-avatar.gender-M { background: #E3EEF2; color: #2F6B82; }
.dir-avatar.gender-F { background: #F6E6DE; color: var(--ft-accent); }
.dir-photo { background: #EFE9DF; border: 1px solid var(--ft-border); }
.dir-card-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: .85rem; color: var(--ft-ink-soft); min-height: 1px; }
.dir-meta-line i { width: 16px; text-align: center; }
.dir-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.dir-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ft-ink-soft); white-space: nowrap; }
.dir-row-name { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ft-ink); font-weight: 500; }
.dir-row-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; object-fit: cover; font-size: .9rem; }

.pf-photo { width: 120px; height: 120px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: #EFE9DF; color: var(--ft-ink-soft); font-size: 2.4rem; border: 1px solid var(--ft-border); }
.pf-photo img { width: 100%; height: 100%; object-fit: cover; }

.tc-avatar img, .tree-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

/* header search */
.global-search { position: relative; flex: 1 1 220px; max-width: 340px; min-width: 150px; }
.gs-results { position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 1050; background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); box-shadow: 0 10px 28px rgba(0, 0, 0, .14); padding: 6px; max-height: 70vh; overflow-y: auto; margin: 0; }
.gs-item { display: flex; align-items: center; border-radius: 8px; }
.gs-item:hover, .gs-item.active { background: var(--ft-surface); }
.gs-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; text-decoration: none; color: var(--ft-ink); }
.gs-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: #EFE9DF; color: var(--ft-ink-soft); font-size: .85rem; }
.gs-avatar.gender-M { background: #E3EEF2; color: #2F6B82; }
.gs-avatar.gender-F { background: #F6E6DE; color: var(--ft-accent); }
.gs-text { display: flex; flex-direction: column; min-width: 0; }
.gs-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-dates { font-size: .78rem; color: var(--ft-ink-soft); }
.gs-locate { flex: none; padding: 8px 10px; color: var(--ft-ink-soft); text-decoration: none; }
.gs-locate:hover { color: var(--ft-primary); }
.gs-empty, .gs-all { padding: 8px 10px; font-size: .9rem; }
.gs-empty { color: var(--ft-ink-soft); }
@media (max-width: 991.98px) {
    .header-inner { flex-wrap: wrap; }
    .global-search { order: 5; flex: 1 0 100%; max-width: none; margin-bottom: 8px; }
}

/* ---- Phase 5: administration ------------------------------------------------------------ */
.admin-subnav { gap: .25rem; flex-wrap: wrap; }
.admin-subnav .nav-link { border-radius: 999px; padding: .35rem .9rem; color: var(--bs-body-color); border: 1px solid var(--bs-border-color); }
.admin-subnav .nav-link.active { background: var(--bs-primary); color: #fff; border-color: var(--bs-primary); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.stat-card { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem .5rem; border: 1px solid var(--bs-border-color); border-radius: .75rem; background: var(--bs-body-bg); text-decoration: none; color: inherit; text-align: center; }
a.stat-card:hover { border-color: var(--bs-primary); }
.stat-num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .85rem; color: var(--bs-secondary-color); }
.req-card .req-old { color: var(--bs-secondary-color); }
.req-card .req-new { font-weight: 600; }
.req-status-PENDING { background: #b7791f; }
.req-status-APPROVED { background: #2f855a; }
.req-status-REJECTED { background: #9b2c2c; }
.req-status-FAILED { background: #6b46c1; }
.dup-person { min-width: 0; overflow-wrap: anywhere; }
.merge-card { min-height: 5rem; }
.hist-entry { padding: .6rem 0; border-bottom: 1px solid var(--bs-border-color); }
.hist-entry:last-child { border-bottom: 0; }
.hist-changes { list-style: none; margin: .3rem 0 0; padding-inline-start: 1rem; }
.hist-change { margin-bottom: .25rem; overflow-wrap: anywhere; }

/* ---- Phase 6: timeline, gallery, events, news, home widgets ---- */
.timeline { position: relative; padding-inline-start: 28px; border-inline-start: 2px solid var(--ft-border); margin-inline-start: 8px; }
.tl-year { font-weight: 700; font-size: 1.15rem; margin: 18px 0 8px -28px; padding-inline-start: 28px; }
.tl-item { position: relative; display: flex; gap: 12px; padding: 8px 0; }
.tl-dot { position: absolute; inset-inline-start: -37px; top: 12px; width: 16px; height: 16px; border-radius: 50%; background: var(--ft-card); border: 2px solid currentColor; font-size: 8px; display: flex; align-items: center; justify-content: center; }
.tl-BIRTH { color: #2e7d32; } .tl-DEATH { color: #6c757d; } .tl-MARRIAGE { color: #c2185b; } .tl-EVENT { color: #1565c0; }
.tl-when { min-width: 110px; font-size: .85rem; color: #6c757d; }
.tl-body { flex: 1; color: inherit; }
.tl-body a { color: var(--bs-body-color); }
.photo-grid, .album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.album-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.photo-tile { display: block; padding: 0; border: 0; background: #eee; border-radius: 8px; overflow: hidden; aspect-ratio: 1 / 1; cursor: pointer; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-large { max-width: 100%; max-height: 65vh; display: block; margin: 0 auto; border-radius: 8px; }
.album-card { display: block; color: inherit; text-decoration: none; background: var(--ft-card); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); overflow: hidden; }
.album-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.album-cover { aspect-ratio: 4 / 3; background: #eee center / cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: #aaa; }
.album-title { font-weight: 600; padding: 8px 12px 0; }
.album-count { font-size: .85rem; color: #6c757d; padding: 0 12px 10px; }
.cm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: #eef2f7; border: 1px solid var(--ft-border); font-size: .9rem; }
.cm-chip-static { text-decoration: none; color: inherit; }
.cm-text { white-space: pre-wrap; }
.home-row { padding: 8px 0; border-bottom: 1px solid var(--ft-border); }
.home-row:last-child { border-bottom: 0; }
.news-pinned { border-inline-start: 4px solid #f9a825; }

/* The menu button sits outside a Bootstrap .navbar, so it draws its own icon. */
.nav-burger { width: 42px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; color: var(--ft-primary, #1f6f5f); border-color: var(--ft-border); }

/* ---- Phase 7: relationship explorer ---- */
.kin-sentence { font-size: 1.35rem; font-weight: 600; margin-bottom: .25rem; }
.kin-path { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.kin-step { background: #eef2f7; border: 1px solid var(--ft-border); border-radius: 999px; padding: 4px 14px; }
.kin-arrow { color: var(--ft-ink-soft); padding-inline-start: 18px; font-size: .8rem; }

/* ---- Phase 8: accessibility and phone polish ------------------------------------------------ */
:root { --ft-accent-text: #8F4A26; }
/* Text colours that meet 4.5:1 on the cream and white backgrounds. */
.text-muted, .form-text { color: var(--ft-ink-soft) !important; }
.badge-soon { color: var(--ft-accent-text); }
a:not(.btn):not(.nav-link):not(.dropdown-item) { text-underline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible, .form-check-input:focus-visible { outline: 3px solid var(--ft-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (max-width: 767.98px) {
    /* 16px fields stop iOS zooming in on focus; larger tap targets for small buttons and chips. */
    .form-control, .form-select { font-size: 16px; }
    .btn-sm, .tp-chip, .tree-hit { min-height: 40px; }
    .page-title { font-size: 1.5rem; }
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .admin-subnav { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
    .admin-subnav .nav-link { white-space: nowrap; }
}
@media print {
    .skip-link, .main-nav, .nav-burger, .admin-subnav { display: none !important; }
}

/* Photo editor (profile picture) */
.pe-stage { position: relative; width: min(100%, 360px); aspect-ratio: 1 / 1; overflow: hidden; border-radius: 12px; background: #EFE9DF; touch-action: none; }
.pe-stage canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.pe-stage canvas:active { cursor: grabbing; }
.pe-guide { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(251, 248, 243, .62); border: 2px solid #fff; pointer-events: none; }

/* ---- Admin data table (wwwroot/js/admintable.js) ---- */
.at-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.at-sortable:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: -2px; }
.at-sortable .at-sort-icon { opacity: .55; font-size: .8em; }
.at-sortable[aria-sort="ascending"] .at-sort-icon,
.at-sortable[aria-sort="descending"] .at-sort-icon { opacity: 1; }
.at-toolbar .at-search { max-width: 16rem; }
