/*
Theme Name:   DustMagic Child
Template:     dustmagic-theme
Version:      1.5.0
Description:  Child theme for DustMagic. Recommended-reading hero, per-hub sticky sections, search routing + GA4, search autocomplete, page-header/search-bar ordering, and mobile responsiveness pass.
Author:       DustMagic
*/

/* ---------- Safety: prevent horizontal scroll on mobile ---------- */
html, body { overflow-x: hidden; }

/* ---------- Recommended reading heading ---------- */
.recommended-heading { margin: 2rem 0 1rem; }
.recommended-heading h2 {
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    margin: 0;
}

/* ---------- Hero featured card — 50/50 image + text ---------- */
.featured-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: stretch;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
}
.featured-hero .hero-thumb {
    display: block;
    position: relative;
    min-height: 280px;
    overflow: hidden;
}
.featured-hero .hero-thumb a,
.featured-hero .hero-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.featured-hero .hero-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem;
    gap: 0.75rem;
}
.featured-hero .hero-category {
    color: #22d3ee;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.featured-hero .hero-body h2 {
    font-size: 1.75rem;
    line-height: 1.2;
    margin: 0;
}
.featured-hero .hero-body h2 a { color: inherit; text-decoration: none; }
.featured-hero .hero-body h2 a:hover { text-decoration: underline; }
.featured-hero .hero-excerpt {
    color: rgba(255, 255, 255, 0.72);
    font-size: 1rem;
    line-height: 1.55;
}
.featured-hero .hero-meta {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
@media (max-width: 800px) {
    .featured-hero { grid-template-columns: 1fr; gap: 0; }
    .featured-hero .hero-thumb { min-height: 200px; }
    .featured-hero .hero-body { padding: 1.25rem; gap: 0.6rem; }
    .featured-hero .hero-body h2 { font-size: 1.25rem; }
    .featured-hero .hero-excerpt { font-size: 0.95rem; }
}
@media (max-width: 480px) {
    .featured-hero .hero-thumb { min-height: 180px; }
    .featured-hero .hero-body h2 { font-size: 1.15rem; }
    .featured-hero .hero-excerpt { font-size: 0.9rem; line-height: 1.5; }
}

/* ---------- Featured grid (legacy 3 cards) ---------- */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}
@media (max-width: 900px) { .featured-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .featured-grid { grid-template-columns: 1fr; gap: 1rem; } }

/* ---------- Hub-split latest sections ---------- */
.hub-section { margin-top: 2.5rem; }
.hub-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.hub-section-heading h2 {
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    margin: 0;
}
.hub-section-heading .hub-view-all {
    color: #22d3ee;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
}
.hub-section-heading .hub-view-all:hover { text-decoration: underline; }

@media (max-width: 600px) {
    .hub-section { margin-top: 2rem; }
    .hub-section-heading h2 { font-size: 1.1rem; }
    .hub-section-heading .hub-view-all { font-size: 0.85rem; }
    .recommended-heading h2 { font-size: 1.1rem; }
}

/* Space between page-header and the search-bar below it */
.page-header + .search-bar { margin-top: 1rem; }

/* ---------- Search autocomplete dropdown ---------- */
.search-bar form { position: relative; }
.search-autocomplete {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #0f0f12;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    overflow: hidden;
    z-index: 50;
    max-height: 420px;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.search-autocomplete .sa-item,
.search-autocomplete .sa-all {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.95rem;
}
.search-autocomplete .sa-item:last-of-type { border-bottom: none; }
.search-autocomplete .sa-item:hover,
.search-autocomplete .sa-item.is-active,
.search-autocomplete .sa-all:hover,
.search-autocomplete .sa-all.is-active { background: rgba(34, 211, 238, 0.08); }
.search-autocomplete .sa-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-autocomplete .sa-cat {
    color: #22d3ee;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.search-autocomplete .sa-empty {
    padding: 0.85rem 1rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.search-autocomplete .sa-all {
    color: #22d3ee;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: none;
}
@media (max-width: 480px) {
    .search-autocomplete .sa-item,
    .search-autocomplete .sa-all { padding: 0.7rem 0.85rem; font-size: 0.9rem; gap: 0.5rem; }
    .search-autocomplete .sa-cat { font-size: 0.65rem; }
}

/* ---------- Page-header above search on category & search pages ---------- */
body.category .site-content,
body.search .site-content { display: flex; flex-direction: column; }
body.category .site-content > .page-header,
body.search .site-content > .page-header { order: 1; }
body.category .site-content > .search-bar,
body.search .site-content > .search-bar { order: 2; }
body.category .site-content > .hub-filters,
body.search .site-content > .hub-filters { order: 3; }
body.category .site-content > .category-nav,
body.search .site-content > .category-nav { order: 4; }
body.category .site-content > .articles-grid,
body.category .site-content > .pagination,
body.search .site-content > .articles-grid,
body.search .site-content > .pagination { order: 5; }

/* Consistent search bar width across all pages */
.search-bar {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}
.search-bar form { width: 100%; }

@media (max-width: 600px) {
    .search-bar { margin-top: 1rem; }
}

/* ---------- Filter rows (hub-filters, category-nav) — wrap nicely on mobile ---------- */
.hub-filters,
.category-nav {
    flex-wrap: wrap;
    row-gap: 0.5rem;
}
@media (max-width: 600px) {
    .hub-filters,
    .category-nav {
        /* Horizontal scroll fallback on very narrow screens */
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-start;
    }
    .hub-filter,
    .category-nav a {
        font-size: 0.85rem;
        padding: 0.35rem 0.7rem;
    }
    .hub-filter-label {
        font-size: 0.75rem;
        width: 100%;
        margin-bottom: 0.25rem;
    }
}

/* ---------- Hub "View all" CTA card — cyan, white, minimal ---------- */
.articles-grid .hub-cta-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 0.5rem;
    background: #22d3ee;
    color: #ffffff;
    padding: 1.75rem;
    border-radius: 12px;
    text-decoration: none;
    min-height: 200px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.articles-grid .hub-cta-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(34, 211, 238, 0.25);
}
.articles-grid .hub-cta-card .cta-title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    color: #ffffff;
}
.articles-grid .hub-cta-card .cta-arrow {
    font-weight: 700;
    color: #ffffff;
    margin-top: auto;
}
@media (max-width: 1100px) {
    .articles-grid .hub-cta-card { min-height: 160px; padding: 1.5rem; }
    .articles-grid .hub-cta-card .cta-title { font-size: 1.2rem; }
}
@media (max-width: 600px) {
    .articles-grid .hub-cta-card {
        min-height: 0;
        padding: 1.25rem 1.5rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .articles-grid .hub-cta-card .cta-title { font-size: 1.05rem; }
    .articles-grid .hub-cta-card .cta-arrow { margin-top: 0; margin-left: 0.75rem; }
}

/* ---------- Hub grid: 4 cols (3 posts + CTA) ---------- */
.hub-section .articles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}
@media (max-width: 1100px) {
    .hub-section .articles-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}
@media (max-width: 600px) {
    .hub-section .articles-grid { grid-template-columns: 1fr; gap: 1rem; }
}

/* ---------- Page header / hero copy on mobile ---------- */
@media (max-width: 600px) {
    .page-header { padding: 1rem 0; }
    .page-header h1 { font-size: 1.6rem !important; }
    .page-header p { font-size: 0.95rem; line-height: 1.5; }
    .page-header .section-label { font-size: 0.7rem; }
}

/* ---------- Article card polish on mobile ---------- */
@media (max-width: 600px) {
    .articles-grid .post-card,
    .articles-grid article { padding: 1.25rem; }
    .articles-grid .post-card h2,
    .articles-grid article h2 { font-size: 1.05rem; line-height: 1.3; }
    .articles-grid .post-card p,
    .articles-grid article p { font-size: 0.9rem; line-height: 1.5; }
    .articles-grid .post-meta,
    .articles-grid article .post-meta { font-size: 0.8rem; }
}

/* ---------- Pagination readable on mobile ---------- */
@media (max-width: 600px) {
    .pagination { flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
    .pagination a, .pagination span { font-size: 0.85rem; padding: 0.4rem 0.7rem; }
}