/* ===================================
   Al-Haymouni Family Website
   Shared Styles & Variables
   =================================== */

/* --- CSS Variables --- */
:root {
    --primary: #782020;
    --primary-light: #9B2C2C;
    --primary-dark: #5C1414;
    --secondary: #586134;
    --secondary-light: #6B8E23;
    --gold: #B88A4D;
    --gold-light: #C5A059;
    --gold-dark: #8B6914;
    --cream: #F5F0E6;
    --bg-light: #F9F6F0;
    --bg-dark: #121212;
    /* Deeper, cleaner dark background */
    --surface-light: #FFFFFF;
    --surface-dark: #1E1E1E;
    /* Distinct modern dark surface */
    --text-dark: #1A120B;
    --text-light: #F5F0E6;
    --font-display: 'Amiri', serif;
    --font-body: 'Cairo', sans-serif;
    --font-serif-en: 'Cinzel', serif;
    --transition-speed: 300ms;
}

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

html {
    overflow-x: clip;
}

body {
    font-family: var(--font-body);
    line-height: 1.7;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    opacity: 0;
    /* Hidden until page-transition overlay is ready — prevents flash */
    animation: body-fallback-reveal 0s 2s forwards;
    /* Safety: show after 2s if JS fails */
}

@keyframes body-fallback-reveal {
    to {
        opacity: 1;
    }
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--cream);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.dark ::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

.dark ::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
}

/* --- Islamic Pattern Overlay --- */
.islamic-pattern {
    background-color: transparent;
    background-image:
        linear-gradient(30deg, var(--primary) 12%, transparent 12.5%, transparent 87%, var(--primary) 87.5%),
        linear-gradient(150deg, var(--primary) 12%, transparent 12.5%, transparent 87%, var(--primary) 87.5%),
        linear-gradient(30deg, var(--primary) 12%, transparent 12.5%, transparent 87%, var(--primary) 87.5%),
        linear-gradient(150deg, var(--primary) 12%, transparent 12.5%, transparent 87%, var(--primary) 87.5%),
        linear-gradient(60deg, rgba(85, 107, 47, 0.47) 25%, transparent 25.5%, transparent 75%, rgba(85, 107, 47, 0.47) 75%),
        linear-gradient(60deg, rgba(85, 107, 47, 0.47) 25%, transparent 25.5%, transparent 75%, rgba(85, 107, 47, 0.47) 75%);
    background-size: 80px 140px;
    background-position: 0 0, 0 0, 40px 70px, 40px 70px, 0 0, 40px 70px;
    opacity: 0.03;
}

.dark .islamic-pattern {
    opacity: 0.05;
    filter: invert(1);
}

/* --- Dot Pattern --- */
.bg-pattern {
    background-color: transparent;
    background-image: radial-gradient(var(--gold) 1px, transparent 1px);
    background-size: 30px 30px;
    opacity: 0.1;
}

/* --- Decorative Gold Divider --- */
.gold-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.gold-divider-thick {
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), var(--primary), var(--gold), transparent);
}

/* --- Top Gradient Bar --- */
.top-bar-gradient {
    height: 4px;
    background: linear-gradient(to left, var(--primary), var(--gold), var(--secondary));
}

/* --- Animations --- */
@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse-gold {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(180, 142, 67, 0.4);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(180, 142, 67, 0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes spin-slow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* --- Animation Utility Classes --- */
.animate-float {
    animation: float 6s ease-in-out infinite;
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.5s ease-out forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.5s ease-out forwards;
}

.animate-slide-in-left {
    animation: slideInLeft 0.5s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.4s ease-out forwards;
}

.animate-pulse-gold {
    animation: pulse-gold 2s ease-in-out infinite;
}

/* Stagger delays */
.stagger-1 {
    animation-delay: 0.1s;
}

.stagger-2 {
    animation-delay: 0.2s;
}

.stagger-3 {
    animation-delay: 0.3s;
}

.stagger-4 {
    animation-delay: 0.4s;
}

.stagger-5 {
    animation-delay: 0.5s;
}

.stagger-6 {
    animation-delay: 0.6s;
}

.stagger-7 {
    animation-delay: 0.7s;
}

.stagger-8 {
    animation-delay: 0.8s;
}

/* Initially hidden for stagger animation */
[class*="stagger-"] {
    opacity: 0;
}

/* === Smooth Scroll Reveal === */
.scroll-reveal {
    opacity: 0;
    transform: translateY(32px);
    transition:
        opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger siblings automatically */
.scroll-reveal:nth-child(2) {
    transition-delay: 0.08s;
}

.scroll-reveal:nth-child(3) {
    transition-delay: 0.16s;
}

.scroll-reveal:nth-child(4) {
    transition-delay: 0.24s;
}

.scroll-reveal:nth-child(5) {
    transition-delay: 0.32s;
}

.scroll-reveal:nth-child(6) {
    transition-delay: 0.40s;
}

/* Variant animations via data attribute */
.scroll-reveal[data-anim="left"] {
    transform: translateX(32px);
}

.scroll-reveal[data-anim="right"] {
    transform: translateX(-32px);
}

.scroll-reveal[data-anim="scale"] {
    transform: scale(0.92);
}

.scroll-reveal[data-anim="left"].revealed,
.scroll-reveal[data-anim="right"].revealed,
.scroll-reveal[data-anim="scale"].revealed {
    transform: none;
}

/* === Scroll-to-Top Button === */
#scrollToTopBtn {
    position: fixed;
    bottom: 28px;
    left: 28px;
    /* left side keeps it away from RTL content */
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: var(--gold);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(120, 32, 32, 0.35);
    opacity: 0;
    transform: translateY(16px) scale(0.85);
    transition: opacity 0.35s ease, transform 0.35s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    pointer-events: none;
    z-index: 998;
}

#scrollToTopBtn.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

#scrollToTopBtn:hover {
    background: var(--secondary);
    box-shadow: 0 6px 28px rgba(88, 97, 52, 0.4);
}

#scrollToTopBtn .material-icons,
#scrollToTopBtn .material-icons-outlined {
    font-size: 22px;
    line-height: 1;
}

/* === Page Transition Overlay === */
#page-transition {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: linear-gradient(170deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    transform: translateY(0);
    transition: transform 0.6s cubic-bezier(0.76, 0, 0.24, 1);
    pointer-events: none;
    overflow: hidden;
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

#page-transition::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(184, 138, 77, 0.08) 1.5px, transparent 1.5px);
    background-size: 28px 28px;
}

#page-transition img {
    height: 80px;
    width: auto;
    /* -webkit-filter for iOS Safari, no drop-shadow to reduce GPU compositing cost */
    -webkit-filter: brightness(0) invert(1);
    filter: brightness(0) invert(1);
    position: relative;
    z-index: 1;
    animation: pt-logo-pulse 0.9s ease-in-out infinite;
    /* Force own GPU compositing layer to prevent filter flicker on mobile */
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

@keyframes pt-logo-pulse {

    0%,
    100% {
        transform: scale(1) translateZ(0);
        opacity: 1;
    }

    50% {
        transform: scale(1.1) translateZ(0);
        opacity: 0.75;
    }
}

#page-transition span {
    font-family: 'Amiri', serif;
    color: var(--gold);
    font-size: 1.4rem;
    letter-spacing: 0.15em;
    position: relative;
    z-index: 1;
}

.pt-line {
    width: 110px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.55;
    position: relative;
    z-index: 1;
}

/* === Navbar on scroll === */
.nav-elevated {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1) !important;
    border-bottom-color: rgba(184, 138, 77, 0.5) !important;
}

/* --- Tree Styles --- */
.tree-container {
    position: relative;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    /* prevent browser scroll/pinch-zoom inside the tree */
    -webkit-user-select: none;
    user-select: none;
}

.tree-container:active {
    cursor: grabbing;
}

.tree-canvas {
    transform-origin: 0 0;
    min-width: 100%;
    min-height: 100%;
}

/* Tree Nodes */
.tree-node {
    position: absolute;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tree-node:hover {
    transform: translateY(-3px);
}

.tree-node.active {
    z-index: 10;
}

.tree-node.highlighted {
    animation: pulse-gold 1.5s ease-in-out infinite;
}

/* Tree Connectors (CSS lines) */
.tree-connector-v {
    position: absolute;
    width: 2px;
    background: var(--gold);
    opacity: 0.6;
}

.tree-connector-h {
    position: absolute;
    height: 2px;
    background: var(--gold);
    opacity: 0.6;
}

.dark .tree-connector-v,
.dark .tree-connector-h {
    opacity: 0.4;
}

/* --- Card Styles --- */
.card-heritage {
    border-radius: 1rem;
    border-top: 4px solid var(--gold);
    transition: all 0.3s ease;
    background: var(--surface-light);
}

.dark .card-heritage {
    background: var(--surface-dark);
}

.card-heritage:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(123, 27, 27, 0.15);
}

.dark .card-heritage:hover {
    box-shadow: 0 12px 40px rgba(180, 142, 67, 0.1);
}

/* --- Badge Styles --- */
.badge-gold {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-secondary {
    background: var(--secondary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* --- Glow Effect --- */
.glow-gold {
    box-shadow: 0 0 30px rgba(180, 142, 67, 0.3);
}

.glow-primary {
    box-shadow: 0 0 30px rgba(123, 27, 27, 0.3);
}

/* --- Corner Ornaments --- */
.corner-ornament {
    position: absolute;
    width: 60px;
    height: 60px;
    opacity: 0.15;
}

.corner-ornament::before,
.corner-ornament::after {
    content: '';
    position: absolute;
    background: var(--gold);
}

.corner-ornament-tl {
    top: 0;
    left: 0;
}

.corner-ornament-tl::before {
    top: 8px;
    left: 8px;
    width: 30px;
    height: 2px;
}

.corner-ornament-tl::after {
    top: 8px;
    left: 8px;
    width: 2px;
    height: 30px;
}

.corner-ornament-tr {
    top: 0;
    right: 0;
}

.corner-ornament-tr::before {
    top: 8px;
    right: 8px;
    width: 30px;
    height: 2px;
}

.corner-ornament-tr::after {
    top: 8px;
    right: 8px;
    width: 2px;
    height: 30px;
}

.corner-ornament-bl {
    bottom: 0;
    left: 0;
}

.corner-ornament-bl::before {
    bottom: 8px;
    left: 8px;
    width: 30px;
    height: 2px;
}

.corner-ornament-bl::after {
    bottom: 8px;
    left: 8px;
    width: 2px;
    height: 30px;
}

.corner-ornament-br {
    bottom: 0;
    right: 0;
}

.corner-ornament-br::before {
    bottom: 8px;
    right: 8px;
    width: 30px;
    height: 2px;
}

.corner-ornament-br::after {
    bottom: 8px;
    right: 8px;
    width: 2px;
    height: 30px;
}

/* --- Timeline Styles --- */
.timeline-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--gold), var(--primary), var(--secondary));
    right: 50%;
    transform: translateX(50%);
}

.timeline-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold);
    border: 3px solid var(--cream);
    position: absolute;
    right: 50%;
    transform: translateX(50%);
    z-index: 2;
}

.dark .timeline-dot {
    border-color: var(--bg-dark);
}

/* --- Map Marker --- */
.map-marker {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border: 2px solid var(--gold);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    position: absolute;
}

.map-marker:hover {
    transform: scale(1.5);
    z-index: 10;
}

.map-marker.active {
    animation: pulse-gold 1.5s infinite;
}

/* --- Modal / Overlay --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--surface-light);
    border-radius: 1.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    border-top: 4px solid var(--gold);
}

.dark .modal-content {
    background: var(--surface-dark);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* --- Print Styles --- */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    .card-heritage {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}

/* --- RTL Specific Fixes --- */
[dir="rtl"] .space-x-reverse> :not([hidden])~ :not([hidden]) {
    --tw-space-x-reverse: 1;
}

/* --- Responsive Sidebar --- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Search Highlight --- */
.search-highlight {
    background: rgba(180, 142, 67, 0.3);
    border-radius: 2px;
    padding: 0 2px;
}

/* --- Generation Colors --- */
.gen-1 {
    --gen-color: #782020;
}

.gen-2 {
    --gen-color: #586134;
}

.gen-3 {
    --gen-color: #B88A4D;
}

.gen-4 {
    --gen-color: #2C5F7C;
}

.gen-5 {
    --gen-color: #7C4D8A;
}

/* --- Loading Skeleton --- */
.skeleton {
    background: linear-gradient(90deg, #e0d8c8 25%, #d4cbb8 50%, #e0d8c8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

.dark .skeleton {
    background: linear-gradient(90deg, #1E1E1E 25%, #2A2A2A 50%, #1E1E1E 75%);
    background-size: 200% 100%;
}

/* --- Tooltip --- */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    right: 50%;
    transform: translateX(50%);
    padding: 0.5rem 0.75rem;
    background: var(--text-dark);
    color: var(--text-light);
    font-size: 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 50;
    margin-bottom: 8px;
}

.tooltip:hover::after {
    opacity: 1;
}

/* --- Notification toast --- */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 2rem;
    border-radius: 1rem;
    background: var(--primary);
    color: white;
    font-weight: 600;
    z-index: 200;
    transition: transform 0.4s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* === Meta-Root Node (id=1, generation=0) === */
.tree-node-root {
    z-index: 5;
}

.tree-node-root:hover {
    transform: none;
    /* no hover lift for root */
}

.meta-root-card {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--gold-dark));
    min-height: 100px;
}

.meta-root-bg {
    background: radial-gradient(ellipse at 30% 20%, rgba(180, 142, 67, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(123, 27, 27, 0.2) 0%, transparent 60%);
}

.dark .meta-root-card {
    background: linear-gradient(135deg, #2a0a0a, var(--primary-dark), #3a2a10);
}

/* === Tree Node Action Buttons === */
.tree-node-actions button {
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.tree-node-actions button:hover {
    transform: scale(1.05);
}

/* === Quick-Add Dropdown Menu === */
/* Position is now handled inline via JS (fixed, body-level) */
.quick-add-menu {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.quick-add-menu.show {
    opacity: 1;
    pointer-events: auto;
}

.quick-add-menu-inner {
    background: var(--surface-light);
    border: 1px solid rgba(180, 142, 67, 0.3);
    border-radius: 0.75rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    padding: 0.35rem;
    min-width: 180px;
    overflow: hidden;
}

.dark .quick-add-menu-inner {
    background: var(--surface-dark);
    border-color: rgba(180, 142, 67, 0.2);
}

.quick-add-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dark);
    transition: background 0.15s ease;
    white-space: nowrap;
    text-align: right;
}

.dark .quick-add-item {
    color: var(--text-light);
}

.quick-add-item:hover {
    background: rgba(180, 142, 67, 0.15);
}

.quick-add-item .material-icons-outlined {
    color: var(--gold);
}

/* ============================================================
   === Tree Node Card — Photo Right, Border Top ===
   ============================================================ */
.node-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.09);
    border-top: 4px solid var(--gold);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    position: relative;
}

.dark .node-card {
    background: #1E1E1E;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.40);
}

.tree-node:hover .node-card {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.16);
    transform: translateY(-1px);
}

.tree-node.active .node-card {
    box-shadow: 0 0 0 2px var(--gold), 0 5px 20px rgba(0, 0, 0, 0.16);
}

.tree-node.highlighted .node-card {
    box-shadow: 0 0 0 2px #2563eb, 0 5px 20px rgba(0, 0, 0, 0.16);
}

/* Card body padding */
.node-card-body {
    padding: 9px 10px 8px;
}

/* ─── Header row: avatar + info (RTL: avatar on right) ─────── */
.node-header-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    direction: rtl;
    /* avatar appears on the right naturally */
}

/* Avatar circle */
.node-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    border: 2px solid transparent;
    overflow: hidden;
}

.node-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Name + details block (next to avatar, on the left in RTL) */
.node-name-block {
    flex: 1;
    min-width: 0;
    text-align: right;
}

/* Name — clickable, shows lineage on click */
.node-name {
    font-weight: 700;
    font-size: 11.5px;
    line-height: 1.35;
    color: #1a120b;
    word-break: break-word;
    cursor: pointer;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s;
}

.node-name:hover {
    color: var(--primary);
}

.dark .node-name {
    color: #f5f0e6;
}

.dark .node-name:hover {
    color: var(--gold);
}

/* Birth / death dates */
.node-dates {
    font-size: 9px;
    color: #6b7280;
    margin-top: 2px;
}

.dark .node-dates {
    color: #9ca3af;
}

/* Profession only (no location) */
.node-profession {
    font-size: 9.5px;
    color: var(--secondary);
    font-weight: 600;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark .node-profession {
    color: #8fa85a;
}

/* Spouse inline badge */
.node-chip-spouse-inline {
    display: inline-block;
    font-size: 8.5px;
    font-weight: 600;
    border-radius: 999px;
    padding: 1px 6px;
    white-space: nowrap;
    background: rgba(180, 142, 67, 0.12);
    color: #8B6914;
    margin-top: 2px;
}

.dark .node-chip-spouse-inline {
    background: rgba(180, 142, 67, 0.2);
    color: #B88A4D;
}

/* Legacy aliases (kept for any old references) */
.node-meta2 {
    font-size: 9px;
    color: #586134;
    margin-top: 3px;
}

.dark .node-meta2 {
    color: #8fa85a;
}

.node-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 8.5px;
    font-weight: 600;
    border-radius: 999px;
    padding: 1px 6px;
    white-space: nowrap;
}

.node-chip-spouse {
    background: rgba(180, 142, 67, 0.12);
    color: #8B6914;
    margin-top: 2px;
}

.dark .node-chip-spouse {
    background: rgba(180, 142, 67, 0.2);
    color: #B88A4D;
}

/* Deceased — short diagonal line at top-right corner */
.node-death-ribbon {
    position: absolute;
    top: 0;
    right: 0;
    width: 22px;
    height: 22px;
    background: linear-gradient(45deg,
            transparent calc(50% - 2px),
            #444 calc(50% - 2px),
            #444 calc(50% + 2px),
            transparent calc(50% + 2px));
    pointer-events: none;
    z-index: 5;
}

.dark .node-death-ribbon {
    background: linear-gradient(45deg,
            transparent calc(50% - 2px),
            #444 calc(50% - 2px),
            #444 calc(50% + 2px),
            transparent calc(50% + 2px));
}

/* Nickname (كنية) */
.node-nickname {
    font-size: 9px;
    font-weight: 600;
    color: #B88A4D;
    margin-top: 1px;
    font-style: italic;
}

.dark .node-nickname {
    color: #C5A059;
}

/* ─── Circular "+" button slightly below the card ─────────── */
.node-plus-btn {
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--secondary);
    color: #fff;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.20);
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    z-index: 6;
}

.node-plus-btn:hover {
    background: var(--primary);
    transform: translateX(-50%) scale(1.2);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.node-plus-btn:active {
    transform: translateX(-50%) scale(0.95);
}

/* Visitor suggest variant */
.node-plus-suggest {
    background: var(--gold-dark);
}

.node-plus-suggest:hover {
    background: var(--gold);
}

.dark .node-plus-btn {
    border-color: #2C2825;
}

/* ============================================================
   === Pending (suggested) Node ===
   ============================================================ */
.tree-node-pending .node-card {
    opacity: 0.65;
    border-top-style: dashed;
    border-top-color: #f59e0b;
    filter: saturate(0.65);
}

.tree-node-pending:hover .node-card {
    opacity: 0.85;
    filter: saturate(1);
}

.pending-badge {
    /* Normal flow — sits above node-card, no overflow clipping */
    display: block;
    text-align: center;
    background: #f59e0b;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    border-radius: 999px;
    padding: 2px 9px;
    margin-bottom: 5px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
    line-height: 1.6;
}

/* ============================================================
   === Lineage Tooltip ===
   ============================================================ */
.lineage-tooltip {
    position: fixed;
    z-index: 9000;
    background: #1a120b;
    color: #f5f0e6;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.8;
    max-width: 320px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(180, 142, 67, 0.4);
    pointer-events: none;
    direction: rtl;
    text-align: right;
}

.dark .lineage-tooltip {
    background: #0d0806;
    border-color: rgba(180, 142, 67, 0.5);
}

.lineage-tooltip .lineage-title {
    font-size: 9px;
    color: var(--gold);
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lineage-tooltip .lineage-chain {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.lineage-tooltip .lineage-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.lineage-tooltip .lineage-item .gen-num {
    font-size: 8px;
    color: rgba(245, 240, 230, 0.4);
    min-width: 10px;
}

.lineage-tooltip .lineage-arrow {
    color: var(--gold);
    font-size: 10px;
    opacity: 0.6;
}

/* ============================================================
   === Today's Info Panel (sidebar) ===
   ============================================================ */
#todayInfoPanel {
    border-bottom: 1px solid #e5e7eb;
}

.dark #todayInfoPanel {
    border-color: #374151;
}

.today-info-section {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
}

.today-info-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.today-info-names {
    font-size: 11px;
    color: #374151;
    line-height: 1.6;
}

.dark .today-info-names {
    color: #d1d5db;
}

.today-info-name-link {
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    transition: opacity 0.15s;
}

.dark .today-info-name-link {
    color: var(--gold);
}

.today-info-name-link:hover {
    opacity: 0.75;
}

/* === Suggestion Modal === */
#suggestModal .suggest-form-label {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 4px;
    display: block;
}

.dark #suggestModal .suggest-form-label {
    color: #d1d5db;
}

#suggestModal input,
#suggestModal select,
#suggestModal textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 13px;
    background: #f9fafb;
    transition: border-color 0.15s;
    font-family: inherit;
}

.dark #suggestModal input,
.dark #suggestModal select,
.dark #suggestModal textarea {
    background: #1A120B;
    border-color: #4b5563;
    color: #f5f0e6;
}

#suggestModal input:focus,
#suggestModal select:focus,
#suggestModal textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(180, 142, 67, 0.15);
}