/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,500;0,700;1,400&display=swap');

/* CSS Variables */
:root {
    --transition-speed: 0.3s;
}

/* Theme 1: Heritage (Classic, Warm, Parchment) */
.theme-heritage {
    --bg-gradient: linear-gradient(135deg, #fdfbf7 0%, #f5f2eb 100%);
    --bg-color: #fdfbf7;
    --text-color: #2c2520;
    --text-muted: #6e6259;
    --accent-color: #8c7a6b;
    --link-color: #a05a2c;
    --link-hover: #dd6b20;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: 1px solid #d4c5b9;
    --card-border-inner: 1px double #c3b0a0;
    --card-shadow: 0 4px 15px rgba(140, 122, 107, 0.15);
    --card-shadow-hover: 0 10px 25px rgba(140, 122, 107, 0.25);
    --line-color: #8c7a6b;
    --line-glow: transparent;
    --divider-color: #d4c5b9;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Playfair Display', serif;
    --img-ring: 3px solid #c3b0a0;
    --img-radius: 8px;
}

/* Theme 2: Slate (Modern, Dark, Glassmorphism) */
.theme-slate {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #38bdf8;
    --link-color: #f59e0b;
    --link-hover: #fbbf24;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: 1px solid rgba(255, 255, 255, 0.1);
    --card-border-inner: none;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 12px 40px 0 rgba(56, 189, 248, 0.15);
    --line-color: #f59e0b;
    --line-glow: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5));
    --divider-color: rgba(255, 255, 255, 0.1);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --img-ring: 3px solid #f59e0b;
    --img-radius: 50%;
}

/* Theme 3: Sage (Botanical, Light Green, Minimalist) */
.theme-sage {
    --bg-gradient: linear-gradient(135deg, #f4f7f4 0%, #e2ede2 100%);
    --bg-color: #f4f7f4;
    --text-color: #2b3a2b;
    --text-muted: #5c6e5c;
    --accent-color: #4a6b4c;
    --link-color: #3b5c3d;
    --link-hover: #7ba677;
    --card-bg: #ffffff;
    --card-border: 1px solid #d0ded0;
    --card-border-inner: none;
    --card-shadow: 0 4px 12px rgba(74, 107, 76, 0.08);
    --card-shadow-hover: 0 8px 24px rgba(74, 107, 76, 0.16);
    --line-color: #628764;
    --line-glow: transparent;
    --divider-color: #d0ded0;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Inter', sans-serif;
    --img-ring: 3px solid #628764;
    --img-radius: 18px;
}

/* Global Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    min-height: 100vh;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.content-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Navigation & Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--divider-color);
    transition: border-color var(--transition-speed) ease;
    gap: 15px;
}

.header-left {
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-icon-link {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    transition: transform var(--transition-speed) ease, background-color var(--transition-speed) ease;
}

.header-icon-link:hover {
    transform: scale(1.1);
    background-color: rgba(255, 255, 255, 0.1);
}

.theme-icon {
    height: 24px;
    width: 24px;
    transition: filter var(--transition-speed) ease;
}

.theme-slate .home-icon {
    filter: invert(1) brightness(1.5);
}

.main-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: center;
    transition: font-family var(--transition-speed) ease;
}

/* Theme Switcher */
.theme-toggle-container {
    display: flex;
    background: rgba(0, 0, 0, 0.06);
    padding: 4px;
    border-radius: 30px;
    border: 1px solid var(--divider-color);
    transition: background var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.theme-slate .theme-toggle-container {
    background: rgba(255, 255, 255, 0.08);
}

.theme-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition-speed) ease;
}

.theme-btn:hover {
    color: var(--text-color);
}

.theme-btn.active {
    background-color: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-slate .theme-btn.active {
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Intro Card */
.intro-card {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--card-shadow);
    transition: all var(--transition-speed) ease;
    backdrop-filter: blur(8px);
}

.intro-card p {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-muted);
    font-style: italic;
}

/* Section Title */
.section-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 600;
    text-align: center;
    margin-top: 15px;
    margin-bottom: 5px;
    color: var(--accent-color);
    transition: color var(--transition-speed) ease, font-family var(--transition-speed) ease;
}

/* Tree Viewports (Scrollable on mobile) */
.tree-viewport {
    width: 100%;
    overflow-x: auto;
    padding: 20px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

/* Scrollbar styling */
.tree-viewport::-webkit-scrollbar {
    height: 6px;
}

.tree-viewport::-webkit-scrollbar-track {
    background: transparent;
}

.tree-viewport::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 10px;
}

/* Tree Container */
.tree-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 60px;
    min-width: max-content;
    margin: 0 auto;
}

/* Generation Rows */
.generation-row {
    display: flex;
    justify-content: center;
    gap: 120px;
    width: 100%;
    margin-bottom: 80px;
    position: relative;
    z-index: 2;
}

.generation-row:last-child {
    margin-bottom: 0;
}

/* Groups */
.couple-group {
    display: flex;
    gap: 40px;
    position: relative;
}

.children-group {
    display: flex;
    gap: 60px;
    position: relative;
}

.family-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
}


/* Person Card */
.person {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 16px;
    padding: 16px;
    width: 150px;
    text-align: center;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-speed) cubic-bezier(0.165, 0.84, 0.44, 1),
                box-shadow var(--transition-speed) ease,
                background-color var(--transition-speed) ease,
                border var(--transition-speed) ease;
    backdrop-filter: blur(12px);
}

/* Double border style for Heritage */
.theme-heritage .person::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: var(--card-border-inner);
    border-radius: 12px;
    pointer-events: none;
    transition: border var(--transition-speed) ease;
}

.person:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-shadow-hover);
}

/* Surnames */
.surname {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

.surname a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px dotted transparent;
    transition: all var(--transition-speed) ease;
}

.surname a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}

/* Photos */
.photo-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 12px;
    border-radius: var(--img-radius);
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: border-radius var(--transition-speed) ease;
}

.person img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: var(--img-ring);
    border-radius: var(--img-radius);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), 
                border var(--transition-speed) ease,
                border-radius var(--transition-speed) ease;
}

.person:hover img {
    transform: scale(1.08);
}

/* Personal Details */
.details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.details .name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.details .year {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Tree Divider */
.tree-divider-container {
    width: 100%;
    padding: 20px 0;
    display: flex;
    justify-content: center;
}

.tree-divider {
    border: 0;
    height: 1px;
    background: var(--divider-color);
    width: 80%;
    transition: background var(--transition-speed) ease;
}

/* SVG Overlay & Paths */
.tree-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.tree-line {
    fill: none;
    stroke: var(--line-color);
    stroke-width: 2.5px;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: var(--line-glow);
    transition: stroke var(--transition-speed) ease, filter var(--transition-speed) ease;
}

/* Footer styling */
.main-footer {
    text-align: center;
    padding: 30px 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--divider-color);
    margin-top: 20px;
    transition: border-color var(--transition-speed) ease;
}

/* Media Queries for fine tuning header on tiny screens */
@media (max-width: 600px) {
    .main-header {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        padding-bottom: 20px;
    }
    
    .main-title {
        font-size: 1.8rem;
    }
    
    .intro-card {
        padding: 15px;
    }
}
