/* ============================================================
   GLOBAL & ROOT VARIABLES
   ============================================================ */
:root {
    --primary-blue: #8b4513;
    --secondary-blue: #5c2e0a;
    --accent-color: #daa520;
    --bg-color: #f8f2e6;
    --card-bg-light: #ffffff;
    --card-bg-alt-light: #fef5e8;
    --text-color: #2a2418;
    --text-muted: #6b5b4a;
    --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;
}

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;
    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 {
    flex: 1 0 auto;
    width: 100%;
    padding: 40px 0;
    min-height: auto;
    height: auto;
}

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

footer, .footer {
    margin-top: auto !important;
}

/* ============================================================
   HEADER & NAVIGATION
   ============================================================ */
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 {
    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;
}

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 {
    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);
}

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

.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;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 8px;
}

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

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;
}

.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;
}

.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;
    font-style: italic;
    font-family: 'Cormorant Garamond', serif;
}

/* ============================================================
   CULTURAL COMPONENTS
   ============================================================ */
.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);
}

.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;
}

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

.generation {
    margin: 30px 0;
}

.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 {
    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;
}

.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;
}

.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;
}

.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
   ============================================================ */
.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);
}

.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-card h3 {
    margin: 0 0 8px 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary-color, #005580);
    transition: color 0.2s ease;
}

.family-card:hover h3 {
    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 var(--primary-color, #005580);
}

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

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

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

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

.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 - BACKGROUND IMAGE METHOD (FINAL WORKING)
   ============================================================ */

/* Gallery Filters */
.gallery-filters {
    margin: 20px 0 30px;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 18px !important;
    border-radius: 20px !important;
    background: #fff !important;
    color: #495057 !important;
    text-decoration: none !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    border: 2px solid #e9ecef !important;
    transition: all 0.3s ease !important;
}

.filter-btn:hover {
    background: #e9ecef !important;
    color: #212529 !important;
    text-decoration: none !important;
    transform: translateY(-2px) !important;
}

.filter-btn.active {
    background: var(--cultural-gold, #0055aa) !important;
    color: #fff !important;
    border-color: var(--cultural-gold, #0055aa) !important;
}

.filter-btn .badge {
    background: rgba(255,255,255,0.2) !important;
    color: inherit !important;
    font-size: 0.7rem !important;
    padding: 2px 8px !important;
    border-radius: 12px !important;
}

.filter-btn.active .badge {
    background: rgba(255,255,255,0.25) !important;
}

/* Gallery Grid Container - Bootstrap Grid */
.gallery-grid-container .row {
    display: flex !important;
    flex-wrap: wrap !important;
    margin-right: -8px !important;
    margin-left: -8px !important;
}

.gallery-grid-container [class*="col-"] {
    flex: 0 0 auto !important;
    padding-right: 8px !important;
    padding-left: 8px !important;
}

.gallery-grid-container .col-6 {
    width: 50% !important;
    flex: 0 0 50% !important;
    max-width: 50% !important;
}

@media (min-width: 768px) {
    .gallery-grid-container .col-md-4 {
        width: 33.333333% !important;
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
    }
}

@media (min-width: 992px) {
    .gallery-grid-container .col-lg-3 {
        width: 25% !important;
        flex: 0 0 25% !important;
        max-width: 25% !important;
    }
}

/* ===== GALLERY ITEM - BACKGROUND IMAGE FILL ===== */
.gallery-grid-container .gallery-item {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 4 / 3 !important;
    overflow: hidden !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
    background-color: lightgrey !important;  /* ✅ Light cream/beige */
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-image: var(--gallery-image, none);
}

.gallery-grid-container .gallery-item:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
}

/* Clickable link covers the entire card */
.gallery-grid-container .gallery-item .gallery-thumb-link {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
    display: block !important;
    text-decoration: none !important;
}

/* Hide any <img> tags inside (fallback) */
.gallery-grid-container .gallery-item img {
    display: none !important;
}

/* ===== CAPTION - OVERLAY ON HOVER ===== */
.gallery-grid-container .gallery-item .gallery-caption {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 12px 14px 10px !important;
    background: linear-gradient(transparent, rgba(0,0,0,0.85)) !important;
    color: #fff !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    z-index: 2 !important;
    pointer-events: none !important;
}

.gallery-grid-container .gallery-item:hover .gallery-caption {
    opacity: 1 !important;
}

/* Gallery Meta */
.gallery-grid-container .gallery-item .gallery-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.gallery-grid-container .gallery-item .gallery-meta .badge {
    font-size: 0.65rem;
    padding: 2px 10px;
    border-radius: 12px;
    background: rgba(0,0,0,0.5);
    color: #fff;
}

.gallery-grid-container .gallery-item .upload-date {
    color: rgba(255,255,255,0.7);
    font-size: 0.7rem;
}

.gallery-grid-container .gallery-item .gallery-details {
    display: block;
}

.gallery-grid-container .gallery-item .gallery-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-grid-container .gallery-item .gallery-description {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Family Badge (used inside gallery) */
.family-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #e8f0fe;
    color: #005580;
}

.family-badge.clan-badge {
    background: #fef3e8;
    color: #8b4513;
}

.gallery-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.upload-date {
    font-size: 0.7rem;
    color: #999;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state i {
    color: var(--primary-color, #005580);
    opacity: 0.5;
    margin-bottom: 15px;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.gallery-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.gallery-lightbox.active {
    display: flex !important;
}

.gallery-lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.gallery-lightbox .caption {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: #fff;
    max-width: 80%;
}

.gallery-lightbox .caption-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.gallery-lightbox .caption-description {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
}

.gallery-lightbox .close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 10;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
    font-weight: 300;
}

.gallery-lightbox .close-btn:hover {
    background: rgba(255,255,255,0.15);
}

.gallery-lightbox .nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 10;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    transition: background 0.3s ease;
}

.gallery-lightbox .nav-btn:hover {
    background: rgba(255,255,255,0.25);
}

.gallery-lightbox .prev-btn {
    left: 20px;
}

.gallery-lightbox .next-btn {
    right: 20px;
}

/* ============================================================
   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) {
    .families-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 18px;
    }

    .family-card {
        padding: 16px;
    }

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

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

    .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;
    }

    .hero-tagline {
        font-size: 1.2rem;
    }

    .member-card {
        width: 140px;
    }

    .event-card {
        flex-direction: column;
        text-align: center;
    }

    .brand .logo {
        height: 40px;
        max-width: 150px;
    }

    .gallery-lightbox img {
        max-height: 70vh;
    }

    .gallery-lightbox .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .gallery-lightbox .close-btn {
        font-size: 2rem;
        top: 10px;
        right: 15px;
    }

    .gallery-lightbox .caption-title {
        font-size: 1rem;
    }
}

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

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

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

    .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;
    }

    .gallery-lightbox img {
        max-height: 60vh;
    }
}
