/* ================================================================
   PISTON TRIBE — BLOG STYLES
   Extends product-archive-layout.css (layout skeleton is shared).
   All .pt-archive-page / .pt-archive-layout / .pt-archive-sidebar /
   .pt-archive-topbar / .pt-archive-sort-select classes come from
   product-archive-layout.css — do not duplicate them here.
   ================================================================ */

/* ================================================================
   BLOG PAGE WRAPPER OVERRIDES — desktop only
   Mobile keeps product-archive-layout.css padding-top: 0 so the
   mobile bar sits flush against the site header on initial load.
   ================================================================ */
@media (min-width: 901px) {
    /* Tighten the top gap */
    .pt-archive-page {
        padding-top: 8px;
    }
    /* Reduce gap between top of page and the two-column layout */
    .pt-archive-layout {
        padding-top: 12px;
    }
}

/* ── Sidebar: flex column so filter scrolls within sticky viewport space ── */
.pt-archive-sidebar:not(.has-cat-header),
.pt-archive-sidebar.has-cat-header {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 30px); /* 30px = sidebar sticky top */
}

/* ── Breadcrumb inside sidebar ──
   Override product-archive-layout.css max-width / margin: auto centering.
   overflow-x: auto + white-space: nowrap allow horizontal scroll if needed. */
.pt-archive-sidebar .pt-archive-breadcrumb {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 10px 20px 12px;
    flex-shrink: 0;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none; /* hide scrollbar — scroll is a fallback only */
}
.pt-archive-sidebar .pt-archive-breadcrumb::-webkit-scrollbar { display: none; }

/* Homepage sidebar only: breadcrumb acts as the topbar counterpart.
   min-height: 69px = select height (~36px) + topbar padding-bottom (14px)
   + topbar margin-bottom (20px) — so the filter card starts level with
   the top of the post grid. Category pages have H1+desc above, so they
   don't need this override. */
.pt-archive-sidebar:not(.has-cat-header) .pt-archive-breadcrumb {
    min-height: 69px;
}

/* ── Mobile overrides ── */
@media (max-width: 900px) {
    /* Stick mobile bar immediately below the site header (header ≈ 48px) */
    .pt-archive-mobile-bar {
        top: 48px;
    }

    /* Ensure no padding gap between header and mobile bar on initial load */
    .pt-archive-page {
        padding-top: 0;
    }

    /* Category archive: reveal sidebar for H1 only; filter is in the popup */
    .pt-archive-sidebar.has-cat-header {
        display: block;
        position: static;
        width: 100%;
        max-height: none;
        margin-top: 0;
    }
    .pt-archive-sidebar.has-cat-header .pt-blog-filter {
        display: none;
    }
}

/* ================================================================
   BREADCRUMBS — match WooCommerce breadcrumb appearance
   product-archive-layout.css targets .woocommerce-breadcrumb;
   blog uses a plain <nav> so we replicate the same rules here.
   ================================================================ */
.pt-archive-breadcrumb nav {
    font-size: 0.82rem;
    color: #65676b;
}
.pt-archive-breadcrumb nav a {
    color: #65676b;
    text-decoration: none;
}
.pt-archive-breadcrumb nav a:hover {
    color: #050505;
}
.pt-archive-breadcrumb nav span[aria-hidden] {
    margin: 0 4px;
    color: #bcc0c4;
}

/* ================================================================
   BLOG FILTER — applies in BOTH desktop sidebar and mobile popup
   Scoped to .pt-blog-filter so the popup gets identical styles.
   product-archive-layout.css scopes equivalent rules to
   .pt-archive-sidebar, which doesn't cover the popup context.
   ================================================================ */

/* ── Card wrapper (sidebar only — popup has its own container) ── */
.pt-archive-sidebar .pt-blog-filter {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e4e6eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;        /* fill remaining sidebar height in flex context */
    min-height: 0;  /* allow flex item to shrink so overflow kicks in */
    scrollbar-width: thin;
}
.pt-archive-sidebar .pt-blog-filter::-webkit-scrollbar { width: 6px; }
.pt-archive-sidebar .pt-blog-filter::-webkit-scrollbar-track { background: transparent; }
.pt-archive-sidebar .pt-blog-filter::-webkit-scrollbar-thumb { background: #bcc0c4; border-radius: 4px; }
.pt-archive-sidebar .pt-blog-filter::-webkit-scrollbar-thumb:hover { background: #a0a3a7; }

/* "Clear filters" link */
#pt-blog-unselect-all {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #65676b;
    padding: 12px 20px 0;
    cursor: pointer;
    margin: 0;
    display: block;
}
#pt-blog-unselect-all:hover { color: #050505; }

/* ── Filter groups ── */
.pt-blog-filter .filter-group {
    border-bottom: 1px solid #e4e6eb;
    margin-bottom: 0;
    padding-bottom: 0;
}
.pt-blog-filter .filter-group:last-child { border-bottom: none; }

/* ── Toggle header ── */
.pt-blog-filter h4.filter-toggle {
    font-size: 0.78rem;
    font-weight: 800;
    color: #050505;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 13px 20px;
    margin: 0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    background: #f5f6f7;
    transition: background 0.15s;
}
.pt-blog-filter h4.filter-toggle:hover { background: #edeef0; }

/* ── Parent-category label (inside the h4, not .filter-content) ──
   product-archive-layout.css only flexes labels inside .filter-content;
   this rule covers the parent-level label that sits inside the h4 header.
   flex:1 pushes the toggle icon to the far right.
   ── */
.pt-blog-filter h4.filter-toggle .pt-blog-cat-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: #050505;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

/* ── Toggle icon ──
   Override the 0.7rem set by product-archive-layout.css.
   Rotates −90° when the group is collapsed (pointing right ▸).
   ── */
.pt-blog-filter .toggle-icon {
    font-size: 1rem;
    line-height: 1;
    color: #8c939d;
    flex-shrink: 0;
    padding-left: 8px;
    transition: transform 0.22s ease;
    cursor: pointer;
}
.pt-blog-filter .filter-toggle.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* ── Filter content area ── */
.pt-blog-filter .filter-content {
    padding: 4px 20px 16px;
}

/* ── Subcategory list — reset browser list defaults ── */
.pt-blog-filter ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.pt-blog-filter ul li {
    margin-bottom: 6px;
    padding-left: 0;
}

/* ── Subcategory labels (inside .filter-content) ── */
.pt-blog-filter .filter-content .pt-blog-cat-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: #050505;
    cursor: pointer;
    font-weight: 500;
}

/* ── Custom checkboxes ──
   Duplicates .pt-archive-sidebar .filter-checkbox so the popup
   (outside .pt-archive-sidebar) gets the same styled boxes.
   ── */
.pt-blog-filter .filter-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1.5px solid #ced0d4;
    appearance: none;
    -webkit-appearance: none;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
    margin-right: 0;
}
.pt-blog-filter .filter-checkbox:checked {
    background: #050505;
    border-color: #050505;
}

/* ── Locked checkboxes (category archive — cannot be unchecked) ──
   Browsers grey disabled inputs; override to keep the checked appearance.
   Cursor on the label is also changed to signal non-interactivity.       */
.pt-blog-filter .filter-checkbox.pt-blog-cat-locked {
    opacity: 1;              /* override browser's disabled greying */
    cursor: default;
    background: #050505;     /* keep checked colour */
    border-color: #050505;
}
.pt-blog-filter .filter-checkbox.pt-blog-cat-locked::before {
    content: '';
    position: absolute;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -55%) rotate(45deg);
    top: 45%;
    left: 50%;
}
.pt-cat-label-locked {
    cursor: default;
    color: #65676b;          /* slightly muted to hint the field is fixed */
}
.pt-blog-filter .filter-checkbox:checked::before {
    content: '';
    position: absolute;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -55%) rotate(45deg);
    top: 45%;
    left: 50%;
}

/* ================================================================
   CATEGORY ARCHIVE HEADER — inside .pt-archive-sidebar
   Desktop: padded to match filter card gutter.
   Mobile: full-width with page-edge padding (sidebar is block).
   ================================================================ */
.pt-cat-archive-header {
    padding: 20px 20px 16px;
    flex-shrink: 0; /* don't let H1 compress in flex sidebar */
}
@media (max-width: 900px) {
    .pt-cat-archive-header {
        padding: 16px 4%;
    }
}
/* Desktop: tighten padding so H1 + breadcrumb (now inside header) = 69px,
   matching the topbar height and aligning the filter with the post grid.
   Math: 12(top) + 31(H1) + 0(H1 margin) + 6(bc top) + 13(bc text) + 7(bc bottom) = 69px */
@media (min-width: 901px) {
    .pt-cat-archive-header {
        padding: 12px 20px 0;
        min-height: 69px;
    }
    /* Remove H1 bottom margin — breadcrumb padding-top provides the gap */
    .pt-cat-archive-header .pt-cat-archive-title {
        margin-bottom: 0;
    }
    /* Override the general sidebar breadcrumb padding for this nested instance */
    .pt-archive-sidebar .pt-cat-archive-header .pt-archive-breadcrumb {
        padding: 6px 0 7px;
    }
}
.pt-cat-archive-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #050505;
    margin: 0 0 6px;
    line-height: 1.2;
}
.pt-cat-archive-desc {
    font-size: 0.9rem;
    color: #65676b;
    margin: 0;
    line-height: 1.5;
}

/* ================================================================
   POST COUNT
   ================================================================ */
#pt-blog-count {
    font-size: 0.9rem;
    color: #65676b;
    font-weight: 500;
}

/* ================================================================
   POST CARD GRID
   ================================================================ */
.pt-blog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.pt-blog-no-results {
    grid-column: 1 / -1;
    padding: 40px;
    text-align: center;
    color: #65676b;
}

#pt-blog-grid.is-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.15s;
}

.pt-blog-card {
    background: #fff;
    border: 1px solid #e4e6eb;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s;
    position: relative; /* stretched-link anchor */
}
.pt-blog-card:hover { border-color: #bcc0c4; }

.pt-blog-card-image-link { display: block; }
.pt-blog-card-image {
    height: 200px;
    background: #e4e6eb center / cover no-repeat;
}

/* Stretched link — title ::after covers the whole card */
.pt-blog-card-title a::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Category badge stays tappable above the overlay */
.pt-blog-category-badge {
    position: relative;
    z-index: 2;
}

.pt-blog-card-body {
    padding: 18px 20px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.pt-blog-category-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #050505;
    background: #f0f2f5;
    border-radius: 4px;
    padding: 3px 8px;
    margin-bottom: 10px;
    text-decoration: none;
    position: relative;
    z-index: 2;
}

.pt-blog-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #050505;
    line-height: 1.4;
    margin: 0 0 10px;
}
.pt-blog-card-title a { color: inherit; text-decoration: none; }
.pt-blog-card-title a:hover { color: #000; text-decoration: underline; }

.pt-blog-card-excerpt {
    font-size: 0.85rem;
    color: #65676b;
    line-height: 1.55;
    margin: 0 0 16px;
    flex: 1;
}

.pt-blog-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #8a8d91;
    padding-top: 12px;
    border-top: 1px solid #f0f2f5;
}

/* ================================================================
   PAGINATION
   ================================================================ */
#pt-blog-pagination {
    margin-top: 16px;
}

.pt-blog-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pt-blog-pagination a,
.pt-blog-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e4e6eb;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #050505;
    text-decoration: none;
    background: #fff;
    transition: border-color 0.12s, background 0.12s;
}
.pt-blog-pagination a:hover {
    border-color: #bcc0c4;
    background: #f7f7f7;
}
.pt-blog-pagination .current {
    background: #050505;
    color: #fff;
    border-color: #050505;
}
.pt-blog-pagination .dots {
    border: none;
    background: none;
    color: #8a8d91;
    cursor: default;
}

/* ================================================================
   MOBILE FILTER POPUP
   ================================================================ */
.pt-blog-filter-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
}
.pt-blog-filter-popup.is-open { display: block; }

.pt-blog-popup-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.pt-blog-filter-popup-inner {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: #fff;
    overflow-y: auto;
    /* Extra top padding so content clears the close button */
    padding: 52px 0 20px;
    z-index: 1;
    scrollbar-width: thin;
}

#pt-blog-popup-close {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 1.3rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #65676b;
    z-index: 2;
}
#pt-blog-popup-close:hover { color: #050505; }

/* Inside popup the filter card styling is handled by the popup container */
.pt-blog-filter-popup-inner .pt-blog-filter {
    background: transparent;
    border: none;
    box-shadow: none;
    max-height: none;
    overflow: visible;
}

#pt-blog-popup-apply {
    display: block;
    width: calc(100% - 40px);
    margin: 24px 20px 0;
    background: #050505;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 13px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
#pt-blog-popup-apply:hover { background: #333; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
    .pt-blog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}
@media (max-width: 600px) {
    .pt-blog-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

