/*
 * HealthAffPro Mega Categories Stylesheet
 *
 * This stylesheet provides the styles for the mega menu, topics directory,
 * category archives, featured posts and search UI. It builds on the
 * original styles shipped with the plugin and introduces a two‑column
 * layout in the mega menu (categories on the left, latest posts on the
 * right), limits each category column to eight links, and adds a search
 * bar to the topics directory page. Additional responsive tweaks enable
 * basic support for mobile devices.
 */

/* Mega menu container */
.hap-mega-menu {
    position: absolute;
    left: 0;
    top: 100%;
    width: 100vw;
    background: #f2ece3;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: all 0.22s ease;
    z-index: 99999;
}
.menu-item:hover > .hap-mega-menu,
.menu-item.hap-open > .hap-mega-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

/* Inner grid: left side for categories, right side for posts */
.hap-mega-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 28px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 34px;
}

/* Header row: parent category name and ALL link */
.hap-mega-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.18);
    margin-bottom: 18px;
}
.hap-mega-head-row span {
    font-size: 15px;
    font-weight: 700;
    border: 2px solid rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    text-transform: uppercase;
}
.hap-mega-all {
    font-size: 14px;
    font-weight: 700;
    text-decoration: underline;
}

/* Category grid */
.hap-mega-grid {
    display: grid;
    gap: 20px 40px;
}
/* Columns adjust based on number of chunks */
.hap-mega-grid.hap-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}
.hap-mega-grid.hap-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.hap-mega-grid.hap-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.hap-mega-grid.hap-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.hap-mega-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.hap-mega-cat {
    font-size: 16px;
    line-height: 1.45;
    color: #111;
    text-decoration: none;
}
.hap-mega-cat:hover {
    color: #005f73;
    text-decoration: underline;
}

/* Right column: featured posts */
.hap-mega-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.hap-mega-featured {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.hap-mega-post {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
}
.hap-mega-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    flex-shrink: 0;
    background: #ddd;
    border-radius: 4px;
}
.hap-mega-post-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.hap-mega-post-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}
.hap-mega-post-date {
    font-size: 12px;
    color: #666;
}

/* Placeholder thumbnail if no image */
.hap-mega-thumb.placeholder {
    background: #ccc;
}

/* Topics directory page */
.hap-topics-hero {
    padding: 50px 0 20px;
    background: #d6ecec;
}
.hap-topics-title {
    margin: 0 0 10px;
    font-size: clamp(34px, 6vw, 64px);
    line-height: 1.05;
    font-weight: 800;
    color: #231f20;
}
.hap-topics-desc {
    font-size: 18px;
    color: #2d2d2d;
    line-height: 1.7;
    max-width: 760px;
}
.hap-topics-directory {
    padding: 30px 0 60px;
    background: #fff;
}
.hap-topics-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    margin-bottom: 28px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.14);
}
.hap-topics-letters a {
    color: #111;
    text-decoration: none;
    font-weight: 600;
}
.hap-letter-group {
    margin-bottom: 36px;
}
.hap-letter-group h2 {
    font-size: 42px;
    margin: 0 0 16px;
    line-height: 1;
}
.hap-letter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 34px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
}
.hap-letter-grid a {
    text-decoration: none;
    color: #111;
    font-size: 17px;
    line-height: 1.5;
}
@media (max-width: 767px) {
    .hap-letter-grid {
        grid-template-columns: 1fr;
    }
}

/* Topics directory search */
.hap-topics-search {
    margin: 20px 0 30px;
    max-width: 500px;
    position: relative;
}
.hap-topics-search input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#hap-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    z-index: 10;
    display: none;
    max-height: 220px;
    overflow-y: auto;
}
#hap-search-results a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: #111;
    border-bottom: 1px solid #eee;
}
#hap-search-results a:hover {
    background: #f5f5f5;
}

/* Category archive custom layout */
.hap-category-hero {
    padding: 60px 0 30px;
    background: #e8f3f3;
}
.hap-category-title {
    margin: 0;
    font-size: clamp(32px, 5vw, 56px);
    font-weight: 800;
    line-height: 1.1;
    color: #231f20;
}
.hap-category-desc {
    font-size: 18px;
    max-width: 720px;
    margin-top: 14px;
    line-height: 1.6;
    color: #333;
}
.hap-subtopics-nav {
    margin: 30px 0;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
}
.hap-subtopics-nav a {
    font-size: 14px;
    text-decoration: none;
    color: #005f73;
    font-weight: 600;
}
.hap-subtopics-nav a:hover {
    text-decoration: underline;
}
.hap-post-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px;
}
.hap-archive-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    border-radius: 6px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background: #fff;
}
.hap-archive-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}
.hap-archive-thumb.placeholder {
    width: 100%;
    height: 200px;
    background: #ddd;
}
.hap-archive-card-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.hap-archive-card-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}
.hap-archive-card-excerpt {
    font-size: 14px;
    color: #555;
}
.hap-archive-card-date {
    font-size: 12px;
    color: #888;
    margin-top: auto;
}
@media (max-width: 767px) {
    .hap-mega-inner {
        grid-template-columns: 1fr;
    }
    .hap-mega-right {
        margin-top: 20px;
    }
    .hap-post-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile-specific adjustments for mega menu */
@media (max-width: 767px) {
    /* On mobile, render mega menu statically below the menu item when opened */
    .hap-mega-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        transform: none;
        opacity: 1;
        visibility: hidden;
        pointer-events: none;
        display: none;
        margin-top: 4px;
    }
    .menu-item.hap-open > .hap-mega-menu {
        display: block;
        visibility: visible;
        pointer-events: auto;
    }
    /* Make the arrow slightly larger on mobile */
    .hap-mobile-arrow {
        border-left-width: 5px;
        border-right-width: 5px;
        border-top-width: 6px;
    }
}

/* Simple arrow indicator for mobile */
.hap-mobile-arrow {
    margin-left: 6px;
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid #111;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
}
/* Hide the mobile arrow on larger screens */
@media (min-width: 768px) {
    .hap-mobile-arrow {
        display: none;
    }
}
.menu-item.hap-open > a .hap-mobile-arrow {
    transform: rotate(180deg);
}