/* Latest and Greatest Block Styles */

.latest-and-greatest {
    width: 100%;
    padding: 40px 0;
}

.lng-content-wrapper {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

/* Sidebar Styles */
.lng-sidebar {
    flex: 0 0 25%;
    min-width: 250px;
}

.lng-title {
    font-family: 'Della Respira', serif;
    font-size: 36px;
    color: var(--dark-grey);
    margin: 0 0 20px 0;
    line-height: 1.2;
}

.lng-intro {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 25px;
}

.lng-intro p {
    margin-bottom: 15px;
}

/* Posts Container */
.lng-posts-container {
    flex: 1;
    min-width: 0;
    padding: 0 50px;
}

.lng-posts-container button.flickity-prev-next-button.previous {
    left: -70px;
}
.lng-posts-container button.flickity-prev-next-button.next {
    right: -70px;
}

/* No Sidebar Layout */
.lng-layout-2 .lng-content-wrapper {
    justify-content: center;
}

.lng-layout-2 .lng-posts-container {
    flex: none;
    width: 100%;
}

/* Grid Layout */
.lng-grid-wrapper {
    display: grid;
    gap: 30px;
}

.lng-columns-3 .lng-grid-wrapper {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.lng-columns-4 .lng-grid-wrapper {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Slider Layout */
.lng-slider-wrapper {
    margin: 0 -15px;
    overflow: visible; /* Ensure overflow is visible for proper slider behavior */
}

.lng-slider .lng-card {
    width: 300px !important; /* Force width to ensure Flickity can measure it */
    margin: 0 15px;
    display: block;
    vertical-align: top;
    position: relative;
    box-sizing: border-box; /* Ensure consistent width calculation */
    flex-shrink: 0; /* Prevent any flex shrinking if parent has flex context */
}

/* Card Styles */
.lng-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    position: relative; /* Ensure normal positioning */
}

/* Grid cards use flex layout, slider cards use block layout */
.lng-grid .lng-card {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 350px;
}

.lng-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

/* Flex layout for grid cards */
.lng-grid .card-link {
    display: flex;
    flex-direction: column;
}

.card-image {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--light-lavender);
    flex-shrink: 0;
}

.card-content {
    padding: 20px;
    position: relative;
}

/* Flex layout for grid cards */
.lng-grid .card-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    justify-content: space-between;
}

/* Block layout for slider cards */
.lng-slider .card-content {
    height: calc(100% - 200px); /* Subtract image height */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
}

.card-title-flex {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 5px;
}

.card-title {
    font-family: 'Della Respira', serif;
    font-size: 18px;
    color: var(--dark-grey);
    margin: 0;
    line-height: 1.3;
    flex: 1;
    margin-right: 10px;
}

.card-year {
    font-size: 14px;
    color: var(--grey);
    flex-shrink: 0;
}

.card-excerpt {
    font-size: 14px;
    line-height: 1.5;
    color: var(--grey);
    margin-bottom: 5px;
}

.card-meta {
    font-size: 12px;
    color: var(--sage);
    font-style: italic;
    margin-top: auto;
}

/* Flickity Overrides */
.lng-slider-wrapper.flickity-enabled {
    /* Let Flickity handle its own sizing */
}

.lng-slider-wrapper .flickity-viewport {
    overflow: hidden; /* Standard Flickity viewport behavior */
    height: auto; /* Allow height to adjust to content */
}

.lng-slider-wrapper .flickity-slider {
    /* Let Flickity handle its own positioning - don't override with flex */
    position: relative;
}

/* Ensure Flickity cells are positioned correctly */
.lng-slider-wrapper .flickity-slider .lng-card {
    /* Let Flickity handle positioning - minimal interference */
    display: block;
    vertical-align: top;
}

.flickity-button {
    background: var(--night-sky);
    border-radius: 50%;
    width: 44px;
    height: 44px;
}

.flickity-button:hover {
    background: var(--jasper);
}

.flickity-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.flickity-button-icon {
    fill: white;
}

.flickity-prev-next-button.previous {
    left: -60px;
}

.flickity-prev-next-button.next {
    right: -60px;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .lng-container {
        padding: 0 15px;
    }
    
    .lng-content-wrapper {
        gap: 30px;
    }
    
    .flickity-prev-next-button.previous {
        left: -50px;
    }
    
    .flickity-prev-next-button.next {
        right: -50px;
    }
}

@media (max-width: 768px) {
    .latest-and-greatest {
        padding: 30px 0;
    }
    
    .lng-content-wrapper {
        flex-direction: column;
        gap: 30px;
    }
    
    /* Mobile: Sidebar always comes first regardless of layout setting */
    .lng-layout-0 .lng-sidebar,
    .lng-layout-1 .lng-sidebar {
        order: -1;
        flex: none;
        width: 100%;
        min-width: auto;
        text-align: center;
    }
    
    .lng-posts-container {
        flex: none;
        width: 100%;
    }
    
    .lng-title {
        font-size: 28px;
    }
    
    .lng-columns-3 .lng-grid-wrapper,
    .lng-columns-4 .lng-grid-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .lng-slider .lng-card {
        width: 280px;
        margin: 0 10px;
        /* Remove fixed height to allow natural content flow */
        display: block;
        vertical-align: top;
    }
    
    /* Remove fixed min-heights that could interfere with slider behavior */
    .lng-slider-wrapper.flickity-enabled,
    .lng-slider-wrapper .flickity-viewport {
        /* Let height adjust naturally to content */
    }
    
    .flickity-prev-next-button.previous {
        left: -35px;
    }
    
    .flickity-prev-next-button.next {
        right: -35px;
    }
    
    .card-image {
        height: 180px;
    }
    
    .card-content {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .lng-container {
        padding: 0 10px;
    }
    
    .lng-slider .lng-card {
        width: 260px;
        /* Remove fixed height to allow natural content flow */
        display: block;
        vertical-align: top;
    }
    
    /* Remove fixed min-heights that could interfere with slider behavior */
    .lng-slider-wrapper.flickity-enabled,
    .lng-slider-wrapper .flickity-viewport {
        /* Let height adjust naturally to content */
    }
    
    .flickity-prev-next-button {
        display: none;
    }
    
    .card-title {
        font-size: 16px;
    }
    
    .card-title-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .card-year {
        align-self: flex-end;
    }
}

/* Layout Variations */
.lng-layout-1 .lng-content-wrapper {
    flex-direction: row-reverse;
}

/* Dark Background Adjustments */
.latest-and-greatest[style*="--night-sky"],
.latest-and-greatest[style*="--clay"],
.latest-and-greatest[style*="--dark-grey"] {
    color: white;
}

.latest-and-greatest[style*="--night-sky"] .lng-title,
.latest-and-greatest[style*="--clay"] .lng-title,
.latest-and-greatest[style*="--dark-grey"] .lng-title {
    color: white;
}

/* Light Background Adjustments */
.latest-and-greatest[style*="--light-lavender"] .lng-card,
.latest-and-greatest[style*="--linen"] .lng-card {
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}
