/**
 * style/main.css
 *
 * Styles for the zucal.org project.
 * Follows the "Google Design Code" philosophy:
 * - Clean, minimalist, accessible [cite: 192]
 * - Mobile-first responsive design [cite: 193, 228]
 * - No external frameworks [cite: 225]
 */

/* 1. CSS Reset [cite: 226] */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 2. Root Variables (Palette & Typography) [cite: 195, 198-202, 227] */
:root {
    --primary-color: #1A237E;  /* Deep Blue */
    --secondary-color: #BFA05A; /* Warm Gold */
    --text-color: #212121;
    --text-light: #616161;
    --background-color: #F7F7F7;
    --card-background: #FFFFFF;
    --border-color: #E0E0E0;
    
    --font-family: 'Inter', sans-serif;
}

/* 3. Base & Typography Styles */
body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
}

h1, h2, h3, h4 {
    font-weight: 600;
    margin-bottom: 0.75em;
    line-height: 1.3;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; color: var(--primary-color); }
h3 { font-size: 1.25rem; }
p { margin-bottom: 1em; }
a { color: var(--primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 4. Layout (Header, Main, Footer) [cite: 209, 219, 221] */
.site-header {
    background-color: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}
.site-title:hover { text-decoration: none; }
.main-nav ul {
    list-style: none;
    display: flex;
    gap: 1rem;
}
.main-nav a {
    font-weight: 600;
    color: var(--text-light);
    padding: 0.5rem;
    border-bottom: 2px solid transparent;
}
.main-nav a:hover, .main-nav a.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

main#app-root {
    flex-grow: 1;
    padding: 2rem 0;
}

.site-footer {
    background-color: #333;
    color: var(--background-color);
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
}

/* 5. Components (Cards, Buttons, Inputs) [cite: 203] */
.card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.button {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--card-background);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease, transform 0.2s ease;
}
.button:hover {
    background-color: #11185a; /* Darker primary */
    text-decoration: none;
    transform: translateY(-2px);
}

.search-input {
    width: 100%;
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 1rem;
}

/* 6. Page-Specific Styles */

/* Homepage [cite: 245] */
.homepage-header {
    text-align: center;
    margin-bottom: 2rem;
}
.homepage-header h1 {
    font-size: 2.5rem;
}
.homepage-header p {
    font-size: 1.15rem;
    color: var(--text-light);
}
#search-results ul {
    list-style: none;
    margin-top: 1rem;
}
#search-results li a {
    display: block;
    padding: 0.75rem 1rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
#search-results li a:hover {
    background: #fdfdfd;
    border-color: var(--primary-color);
    text-decoration: none;
}

/* History View [cite: 261] */
.history-view article {
    margin-bottom: 2rem;
}
.history-view section {
    margin-bottom: 1.5rem;
}
.history-view table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.history-view th, .history-view td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
    vertical-align: top;
}
.history-view th {
    background-color: #f0f0f0;
    font-weight: 600;
}

/* Branch Profile View [cite: 254] */
.branch-profile-header {
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}
.branch-profile-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0;
}
.branch-profile-header .branch-id {
    font-family: monospace;
    font-size: 1rem;
    color: var(--text-light);
}
.branch-links ul {
    list-style: none;
}
.branch-links li {
    margin-bottom: 0.25rem;
}

/* Family Tree Explorer (CSS-based) [cite: 230, 251] */
.tree-explorer {
    overflow-x: auto;
    padding: 1rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.tree-explorer ul {
    list-style: none;
    position: relative;
    padding-left: 20px;
}
/* Style for the root of the tree */
.tree-explorer > ul {
    padding-left: 0;
}
.tree-explorer li {
    position: relative;
    padding: 0.25rem 0 0.25rem 20px;
}
.tree-explorer li a {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #f4f6ff;
    border: 1px solid #cdd6ff;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}
.tree-explorer li a:hover {
    background: var(--primary-color);
    color: var(--card-background);
    text-decoration: none;
}

/* CSS lines for the tree */
.tree-explorer li::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 0;
    width: 20px;
    height: 1px;
    background: var(--border-color);
}
.tree-explorer li::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 1px;
    background: var(--border-color);
}
/* Hide connector for the last child */
.tree-explorer li:last-child::after {
    height: 14px;
}
/* Hide connector for the root node's "parent" */
.tree-explorer > ul > li::after {
    display: none;
}
.tree-explorer > ul > li::before {
    display: none;
}


/* 7. Responsive Design (Mobile-First) [cite: 228] */
@media (min-width: 768px) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .main-nav ul {
        gap: 1.5rem;
    }

    .homepage-header h1 { font-size: 3rem; }
    .homepage-header p { font-size: 1.25rem; }

    .branch-profile-grid {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 2rem;
    }
}