/* ═══════════════════════════════════════════════════════
   BPTK Tabbed Blog Roll — Frontend Styles
   All theme colours are driven by CSS custom properties
   injected inline by the PHP shortcode renderer, making
   every [bptk_blog_roll id="X"] instance independently
   themeable.

   Property reference (set on .bptk-tbr):
     --tbr-accent         active tab bg, badges, cta glow
     --tbr-tab-bg         inactive tab background
     --tbr-tab-text       inactive tab text
     --tbr-card-bg        post card background
     --tbr-card-border    post card border
     --tbr-featured-bg    featured article background
     --tbr-featured-text  featured article text
     --tbr-load-more-bg   load more button background
═══════════════════════════════════════════════════════ */

/* ── Fallback defaults ──────────────────────────────── */

.bptk-tbr {
    --tbr-accent:            #2563eb;
    --tbr-tab-bg:            #f1f5f9;
    --tbr-tab-text:          #64748b;
    --tbr-card-bg:           #ffffff;
    --tbr-card-border:       #e2e8f0;
    --tbr-featured-bg:       #0f172a;
    --tbr-featured-title:    #ffffff;
    --tbr-featured-text:     #f8fafc;
    --tbr-load-more-bg:      #2563eb;
    --tbr-card-title-size:   16px;
    --tbr-card-excerpt-size: 13px;

    width: 100%;
    font-family: inherit;
    box-sizing: border-box;
}

.bptk-tbr *,
.bptk-tbr *::before,
.bptk-tbr *::after {
    box-sizing: inherit;
}

/* ══════════════════════════════════════════════════════
   FEATURED ARTICLE
══════════════════════════════════════════════════════ */

.bptk-tbr-featured {
    border-radius: 14px;
    overflow: hidden;
    background: var(--tbr-featured-bg);
    margin-bottom: 28px;
}

.bptk-tbr-featured-inner {
    display: flex;
    align-items: stretch;
    text-decoration: none !important;
    color: var(--tbr-featured-text) !important;
    min-height: 280px;
}

.bptk-tbr-featured-image-wrap {
    flex: 0 0 45%;
    overflow: hidden;
    max-height: 360px;
    min-height: 220px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Scale effect on hover via transform on the wrapper itself */
    transition: transform .4s ease;
}

.bptk-tbr-featured-inner:hover .bptk-tbr-featured-image-wrap {
    transform: scale(1.03);
}

.bptk-tbr-featured-content {
    flex: 1;
    padding: 36px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
}

.bptk-tbr-featured-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--tbr-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    border-radius: 20px;
    align-self: flex-start;
}

.bptk-tbr .bptk-tbr-featured-title {
    font-size: 26px !important;
    font-weight: 800 !important;
    line-height: 1.2em !important;
    color: var(--tbr-featured-title, #ffffff) !important;
    margin: 0 !important;
}

.bptk-tbr-featured-excerpt {
    font-size: 15px;
    line-height: 1.65;
    color: rgba(248,250,252,.7);
    margin: 0;
}

.bptk-tbr-featured-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.bptk-tbr-featured-date {
    font-size: 12.5px;
    color: rgba(248,250,252,.5);
}

.bptk-tbr-featured-cta {
    font-size: 13px;
    font-weight: 700;
    color: var(--tbr-accent);
    transition: letter-spacing .15s;
}

.bptk-tbr-featured-inner:hover .bptk-tbr-featured-cta {
    letter-spacing: .03em;
}

/* ══════════════════════════════════════════════════════
   TAB FILTERS
══════════════════════════════════════════════════════ */

.bptk-tbr-tabs-wrap {
    margin-bottom: 22px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.bptk-tbr-tabs-wrap::-webkit-scrollbar {
    display: none;
}

.bptk-tbr-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 2px;
    white-space: nowrap;
}

.bptk-tbr-tab {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border: 1.5px solid var(--tbr-card-border);
    border-radius: 24px;
    background: var(--tbr-tab-bg);
    color: var(--tbr-tab-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
    line-height: 1;
}

.bptk-tbr-tab:hover {
    border-color: var(--tbr-accent);
    color: var(--tbr-accent);
}

.bptk-tbr-tab.is-active {
    background: var(--tbr-accent);
    border-color: var(--tbr-accent);
    color: #fff;
}

.bptk-tbr-tab.is-loading {
    opacity: .6;
    cursor: wait;
}

/* ══════════════════════════════════════════════════════
   BODY LAYOUT  (grid + sidebar)
══════════════════════════════════════════════════════ */

.bptk-tbr-body {
    display: flex;
    align-items: flex-start;
    gap: 28px;
}

.bptk-tbr-main {
    flex: 1;
    min-width: 0;
}

/* ══════════════════════════════════════════════════════
   POST CARD GRID
══════════════════════════════════════════════════════ */

.bptk-tbr-grid {
    display: grid;
    gap: 22px;
}

/* 3 columns — no sidebar */
.bptk-tbr:not(.has-sidebar) .bptk-tbr-grid {
    grid-template-columns: repeat(3, 1fr);
}

/* 2 columns — sidebar visible */
.bptk-tbr.has-sidebar .bptk-tbr-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* Loading state: cards faded */
.bptk-tbr-grid.is-loading {
    opacity: .5;
    pointer-events: none;
    transition: opacity .2s;
}

/* ── Post card ──────────────────────────────────────── */

.bptk-tbr-card {
    background: var(--tbr-card-bg);
    border: 1px solid var(--tbr-card-border);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
}

.bptk-tbr-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,.1);
    border-color: var(--tbr-accent);
    transform: translateY(-2px);
}

.bptk-tbr-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none !important;
    color: inherit !important;
}

.bptk-tbr-card-image-wrap {
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.bptk-tbr-card-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.bptk-tbr-card:hover .bptk-tbr-card-img {
    transform: scale(1.04);
}

.bptk-tbr-card-body {
    flex: 1;
    padding: 16px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bptk-tbr-card-cat {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--tbr-accent);
}

.bptk-tbr .bptk-tbr-card-title {
    font-size: var(--tbr-card-title-size, 16px) !important;
    font-weight: 700 !important;
    line-height: 1.2em !important;
    color: #111827 !important;
    margin: 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bptk-tbr .bptk-tbr-card-excerpt {
    font-size: var(--tbr-card-excerpt-size, 13px) !important;
    line-height: 1.6 !important;
    color: #4b5563 !important;
    margin: 0 !important;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bptk-tbr-card-date {
    font-size: 11.5px;
    color: #9ca3af;
    margin-top: auto;
    padding-top: 4px;
}

/* ══════════════════════════════════════════════════════
   LOAD MORE
══════════════════════════════════════════════════════ */

.bptk-tbr-load-more-wrap {
    margin-top: 30px;
    display: flex;
    justify-content: center;
}

.bptk-tbr-load-more-wrap[hidden] {
    display: none;
}

.bptk-tbr-load-more {
    padding: 12px 36px;
    background: var(--tbr-load-more-bg);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease;
    line-height: 1;
}

.bptk-tbr-load-more:hover {
    filter: brightness(.88);
    transform: translateY(-1px);
}

.bptk-tbr-load-more:disabled {
    opacity: .6;
    cursor: wait;
    transform: none;
}

/* ══════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════ */

.bptk-tbr-sidebar {
    flex: 0 0 300px;
    min-width: 0;
}

.bptk-tbr-sidebar-inner {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Sticky state is applied entirely via JS (position:fixed) so it works
   even when ancestor elements have overflow:hidden (e.g. Breakdance sections).
   The .is-sticky class is kept as a JS hook — no CSS position rules here. */

/* ── Sidebar block ──────────────────────────────────── */

.bptk-tbr-sb-block {
    /* bg, border, shadow set inline via PHP */
    border-radius: 10px;
    overflow: hidden;
}

/* Optional block image (sits above inner content, edge-to-edge) */
.bptk-tbr-sb-image {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 0; /* block already clips via overflow:hidden */
}

.bptk-tbr .bptk-tbr-sb-inner {
    padding: 20px;
    font-size: var(--tbr-sb-t, 14px) !important;
    line-height: 1.65;
    color: var(--tbr-sb-text, #374151) !important;
}

/* Cascade heading size and title colour via CSS variables set inline */
.bptk-tbr .bptk-tbr-sb-inner h1,
.bptk-tbr .bptk-tbr-sb-inner h2,
.bptk-tbr .bptk-tbr-sb-inner h3,
.bptk-tbr .bptk-tbr-sb-inner h4,
.bptk-tbr .bptk-tbr-sb-inner h5,
.bptk-tbr .bptk-tbr-sb-inner h6 {
    font-size: var(--tbr-sb-h, 18px) !important;
    line-height: 1.2em !important;
    color: var(--tbr-sb-title, #111827) !important;
    margin-top: 0 !important;
}

/* Title heading rendered from the Title field (above HTML content) */
.bptk-tbr .bptk-tbr-sb-inner .bptk-tbr-sb-title {
    margin-bottom: 10px !important;
}

/* Paragraphs and generic text use body text colour */
.bptk-tbr .bptk-tbr-sb-inner p,
.bptk-tbr .bptk-tbr-sb-inner li,
.bptk-tbr .bptk-tbr-sb-inner span,
.bptk-tbr .bptk-tbr-sb-inner a:not(.bptk-tbr-sb-cta) {
    color: var(--tbr-sb-text, #374151) !important;
}

/* CTA button */
.bptk-tbr-sb-cta {
    display: block;
    margin-top: 14px;
    padding: 10px 16px;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 700;
    text-align: center;
    text-decoration: none !important;
    transition: filter .15s;
}

.bptk-tbr-sb-cta:hover {
    filter: brightness(.88);
}

/* ══════════════════════════════════════════════════════
   SKELETON / PLACEHOLDER CARDS (during AJAX load)
══════════════════════════════════════════════════════ */

@keyframes tbr-shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.bptk-tbr-skeleton {
    background: var(--tbr-card-bg);
    border: 1px solid var(--tbr-card-border);
    border-radius: 12px;
    overflow: hidden;
}

.bptk-tbr-skeleton-img {
    height: 160px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: tbr-shimmer 1.4s infinite;
}

.bptk-tbr-skeleton-body {
    padding: 16px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bptk-tbr-skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: tbr-shimmer 1.4s infinite;
}

.bptk-tbr-skeleton-line--short { width: 40%; }
.bptk-tbr-skeleton-line--med   { width: 70%; }
.bptk-tbr-skeleton-line--full  { width: 100%; }
.bptk-tbr-skeleton-title {
    height: 18px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: tbr-shimmer 1.4s infinite;
}

/* ══════════════════════════════════════════════════════
   MOBILE  (≤ 768 px)
══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Featured: stack image above content */
    .bptk-tbr-featured-inner {
        flex-direction: column;
        min-height: auto;
    }

    .bptk-tbr-featured-image-wrap {
        flex: none;
        height: 220px;  /* explicit height required when stacked vertically */
        max-height: 220px;
        min-height: 0;
    }

    .bptk-tbr-featured-content {
        padding: 22px 20px 24px;
        gap: 10px;
    }

    .bptk-tbr .bptk-tbr-featured-title {
        font-size: 20px !important;
    }

    /* Body: stack sidebar below posts */
    .bptk-tbr-body {
        flex-direction: column;
    }

    .bptk-tbr-sidebar {
        flex: none;
        width: 100%;
    }

    /* Disable sticky on mobile */
    .bptk-tbr-sidebar.is-sticky .bptk-tbr-sidebar-inner {
        position: static;
    }

    /* 2 columns on tablets (with or without sidebar) */
    .bptk-tbr:not(.has-sidebar) .bptk-tbr-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bptk-tbr.has-sidebar .bptk-tbr-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    /* Single column on small phones */
    .bptk-tbr .bptk-tbr-grid {
        grid-template-columns: 1fr !important;
    }

    .bptk-tbr-featured-content {
        padding: 18px 16px 20px;
    }

    .bptk-tbr .bptk-tbr-featured-title {
        font-size: 17px !important;
    }
}
