/**
 * ArticleCard Component Styles
 * 
 * Reusable component for displaying articles in feeds, trending sections, and related articles.
 * Supports three variants: standard, compact, horizontal
 * 
 * VARIANTS:
 * - standard: Full-featured vertical card (excerpt, author, full metadata)
 * - compact: Minimal vertical card (title, date, reading time only)
 * - horizontal: Side-by-side layout (image left, content right)
 */

/* ============================================================================
   BASE ARTICLE CARD STYLES
   ============================================================================ */

.article-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    position: relative;
}

/* ============================================================================
   INTERACTIVE STATES
   ============================================================================ */

.article-card {
    cursor: pointer;
}

/* Hover elevation effect */
.article-card:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
    border-color: var(--primary);
}

/* Focus state for keyboard navigation */
.article-card:focus-within {
    outline: 2px solid var(--primary, #667eea);
    outline-offset: 2px;
}

/* Touch device hover (reduced elevation on mobile) */
@media (hover: none) {
    .article-card:hover {
        transform: translateY(0);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    }
}

/* ============================================================================
   ARTICLE LINK
   ============================================================================ */

.article-card__image-link {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    text-decoration: none;
    cursor: pointer;
}

.article-card__image-link:focus {
    outline: 2px solid var(--primary, #667eea);
    outline-offset: -2px;
    z-index: 10;
}

.article-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
    outline: none;
}

.article-card__link:focus {
    /* Focus ring handled by parent */
}

.article-card__link-text {
    pointer-events: none;
}

/* Standard variant: add button styling */
.article-card--standard .article-card__link {
    display: inline-flex;
    flex-direction: row;
    height: auto;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    margin-top: auto;
    color: white;
    background-color: var(--primary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    border: none;
}

.article-card--standard .article-card__link:hover {
    background-color: var(--primary-dark);
    transform: translateX(2px);
}

.article-card--standard .article-card__link:focus {
    outline: 2px solid var(--primary, #667eea);
    outline-offset: 2px;
}

/* ============================================================================
   IMAGE SECTION
   ============================================================================ */

.article-card__image-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #e9e9e9 100%);
    flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
    .article-card__image-wrapper {
        background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
    }
}

.article-card__image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Image fade-in animation when lazy-loaded */
.article-card__image {
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Overlay for better text readability on image */
.article-card__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
    transition: background 0.3s ease;
}

.article-card:hover .article-card__overlay {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.15) 100%);
}

/* ============================================================================
   CATEGORY BADGE
   ============================================================================ */

.article-card__category {
    display: inline-block;
    padding: 4px 12px;
    background-color: var(--primary, #667eea);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1;
}

.article-card__category:hover {
    background-color: #764ba2;
    text-decoration: none;
}

.article-card__category:focus {
    outline: 2px solid #764ba2;
    outline-offset: 2px;
}

/* Category badge positioned on image overlay (compact variant) */
.article-card__category--overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    background-color: var(--primary);
    backdrop-filter: blur(4px);
    color: white !important;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.3s ease;
    white-space: nowrap;
    line-height: 1;
}

/* ==========================================================================
   FEATURED / TRENDING BADGES
   --------------------------------------------------------------------------
   Small inline badges used across article cards and admin lists to highlight
   Featured and Trending content. Keep them compact and high-contrast.
   ========================================================================== */
.badge-featured,
.badge-trending {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.6875rem; /* 11px */
    font-weight: 700;
    border-radius: 999px;
    color: #ffffff;
    line-height: 1;
    vertical-align: middle;
    margin-left: 8px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

.badge-featured {
    background: linear-gradient(90deg, #f6c844 0%, #f08c00 100%);
}

.badge-trending {
    background: linear-gradient(90deg, #ff6b6b 0%, #ff3b30 100%);
}

@media (prefers-color-scheme: dark) {
    .badge-featured { box-shadow: 0 4px 10px rgba(0,0,0,0.28); }
    .badge-trending { box-shadow: 0 4px 10px rgba(0,0,0,0.28); }
}

/* ============================================================================
   CONTENT SECTION
   ============================================================================ */

.article-card__content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 20px;
    gap: 12px;
}

.article-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================================
   TITLE
   ============================================================================ */

.article-card__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary, #0f0f0f);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

@media (prefers-color-scheme: dark) {
    .article-card__title {
        color: var(--text-primary, #ffffff);
    }
}

.article-card:hover .article-card__title {
    color: var(--primary, #667eea);
}

/* ============================================================================
   EXCERPT
   ============================================================================ */

.article-card__excerpt {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary, #666666);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (prefers-color-scheme: dark) {
    .article-card__excerpt {
        color: var(--text-secondary, #999999);
    }
}

/* ============================================================================
   AUTHOR SECTION (Standard variant only)
   ============================================================================ */

.article-card__author-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.article-card__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    flex-shrink: 0;
    border: 2px solid var(--border-color, #e0e0e0);
}

@media (prefers-color-scheme: dark) {
    .article-card__avatar {
        border-color: var(--border-color, #333333);
    }
}

.article-card__author-details {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow text truncation */
}

.article-card__author {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #0f0f0f);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (prefers-color-scheme: dark) {
    .article-card__author {
        color: var(--text-primary, #ffffff);
    }
}

/* ============================================================================
   METADATA SECTION
   ============================================================================ */

.article-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto; /* Push to bottom */
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

@media (prefers-color-scheme: dark) {
    .article-card__meta {
        border-color: var(--border-color, #333333);
    }
}

.article-card__meta--compact {
    border-top: none;
    padding-top: 0;
}

.article-card__date {
    font-size: 0.8125rem;
    color: var(--text-secondary, #999999);
    white-space: nowrap;
}

.article-card__reading-time {
    font-size: 0.8125rem;
    color: var(--text-secondary, #999999);
    white-space: nowrap;
}

.article-card__stats {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ============================================================================
   STANDARD VARIANT
   ============================================================================ */

.article-card--standard {
    display: flex;
    flex-direction: column;
}

.article-card--standard .article-card__content {
    padding: 20px;
}

.article-card--standard .article-card__title {
    font-size: 1.125rem;
}

/* Hide excerpt on small screens */
@media (max-width: 576px) {
    .article-card--standard .article-card__excerpt {
        display: none;
    }

    .article-card--standard .article-card__content {
        padding: 16px;
        gap: 10px;
    }
}

/* ============================================================================
   COMPACT VARIANT
   ============================================================================ */

.article-card--compact {
    display: flex;
    flex-direction: column;
}

.article-card--compact .article-card__image-wrapper {
    padding-bottom: 56.25%; /* 16:9 */
}

.article-card--compact .article-card__content {
    padding: 16px;
    gap: 8px;
}

.article-card--compact .article-card__title {
    font-size: 1rem;
    -webkit-line-clamp: 2;
    margin-bottom: 4px;
}

.article-card--compact .article-card__meta {
    border-top: none;
    padding-top: 0;
    gap: 8px;
    flex-wrap: wrap;
}

.article-card--compact .article-card__date,
.article-card--compact .article-card__reading-time {
    font-size: 0.75rem;
    color: var(--text-secondary, #999999);
}

/* ============================================================================
   HORIZONTAL VARIANT
   ============================================================================ */

.article-card--horizontal .article-card__link {
    flex-direction: row;
}

.article-card--horizontal .article-card__image-wrapper {
    width: 200px;
    min-width: 200px;
    padding-bottom: 0;
    height: 200px;
}

.article-card--horizontal .article-card__content {
    flex-grow: 1;
    padding: 18px;
    justify-content: space-between;
    gap: 10px;
}

.article-card--horizontal .article-card__title {
    font-size: 1.0625rem;
    -webkit-line-clamp: 2;
}

.article-card--horizontal .article-card__excerpt {
    -webkit-line-clamp: 3;
    font-size: 0.875rem;
}

.article-card--horizontal .article-card__meta {
    flex-wrap: wrap;
    border-top: 1px solid var(--border-color, #e0e0e0);
    padding-top: 10px;
    gap: 8px;
    margin-top: 8px;
}

@media (prefers-color-scheme: dark) {
    .article-card--horizontal .article-card__meta {
        border-color: var(--border-color, #333333);
    }
}

/* Responsive: Stack on tablets and smaller */
@media (max-width: 768px) {
    .article-card--horizontal .article-card__link {
        flex-direction: column;
    }

    .article-card--horizontal .article-card__image-wrapper {
        width: 100%;
        min-width: 100%;
        height: auto;
        padding-bottom: 56.25%;
    }

    .article-card--horizontal .article-card__excerpt {
        display: none;
    }
}

/* ============================================================================
   GRID LAYOUTS
   ============================================================================ */

/* Standard cards grid */
.article-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* Compact cards grid (trending, related) */
.article-cards-grid--compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Horizontal cards grid */
.article-cards-grid--horizontal {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Trending cards (3-column on desktop) */
@media (max-width: 1024px) {
    .article-cards-grid--compact {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .article-cards-grid,
    .article-cards-grid--compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 576px) {
    .article-cards-grid,
    .article-cards-grid--compact {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* High contrast mode support */
@media (prefers-contrast: more) {
    .article-card {
        border-width: 2px;
    }

    .article-card__category {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .article-card,
    .article-card__image,
    .article-card__overlay,
    .article-card__category,
    .article-card__title {
        transition: none;
    }

    .article-card:hover {
        transform: none;
    }
}

/* Focus visible for keyboard users */
.article-card__link:focus-visible {
    outline: 2px solid var(--primary, #667eea);
    outline-offset: 2px;
}

/* Skip link support */
.article-card__title:focus {
    outline: 2px solid var(--primary, #667eea);
    outline-offset: 2px;
}

/* ============================================================================
   LOADING STATE (skeleton)
   ============================================================================ */

.article-card--loading {
    opacity: 0.6;
    pointer-events: none;
}

.article-card--loading .article-card__image,
.article-card--loading .article-card__title,
.article-card--loading .article-card__excerpt,
.article-card--loading .article-card__avatar {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

/* Hide on small screens */
@media (max-width: 576px) {
    .article-card__excerpt {
        display: none;
    }
}

/* Ensure proper spacing in lists */
.article-cards-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.article-cards-list li {
    display: contents;
}
