/**
 * Shared Article Card Styles
 * Used by multiple widgets and shortcodes
 */

/* Base article card styling */
.cp-article-card {
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    background: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    border: none;
    position: relative;
}

.cp-article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.cp-article-card-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cp-article-card-link:hover {
    text-decoration: none;
    color: inherit;
}

/* Article image */
.cp-article-image {
    width: 100%;
    object-fit: contain;
    object-position: center;
    height: auto;
    aspect-ratio: 16/9;
    display: block;
    background: #f7fafc;
}

.cp-article-image.is-loading {
    visibility: hidden;
}

/* Article content container */
.cp-article-content {
    padding: clamp(8px, 1.2vw, 12px);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: clamp(4px, 0.6vw, 6px);
}

/* Article title */
.cp-article-title {
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.25;
    font-size: clamp(0.875rem, 1.4vw, 1rem);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-article-card:hover .cp-article-title {
    color: #2563eb;
}

/* Article meta (author, date) */
.cp-article-meta {
    display: flex;
    align-items: center;
    gap: clamp(4px, 0.6vw, 6px);
    color: #666;
    font-size: clamp(0.7rem, 0.85vw, 0.75rem);
    margin-top: clamp(2px, 0.3vw, 3px);
}

.cp-article-author {
    display: flex;
    align-items: center;
    gap: clamp(2px, 0.3vw, 3px);
    font-weight: 500;
}

.cp-article-author:not(:empty)::before {
    content: "👤";
    font-size: clamp(0.7rem, 0.85vw, 0.75rem);
}

.cp-article-date {
    display: flex;
    align-items: center;
    gap: clamp(2px, 0.3vw, 3px);
    opacity: 0.8;
}

.cp-article-meta:has(.cp-article-author) .cp-article-date::before {
    content: "•";
    color: #cbd5e0;
}

/* Article description/excerpt */
.cp-article-description {
    color: #666;
    line-height: 1.4;
    margin: clamp(4px, 0.6vw, 6px) 0 0 0;
    font-size: clamp(0.75rem, 1vw, 0.8125rem);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Article tags/categories */
.cp-article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(4px, 0.6vw, 6px);
    margin-top: auto;
    padding-top: 8px;
    margin-bottom: clamp(2px, 0.3vw, 3px);
}

.cp-article-tag {
    display: inline-block;
    background: #3b82f6;
    color: white;
    padding: clamp(2px, 0.4vw, 3px) clamp(6px, 0.8vw, 8px);
    border-radius: 3px;
    font-size: clamp(0.625rem, 0.75vw, 0.7rem);
    font-weight: 600;
    text-transform: capitalize;
    text-decoration: none;
    line-height: 1.2;
}

.cp-article-tag:hover {
    opacity: 0.9;
    text-decoration: none;
}

/* Category-specific colors */
.cp-article-tag.business   { background-color: #10b981 !important; }
.cp-article-tag.politics   { background-color: #8b5cf6 !important; }
.cp-article-tag.sports     { background-color: #ac7f0f !important; }
.cp-article-tag.hbcu       { background-color: #73000a !important; }
.cp-article-tag.health     { background-color: #cd4589 !important; }
.cp-article-tag.education  { background-color: #06b6d4 !important; }
.cp-article-tag.technology { background-color: #333333 !important; }
.cp-article-tag.local      { background-color: #3b82f6 !important; }
.cp-article-tag.finance    { background-color: #047857 !important; }
.cp-article-tag.community  { background-color: #374151 !important; }
.cp-article-tag.obituaries { background-color: #4A0E4E !important; }
.cp-article-tag.travel     { background-color: #0e7490 !important; }
.cp-article-tag.lifestyle  { background-color: #f97316 !important; }
.cp-article-tag.culture    { background-color: #a502a8 !important; }
.cp-article-tag.faith      { background-color: #1E40AF !important; }
.cp-article-tag.news       { background-color: #3b82f6 !important; }
.cp-article-tag.opinion    { background-color: #6366f1 !important; }
.cp-article-tag.entertainment { background-color: #ec4899 !important; }

/* Read more link */
.cp-article-read-more {
    display: inline-flex;
    align-items: center;
    gap: clamp(2px, 0.3vw, 3px);
    color: #2563eb;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.85vw, 0.75rem);
    margin-top: clamp(4px, 0.6vw, 6px);
    text-decoration: none;
}

.cp-article-read-more:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.cp-article-read-more::after {
    content: " →";
}

/* Size variants */
.cp-article-card-featured .cp-article-image {
    height: clamp(240px, 24vw, 400px);
}

.cp-article-card-featured .cp-article-title {
    font-size: clamp(1.125rem, 2vw, 1.25rem);
}

.cp-article-card-medium .cp-article-image {
    height: clamp(140px, 16vw, 160px);
}

.cp-article-card-small .cp-article-image {
    height: clamp(120px, 12vw, 175px);
}

.cp-article-card-small .cp-article-title {
    font-size: clamp(0.8rem, 1.2vw, 0.875rem);
}

.cp-article-card-small .cp-article-description {
    font-size: clamp(0.7rem, 0.95vw, 0.75rem);
    -webkit-line-clamp: 2;
}

/* Grid layouts */
.cp-articles-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.cp-articles-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .cp-articles-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .cp-article-content {
        padding: 12px;
    }

    .cp-article-title {
        font-size: 1rem;
        -webkit-line-clamp: 3;
    }

    .cp-article-description {
        font-size: 0.875rem;
        -webkit-line-clamp: 2;
    }
}

@media (max-width: 480px) {
    .cp-article-image {
        /* aspect-ratio handles height */
    }

    .cp-article-tags {
        gap: 4px;
    }

    .cp-article-tag {
        font-size: 0.6875rem;
        padding: 3px 6px;
    }
}

/* Loading states */
.cp-article-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.cp-article-card.loading .cp-article-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: cp-loading 1.5s infinite;
}

@keyframes cp-loading {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Print styles */
@media print {
    .cp-article-card {
        border: 1px solid #ccc;
        page-break-inside: avoid;
        margin-bottom: 16px;
    }

    .cp-article-card:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Image placeholder - matches article image styling exactly */
.img-placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    display: block;
    position: relative;
    background: #f7fafc;
    overflow: hidden;
}

.article-list-feed-wrapper .img-placeholder {
    order: 2; /* Show image placeholder above content in list feed */
}

.img-placeholder svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 25%;
    height: 25%;
    min-width: 80px;
    min-height: 80px;
    max-width: 120px;
    max-height: 120px;
    opacity: 0.5;
}

.img-placeholder span {
    display: none; /* Hide "No Image" text */
}