/* ============================================================================
 * TopTan Wholesale — Blog redesign (grid listing + single post)
 * Source: design_handoff — "Blog.dc.html" / "Blog Mobile.dc.html".
 *
 * GOLDEN RULE: every colour references the admin-editable design tokens
 * (--brand / --ink / --surface / --border … from toptan-tokens.css →
 * base.blade.php :root), never a hard-coded hex. Loads LAST in config.php so
 * it wins over inherited b2b.css / fbl-*.css / toptan-pages.css.
 *
 * Scopes: `.tt-blog` (listing) and `.tt-post` (single article). Both break
 * out of the legacy Botble column/sidebar grid via :has() so the theme
 * layouts stay untouched.
 * ========================================================================== */

:root {
    /* Local derivations off the shared tokens — kept here so the palette
     * source of truth stays the Theme-Options vars. */
    --tt-blog-meta: color-mix(in srgb, var(--ink-3) 76%, var(--bg));      /* dates, view counts (#9AA5A1-ish) */
    --tt-blog-prose: color-mix(in srgb, var(--ink) 55%, var(--ink-2));    /* article body (#33403C-ish) */
    --tt-blog-tag-bg: color-mix(in srgb, var(--bg) 55%, var(--surface));  /* neutral tag pill (#F4F6F5-ish) */
}

/* ---------------------------------------------------------------------------
 * Break out of the legacy layout: the listing template renders inside
 * `.col-lg-9` next to a `.col-lg-3` widget sidebar; the single post renders
 * inside `.col-lg-9.m-auto`. The redesign is full-width / self-contained, so
 * neutralise the wrapping column and hide the legacy blog sidebar.
 * ------------------------------------------------------------------------- */
.row:has(> .col-lg-9 > .tt-blog) > .col-lg-3.primary-sidebar { display: none; }
.row:has(> .col-lg-9 > .tt-blog) > .col-lg-9,
.row:has(> .col-lg-9 > .tt-post) > .col-lg-9 {
    flex: 0 0 100%;
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

.tt-blog *,
.tt-post * { box-sizing: border-box; }

.tt-blog a,
.tt-post a { text-decoration: none; }

/* ===========================================================================
 * BLOG LISTING (grid)
 * ======================================================================== */
.tt-blog {
    max-width: 1180px;
    margin: 0 auto;
    padding: 8px 0 24px;
    font-family: var(--font-text);
    color: var(--ink);
}

/* --- Featured hero card --- */
.tt-blog-featured {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card, 12px);
    overflow: hidden;
    color: var(--ink);
    /* Breathing room before the post grid below (the grid's `gap` only spaces
       its own items, not its top edge). */
    margin-bottom: 20px;
    transition: box-shadow .18s ease, transform .18s ease;
}
.tt-blog-featured:hover { box-shadow: var(--shadow-hover); color: var(--ink); transform: translateY(-2px); }
.tt-blog-featured__media {
    position: relative;
    min-height: 260px;
    background: var(--tt-blog-tag-bg) center/cover no-repeat;
}
.tt-blog-featured__badge {
    position: absolute;
    top: 14px;
    inset-inline-start: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--brand-deep);
    color: #fff;
    border-radius: var(--r-pill, 999px);
    padding: 5px 12px;
    font-size: 10.5px;
    font-weight: var(--fw-bold, 700);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.tt-blog-featured__body {
    padding: 32px 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.tt-blog-featured__title {
    font-size: 23px;
    font-weight: var(--fw-bold, 700);
    margin: 12px 0 0;
    letter-spacing: -0.015em;
    line-height: 1.3;
    color: var(--ink);
    text-wrap: balance;
}
.tt-blog-featured__excerpt {
    font-size: 13.5px;
    color: var(--ink-3);
    margin: 10px 0 0;
    line-height: 1.6;
}

/* --- Category chips --- */
.tt-blog-chips {
    display: flex;
    gap: 8px;
    margin: 22px 0 18px;
    flex-wrap: wrap;
}
.tt-chip {
    padding: 8px 16px;
    border-radius: var(--r-pill, 999px);
    font-size: 12.5px;
    font-weight: var(--fw-semibold, 600);
    cursor: pointer;
    background: var(--surface);
    color: var(--ink-2);
    border: 1px solid var(--border);
    white-space: nowrap;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.tt-chip:hover { border-color: var(--brand); color: var(--brand); }
.tt-chip.is-active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.tt-chip.is-active:hover { color: #fff; }

/* --- Post grid --- */
.tt-blog-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}
.tt-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card, 12px);
    overflow: hidden;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    transition: box-shadow .18s ease, transform .18s ease;
}
.tt-card:hover { box-shadow: var(--shadow-hover); color: var(--ink); transform: translateY(-2px); }
.tt-card__media {
    height: 150px;
    background: var(--tt-blog-tag-bg) center/cover no-repeat;
    flex: none;
}
.tt-card__body {
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.tt-card__title {
    font-size: 15px;
    font-weight: var(--fw-semibold, 600);
    margin-top: 9px;
    line-height: 1.4;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tt-card__excerpt {
    font-size: 12px;
    color: var(--ink-3);
    margin-top: 6px;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tt-card__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.tt-card__author { font-size: 11.5px; color: var(--ink-2); font-weight: var(--fw-medium, 500); }

/* --- Shared meta row (tag pill + date) --- */
.tt-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tt-tag {
    background: var(--brand-tint);
    color: var(--brand);
    border-radius: var(--r-badge, 4px);
    padding: 2px 8px;
    font-size: 10px;
    font-weight: var(--fw-semibold, 600);
}
.tt-tag--lg { padding: 3px 10px; font-size: 10.5px; }
.tt-date { font-size: 11px; color: var(--tt-blog-meta); }

/* --- Author byline chip --- */
.tt-byline { display: flex; gap: 9px; align-items: center; margin-top: 14px; }
.tt-avatar {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--brand-tint) center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-bold, 700);
    color: var(--brand);
    font-size: 10px;
    flex: none;
}
.tt-avatar--sm { width: 24px; height: 24px; border-radius: 6px; font-size: 9px; }
.tt-byline__name { font-size: 12px; color: var(--ink-2); font-weight: var(--fw-medium, 500); }
.tt-byline__more {
    margin-inline-start: auto;
    font-size: 12.5px;
    font-weight: var(--fw-semibold, 600);
    color: var(--brand);
    white-space: nowrap;
}

/* --- Newsletter band --- */
.tt-news {
    background: var(--brand-deep);
    border-radius: var(--r-card, 12px);
    padding: 28px 36px;
    display: flex;
    align-items: center;
    gap: 28px;
    margin-top: 28px;
    flex-wrap: wrap;
    row-gap: 18px;
}
.tt-news__copy { flex: 1; min-width: 240px; }
.tt-news__title { font-size: 17px; font-weight: var(--fw-semibold, 600); color: #fff; }
.tt-news__sub {
    font-size: 12.5px;
    color: color-mix(in srgb, #fff 72%, var(--brand-deep));
    margin-top: 4px;
}
.tt-news__form { display: flex; flex: none; }
.tt-news__form .form-subscribe,
.tt-news__form .newsletter-form { display: flex; width: 100%; }
.tt-news__form input[type="email"],
.tt-news__form input[type="text"] {
    border: none;
    border-radius: var(--r-control, 6px) 0 0 var(--r-control, 6px);
    padding: 12px 16px;
    font-size: 13.5px;
    font-family: inherit;
    width: 240px;
    min-width: 0;
}
.tt-news__form input:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, #fff 40%, transparent); }
.tt-news__form button,
.tt-news__form .btn {
    background: #fff;
    color: var(--brand);
    border: none;
    border-radius: 0 var(--r-control, 6px) var(--r-control, 6px) 0;
    padding: 0 20px;
    font-size: 13.5px;
    font-weight: var(--fw-semibold, 600);
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.tt-news__form button:hover,
.tt-news__form .btn:hover { background: #fff; color: var(--brand-deep); }

/* Pagination spacing */
.tt-blog .pagination-area,
.tt-blog nav[role="navigation"] { margin-top: 28px; }

/* Optically centre the page numbers/arrows inside their circles. The inherited
   base theme forces `line-height: 40px !important` onto a 34px-tall button, which
   pushes the glyph off-centre; reset it and let flexbox do the centring. The long
   selector + `!important` are needed to beat that base `!important` rule. */
.tt-blog .pagination-area .pagination .page-item .page-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    padding: 0 !important;
}

/* ===========================================================================
 * SINGLE POST
 * ======================================================================== */
.tt-post {
    max-width: 1080px;
    margin: 0 auto;
    padding: 8px 0 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 40px;
    align-items: start;
    font-family: var(--font-text);
    color: var(--ink);
}
.tt-post__crumbs {
    font-size: 13px;
    color: var(--ink-3);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.tt-post__crumbs a { color: var(--ink-3); }
.tt-post__crumbs a:hover { color: var(--brand); }
.tt-post__crumbs .current { color: var(--ink); font-weight: var(--fw-medium, 500); }

.tt-post__cat { margin-top: 16px; }
.tt-post__title {
    font-size: 32px;
    font-weight: var(--fw-bold, 700);
    margin: 14px 0 0;
    letter-spacing: -0.02em;
    line-height: 1.22;
    text-wrap: balance;
    color: var(--ink);
}
.tt-post__cat + .tt-post__title { margin-top: 10px; }

.tt-post__head { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.tt-post__head .tt-avatar { width: 36px; height: 36px; border-radius: 8px; font-size: 12px; }
.tt-post__author { font-size: 13px; font-weight: var(--fw-semibold, 600); color: var(--ink); }
.tt-post__author-meta { font-size: 11.5px; color: var(--tt-blog-meta); }
.tt-post__actions { margin-left: auto; display: flex; gap: 8px; }
.tt-post__btn {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-control, 6px);
    padding: 8px 14px;
    font-size: 12px;
    font-weight: var(--fw-semibold, 600);
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: border-color .15s ease, color .15s ease;
}
.tt-post__btn:hover { border-color: var(--brand); color: var(--brand); }

.tt-post__hero {
    border-radius: var(--r-card, 12px);
    background: var(--tt-blog-tag-bg) center/cover no-repeat;
    margin-top: 20px;
    aspect-ratio: 16 / 8;
    width: 100%;
}

/* Article prose */
.tt-post__body {
    font-size: 15px;
    line-height: 1.75;
    color: var(--tt-blog-prose);
    margin-top: 24px;
    max-width: 680px;
}
.tt-post__body p { margin: 0 0 18px; }
.tt-post__body > p:first-of-type { font-size: 17px; line-height: 1.65; color: var(--ink); }
.tt-post__body h2 {
    font-size: 20px;
    font-weight: var(--fw-semibold, 600);
    margin: 26px 0 10px;
    letter-spacing: -0.01em;
    color: var(--ink);
    scroll-margin-top: 90px;
}
.tt-post__body h3 {
    font-size: 17px;
    font-weight: var(--fw-semibold, 600);
    margin: 22px 0 8px;
    color: var(--ink);
    scroll-margin-top: 90px;
}
.tt-post__body img { max-width: 100%; height: auto; border-radius: var(--r-card, 10px); }
.tt-post__body ul,
.tt-post__body ol { margin: 0 0 18px; padding-left: 22px; }
.tt-post__body li { margin-bottom: 6px; }
.tt-post__body a { color: var(--brand); text-decoration: underline; }
.tt-post__body blockquote,
.tt-post__body .tt-callout {
    background: var(--brand-tint);
    border-left: 3px solid var(--brand);
    border-radius: 0 8px 8px 0;
    padding: 14px 20px;
    margin: 0 0 18px;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--ink);
}

/* Tags */
.tt-post__tags { display: flex; gap: 6px; margin-top: 26px; flex-wrap: wrap; align-items: center; }
.tt-post__tags-label {
    font-size: 11.5px;
    font-weight: var(--fw-semibold, 600);
    color: var(--tt-blog-meta);
    margin-inline-end: 2px;
}
.tt-post__tags a {
    background: var(--tt-blog-tag-bg);
    color: var(--ink-2);
    border: 1px solid var(--border);
    border-radius: var(--r-badge, 4px);
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: var(--fw-medium, 500);
}
.tt-post__tags a:hover { border-color: var(--brand); color: var(--brand); }

/* Sidebar */
.tt-post__aside {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.tt-aside-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card, 12px);
    padding: 18px 20px;
}
.tt-aside-card__title {
    font-size: 11px;
    font-weight: var(--fw-bold, 700);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 12px;
    color: var(--ink-3);
}
.tt-toc-list { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.tt-toc-list a {
    color: var(--ink-2);
    padding: 4px 0 4px 12px;
    border-inline-start: 2px solid transparent;
}
.tt-toc-list a:hover { color: var(--brand); }
.tt-toc-list a.is-active {
    color: var(--brand);
    font-weight: var(--fw-semibold, 600);
    border-inline-start-color: var(--brand);
}

.tt-related { display: flex; flex-direction: column; gap: 12px; }
.tt-related a { display: flex; gap: 10px; color: var(--ink); align-items: center; }
.tt-related a:hover .tt-related__title { color: var(--brand); }
.tt-related__thumb {
    width: 52px;
    height: 40px;
    border-radius: 6px;
    background: var(--tt-blog-tag-bg) center/cover no-repeat;
    flex: none;
}
.tt-related__title { font-size: 12px; font-weight: var(--fw-medium, 500); line-height: 1.4; }

.tt-aside-cta { background: linear-gradient(135deg, var(--brand-deep), var(--brand)); border-radius: var(--r-card, 12px); padding: 18px 20px; }
.tt-aside-cta__title { font-size: 13px; font-weight: var(--fw-semibold, 600); color: #fff; }
.tt-aside-cta__sub {
    font-size: 11.5px;
    color: color-mix(in srgb, #fff 72%, var(--brand-deep));
    margin-top: 4px;
    line-height: 1.5;
}
.tt-aside-cta__btn {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 10px;
    background: #fff;
    color: var(--brand);
    border: none;
    border-radius: var(--r-control, 6px);
    padding: 10px 0;
    font-size: 12px;
    font-weight: var(--fw-semibold, 600);
    cursor: pointer;
}
.tt-aside-cta__btn:hover { color: var(--brand-deep); }

/* ===========================================================================
 * RESPONSIVE — tablet & mobile
 * ======================================================================== */
@media (max-width: 991px) {
    .tt-blog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tt-post { grid-template-columns: 1fr; gap: 24px; }
    .tt-post__aside { position: static; }
}

@media (max-width: 640px) {
    .tt-blog { padding: 4px 0 16px; }
    .tt-blog-featured { grid-template-columns: 1fr; }
    .tt-blog-featured__media { min-height: 160px; }
    .tt-blog-featured__body { padding: 16px; }
    .tt-blog-featured__title { font-size: 17px; }

    /* Chips: horizontal scroll strip */
    .tt-blog-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        margin: 4px -16px 16px;
        padding: 0 16px;
    }
    .tt-blog-chips::-webkit-scrollbar { display: none; }
    .tt-chip { flex: none; padding: 8px 14px; font-size: 12px; }

    /* Grid → stacked horizontal list cards */
    .tt-blog-grid { grid-template-columns: 1fr; gap: 10px; }
    .tt-card { flex-direction: row; gap: 12px; padding: 12px 14px; border-radius: 10px; }
    .tt-card__media {
        width: 88px;
        height: 68px;
        border-radius: 7px;
        align-self: center;
    }
    .tt-card__body { padding: 0; min-width: 0; }
    .tt-card__title { font-size: 13.5px; margin-top: 5px; }
    .tt-card__excerpt { display: none; }
    .tt-card__foot { display: none; }

    .tt-news { flex-direction: column; align-items: stretch; gap: 12px; padding: 20px; }
    .tt-news__form input[type="email"],
    .tt-news__form input[type="text"] { width: auto; flex: 1; }

    .tt-post__title { font-size: 22px; }
    .tt-post__body { font-size: 14.5px; }
    .tt-post__actions .tt-post__btn span { display: none; }
}

/* ===========================================================================
 * RTL
 * ======================================================================== */
[dir="rtl"] .tt-blog-featured { grid-template-columns: 1fr 1.3fr; }
[dir="rtl"] .tt-post__body blockquote,
[dir="rtl"] .tt-post__body .tt-callout {
    border-left: none;
    border-right: 3px solid var(--brand);
    border-radius: 8px 0 0 8px;
}
[dir="rtl"] .tt-post__actions { margin-left: 0; margin-right: auto; }
@media (max-width: 640px) {
    [dir="rtl"] .tt-blog-featured { grid-template-columns: 1fr; }
}
