/* ============================================================
   GLOBAL & ROOT VARIABLES
   ============================================================ */
:root {
    /* Brand Colors - Rich, Earthy, Traditional */
    --primary-blue: #8b4513;
    --secondary-blue: #5c2e0a;
    --accent-color: #daa520;

    /* Backgrounds */
    --bg-color: #f8f2e6;
    --card-bg-light: #ffffff;
    --card-bg-alt-light: #fef5e8;

    /* Text */
    --text-color: #2a2418;
    --text-muted: #6b5b4a;

    /* Borders & Shadows */
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    --border-radius-full: 999px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 8px 20px rgba(0,0,0,0.1);
}

/* ============================================================
   BASE LAYOUT & STICKY FOOTER
   ============================================================ */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 1.05rem;
    line-height: 1.7;
    text-align: justify;
    hyphens: auto;
    background-image: url('/pattern-tribal.png');
    background-repeat: repeat;
    background-attachment: fixed;
    background-size: 200px;
    background-opacity: 0.02;
    transition: opacity 0.15s ease-in-out;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

main.main-content {
    width: 100%;
    display: block;
    flex: 1;
    padding: 40px 0;
    min-height: 40vh;
}

.main-content:empty {
    padding: 20px 0;
    min-height: 20vh;
}

.page-body {
    padding-bottom: 40px;
}

.footer {
    margin-top: auto;
    position: relative;
    z-index: 10;
}

/* ============================================================
   PROFESSIONAL NAVIGATION HEADER
   ============================================================ */
header {
    background: #1a1a2e;
    color: white;
    padding: 0.8rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    width: 100%;
}

.header-inner {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    max-width: 1200px;
    min-height: 65px;
    margin: 0 auto;
    padding: 0 15px;
    gap: 15px;
    width: 100%;
    box-sizing: border-box;
}

/* Brand Logo (Anchored Far Left) */
.brand {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    text-decoration: none;
    margin-right: auto;
}

.brand .logo {
    height: 50px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    display: block;
}

.brand-text {
    color: #d4a373;
    font-size: 1.3rem;
    font-weight: bold;
}

/* Navigation Structure */
nav {
    display: flex;
    align-items: center;
    max-width: 100%;
}

nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1.5rem;
    align-items: center;
}

nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
    display: inline-block;
    text-align: center;
    line-height: 1.2;
}

nav ul li a:hover {
    color: #daa520;
}

/* Dropdown Sub-menus Fix */
.dropdown {
    position: relative;
}

.dropdown > a::after {
    content: " ▾";
    font-size: 0.7rem;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #1a1a2e;
    min-width: 180px;
    padding: 0.5rem 0;
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    display: none;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    border: 1px solid rgba(212, 163, 115, 0.15);
}

/* Desktop: Hover triggers dropdown */
@media (min-width: 901px) {
    .dropdown:hover .dropdown-menu {
        opacity: 1;
        visibility: visible;
        display: block;
    }
}

/* Mobile: Active class triggers dropdown */
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    display: block;
}

.dropdown-menu li {
    display: block;
    padding: 0;
}

.dropdown-menu li a {
    display: block;
    padding: 8px 16px;
    color: #d4c5a9;
    font-size: 0.9rem;
    white-space: nowrap;
    text-align: left;
}

.dropdown-menu li a:hover {
    background: rgba(212, 163, 115, 0.15);
    color: #daa520;
}

/* Mobile Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 8px;
    flex: 0 0 auto;
}

/* ============================================================
   TYPOGRAPHY & HERO SECTIONS
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
}

/* Heading Hierarchy */
h1 {
    font-size: clamp(2.2rem, 4vw, 3rem);
    position: relative;
    display: inline-block;
}

h1::after {
    content: '✦';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--accent-color);
    font-size: 1.5rem;
}

h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--accent-color);
    display: inline-block;
    padding-bottom: 6px;
    color: var(--primary-color, #005580);
}

h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

/* Standard Dynamic Hero Section */
.hero-section {
    width: 100%;
    padding: 80px 0;
    text-align: center;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Preset Cultural Hero Section (With Overlay Pattern) */
.hero {
    width: 100%;
    padding: 80px 0;
    text-align: center;
    background: linear-gradient(135deg, rgba(139,69,19,0.9), rgba(92,46,10,0.95)),
                url('/cultural-pattern.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-blend-mode: overlay;
    position: relative;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-section .container,
.hero .container {
    position: relative;
    z-index: 2;
}

.hero-title {
    font-size: clamp(2.4rem, 5vw, 3rem);
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 0;
}

.hero-tagline {
    font-size: 1.6rem;
    font-weight: 300;
    letter-spacing: 0;
    text-transform: none;
    font-style: italic;
    font-family: 'Cormorant Garamond', serif;
}

/* ============================================================
   CULTURAL COMPONENTS
   ============================================================ */
/* Artifact Cards */
.artifact-card {
    background: var(--card-bg-light);
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s;
    border: 1px solid rgba(218,165,32,0.3);
    position: relative;
}

.artifact-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-color);
}

.artifact-icon {
    font-size: 3rem;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.artifact-card h3 {
    font-size: 1.15rem;
    margin-bottom: 10px;
}

/* Family Tree */
.family-tree {
    background: var(--card-bg-alt-light);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    position: relative;
}

.generation {
    margin: 30px 0;
    position: relative;
}

.generation-title {
    background: var(--accent-color);
    color: white;
    display: inline-block;
    padding: 8px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.member-card {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin: 10px;
    display: inline-block;
    width: 180px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.member-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-left: 3px solid var(--accent-color);
}

.member-name {
    font-weight: bold;
    font-size: 1rem;
    margin: 5px 0;
}

.member-title {
    font-size: 0.75rem;
    color: var(--accent-color);
    text-transform: uppercase;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent-color), transparent);
}

.timeline-item {
    position: relative;
    margin-bottom: 30px;
    padding-left: 25px;
}

.timeline-item::before {
    content: '●';
    position: absolute;
    left: -22px;
    top: 0;
    color: var(--accent-color);
    font-size: 1rem;
}

.timeline-year {
    font-weight: bold;
    color: var(--primary-blue);
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.timeline-event {
    background: var(--card-bg-light);
    padding: 15px;
    border-radius: 12px;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: all 0.3s;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 10px;
    font-size: 0.85rem;
    transform: translateY(100%);
    transition: all 0.3s;
}

.gallery-item:hover .gallery-caption {
    transform: translateY(0);
}

/* Events Calendar */
.event-card {
    background: var(--card-bg-light);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    gap: 15px;
    align-items: center;
    transition: all 0.3s;
}

.event-card:hover {
    transform: translateX(8px);
    box-shadow: var(--shadow-md);
}

.event-date {
    background: var(--accent-color);
    color: white;
    text-align: center;
    padding: 12px;
    border-radius: 12px;
    min-width: 80px;
}

.event-day {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
}

.event-month {
    font-size: 0.75rem;
    text-transform: uppercase;
}

.event-content {
    flex: 1;
}

.event-title {
    font-weight: bold;
    margin-bottom: 5px;
}

/* Buttons */
.btn, .btn-primary, a.btn, a.btn-primary {
    border-radius: 50px !important;
    text-transform: uppercase !important;
    font-weight: 600 !important;
    letter-spacing: 1px !important;
    font-size: 0.85rem !important;
    padding: 12px 28px !important;
    background: var(--primary-blue) !important;
    border: 1px solid var(--accent-color) !important;
}

.btn:hover, .btn-primary:hover {
    background: var(--secondary-blue) !important;
    border-color: var(--accent-color) !important;
    transform: translateY(-2px) !important;
}

/* Dividers */
.divider {
    text-align: center;
    margin: 40px 0;
    color: var(--accent-color);
    font-size: 1.2rem;
    letter-spacing: 8px;
}

.divider::before,
.divider::after {
    content: '✦';
    margin: 0 10px;
    opacity: 0.5;
}

/* ============================================================
   FAMILIES GRID - Heritage Styling
   ============================================================ */

.families-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin: 30px 0;
}

.family-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.25s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(139, 69, 19, 0.08);
    position: relative;
}

.family-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

.family-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* ---- FAMILY HEADINGS (Warm, Heritage Blue) ---- */

.family-card h3 {
    margin: 0 0 8px 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #005580;
    color: var(--primary-color, #005580);
    transition: color 0.2s ease;
}

.family-card:hover h3 {
    color: #003d5e;
    color: var(--secondary-color, #003366);
}

.family-motto {
    font-style: italic;
    color: #777;
    font-size: 0.9rem;
    margin: 4px 0 12px 0;
    padding-left: 12px;
    border-left: 3px solid #005580;
    border-left-color: var(--primary-color, #005580);
}

.family-description {
    color: #444;
    line-height: 1.8;
    font-size: 0.95rem;
    margin-bottom: 0;
}

/* ---- SECTION HEADERS (Refined, Not Corporate) ---- */

.family-section {
    margin: 30px 0;
}

.family-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color, #005580);
    margin-bottom: 10px;
    letter-spacing: 0;
    border-bottom: none;
    display: inline-block;
}

.family-section p {
    color: #5c4f3e;
    font-size: 1rem;
    line-height: 1.8;
}

/* ---- STATS (Warm, Heritage) ---- */

.family-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0 25px;
    padding: 16px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.stat-item {
    background: #faf4ec;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-item strong {
    color: var(--primary-color, #005580);
    font-weight: 700;
}

/* ---- GALLERY (Heritage) ---- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.gallery-item {
    border-radius: 10px;
    overflow: hidden;
    background: #faf4ec;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.25s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    border-radius: 0;
    transition: transform 0.4s ease;
}

.gallery-item:hover img {
    transform: scale(1.03);
}

.gallery-item figcaption {
    padding: 10px 14px;
    font-size: 0.88rem;
    color: #5c4f3e;
    font-weight: 500;
    background: #fff;
}

/* ---- GALLERY SECTION HEADER (Refined) ---- */

.gallery-section h2 {
    color: var(--primary-color, #005580);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    border-bottom: none;
    letter-spacing: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .families-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 18px;
        margin: 20px 0;
    }

    .family-card {
        padding: 16px;
    }

    .family-card h3 {
        font-size: 1.05rem;
    }

    .family-section h2 {
        font-size: 1.25rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }

    .gallery-item img {
        height: 150px;
    }

    .family-stats {
        gap: 8px;
        padding: 12px 0;
    }

    .stat-item {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .hero-title {
        font-size: clamp(1.8rem, 4vw, 2.2rem);
    }

    .hero-subtitle {
        font-size: 1.05rem;
    }
}

@media (max-width: 480px) {
    .families-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .gallery-item img {
        height: 120px;
    }

    .family-section h2 {
        font-size: 1.1rem;
    }

    .hero-title {
        font-size: clamp(1.6rem, 3.5vw, 1.8rem);
    }

    h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.4rem;
    }
}

/* ============================================================
   FOOTER - Uses !important for critical positioning
   ============================================================ */

/* Footer */
footer {
    background-color: var(--secondary-blue);
    border-top: 5px solid var(--accent-color);
    color: #d4c5a5;
    position: relative;
}

footer::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
    background: repeating-linear-gradient(
        90deg,
        var(--accent-color),
        var(--accent-color) 20px,
        transparent 20px,
        transparent 40px
    );
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */
@media (max-width: 900px) {
    .menu-toggle {
        display: block;
    }

    .header-inner {
        flex-wrap: wrap;
        padding: 0 15px;
        min-height: 55px;
    }

    nav {
        flex: 1 1 100%;
        order: 3;
        justify-content: flex-start;
        margin-top: 5px;
    }

    nav ul {
        display: none;
        flex-direction: column;
        width: 100%;
        padding: 0.5rem 0;
        gap: 0.3rem;
    }

    nav ul.show {
        display: flex;
    }

    nav ul li {
        width: 100%;
    }

    nav ul li a {
        padding: 8px 12px;
        font-size: 0.9rem;
        width: 100%;
        text-align: left;
    }

    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        display: none;
        box-shadow: none;
        border: none;
        padding-left: 20px;
        background: transparent;
        min-width: auto;
    }

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

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.4rem; }
    h3 { font-size: 1.05rem; }
    .hero-title { font-size: clamp(1.8rem, 4vw, 2.2rem); }
    .hero-subtitle { font-size: 1.05rem; }
    .hero-tagline { font-size: 1.2rem; }
    .member-card { width: 140px; }
    .event-card { flex-direction: column; text-align: center; }
    .gallery-grid { grid-template-columns: 1fr; }
    .main-content { padding: 40px 0; }
    .brand .logo {
        height: 40px;
        max-width: 150px;
    }
}

@media (max-width: 600px) {
    .header-inner {
        padding: 0 10px;
        min-height: 50px;
    }

    nav ul li a {
        font-size: 0.85rem;
        padding: 6px 10px;
    }
}

/* ============================================================
   AUTO-HEIGHT & FLEX LAYOUT PATCH
   ============================================================ */

/* 1. Ensure body uses natural flex distribution */
html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 2. Remove fixed height locks on main wrapper and sub-elements */
main,
.main-content,
.page-body,
[class$="-page"] .main-content {
    flex: 1 0 auto !important;
    min-height: auto !important;
    height: auto !important;
}

/* 3. Keep sticky footer at bottom for short content pages */
footer,
.footer {
    margin-top: auto !important;
}
