* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    margin: 0;
    padding: 0;
    background: 
        /* Parchment texture base */
        radial-gradient(circle at 20% 80%, rgba(245, 241, 235, 0.8) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(235, 230, 220, 0.6) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(250, 245, 240, 0.4) 0%, transparent 50%),
        /* Subtle paper grain */
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(139, 69, 19, 0.1) 2px,
            rgba(139, 69, 19, 0.1) 4px
        ),
        /* Aged paper color overlay */
        linear-gradient(135deg, #f8f6f1 0%, #e8e4d9 50%, #d4c8b8 100%);
    background-size: 
        auto,
        auto,
        auto,
        8px 8px,
        auto;
    background-repeat: 
        no-repeat,
        no-repeat,
        no-repeat,
        repeat,
        no-repeat;
    background-position: 
        center,
        center,
        center,
        center,
        center;
    overflow: hidden;
    position: relative;
}

/* Parchment texture now applied directly to body background */

/* 🎨 STATIC PARTICLE EFFECTS 🎨 */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(139, 38, 53, 0.15), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(160, 82, 45, 0.1), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(139, 38, 53, 0.2), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(160, 82, 45, 0.15), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(139, 38, 53, 0.1), transparent),
        radial-gradient(1px 1px at 200px 60px, rgba(160, 82, 45, 0.2), transparent),
        radial-gradient(2px 2px at 240px 90px, rgba(139, 38, 53, 0.15), transparent),
        radial-gradient(1px 1px at 280px 20px, rgba(160, 82, 45, 0.1), transparent),
        radial-gradient(2px 2px at 320px 70px, rgba(139, 38, 53, 0.2), transparent),
        radial-gradient(1px 1px at 360px 40px, rgba(160, 82, 45, 0.15), transparent);
    background-repeat: repeat;
    background-size: 400px 100px;
    pointer-events: none;
    z-index: -1;
    opacity: 0.6;
}

#family-tree-container {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    width: 100vw;
    height: 100vh;
    position: relative;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    border: 1px solid rgba(139, 38, 53, 0.1);
    box-shadow: 
        0 8px 32px rgba(139, 38, 53, 0.1),
        0 4px 16px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

#family-tree-svg {
    width: 100%;
    height: 100%;
    display: block;
    background-color: white;
    grid-column: 2;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: none;
    padding: 20px 0px 0px 0px;
}


/* Hamburger Menu */
.hamburger-menu {
    position: relative;
    z-index: 30;
    height: 100vh;
    width: 100%;
    grid-column: 1;
    padding: 20px 20px 20px 20px;
    box-sizing: border-box;
    margin-right: 0;
}

.hamburger-icon {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: absolute;
    top: 8px;
    left: 8px;
}

.hamburger-icon span {
    width: 25px;
    height: 3px;
    background-color: #333;
    margin: 3px 0;
    transition: 0.3s;
}

.menu-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 246, 241, 0.95) 100%);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 
        0 8px 32px rgba(139, 38, 53, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    min-width: 200px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(139, 38, 53, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.menu-logo {
    text-align: center;
    margin-bottom: 15px;
}

.coat-of-arms-small {
    width: 120px;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(139, 38, 53, 0.2));
}

@media (max-width: 768px) {
    .coat-of-arms-small {
        width: 300px;
    }
}

.menu-title {
    color: #2c1810;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #8b2635;
}

.menu-content button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin: 8px 0;
    background: linear-gradient(135deg, #8b2635 0%, #6d1e2a 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Georgia', serif;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 15px rgba(139, 38, 53, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.menu-content button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.menu-content button:hover::before {
    left: 100%;
}

/* 🌟 ORIGINAL STUNNING SHIMMER EFFECTS 🌟 */

.menu-content button:hover {
    background: linear-gradient(135deg, #6d1e2a 0%, #5a1a22 100%);
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(139, 38, 53, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.menu-content button:active {
    transform: translateY(0);
    box-shadow: 
        0 4px 15px rgba(139, 38, 53, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.menu-content button:first-child {
    background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
}

.menu-content button:first-child:hover {
    background: linear-gradient(135deg, #8b4513 0%, #6b3410 100%);
}

h3 {
    color: #2c1810;
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    font-family: 'Georgia', serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

p {
    color: #4a4a4a;
    margin: 0 0 10px 0;
    font-size: 14px;
    line-height: 1.6;
    text-align: justify;
    font-family: 'Georgia', serif;
}

.full-text-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow-y: auto;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin: 2% auto;
    padding: 0;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 20px;
    box-shadow: 
        0 25px 50px rgba(139, 38, 53, 0.2),
        0 10px 20px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
    border: 1px solid rgba(139, 38, 53, 0.1);
    animation: modalEntrance 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: center;
}

@keyframes modalEntrance {
    0% {
        opacity: 0;
        transform: scale(0.7) rotateY(-15deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

.modal-header {
    background: linear-gradient(135deg, #8b2635, #6d1e2a);
    color: white;
    padding: 20px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 15px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-body p {
    line-height: 1.5;
    color: #333;
    text-align: justify;
    font-size: 14px;
    margin-bottom: 12px;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body::-webkit-scrollbar {
    width: 12px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(139, 38, 53, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(139, 38, 53, 0.1);
}

.modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #8b2635 0%, #6d1e2a 100%);
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6d1e2a 0%, #5a1a22 100%);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.person-details h3 {
    color: #2c1810;
    font-size: 20px;
    font-weight: 700;
    font-family: 'Georgia', serif;
    text-align: center;
    margin-bottom: 15px;
}

.person-info p {
    color: #4a4a4a;
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.4;
    font-family: 'Georgia', serif;
}

.person-info ul {
    margin: 0px 0 15px 20px;
    padding: 0;
}

.person-info li {
    color: #4a4a4a;
    margin: 4px 0;
    font-size: 14px;
    line-height: 1.3;
    font-family: 'Georgia', serif;
}

.back-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin: 20px 0 0 0;
    background: #8b2635;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Georgia', serif;
    transition: background-color 0.2s;
}

.back-btn::before {
    content: '←';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    opacity: 0.8;
}

.back-btn:hover {
    background: #6d1e2a;
}

@media (max-width: 768px) {

    .menu-title{
        display: none;
    }

    .mobile-header {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 2px solid rgba(139, 38, 53, 0.15);
        padding: 0 20px;
        z-index: 1000;
        box-shadow: 
            0 8px 32px rgba(139, 38, 53, 0.1),
            0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .mobile-header .hamburger-icon {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        background: white;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 8px;
        cursor: pointer;
        z-index: 1001;
    }
    
    .mobile-header .hamburger-icon span {
        background-color: #8b2635;
        width: 20px;
        height: 2px;
        margin: 2px 0;
        transition: 0.3s;
        display: block;
    }
    
    .mobile-header .title {
        font-size: 18px;
        font-weight: bold;
        color: #2c1810;
        grid-column: 2;
        text-align: center;
        padding: 0 20px 8px 20px;
        justify-self: center;
        border-bottom: 2px solid #8b2635;
        margin-bottom: 0;
    }

    .hamburger-menu .hamburger-icon {
        display: none;
    }

    .hamburger-menu .menu-content {
        position: fixed;
        top: 0px;
        left: 0;
        width: 100%;
        height: calc(100vh - 70px);
        background: white;
        z-index: 999;
        padding: 15px;
        box-sizing: border-box;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        /* Prevent body scroll when menu is open */
        overscroll-behavior: contain;
    }
    
    .hamburger-menu {
        display: none;
    }

    .hamburger-menu.active {
        display: block;
    }

    #family-tree-container {
        margin-top: 70px;
        grid-template-columns: 1fr;
        position: relative;
    }

    #family-tree-svg {
        width: 100%;
        height: calc(100vh - 70px);
        min-height: 400px;
        background-color: white;
        display: block;
        grid-column: 1;
        padding: 20px 0px 0px 20px;
    }

    .full-text-modal {
        top: 0;
        height: 100vh;
    }
    
    .modal-content {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        max-height: none;
    }
    
    .modal-header {
        padding: 16px;
        border-radius: 0;
    }
    
    .modal-body {
        max-height: calc(100vh - 80px);
    }
}

@media (min-width: 769px) {

    .mobile-header {
        display: none;
    }
    
    .hamburger-icon {
        display: none;
    }

    .menu-content {
        display: block !important;
        height: 100vh;
        padding: 0px 20px 20px 20px;
        border-radius: 0 8px 8px 0;
        box-shadow: 2px 0 20px rgba(139, 38, 53, 0.15);
        width: 300px !important;
        max-width: 300px !important;
        box-sizing: border-box;
        overflow-y: auto;
        position: relative !important;
        top: auto !important;
        left: auto !important;
        z-index: auto !important;
        background: white !important;
        border: none !important;
        font-size: normal !important;
        color: inherit !important;
        grid-column: 1 !important;
        grid-row: 1 !important;
        justify-self: start !important;
    }
}

/* 🚀 LEGENDARY ANIMATIONS & EFFECTS 🚀 */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

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

/* Apply animations to menu content */
.menu-content {
    /* Smooth fade in without movement */
    opacity: 0;
    animation: fadeIn 0.6s ease-out forwards;
}

.menu-content button {
    /* Smooth fade in without movement */
    opacity: 0;
    animation: fadeIn 0.4s ease-out forwards;
    animation-fill-mode: both;
}

.menu-content button:nth-child(1) { animation-delay: 0.1s; }
.menu-content button:nth-child(2) { animation-delay: 0.2s; }
.menu-content button:nth-child(3) { animation-delay: 0.3s; }

/* Premium hover effects for menu title */
.menu-title {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    color: #2c1810;
}

.menu-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #8b2635, #a0522d);
    transition: left 0.4s ease;
}

.menu-title:hover::after {
    left: 0;
}

/* Enhanced person details animations */
.person-details {
    animation: fadeInUp 0.5s ease-out;
}

.person-info p, .person-info li {
    animation: slideInLeft 0.3s ease-out;
    animation-fill-mode: both;
}

.person-info p:nth-child(1) { animation-delay: 0.1s; }
.person-info p:nth-child(2) { animation-delay: 0.2s; }
.person-info p:nth-child(3) { animation-delay: 0.3s; }
.person-info li:nth-child(1) { animation-delay: 0.4s; }
.person-info li:nth-child(2) { animation-delay: 0.5s; }
.person-info li:nth-child(3) { animation-delay: 0.6s; }

/* 🚀 STUNNING LOADING ANIMATIONS 🚀 */

/* Premium loading states */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

/* 🌟 FAMILY TREE LOADING ANIMATION 🌟 */
.family-tree-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f6f1 0%, #e8e4d9 50%, #d4c8b8 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.family-tree-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-logo {
    margin-bottom: 30px;
    text-align: center;
}

.coat-of-arms {
    width: 180px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(139, 38, 53, 0.3));
    animation: logoFloat 2s ease-in-out infinite;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(139, 38, 53, 0.2);
    border-top: 4px solid #8b2635;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 18px;
    color: #2c1810;
    font-family: 'Georgia', serif;
    text-align: center;
    margin-bottom: 10px;
}

.loading-subtext {
    font-size: 14px;
    color: #6b7280;
    font-family: 'Georgia', serif;
    text-align: center;
}

/* 🌟 MOBILE-SPECIFIC LOADING 🌟 */
@media (max-width: 768px) {
    .family-tree-loading {
        padding: 20px;
    }
    
    .loading-logo {
        margin-bottom: 25px;
    }
    
    .coat-of-arms {
        width: 150px;
    }
    
    .loading-spinner {
        width: 50px;
        height: 50px;
        margin-bottom: 15px;
    }
    
    .loading-text {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .loading-subtext {
        font-size: 12px;
    }
    
    /* 🌟 MOBILE LOADING - SINGLE SPINNER ONLY 🌟 */
}

/* Progress shimmer removed - single spinner only */

@keyframes logoFloat {
    0%, 100% { 
        transform: translateY(0px) scale(1); 
    }
    50% { 
        transform: translateY(-10px) scale(1.05); 
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 🌟 CONTENT LOADING ANIMATIONS 🌟 */
/* Removed to prevent jumpy movement */

/* 🌟 BUTTON LOADING STATES 🌟 */
.button-loading {
    position: relative;
    overflow: hidden;
}

.button-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: buttonShimmer 1.5s infinite;
}

@keyframes buttonShimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Enhanced focus states for accessibility */
button:focus, .hamburger-icon:focus {
    outline: 2px solid #8b2635;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Premium text selection */
::selection {
    background: rgba(139, 38, 53, 0.2);
    color: #2c1810;
}

::-moz-selection {
    background: rgba(139, 38, 53, 0.2);
    color: #2c1810;
}