/* 1. Global Setup */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f4f4;       /* Light grey background canvas behind the card */
    color: #222;
    padding: 40px 20px;
}

/* 2. Master Card Layout (Controls the uniform light blue background color) */
.biography-container {
    background-color: #d1e8ff !important; /* Richer sky blue to bypass monitor glare */
    max-width: 850px;          
    margin: 0 auto;            
    padding: 50px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* 3. Hero Header Elements (Explicit centering controls) */
.biography-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 35px;
    width: 100%;
}

.biography-photo-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    width: 100%;
}

.biography-photo {
    width: 220px;
    height: 220px;
    object-fit: contain;         /* Ensures the entire image frame is fully visible */
    background-color: #ffffff;   /* Fills any side gaps safely with white */
    padding: 8px;                /* Adds a protective inner gap so edges don't clip */
    border-radius: 50%;
    border: 4px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.photo-divider {
    border: 0;
    height: 1px;
    background-color: rgba(11, 37, 69, 0.2);
    width: 120px;
    margin: 15px auto;
    display: block;
}

.biography-hero h1 {
    color: #0B2545;            
    font-size: 2.6rem;
    margin: 0 0 5px 0;
    width: 100%;
}

.biography-dates {
    font-size: 1.1rem;
    color: #4A5568;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin: 0 0 25px 0;
    width: 100%;
}

.biography-header {
    color: #2F4F4F;            
    font-size: 1.25rem;
    line-height: 1.6;
    font-style: italic;
    max-width: 680px;
    margin: 0 auto;
}

/* 4. Biography Narrative Block (Book-styled alignment) */
.biography-text {
    color: #000000;            
    font-size: 1.1rem;
    line-height: 1.8;          
    text-align: justify;       /* Left-to-right straight line alignment */
    text-justify: inter-word;  
    width: 100%;               
    margin-top: 30px;
}

.biography-text h2 {
    color: #0B2545;            
    font-size: 1.6rem;
    text-align: left;          /* Forces header text back to left edge */
    border-bottom: 2px solid rgba(11, 37, 69, 0.15);
    padding-bottom: 8px;
    margin-top: 30px;
    margin-bottom: 20px;
}

.biography-text p {
    margin-bottom: 20px;
}

/* 5. Bottom Call to Action Section */
.tribute-invitation-container {
    margin-top: 40px;
    width: 100%;
}

.invitation-divider {
    border: 0;
    height: 1px;
    background-color: rgba(11, 37, 69, 0.15);
    margin-bottom: 25px;
}

.invitation-message {
    color: #333333;            
    font-size: 1.1rem;
    line-height: 1.8;
    text-align: justify;
    text-justify: inter-word;
    margin-bottom: 25px;
}

.tribute-link-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.tribute-button-link {
    display: inline-block;
    color: #ffffff;            
    background-color: #0B2545; 
    padding: 12px 28px;        
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;     
    border-radius: 6px;        
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease;
}

.tribute-button-link:hover {
    background-color: #1a4475; 
    text-decoration: underline;
}

/* ==========================================================================
   TRIBUTES PAGE SPECIFIC STYLES 
   ========================================================================== */

.tributes-display-section {
    margin-top: 30px;
    margin-bottom: 50px;
}

.tributes-display-section h2 {
    color: #0B2545;
    font-size: 1.6rem;
    border-bottom: 2px solid rgba(11, 37, 69, 0.15);
    padding-bottom: 8px;
    margin-bottom: 25px;
}

.tribute-card {
    background-color: #ffffff; 
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(11, 37, 69, 0.06);
    border-left: 4px solid #0B2545; 
}

.tribute-card h3 {
    margin: 0 0 4px 0;
    color: #0B2545;
    font-size: 1.2rem;
}

.tribute-scrollbox {
    max-height: 180px;         
    overflow-y: auto;          
    padding-right: 10px;       
    margin-top: 8px;
    background-color: #fcfcfc; 
    border: 1px solid rgba(11, 37, 69, 0.08); 
    border-radius: 4px;
    padding: 12px;
}

.tribute-scrollbox::-webkit-scrollbar {
    width: 6px;                
}

.tribute-scrollbox::-webkit-scrollbar-track {
    background: rgba(11, 37, 69, 0.03); 
    border-radius: 4px;
}

.tribute-scrollbox::-webkit-scrollbar-thumb {
    background: rgba(11, 37, 69, 0.2);  
    border-radius: 4px;
}

.tribute-scrollbox::-webkit-scrollbar-thumb:hover {
    background: rgba(11, 37, 69, 0.4);  
}

.tribute-affiliation {
    display: block;
    font-size: 0.95rem;
    color: #555555;
    font-style: italic;
    margin-bottom: 12px;
}

.tribute-message-text {
    color: #222222;
    font-size: 1.05rem;
    line-height: 1.6;
}

.tribute-message-text p {
    margin: 0;
}

.form-section {
    margin-top: 40px;
    padding-top: 20px;
}

.form-section h2 {
    color: #0B2545;
    font-size: 1.6rem;
    border-bottom: 2px solid rgba(11, 37, 69, 0.15);
    padding-bottom: 8px;
    margin-bottom: 25px;
}

.tribute-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    color: #0B2545;
    font-weight: 600;
    font-size: 1rem;
}

.form-group input,
.form-group textarea {
    font-family: Arial, sans-serif;
    font-size: 1rem;
    padding: 12px;
    border: 1px solid rgba(11, 37, 69, 0.2);
    border-radius: 6px;
    background-color: #ffffff;
    color: #222222;
    width: 100%;
    box-sizing: border-box; 
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #0B2545;
    box-shadow: 0 0 0 3px rgba(11, 37, 69, 0.1);
}

.submit-button {
    display: inline-block;
    align-self: flex-start;    
    color: #ffffff;
    background-color: #0B2545;
    padding: 12px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease;
}

.submit-button:hover {
    background-color: #1a4475;
}

.tribute-footer {
    text-align: center;
    color: #555555;
    font-size: 0.9rem;
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid rgba(11, 37, 69, 0.1);
}

.memorial-nav {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 20px 0;
    background: #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border-radius: 6px;
    margin-bottom: 20px;
}

.nav-link {
    text-decoration: none;
    color: #0B2545;
    font-weight: 600;
}

.nav-link.active {
    border-bottom: 2px solid #0B2545;
}

/* ==========================================================================
   ADDED GALLERY IMAGE GRID LAYOUT (FIXED VERSION)
   ========================================================================== */

   /* Unlocks extra screen width specifically for the Image Gallery page layout */
#gallery.biography-container {
    max-width: 1350px !important; /* Widens the container from 850px to 1350px */
    padding: 40px 30px !important; /* Slightly adjustments padding to optimize grid space */
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
    margin-top: 30px;
    margin-bottom: 30px;
    width: 100%;
}

.gallery-item {
    background-color: #ffffff; 
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(11, 37, 69, 0.06);
    border-bottom: 4px solid #0B2545; 
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    page-break-inside: avoid;
    break-inside: avoid;
    
    /* FIX 1: Removed max-height entirely and replaced it with a min-height. 
       This forces empty cards to align perfectly but allows them to expand 
       downwards naturally if a caption needs multiple lines. */
    min-height: 280px; 
    height: auto; 
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 15px rgba(11, 37, 69, 0.12);
}

/* Image framing constraint to ensure consistency across landscape and portrait layout modes */
.gallery-item img {
    width: 100% !important;
    height: 170px !important; /* Forces the photo to stay at a uniform height frame */
    object-fit: contain !important;
    background-color: #fcfcfc;
    border: 1px solid rgba(11, 37, 69, 0.05);
    border-radius: 4px;
    display: block;
}

/* Hard constraint specifically for tall portrait images */
.gallery-item img[src*="2024"] {
    max-height: 150px !important;
    width: auto !important;
    object-fit: contain !important;
}

.gallery-item .caption {
    font-size: 0.95rem;
    color: #222222;            
    text-align: center;
    line-height: 1.4;
    margin: 12px 0 0 0;
    font-weight: 600; /* Made slightly bolder for clean readability */
    width: 100%;
    
    /* FIX 2: Ensure text wraps gracefully inside the card containers */
    word-wrap: break-word;
    overflow-wrap: break-word; 
}
/* ==========================================================================
   SMARTPHONE RESPONSIVE STYLING (FOR SCREENS LOWER THAN 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
    
    /* 1. Shrink outer padding so content has room to breathe on small screens */
    .biography-container {
        width: 95% !important;
        max-width: 95% !important;
        padding: 20px 15px !important; /* Drops 50px padding to a safe 15px */
        margin: 10px auto !important;
        border-radius: 8px !important;
    }

    /* 2. Convert navigation bar into a clean wrap layout */
    .memorial-nav {
        display: flex !important;
        flex-wrap: wrap !important; /* Lets tabs drop to a second line instead of breaking */
        justify-content: center !important;
        gap: 8px !important;
        padding: 10px !important;
    }

    .nav-link {
        font-size: 0.9rem !important; /* Slightly smaller typography for finger-tapping */
        padding: 8px 12px !important;
        text-align: center;
    }

    /* 3. Drop grids to 1 photo/card per row on tiny phone screens */
    .gallery-grid, .tributes-grid {
        grid-template-columns: 1fr !important; /* Flattens to a perfect single vertical stack */
        gap: 15px !important;
    }

    /* 4. Fix image frame height on phones so portrait photos don't stretch */
    .gallery-image-frame, .gallery-item img {
        height: 200px !important;
    }
}