/*
 * Archive Grid Styles for Blog Product Layout
 *
 * These styles create a responsive card grid showing blog posts that are
 * connected to products via the Blog Product Layout plugin. Each card
 * maintains a 1:1 aspect ratio for its thumbnail, displays the post title,
 * a trimmed excerpt, and a read more button. Four cards are displayed per
 * row on larger screens and will wrap on smaller devices.
 */

.bpl-archive-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
}

.bpl-archive-card {
    flex: 0 0 calc(25% - 20px);
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/*
 * Thumbnail maintains a 3:2 ratio using the padding trick (66.666%).
 *
 * The previous version of this stylesheet enforced a 16:9 (1.78:1) ratio for
 * thumbnails.  After enabling certain SEO plugins customers reported that
 * the images appeared excessively tall and the intended 1.5:1 ratio was
 * lost.  To make the cards visually consistent with the product gallery
 * thumbnails we use a 3:2 aspect ratio here.  The padding-top value is
 * calculated as (height / width) × 100 = (2 / 3) × 100 = 66.666%.
 */
.bpl-archive-card .bpl-card-thumb {
    width: 100%;
    position: relative;
    /* 3:2 aspect ratio: 2/3 = 0.6667 → 66.666% padding */
    padding-top: 66.666%;
    overflow: hidden;
    background: #f7f7f7;
}

.bpl-archive-card .bpl-card-thumb img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* When the thumbnail is wrapped in a link we need to ensure the anchor fills the
 * container so the 1:1 ratio still applies.  The anchor becomes a positioned
 * block element that sits on top of the padding placeholder. */
.bpl-archive-card .bpl-card-thumb a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.bpl-archive-card .bpl-card-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.bpl-archive-card h2 {
    font-size: 1rem;
    margin: 0 0 10px;
    line-height: 1.3;
}

/* Ensure the clickable title inherits card styling */
.bpl-archive-card h2 a {
    color: inherit;
    text-decoration: none;
}
.bpl-archive-card h2 a:hover {
    text-decoration: underline;
}

.bpl-archive-card p {
    margin: 0 0 15px;
    flex-grow: 1;
    line-height: 1.4;
    color: #555;
}

.bpl-archive-card .bpl-readmore {
    align-self: flex-start;
    background-color: #0073aa;
    color: #fff;
    padding: 6px 12px;
    text-decoration: none;
    border-radius: 3px;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
}

.bpl-archive-card .bpl-readmore:hover {
    background-color: #005177;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .bpl-archive-card {
        flex: 0 0 calc(33.333% - 20px);
    }
}

@media (max-width: 768px) {
    .bpl-archive-card {
        flex: 0 0 calc(50% - 20px);
    }
}

@media (max-width: 500px) {
    .bpl-archive-card {
        flex: 0 0 100%;
    }
}