/**
 * KS Blog Layout - Frontend Styles
 *
 * All customizable values use CSS custom properties (--kbl-*)
 * set via inline styles from admin settings.
 *
 * @package KS_Blog_Layout
 * @since 1.0.0
 */

/* ═══════════════════════════════════════════
   RESET SCOPE
   ═══════════════════════════════════════════ */
.kbl-blog-wrap *,
.kbl-blog-wrap *::before,
.kbl-blog-wrap *::after {
    box-sizing: border-box;
}

.kbl-blog-wrap a {
    text-decoration: none;
    color: inherit;
}

.kbl-blog-wrap img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ═══════════════════════════════════════════
   BLOG WRAP (page background)
   ═══════════════════════════════════════════ */
.kbl-blog-wrap {
    font-family: var(--kbl-font-body, 'DM Sans', sans-serif);
    font-size: var(--kbl-body-size, 15px);
    color: var(--kbl-text, #2d2d2d);
    background-color: var(--kbl-bg, #f8f7f5);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 60px;
}

/* ═══════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════ */
.kbl-page-header {
    text-align: center;
    padding: 48px 20px 40px;
}

.kbl-page-header h1 {
    font-family: var(--kbl-font-heading, 'DM Serif Display', serif);
    font-weight: 400;
    color: var(--kbl-text, #2d2d2d);
    letter-spacing: -0.5px;
    margin: 0;
    padding: 0;
    line-height: 1.2;
}

/* ═══════════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════════ */
.kbl-container {
    max-width: var(--kbl-container-max, 1280px);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: var(--kbl-gap, 40px);
    align-items: flex-start;
}

.kbl-content {
    flex: 0 0 var(--kbl-content-ratio, 65%);
    max-width: var(--kbl-content-ratio, 65%);
    min-width: 0;
}

/* v1.2.0: when sidebar is disabled, content fills the full width */
.kbl-container.kbl-no-sidebar .kbl-content {
    flex: 0 0 100%;
    max-width: 100%;
}

.kbl-sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 28px;
    align-self: flex-start;
}

/* ════════════════════════════════
   POST ITEM + TITLE ABOVE CARD (v1.2.0)
   ════════════════════════════════ */
.kbl-post-item {
    margin-bottom: 36px;
}

.kbl-post-title-outer {
    font-family: var(--kbl-font-heading, 'DM Serif Display', serif);
    font-size: var(--kbl-post-title-size, 24px);
    font-weight: 400;
    line-height: 1.3;
    color: var(--kbl-post-title-color, #2d2d2d);
    text-align: var(--kbl-post-title-align, left);
    margin: 0 0 12px 0;
    padding: 0;
}
.kbl-post-title-outer a {
    color: inherit;
    transition: color 0.25s;
}

.kbl-post-title-outer a:hover {
    color: var(--kbl-accent, #c0392b);
}

/* ════════════════════════════════
   FEATURED + GRID LAYOUT (v1.2.0)
   ════════════════════════════════ */
.kbl-featured .kbl-post-item {
    margin-bottom: 36px;
}

.kbl-posts-grid {
    display: grid;
    grid-template-columns: repeat(var(--kbl-grid-columns, 4), 1fr);
    gap: var(--kbl-gap, 40px);
}

/* Grid items: each item is a flex column so the title takes its natural
   height and the card fills the REMAINING cell height. Grid already makes
   all cells in a row equal height, so every card ends up aligned. */
.kbl-posts-grid .kbl-post-item {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

/* Grid titles: clamp to max 2 lines (ellipsis) and reserve a fixed 2-line
   min-height so every card starts at the same vertical position regardless
   of whether the title is 1 or 2 lines. 2.6em = 2 × line-height (1.3). */
.kbl-posts-grid .kbl-post-title-outer {
    min-height: 2.6em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* The clamp must apply to the inline content; keep the link inheriting. */
.kbl-posts-grid .kbl-post-title-outer a {
    display: inline;
}

/* Card fills the leftover space below the title.
   Using flex:1 instead of height:100% — height:100% would resolve against
   the whole grid cell and make the card overflow past its item. */
.kbl-posts-grid .kbl-post-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kbl-posts-grid .kbl-post-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kbl-posts-grid .kbl-post-footer {
    margin-top: auto;
}

/* ═══════════════════════════════════════════
   BLOG CARDS
   ═══════════════════════════════════════════ */
.kbl-post-card {
    background: var(--kbl-card-bg, #ffffff);
    border-radius: var(--kbl-card-radius, 10px);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    margin-bottom: 36px;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.kbl-post-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(-3px);
}

/* Thumbnail */
.kbl-post-thumb {
    display: block;
    width: 100%;
    height: var(--kbl-image-height, 320px);
    overflow: hidden;
}

.kbl-post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.kbl-post-card:hover .kbl-post-thumb img {
    transform: scale(1.04);
}

/* Body */
.kbl-post-body {
    padding: 28px 32px 32px;
}

/* Title (legacy v1.1.0 — title inside card. Kept for backwards compat;
   v1.2.0 renders the title via .kbl-post-title-outer above the card.) */
.kbl-post-title {
    font-family: var(--kbl-font-heading, 'DM Serif Display', serif);
    font-size: var(--kbl-title-size, 26px);
    font-weight: 400;
    line-height: 1.35;
    margin: 0 0 14px 0;
    padding: 0;
    color: var(--kbl-text, #2d2d2d);
}

.kbl-post-title a {
    color: inherit;
    transition: color 0.25s;
}

.kbl-post-title a:hover {
    color: var(--kbl-accent, #c0392b);
}

/* Excerpt */
.kbl-post-excerpt {
    color: var(--kbl-text-light, #6b6b6b);
    line-height: 1.7;
    margin-bottom: 20px;
}

.kbl-post-excerpt p {
    margin: 0;
}

/* Footer */
.kbl-post-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

/* Read More Button */
.kbl-read-more {
    display: inline-block;
    background: var(--kbl-btn-bg, #c0392b);
    color: var(--kbl-btn-text, #ffffff);
    padding: 10px 24px;
    border-radius: var(--kbl-btn-radius, 6px);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background 0.25s ease, transform 0.2s ease;
    font-family: var(--kbl-font-body, 'DM Sans', sans-serif);
}

.kbl-read-more:hover {
    background: var(--kbl-accent-hover, #a93226);
    color: var(--kbl-btn-text, #ffffff);
    transform: translateY(-1px);
}

/* Post Meta */
.kbl-post-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: var(--kbl-meta-size, 13px);
    color: var(--kbl-text-light, #6b6b6b);
}

.kbl-post-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.kbl-post-meta svg {
    width: 14px;
    height: 14px;
    opacity: 0.5;
}

/* Category Tag */
.kbl-tag {
    display: inline-block;
    background: var(--kbl-tag-bg, #f0eeea);
    color: var(--kbl-tag-text, #555);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.kbl-tag:hover {
    background: var(--kbl-border, #e8e6e1);
    color: var(--kbl-tag-text, #555);
}

/* ═══════════════════════════════════════════
   NO POSTS
   ═══════════════════════════════════════════ */
.kbl-no-posts {
    text-align: center;
    padding: 60px 20px;
    background: var(--kbl-card-bg, #ffffff);
    border-radius: var(--kbl-card-radius, 10px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.kbl-no-posts h2 {
    font-family: var(--kbl-font-heading, serif);
    margin-bottom: 10px;
}

.kbl-no-posts p {
    color: var(--kbl-text-light, #6b6b6b);
}

/* ═══════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════ */
.kbl-pagination {
    margin-top: 10px;
    text-align: center;
}

.kbl-pagination .page-numbers {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.kbl-pagination .page-numbers li {
    display: inline-flex;
}

.kbl-pagination .page-numbers a,
.kbl-pagination .page-numbers span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--kbl-border, #e8e6e1);
    background: var(--kbl-pag-bg, #ffffff);
    color: var(--kbl-pag-text, #2d2d2d);
    transition: all 0.2s;
    font-family: var(--kbl-font-body, sans-serif);
}

.kbl-pagination .page-numbers a:hover {
    border-color: var(--kbl-pag-active-bg, #c0392b);
    color: var(--kbl-pag-active-bg, #c0392b);
}

.kbl-pagination .page-numbers .current {
    background: var(--kbl-pag-active-bg, #c0392b);
    color: var(--kbl-pag-active-text, #ffffff);
    border-color: var(--kbl-pag-active-bg, #c0392b);
}

/* ═══════════════════════════════════════════
   SIDEBAR – Widgets
   ═══════════════════════════════════════════ */
.kbl-widget {
    background: var(--kbl-sidebar-bg, #ffffff);
    border-radius: var(--kbl-card-radius, 10px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.kbl-widget-title {
    font-family: var(--kbl-font-heading, serif);
    font-size: var(--kbl-sidebar-title-size, 18px);
    font-weight: 400;
    padding: 20px 24px 0;
    margin: 0;
    color: var(--kbl-text, #2d2d2d);
}

/* ═══════════════════════════════════════════
   SIDEBAR – Recent Articles
   ═══════════════════════════════════════════ */
.kbl-recent-list {
    padding: 16px 24px 20px;
}

.kbl-recent-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--kbl-border, #e8e6e1);
    transition: opacity 0.2s;
}

.kbl-recent-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.kbl-recent-item:hover {
    opacity: 0.8;
}

.kbl-recent-thumb {
    width: 72px;
    height: 54px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.kbl-recent-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kbl-recent-info {
    flex: 1;
    min-width: 0;
}

.kbl-recent-info h4 {
    font-family: var(--kbl-font-body, sans-serif);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 4px 0;
    padding: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--kbl-text, #2d2d2d);
}

.kbl-recent-item:hover h4 {
    color: var(--kbl-accent, #c0392b);
}

.kbl-recent-date {
    font-size: 12px;
    color: var(--kbl-text-light, #6b6b6b);
}

/* ═══════════════════════════════════════════
   SIDEBAR – Social Links
   ═══════════════════════════════════════════ */
.kbl-social-list {
    padding: 16px 24px 20px;
    display: flex;
    flex-direction: column;
}

.kbl-social-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 0;
    border-bottom: 1px solid var(--kbl-border, #e8e6e1);
    transition: opacity 0.2s;
}

.kbl-social-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.kbl-social-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kbl-social-icon {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.kbl-social-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.kbl-social-name {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--kbl-text, #2d2d2d);
}

.kbl-social-follow {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--kbl-text-light, #6b6b6b);
    transition: color 0.2s;
}

.kbl-social-item:hover .kbl-social-follow {
    color: var(--kbl-accent, #c0392b);
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 991px) {
    .kbl-container {
        flex-direction: column;
    }

    .kbl-content {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .kbl-sidebar {
        position: static !important;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .kbl-sidebar .kbl-widget {
        flex: 1 1 280px;
    }

    /* v1.2.0: grid drops to max 2 columns on tablet */
    .kbl-posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575px) {
    .kbl-page-header {
        padding: 30px 15px 25px;
    }

    .kbl-page-header h1 {
        font-size: 30px !important;
    }

    .kbl-post-body {
        padding: 20px;
    }

    .kbl-post-title {
        font-size: 21px !important;
    }

    .kbl-post-thumb {
        height: 220px !important;
    }

    .kbl-post-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .kbl-sidebar {
        flex-direction: column;
    }

    .kbl-container {
        padding: 0 15px;
    }

    /* v1.2.0: grid collapses to single column on mobile */
    .kbl-posts-grid {
        grid-template-columns: 1fr;
    }
}
