/*
 * Homepage category blocks, Latest Posts and the shared post card (13 Nov 2026).
 * Same visual language as featured-v2.css: the 16:9 artwork is shown whole,
 * text sits beneath it, titles are clamped by lines rather than characters.
 *
 * Paired with:
 *   category/_block_content_1.php   (every homepage category block)
 *   category/_block_with_tabs.php   (section heading, View all, empty blocks)
 *   post/_post_item.php             (Latest Posts, category, search, load more)
 */

/* Declared on body, not :root: the theme redefines --vr-text-main for dark
   mode below the html element, and a custom property resolves where it is
   declared. On :root the dark-mode text colour was never picked up. */
body {
    --h2-gap: 24px;
    --h2-radius: 10px;
    --h2-text: var(--vr-text-main, #18181b);
    --h2-muted: var(--vr-text-muted, #6b7280);
    --h2-line: var(--vr-gray-150, #e5e7eb);
    --h2-accent: var(--vr-theme-color, #e50914);
    --h2-media-bg: var(--vr-gray-100, #f3f4f6);
}

[data-bs-theme="dark"] body {
    --h2-text: var(--vr-text-main, #f4f4f5);
    --h2-muted: var(--vr-text-muted, #a1a1aa);
    --h2-line: rgba(255, 255, 255, 0.12);
    --h2-media-bg: rgba(255, 255, 255, 0.04);
}

/* ---------- Section headings (all homepage sections) ---------- */

.section .section-title {
    display: block;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--h2-text);
}

.section .section-title::after { content: none; }

.section .section-title > .d-flex { gap: 1rem; min-height: 2.75rem; }

.section .section-title .title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0.4rem 0 0.65rem;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--h2-text);
}

.section .section-title .title::before {
    content: "";
    flex: 0 0 4px;
    height: 1.1em;
    border-radius: 2px;
    background: var(--h2-accent);
}

.section .section-title .title a { color: inherit !important; text-decoration: none; }
.section .section-title .title a:hover { color: var(--h2-accent) !important; }

/* Heading row: title never squeezes. When subcategory tabs don't fit beside
   it, the row wraps and the tabs drop below, right-aligned. (No overflow
   scrolling: the tabs contain a "more" dropdown that would be clipped.) */
.cb-section .section-title > .d-flex { flex-wrap: wrap; row-gap: 0.25rem; }
.cb-section .section-title .title { flex: 0 1 auto; min-width: 0; }
@media (min-width: 992px) { .cb-section .section-title .title { flex: 0 0 auto; white-space: nowrap; } }
.cb-section .nav-category-block { margin-left: auto; flex-wrap: nowrap; border: 0; }
.cb-section .cb-view-all { margin-left: auto; }
.cb-section .nav-category-block + .cb-view-all { margin-left: 0; }
.cb-section .nav-category-block .nav-link {
    white-space: nowrap;
    padding: 0.35rem 0.7rem;
    border-radius: 999px !important;
    color: var(--h2-muted) !important;
    font-size: 0.8rem;
    font-weight: 600;
}
.cb-section .nav-category-block .nav-link:hover { color: var(--h2-text) !important; }
.cb-section .nav-category-block .nav-link.active {
    color: var(--h2-accent) !important;
    background: color-mix(in srgb, var(--h2-accent) 10%, transparent) !important;
}

.cb-view-all,
.section .section-title .view-all {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--h2-line);
    border-radius: 999px;
    color: var(--h2-text) !important;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.cb-view-all:hover,
.section .section-title .view-all:hover {
    border-color: var(--h2-accent);
    color: var(--h2-accent) !important;
}

.cb-view-all svg,
.section .section-title .view-all svg { transition: transform 0.2s ease; }

.cb-view-all:hover svg,
.section .section-title .view-all:hover svg { transform: translateX(2px); }

[dir="rtl"] .cb-view-all svg,
[dir="rtl"] .section .section-title .view-all svg { transform: scaleX(-1); }

/* Narrow screens: arrow-only button so long category names keep their line. */
@media (max-width: 575.98px) {
    .cb-view-all { padding: 0.45rem; }
    .cb-view-all .cb-view-all-text {
        position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip: rect(0 0 0 0); white-space: nowrap;
    }
    .section .section-title .title { font-size: 1.15rem; }
}

.section-category { margin-bottom: 2.75rem; }

/* ---------- Shared media frame (category cards + post cards) ---------- */

.cb-media,
.pi2-media {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    border-radius: var(--h2-radius);
    overflow: hidden;
    background: var(--h2-media-bg);
    isolation: isolate;
}

.cb-img,
.pi2-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;   /* never crop artwork that carries its own headline */
    z-index: 1;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Blurred copy of the same image fills the bars on non-16:9 artwork.
   Same URL and srcset, so it is served from cache. */
.cb-img-bg,
.pi2-img-bg {
    position: absolute;
    inset: -24px;
    width: calc(100% + 48px);
    height: calc(100% + 48px);
    object-fit: cover;
    filter: blur(22px) saturate(1.15);
    opacity: 0.75;
    z-index: 0;
    pointer-events: none;
}

.cb-media > :not(.cb-img):not(.cb-img-bg),
.pi2-media > :not(.pi2-img):not(.pi2-img-bg) { z-index: 2; }

.cb-card:hover .cb-img,
.pi2:hover .pi2-img { transform: scale(1.025); }

/* ---------- Category block: four cards ---------- */

.cb-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--h2-gap);
}

@media (min-width: 576px) { .cb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 992px) { .cb-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.cb-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.cb-body { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }

.cb-title,
.pi2-title {
    margin: 0;
    color: var(--h2-text);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -0.005em;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.cb-title a,
.pi2-title a {
    color: inherit !important;
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0 1px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.25s ease;
}

.cb-card:hover .cb-title a,
.pi2:hover .pi2-title a,
.cb-title a:focus-visible,
.pi2-title a:focus-visible { background-size: 100% 1px; }

/* Whole card clickable through its title link. */
.cb-title a::after,
.pi2-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }

.cb-meta, .cb-meta a, .cb-meta span, .cb-meta i,
.pi2-meta, .pi2-meta a, .pi2-meta span, .pi2-meta i {
    color: var(--h2-muted) !important;
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
}

.cb-meta a, .pi2-meta a, .pi2-cat { position: relative; z-index: 3; }

/* Phones: first card full width, the other three as compact rows. */
@media (max-width: 575.98px) {
    .cb-grid { gap: 1rem; }
    .cb-card:not(:first-child) {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.85rem;
    }
    .cb-card:not(:first-child) .cb-media { flex: 0 0 40%; }
    .cb-card:not(:first-child) .cb-title { font-size: 0.95rem; }
    .cb-card:not(:first-child) .cb-meta { display: none; }
}

/* ---------- Category block: compact list ---------- */

.cb-list {
    list-style: none;
    margin: 1.5rem 0 0;
    padding: 1.25rem 0 0;
    border-top: 1px solid var(--h2-line);
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem var(--h2-gap);
}

@media (min-width: 768px) { .cb-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 992px) { .cb-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.cb-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    min-width: 0;
}

.cb-thumb {
    position: relative;
    flex: 0 0 112px;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: var(--h2-media-bg);
}

.cb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;   /* at 112px the baked-in text is unreadable anyway; fill the frame */
    transition: transform 0.4s ease;
}

.cb-row:hover .cb-thumb img { transform: scale(1.05); }

.cb-row-body { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }

.cb-row-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.cb-row-title a { color: var(--h2-text) !important; text-decoration: none; transition: color 0.2s ease; }
.cb-row-title a::after { content: ""; position: absolute; inset: 0; }
.cb-row:hover .cb-row-title a,
.cb-row-title a:focus-visible { color: var(--h2-accent) !important; }

.cb-row-date { color: var(--h2-muted); font-size: 0.75rem; font-weight: 500; }

/* ---------- Standard post card (.pi2) ---------- */

.pi2 {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 2rem;
}

.pi2 .pi2-body { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }

.pi2 .pi2-cat {
    align-self: flex-start;
    color: var(--cat, var(--h2-accent)) !important;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
}

.pi2 .pi2-cat:hover { text-decoration: underline; text-underline-offset: 3px; }

.pi2 .pi2-title { font-size: 1.075rem; }

.pi2 .pi2-summary {
    margin: 0.1rem 0 0;
    color: var(--h2-muted);
    font-size: 0.875rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

/* Theme rules for the old .post-item that would fight the new card. */
.pi2.post-item .image,
.pi2.post-item .badge-category { display: none; }
.pi2.post-item .title { margin: 0; }

/* ---------- Focus + motion ---------- */

.cb-section a:focus-visible,
.pi2 a:focus-visible,
.cb-view-all:focus-visible {
    outline: 2px solid var(--h2-accent);
    outline-offset: 3px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .cb-img, .pi2-img, .cb-thumb img, .cb-title a, .pi2-title a { transition: none; }
    .cb-card:hover .cb-img, .pi2:hover .pi2-img, .cb-row:hover .cb-thumb img { transform: none; }
}

/* ---------- Small post item (Popular / Recommended / Trending widgets) ----------
   Now uses the full 16:9 artwork instead of the old 100x75 / 140x98 crops,
   which were never part of the redesign. */
.post-item-small .image {
    flex: 0 0 128px;
    width: 128px;
    aspect-ratio: 16 / 9;
    height: auto !important;
    border-radius: 8px;
    overflow: hidden;
    background: var(--h2-media-bg);
}
.post-item-small .image a { display: block; width: 100%; height: 100%; }
.post-item-small .image .pis-img { width: 100%; height: 100%; object-fit: cover; }

/* Mega-menu post previews: full 16:9 redesigned artwork instead of the old
   450x280 / 750x415 'mid' crops. */
.menu-post-img-wrapper .ratio { --bs-aspect-ratio: 56.25%; aspect-ratio: 16 / 9; }
.menu-post-img-wrapper .menu-post-img { object-fit: cover; }

/* Related posts on article pages: full 16:9 redesigned artwork. */
.section-related-posts .image.ratio { --bs-aspect-ratio: 56.25%; aspect-ratio: 16 / 9; }

/* ==========================================================================
   Listing pages: category, subcategory, tag, search, all posts (13 Nov 2026)
   Paired with post/posts.php and common/partials/_category_subcategories.php
   ========================================================================== */

.lp-head {
    margin: 0.25rem 0 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 2px solid var(--h2-text);
}

.lp-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    color: var(--h2-accent) !important;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
}

.lp-eyebrow::before {
    content: "";
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

a.lp-eyebrow:hover { text-decoration: underline; text-underline-offset: 3px; }

.lp-head .lp-title {
    margin: 0;
    color: var(--h2-text);
    font-size: clamp(1.75rem, 1.35rem + 1.5vw, 2.5rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.lp-desc {
    max-width: 68ch;
    margin: 0.75rem 0 0;
    color: var(--h2-muted);
    font-size: 1.02rem;
    line-height: 1.65;
}

.lp-count {
    margin: 0.75rem 0 0;
    color: var(--h2-muted);
    font-size: 0.85rem;
}

.lp-count strong { color: var(--h2-text); font-weight: 700; }
.lp-sep { margin: 0 0.35rem; }

/* ---------- Topic chips ---------- */

.lp-chips { margin: 0 0 1.75rem; }

.lp-chips .subcategory-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--h2-line);
    border-radius: 999px;
    background: transparent;
    color: var(--h2-text) !important;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.lp-chips .subcategory-pill:hover { border-color: var(--h2-accent); color: var(--h2-accent) !important; }

.lp-chips .subcategory-pill.active {
    border-color: var(--h2-accent);
    background: var(--h2-accent);
    color: #fff !important;
}

/* ---------- Lead card (page 1) ---------- */

@media (min-width: 768px) {
    .lp-lead .pi2 {
        flex-direction: row;
        align-items: center;
        gap: 1.75rem;
        padding-bottom: 2rem;
        border-bottom: 1px solid var(--h2-line);
    }

    .lp-lead .pi2-media { flex: 0 0 55%; }
    .lp-lead .pi2-body { flex: 1 1 auto; gap: 0.6rem; }

    .lp-lead .pi2-title {
        font-size: clamp(1.3rem, 1.1rem + 0.6vw, 1.6rem);
        line-height: 1.3;
        -webkit-line-clamp: 4;
        line-clamp: 4;
    }

    .lp-lead .pi2-summary { -webkit-line-clamp: 4; line-clamp: 4; font-size: 0.95rem; }
}

/* ---------- Pagination ---------- */

.section-page .pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    margin: 0.5rem 0 1rem;
}

.section-page .pagination .page-item .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 0.75rem;
    border: 1px solid var(--h2-line) !important;
    border-radius: 10px !important;
    background: transparent !important;
    color: var(--h2-text) !important;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: none !important;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.section-page .pagination .page-item .page-link:hover { border-color: var(--h2-accent) !important; color: var(--h2-accent) !important; }

.section-page .pagination .page-item.active .page-link {
    border-color: var(--h2-accent) !important;
    background: var(--h2-accent) !important;
    color: #fff !important;
}

/* ---------- Empty state ---------- */

.lp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    border: 1px dashed var(--h2-line);
    border-radius: 12px;
    color: var(--h2-muted);
    text-align: center;
}

.lp-empty-title { margin: 0; color: var(--h2-text); font-size: 1.05rem; font-weight: 600; }

/* The site's custom header CSS (Admin > custom header codes) clamps
   .post-item .title, its link, and .post-item p to two lines. It prints after
   this file, so these rules need higher specificity to restore the intended
   clamps on the new cards. The custom CSS itself is left untouched. */
.pi2.post-item .pi2-title { -webkit-line-clamp: 3; line-clamp: 3; }
.pi2.post-item .pi2-title a { display: inline; -webkit-line-clamp: none; overflow: visible; }
.pi2.post-item p.pi2-summary { -webkit-line-clamp: 2; line-clamp: 2; }

@media (min-width: 768px) {
    .lp-lead .pi2.post-item .pi2-title { -webkit-line-clamp: 4; line-clamp: 4; }
    .lp-lead .pi2.post-item p.pi2-summary { -webkit-line-clamp: 4; line-clamp: 4; }
}
