/**
 * Related Articles Widget — v2.0 Styles
 * ──────────────────────────────────────
 * Two-row layout with independent sources.
 * Includes skeleton loading animation for AJAX (random) rows.
 *
 * Breakpoints
 *   Mobile  (≤ 768px)      →  1 column, card-style
 *   Tablet  (769 – 1099px) →  var(--aw-cols-tablet) columns  (default 3)
 *   Desktop (≥ 1100px)     →  var(--aw-cols-desktop) columns (default 3)
 *
 * Thumbnails: 4 : 3 via aspect-ratio + object-fit: cover.
 */

/* ─────────────────────────────────────────────
   Container
   ───────────────────────────────────────────── */
.aw-related-articles {
    --aw-cols-desktop: 3;
    --aw-cols-tablet: 3;
    margin: 32px 0 24px 0;
    padding: 0;
    box-sizing: border-box;
    width: 100%;
}

/* ─────────────────────────────────────────────
   Row Separator (between row 1 & row 2)
   ───────────────────────────────────────────── */
.aw-row-separator {
    height: 0;
    margin: 28px 0;
    border: none;
    border-top: 1px solid #e5e5e5;
}

/* ─────────────────────────────────────────────
   Section Heading
   ───────────────────────────────────────────── */
.aw-related-heading {
    font-size: 20px;
    font-weight: 700;
    color: #222;
    margin: 0 0 18px 0;
    padding: 0 0 10px 0;
    border-bottom: 2px solid #e0e0e0;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

/* ─────────────────────────────────────────────
   Grid
   ───────────────────────────────────────────── */
.aw-grid {
    display: grid;
    grid-template-columns: repeat(var(--aw-cols-desktop), 1fr);
    gap: 22px;
}

/* Fade-in after AJAX load */
.aw-grid--loaded {
    animation: awFadeIn 0.35s ease-out;
}

@keyframes awFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────────────────────────
   Card (link wrapper)
   ───────────────────────────────────────────── */
.aw-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aw-card:hover,
.aw-card:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
    outline: none;
}

.aw-card:hover .aw-thumb {
    transform: scale(1.04);
}

/* ─────────────────────────────────────────────
   Thumbnail Wrapper  (4 : 3)
   ───────────────────────────────────────────── */
.aw-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 6px;
    background-color: #f0f0f0;
}

/* ─────────────────────────────────────────────
   Thumbnail Image
   ───────────────────────────────────────────── */
.aw-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 6px;
    transition: transform 0.3s ease;
}

/* ─────────────────────────────────────────────
   No-thumbnail Placeholder
   ───────────────────────────────────────────── */
.aw-no-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e8e8e8;
}

.aw-no-thumb-icon {
    color: #b0b0b0;
    line-height: 0;
}

/* ─────────────────────────────────────────────
   Title
   ───────────────────────────────────────────── */
.aw-title {
  margin: 10px 0 0 0;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  color: #333;
  word-break: break-word;
  overflow-wrap: break-word;
}

.aw-card:hover .aw-title {
    color: #0073aa;
}

/* ═════════════════════════════════════════════
   Skeleton Loading  (for AJAX rows)
   ═════════════════════════════════════════════ */
.aw-skeleton {
    pointer-events: none;
}

.aw-skeleton-thumb {
    background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
    background-size: 200% 100%;
    animation: awShimmer 1.4s ease-in-out infinite;
}

.aw-skeleton-title {
    margin-top: 10px;
    height: 16px;
    width: 75%;
    border-radius: 4px;
    background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
    background-size: 200% 100%;
    animation: awShimmer 1.4s ease-in-out infinite;
}

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

/* ═════════════════════════════════════════════
   Tablet  (769px – 1099px)
   ═════════════════════════════════════════════ */
@media (max-width: 1099px) and (min-width: 769px) {
    .aw-grid {
        grid-template-columns: repeat(var(--aw-cols-tablet), 1fr);
        gap: 18px;
    }

    .aw-title {
        font-size: 13.5px;
    }
}

/* ═════════════════════════════════════════════
   Mobile  (≤ 768px)  —  Single-column cards
   ═════════════════════════════════════════════ */
@media (max-width: 768px) {
    .aw-related-articles {
        margin: 24px 0 16px 0;
    }

    .aw-related-heading {
        font-size: 18px;
        margin-bottom: 14px;
        padding-bottom: 8px;
    }

    .aw-row-separator {
        margin: 20px 0;
    }

    .aw-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .aw-card {
        flex-direction: column;
        align-items: stretch;
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
        padding: 10px;
        gap: 12px;
    }

    .aw-card:hover,
    .aw-card:focus-visible {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.13);
    }

    .aw-card:hover .aw-thumb {
        transform: none;
    }

    .aw-thumb-wrap {
        flex-shrink: 0;
        width: 100%;
        aspect-ratio: 4 / 3;
        border-radius: 6px;
    }

    .aw-title {
        font-size: 14px;
        margin: 0;
        padding: 4px 0 0 0;
        -webkit-line-clamp: 3;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Skeleton on mobile */
    .aw-skeleton {
        flex-direction: column;
        align-items: stretch;
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
        padding: 10px;
        gap: 12px;
    }

    .aw-skeleton .aw-skeleton-thumb {
        flex-shrink: 0;
        width: 100%;
        aspect-ratio: 4 / 3;
    }

    .aw-skeleton .aw-skeleton-title {
        flex: 1;
        width: auto;
        margin-top: 4px;
    }

    .aw-sponsored-desc {
        font-size: 12px;
        -webkit-line-clamp: 2;
        margin-top: 2px;
    }
}

/* ═════════════════════════════════════════════
   Sponsored Section
   ═════════════════════════════════════════════ */
.aw-sponsored-section {
    margin: 0;
    padding: 0;
}

/* Label below title/desc */
.aw-sponsored-meta {
    margin: 6px 0 0 0;
    padding: 0;
}

.aw-sponsored-label {
    font-size: 14px;
    font-weight: 400;
    color: #757575; /* Passes WCAG AA on white background */
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

/* Optional description */
.aw-sponsored-desc {
    margin: 4px 0 0 0;
    padding: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: #777;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Sponsored card — minor variations from base .aw-card */
.aw-sponsored-card {
    position: relative;
}

/* Skeleton for sponsored section */
.aw-sponsored-skeleton .aw-skeleton-desc {
    margin-top: 6px;
    height: 12px;
    width: 60%;
    border-radius: 4px;
    background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
    background-size: 200% 100%;
    animation: awShimmer 1.4s ease-in-out infinite;
}
