/* ── Reset ───────────────────────────────────────────────── */
.kf-wrap *, .kf-wrap *::before, .kf-wrap *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── CSS Variables ───────────────────────────────────────── */
.kf-wrap {
    --fb-blue:         #1877F2;
    --fb-blue-hover:   #1565d8;
    --fb-blue-light:   #e7f0fd;
    --fb-blue-mid:     #b3cef7;
    --fb-dark:         #050505;
    --fb-grey:         #65676B;
    --kf-radius:       12px;
    --kf-gap:          1rem;
    --kf-shadow:       0 2px 8px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --kf-shadow-hover: 0 12px 32px rgba(24,119,242,.18), 0 4px 12px rgba(0,0,0,.08);

    width: 94%;
    max-width: 1440px;
    margin: 3rem auto 3.5rem;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────── */
.kf-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    margin-bottom: 1.8rem;
}

.kf-header-title {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.kf-header-title h2 {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--fb-dark);
    letter-spacing: -.03em;
    white-space: nowrap;
}

html.dark .kf-header-title h2 {
    color: #ffffff;
}

.kf-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    background: var(--fb-blue);
    border-radius: 50%;
    flex-shrink: 0;
    animation: kf-blink 2.4s ease-in-out infinite;
}

@keyframes kf-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .3; transform: scale(.6); }
}

.kf-header-center {
    display: flex;
    justify-content: center;
}

.kf-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--fb-blue);
    background: var(--fb-blue-light);
    border: 1px solid var(--fb-blue-mid);
    padding: .32rem 1rem;
    border-radius: 100px;
}

.kf-badge svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* ── Grid ────────────────────────────────────────────────── */
.kf-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--kf-gap);
}

/* ── Card ────────────────────────────────────────────────── */
.kf-card {
    position: relative;
    display: block;
    border-radius: var(--kf-radius);
    overflow: hidden;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    text-decoration: none;
    background: #1a1a2e;
    box-shadow: var(--kf-shadow);
    border: 1px solid rgba(0,0,0,.06);
    transition: transform .28s cubic-bezier(.34,1.56,.64,1),
                box-shadow .28s ease,
                border-color .28s ease;
}

.kf-card:hover {
    transform: translateY(-5px) scale(1.015);
    box-shadow: var(--kf-shadow-hover);
    border-color: var(--fb-blue-mid);
}

/* Image */
.kf-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .45s ease;
}

.kf-card:hover .kf-card-img {
    transform: scale(1.06);
}

/* Placeholder */
.kf-card-placeholder {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kf-card-placeholder svg {
    width: 40px;
    height: 40px;
    color: rgba(255,255,255,.2);
}

/* Overlay */
.kf-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0,0,0,0.7) 0%,
        rgba(0,0,0,0.15) 45%,
        rgba(0,0,0,0.05) 100%
    );
    pointer-events: none;
}

/* Card body */
.kf-card-body {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1rem .9rem;
    display: flex;
    flex-direction: column;
    gap: .65rem;
    pointer-events: none;
}

.kf-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 4px rgba(0,0,0,.8);
}

/* Card row: title section and actions */
.kf-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
}

/* Stats container — always one row */
.kf-stats {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex: 1;
    min-width: 0;
}

.kf-stat {
    display: inline-flex;
    align-items: center;
    gap: .22rem;
    font-size: .75rem;
    font-weight: 600;
    color: #ffffff;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: .25rem .5rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.15);
    white-space: nowrap;
}

.kf-stat svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* View Button */
.kf-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .32rem;
    background: var(--fb-blue);
    color: #ffffff;
    font-size: .75rem;
    font-weight: 700;
    padding: .32rem .75rem;
    border-radius: 8px;
    white-space: nowrap;
    border: none;
    box-shadow: 0 2px 8px rgba(24,119,242,.4);
    transition: background .18s ease, transform .15s ease, box-shadow .18s ease;
    pointer-events: all;
    text-decoration: none;
    flex-shrink: 0;
}

.kf-card:hover .kf-view-btn {
    background: var(--fb-blue-hover);
    transform: scale(1.06);
    box-shadow: 0 4px 14px rgba(24,119,242,.55);
}

.kf-view-btn svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* Empty state */
.kf-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--fb-grey);
    background: transparent;
    border-radius: var(--kf-radius);
    border: 1.5px dashed #d0d5e0;
    font-size: .95rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.kf-empty-icon {
    color: #a0aabf;
    opacity: 0.7;
}

html.dark .kf-empty {
    border-color: #3e4042;
    color: #b0b3b8;
}

html.dark .kf-empty-icon {
    color: #55585d;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1200px) {
    .kf-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1024px) {
    .kf-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: .9rem;
    }
}

@media (max-width: 768px) {
    .kf-wrap {
        width: 96%;
        margin: 2rem auto;
    }

    .kf-header {
        grid-template-columns: 1fr;
        gap: .55rem;
    }

    .kf-header-title {
        justify-content: flex-start;
    }

    .kf-header-center {
        justify-content: flex-start;
    }

    .kf-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: .8rem;
    }

    .kf-card-title {
        font-size: .88rem;
    }

    .kf-card-body {
        padding: .75rem .75rem .7rem;
        gap: .5rem;
    }

    .kf-stat {
        font-size: .68rem;
        padding: .2rem .42rem;
        gap: .18rem;
    }

    .kf-view-btn {
        font-size: .68rem;
        padding: .28rem .65rem;
    }
}

@media (max-width: 600px) {
    .kf-wrap {
        width: 96%;
        margin: 1.5rem auto 2rem;
    }

    .kf-header {
        grid-template-columns: 1fr;
        gap: .5rem;
        margin-bottom: 1.5rem;
    }

    .kf-header-title h2 {
        font-size: 1.3rem;
    }

    .kf-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: .7rem;
    }

    .kf-card {
        aspect-ratio: 1 / 1;
    }

    .kf-card-body {
        padding: .65rem .65rem .6rem;
        gap: .5rem;
    }

    .kf-card-title {
        font-size: .78rem;
        -webkit-line-clamp: 2;
    }

    /* Keep stats in one row on mobile */
    .kf-card-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: .45rem;
    }

    .kf-stats {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .25rem;
        width: 100%;
        
    }

    .kf-stat {
        font-size: .62rem;
        padding: .18rem .38rem;
        gap: .15rem;
    }

    .kf-stat svg {
        width: 11px;
        height: 11px;
    }

    .kf-view-btn {
        font-size: .65rem;
        padding: .26rem .55rem;
        gap: .25rem;
    }

    .kf-view-btn svg {
        width: 11px;
        height: 11px;
    }
}

@media (max-width: 380px) {
    .kf-grid {
        gap: .6rem;
    }

    .kf-card-body {
        padding: .6rem .6rem .55rem;
        gap: .45rem;
    }

    .kf-card-title {
        font-size: .72rem;
    }

    .kf-stat {
        font-size: .58rem;
        padding: .16rem .32rem;
    }

    .kf-view-btn {
        font-size: .6rem;
        padding: .24rem .48rem;
    }
}
