/*
 * Frontend Styles for Related Posts AI
 *
 * @package Related_Posts_AI
 */

:root {
    --rpa-bg-color: #f9f9f9;
    --rpa-border-color: #e0e0e0;
    --rpa-text-color: #333;
    --rpa-link-color: #0073aa;
    --rpa-meta-color: #666;
}

@media (prefers-color-scheme: dark) {
    :root {
        --rpa-bg-color: #2c3338;
        --rpa-border-color: #40464d;
        --rpa-text-color: #f0f0f0;
        --rpa-link-color: #4dc3ff;
        --rpa-meta-color: #999;
    }
}

.rpa-related-posts-section {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin-top: 2em;
    border-top: 1px solid var(--rpa-border-color);
    padding-top: 2em;
    color: var(--rpa-text-color);
}

.rpa-related-posts-title {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 1em;
}

.rpa-related-posts-container {
    display: grid;
    /* Use a responsive clamp for a better rhythm */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: clamp(16px, 2vw, 24px);
}

.rpa-related-post-item {
    background-color: var(--rpa-bg-color);
    border: 1px solid var(--rpa-border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    .rpa-related-post-item {
        transition: none !important;
    }
}

.rpa-related-post-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.rpa-related-post-link {
    display: block;
    text-decoration: none;
    color: var(--rpa-text-color);
    padding: 15px;
    /* Add a visible focus outline for accessibility */
    outline-offset: 2px;
}

.rpa-related-post-link:focus-visible {
    outline: 2px solid var(--rpa-link-color);
    border-radius: 6px;
}

.rpa-post-thumbnail {
    margin-bottom: 15px;
    position: relative;
    width: 100%;
    /* Use padding-top fallback for older browsers */
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.rpa-post-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.rpa-post-title {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.rpa-post-meta {
    font-size: 0.9em;
    color: var(--rpa-meta-color);
    margin-top: 8px;
    font-style: italic;
}

.rpa-powered-by {
    margin-top: 2em;
    text-align: center;
    font-size: 0.8em;
    color: var(--rpa-text-color);
}

.rpa-powered-by a {
    color: var(--rpa-link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.rpa-powered-by a:hover,
.rpa-powered-by a:focus-visible {
    color: var(--rpa-admin-secondary); /* Use a themed color */
    text-decoration: underline;
}

/* New Layout: Minimalist List */
.rpa-related-posts-container--minimalist {
    display: block; /* Change from grid to block for a vertical list */
    padding: 10px 0;
}

.rpa-related-posts-container--minimalist .rpa-related-post-item {
    background: transparent;
    border: none;
    box-shadow: none;
    border-bottom: 1px solid var(--rpa-border-color);
    border-radius: 0;
    margin-bottom: 5px;
}

.rpa-related-posts-container--minimalist .rpa-related-post-link {
    padding: 10px 0;
}

.rpa-related-posts-container--minimalist .rpa-post-thumbnail,
.rpa-related-posts-container--minimalist .rpa-post-meta {
    display: none; /* Hide thumbnails and meta */
}

.rpa-related-posts-container--minimalist .rpa-post-title {
    font-size: 1em;
    font-weight: normal;
    text-decoration: underline;
}

/* New Layout: Image Card Grid */
.rpa-related-posts-container--image-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.rpa-related-posts-container--image-card .rpa-related-post-item {
    border: 1px solid var(--rpa-border-color);
    border-radius: 8px;
}

.rpa-related-posts-container--image-card .rpa-related-post-link {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.rpa-related-posts-container--image-card .rpa-post-thumbnail {
    margin-bottom: 0;
}

.rpa-related-posts-container--image-card .rpa-post-thumbnail img {
    border-radius: 8px 8px 0 0;
}

.rpa-related-posts-container--image-card .rpa-post-content {
    padding: 15px;
}

.rpa-related-posts-container--image-card .rpa-post-title {
    font-size: 1.1em;
}

.rpa-related-posts-container--image-card .rpa-post-meta {
    margin-top: 5px;
}

/* Fallback for browsers that don't support flexbox on anchor tags */
.rpa-related-posts-container--image-card .rpa-related-post-link > * {
    margin-bottom: 10px;
}

.rpa-related-posts-container--image-card .rpa-related-post-link > *:last-child {
    margin-bottom: 0;
}