/**
 * ANM Block Theme - Curated Query Custom Card Pattern
 * Scoped root: .anm-cq-custom-card & .anm-cq-grid-template
 */

.wp-block-post-template.anm-cq-grid-template,
ul.anm-cq-grid-template {
    display: grid !important;
    grid-template-columns: repeat(var(--anm-cq-desktop-cols, 3), minmax(0, 1fr)) !important;
    gap: var(--anm-cq-gap, 20px) !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}
@media (max-width: 768px) {
    .wp-block-post-template.anm-cq-grid-template,
    ul.anm-cq-grid-template {
        grid-template-columns: repeat(var(--anm-cq-tablet-cols, 2), minmax(0, 1fr)) !important;
    }
}
@media (max-width: 540px) {
    .wp-block-post-template.anm-cq-grid-template,
    ul.anm-cq-grid-template {
        grid-template-columns: repeat(var(--anm-cq-mobile-cols, 1), minmax(0, 1fr)) !important;
    }
}
.wp-block-post-template.anm-cq--compact-list,
ul.anm-cq--compact-list {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--anm-cq-gap, 14px) !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.anm-cq-custom-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 0 0 16px 0 !important;
    overflow: hidden;
    box-sizing: border-box;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.anm-cq-custom-card:not(:has(.wp-block-post-featured-image))::before {
    content: "AN MEDIA";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 0 0 14px 0 !important;
    border-radius: 0 !important;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid #f1f5f9;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.14em;
    box-sizing: border-box;
}

.anm-cq-custom-card * {
    box-sizing: border-box;
}

.anm-cq-custom-card:hover {
    transform: translateY(-4px);
    border-color: #cbd5e1;
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.08), 0 4px 8px -4px rgba(0, 0, 0, 0.04);
}

/* 1. Ảnh đại diện 16:9 */
.anm-cq-custom-card .wp-block-post-featured-image {
    margin: 0 0 14px 0 !important;
    overflow: hidden;
    border-radius: 0 !important;
    width: 100% !important;
    aspect-ratio: 16/9;
}

.anm-cq-custom-card .wp-block-post-featured-image img {
    transition: transform 0.4s ease;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.anm-cq-custom-card:hover .wp-block-post-featured-image img {
    transform: scale(1.05);
}

/* 2. Badge chuyên mục */
.anm-cq-custom-card .anm-cq-card-badge,
.anm-cq-custom-card .wp-block-post-terms {
    display: inline-flex;
    margin: 0 0 8px 0;
    padding-left: 18px !important;
    padding-right: 18px !important;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #e11d48;
}

.anm-cq-custom-card .anm-cq-card-badge a,
.anm-cq-custom-card .wp-block-post-terms a {
    color: inherit;
    text-decoration: none;
}

/* 3. Tiêu đề 2 dòng */
.anm-cq-custom-card .anm-cq-card-title,
.anm-cq-custom-card .wp-block-post-title {
    margin: 0 0 12px 0;
    padding-left: 18px !important;
    padding-right: 18px !important;
    font-size: 16.5px;
    font-weight: 700;
    line-height: 1.42;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.anm-cq-custom-card .anm-cq-card-title a,
.anm-cq-custom-card .wp-block-post-title a {
    color: #1e293b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.anm-cq-custom-card:hover .anm-cq-card-title a,
.anm-cq-custom-card:hover .wp-block-post-title a {
    color: #f59e0b;
}

/* 4. Meta row: Ngày tháng & Arrow */
.anm-cq-custom-card .anm-cq-card-meta {
    margin: auto 18px 0 18px !important;
    padding: 12px 0 0 0 !important;
    width: calc(100% - 36px) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #f1f5f9;
}

.anm-cq-custom-card .anm-cq-card-date,
.anm-cq-custom-card .wp-block-post-date {
    margin: 0;
    font-size: 12.5px;
    font-weight: 500;
    color: #94a3b8;
}

.anm-cq-custom-card .anm-cq-card-arrow {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #94a3b8;
    transition: transform 0.2s ease, color 0.2s ease;
}

.anm-cq-custom-card:hover .anm-cq-card-arrow {
    transform: translate(2px, -2px);
    color: #f59e0b;
}

/* Biến thể: Standard Card (Ảnh 4:5) */
.anm-cq-card--standard .wp-block-post-featured-image { aspect-ratio: 4/5; }

/* Biến thể: Overlay Card (Text nổi trên ảnh) */
.anm-cq-card--overlay {
    overflow: hidden;
    padding: 20px 18px;
    min-height: 280px;
    justify-content: flex-end;
    border-radius: 14px;
    border: none;
}
.anm-cq-card--overlay .wp-block-post-featured-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    aspect-ratio: unset;
}
.anm-cq-card--overlay .wp-block-post-featured-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.92) 0%, rgba(15, 23, 42, 0.45) 45%, transparent 85%);
    pointer-events: none;
}
.anm-cq-card--overlay > :not(.wp-block-post-featured-image) {
    position: relative;
    z-index: 1;
}
.anm-cq-card--overlay .anm-cq-card-badge,
.anm-cq-card--overlay .anm-cq-card-badge a { color: #fbbf24 !important; }
.anm-cq-card--overlay .anm-cq-card-title a { color: #ffffff !important; }
.anm-cq-card--overlay .anm-cq-card-date { color: #cbd5e1 !important; }

/* Biến thể: Compact List (Danh sách ngang) */
.anm-cq-compact-item {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 16px !important;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    margin: 0 !important;
    align-items: center !important;
}
.wp-block-post-template.anm-cq--compact-list > .wp-block-post {
    margin-bottom: 12px;
}
.anm-cq-compact-item > .wp-block-column:first-child {
    flex: 0 0 110px !important;
    max-width: 110px !important;
    margin: 0 !important;
}
.anm-cq-compact-item > .wp-block-column:last-child {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    margin: 0 !important;
}
.anm-cq-compact-item .wp-block-post-featured-image {
    margin: 0;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1/1;
    width: 110px;
    height: 110px;
}
.anm-cq-compact-item .anm-cq-card-badge,
.anm-cq-compact-item .wp-block-post-terms {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #e11d48;
    margin: 0 0 4px 0;
}
.anm-cq-compact-item .anm-cq-card-badge a,
.anm-cq-compact-item .wp-block-post-terms a { color: inherit; text-decoration: none; }
.anm-cq-compact-item .anm-cq-card-title {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}
.anm-cq-compact-item .anm-cq-card-title a { color: #1e293b; text-decoration: none; }
.anm-cq-compact-item .anm-cq-card-date { font-size: 12px; color: #94a3b8; margin: 0; }

/* ==========================================================================
   Compact Viewport Tuning (max-height: 650px and min-width: 900px)
   ========================================================================== */
@media (max-height: 650px) and (min-width: 900px) {
    .anm-cq-custom-card {
        padding: 10px;
        border-radius: 12px;
    }

    .anm-cq-custom-card .wp-block-post-featured-image {
        aspect-ratio: 16 / 8.5;
        margin-bottom: 8px;
    }

    .anm-cq-custom-card .anm-cq-card-title {
        font-size: 14.5px !important;
        margin-bottom: 4px;
    }
}

