/* Modern CSS Reset & Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Custom Properties - Soft, Elegant Palette */
:root {
    --color-bg-primary: #FDFBF7; /* Soft ivory */
    --color-bg-secondary: #F4F1EA; /* Slightly deeper warm gray/beige */
    --color-text-primary: #2C2C2C; /* Soft black */
    --color-text-secondary: #5A5A5A; /* Muted gray for dates/relationships */
    --color-accent: #8E7A5A; /* Soft elegant gold/bronze */
    --color-accent-hover: #756346;
    --color-border: #E5E0D8;
    
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Inter', sans-serif;
    
    --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.08);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 400;
    margin-bottom: 0.5rem;
}

/* Hero Section */
.hero {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    background-color: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
}

/* Subtle floral background pattern */
.hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('floral-bg.png');
    background-repeat: repeat;
    background-size: 500px;
    opacity: 0.6; /* Increased opacity from 0.12 because image is naturally very light */
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 0;
}

.hero-content {
    max-width: 800px;
    position: relative;
    z-index: 1;
    animation: fadeInDown 1s ease-out;
}

.hero h1 {
    font-size: 1.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--color-accent);
    margin-bottom: 1rem;
}

.hero .name {
    font-size: clamp(3rem, 8vw, 6rem);
    font-style: italic;
    color: var(--color-text-primary);
    line-height: 1.1;
    margin-bottom: 1rem;
}

.hero .dates {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    letter-spacing: 1px;
    margin-bottom: 2rem;
}

.hero .intro {
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    max-width: 600px;
    margin: 0 auto 3rem auto;
}

/* Buttons */
.btn-primary {
    background-color: var(--color-accent);
    color: #fff;
    border: none;
    padding: 1rem 2.5rem;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    border-radius: 30px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-subtle);
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.full-width {
    width: 100%;
}

/* Main Content Area */
.gallery-section {
    max-width: 1200px;
    margin: 4rem auto;
    padding: 0 2rem;
}

.gallery-header {
    text-align: center;
    margin-bottom: 2rem;
}

.gallery-header h3 {
    font-size: 2.5rem;
    color: var(--color-text-primary);
}

.gallery-header p {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
}

/* Vertical Scrolling Gallery */
.vertical-gallery-container {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    max-height: 800px;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
    margin: 0 auto;
    padding: 1rem 0;
}

.gallery-col {
    position: relative;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    padding-bottom: 1.5rem;
}

.gallery-col-inner {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.gallery-card {
    border-radius: 1.5rem; /* 3xl rounded corners */
    overflow: hidden;
    border: 1px solid var(--color-border);
    box-shadow: 0 10px 15px -3px rgba(142, 122, 90, 0.1);
    width: 100%;
    aspect-ratio: 4/5;
    background-color: var(--color-bg-secondary);
    flex-shrink: 0;
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
    background-color: var(--color-border);
}

@keyframes verticalScroll {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(var(--scroll-height, -50%));
    }
}

/* Stagger animation speeds by column */
.col-1 .gallery-col-inner { animation-duration: 25s; }
.col-2 .gallery-col-inner { animation-duration: 35s; }
.col-3 .gallery-col-inner { animation-duration: 30s; }

/* Hide columns on smaller screens (Responsive constraints) */
@media (max-width: 1024px) {
    .hidden-lg { display: none !important; }
}

@media (max-width: 768px) {
    .hidden-md { display: none !important; }
}

.tribute-board {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.feed-header {
    text-align: center;
    margin-bottom: 3rem;
}

.feed-header h3 {
    font-size: 2.5rem;
    color: var(--color-text-primary);
}

/* Masonry Grid */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    align-items: start;
}

/* Tribute Card */
.tribute-card {
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-subtle);
    transition: var(--transition-smooth);
    break-inside: avoid;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUpIn 0.6s ease-out forwards;
    cursor: pointer;
    position: relative;
    height: 450px;
    display: flex;
    flex-direction: column;
}

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

.tribute-image-carousel {
    display: flex;
    width: 100%;
}

.tribute-image-carousel.is-scrollable {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.tribute-image-carousel.is-scrollable::-webkit-scrollbar {
    display: none;
}

.tribute-image-container {
    width: 100%;
    height: 250px;
    background: #EAE6DF;
    flex-shrink: 0;
    scroll-snap-align: center;
}

.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: -1.5rem; /* pull it up over the image */
    margin-bottom: 2rem;
    position: relative;
    z-index: 2;
}

.carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    transition: var(--transition-smooth);
}

.carousel-dot.active {
    background-color: #fff;
    transform: scale(1.3);
}

.tribute-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
    transition: transform 0.5s ease;
}

.tribute-card:hover .tribute-image {
    transform: scale(1.03);
}

/* Provide a specific style for text-only cards to look elegant */
.tribute-card.text-only {
    background: linear-gradient(135deg, #ffffff 0%, #FDFBF7 100%);
    border: 1px solid var(--color-border);
}

.tribute-card.text-only .tribute-message {
    margin-top: auto;
    margin-bottom: auto;
    text-align: center;
}

.tribute-card.text-only .tribute-message::before {
    display: block; /* Centers the quote correctly over centered text */
    margin: 0 auto 0.5rem auto;
    text-align: center;
}

.tribute-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.tribute-message {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--color-text-primary);
    margin-bottom: 1.5rem;
    font-style: italic; /* Makes the message feel more like a letter */
}

/* Base Clamping logic for the feed cards (overridden in the modal overlay) */
.tribute-card .tribute-message {
    display: -webkit-box;
    -webkit-line-clamp: 4; /* Default to 4 lines for text-only */
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Shrink the limit to 2 lines for cards that already take up space with images */
.tribute-card:not(.text-only) .tribute-message {
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.see-more-btn {
    background: none;
    border: none;
    color: var(--color-accent);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0;
    margin-top: -0.5rem;
    margin-bottom: 1.5rem;
    text-decoration: underline;
    display: inline-block;
}

.see-more-btn:hover {
    color: var(--color-accent-hover);
}

/* Quote marks visual flair */
.tribute-message::before {
    content: "“";
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--color-accent);
    opacity: 0.3;
    line-height: 0;
    vertical-align: bottom;
    margin-right: 5px;
}

.tribute-meta {
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    margin-top: auto;
}

.tribute-author {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--color-text-primary);
}

.tribute-relationship {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.25rem;
}

/* Modal CSS */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(253, 251, 247, 0.9);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 1;
    visibility: visible;
    transition: var(--transition-smooth);
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    position: relative;
    transform: translateY(0) scale(1);
    transition: var(--transition-smooth);
    max-height: 90vh;
    overflow-y: auto;
}

.modal.hidden .modal-content {
    transform: translateY(20px) scale(0.95);
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal h2 {
    font-size: 2rem;
    color: var(--color-accent);
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    color: var(--color-text-secondary);
    margin-bottom: 2rem;
}

/* View Tribute Overlay Specifics */
.view-tribute-content {
    background: #FDFBF7;
    padding: 0; /* Let the container handle padding */
    max-width: 800px;
}

/* Inherits card structure but blows it up for the modal */
#overlay-tribute-container .tribute-card {
    height: auto; /* allow it to grow past 450px */
    max-height: none; /* remove limits */
    box-shadow: none;
    transform: none;
    animation: none;
    opacity: 1; /* Make visible since we disabled the fade up animation */
    cursor: default;
    background: transparent;
    border: none;
    display: block; /* Remove flex constraints so height grows naturally */
}

#overlay-tribute-container .tribute-card:hover {
    transform: none; /* Disable hover float inside the modal */
}

#overlay-tribute-container .tribute-message {
    -webkit-line-clamp: unset; /* Remove line clamp to show full message */
    line-clamp: unset;
    font-size: 1.15rem; /* slightly larger text for reading */
    overflow: visible;
}

#overlay-tribute-container .see-more-btn {
    display: none; /* Hide the 'see more' button when already viewing full size */
}

#overlay-tribute-container .tribute-image-carousel.is-scrollable {
    overflow-x: auto; /* keep it scrollable in modal */
    padding-bottom: 1rem; /* breathing room for scroll area */
}

#overlay-tribute-container .tribute-image-container {
    max-height: 60vh; /* Allow huge glorious images inside the popup */
    height: auto; /* Let it grow naturally up to max-height */
    border-radius: var(--radius-lg);
    margin-right: 1rem; /* Gap between multiple images */
}

#overlay-tribute-container .tribute-image-container:last-child {
    margin-right: 0;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--color-text-primary);
}

input[type="text"],
textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    background-color: var(--color-bg-primary);
    transition: var(--transition-smooth);
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(142, 122, 90, 0.1);
}

.hidden-input {
    display: none;
}

.file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    color: var(--color-text-secondary);
    background-color: var(--color-bg-primary);
}

.file-label:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background-color: #fff;
}

.upload-icon {
    font-size: 1.5rem;
}

/* Image Preview in Form */
.image-preview {
    margin-top: 1rem;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.image-preview img {
    width: 100%;
    max-height: 250px;
    object-fit: contain;
    background-color: #000;
    display: block;
}

.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
}

.remove-btn:hover {
    background: rgba(0,0,0,0.8);
}

/* Empty State / Loading State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    grid-column: 1 / -1;
    color: var(--color-text-secondary);
}

.empty-state i {
    font-size: 3rem;
    color: var(--color-border);
    margin-bottom: 1rem;
    display: block;
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeUpIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Footer */
.site-footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 3rem 2rem;
    margin-top: 2rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    font-style: italic;
    background-color: var(--color-bg-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .masonry-grid {
        grid-template-columns: 1fr;
    }
    
    .hero {
        padding: 3rem 1.5rem;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .gallery-item {
        flex: 0 0 100%; /* Show 1 item visible at a time on mobile devices */
    }
}
