/* Header category mega menu — fixed under nav, fully responsive */

.hm-root {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

.hm-trigger {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .48rem .85rem;
    border-radius: 999px;
    border: 1px solid #e5ecd9;
    background: linear-gradient(180deg, #f7fbf2, #eef8e6);
    color: #3f7a18;
    font-weight: 800;
    font-size: .86rem;
    cursor: pointer;
    transition: .18s ease;
}

.hm-trigger .hm-trigger-ico {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #7fc945;
    color: #fff;
}

.hm-trigger .hm-trigger-ico svg {
    width: 13px;
    height: 13px;
}

.hm-trigger .chev {
    opacity: .65;
    transition: transform .2s ease;
}

.hm-root.is-open .hm-trigger .chev {
    transform: rotate(180deg);
}

.hm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 230;
    background: rgba(15, 23, 42, .4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}

.hm-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Fixed to viewport under .rh-nav — avoids overflow/clip bugs */
.hm-panel {
    position: fixed;
    inset-inline: 0;
    top: var(--hm-top, 140px);
    z-index: 240;
    padding: 10px max(12px, calc((100vw - 1180px) / 2));
    margin: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}

.hm-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
    transform: none;
}

.hm-panel.is-open .hm-panel-inner {
    pointer-events: auto;
}

.hm-panel-inner {
    width: min(1180px, 100%);
    margin-inline: auto;
    height: min(70vh, 560px);
    max-height: min(70vh, 560px);
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 210px;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    background:
        radial-gradient(640px 200px at 100% 0%, rgba(127, 201, 69, .11), transparent 55%),
        #fff;
    border: 1px solid #e8edf2;
    border-radius: 18px;
    box-shadow: 0 22px 56px rgba(15, 23, 42, .16);
    overflow: hidden;
    min-height: 0;
}

.hm-side {
    background: #f7faf3;
    border-left: 1px solid #eef2e8;
    padding: .55rem .4rem .55rem .45rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

.hm-side-label {
    flex: 0 0 auto;
    padding: .25rem .55rem .4rem;
    color: #8a8a8a;
    font-size: .7rem;
    font-weight: 800;
}

.hm-side-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 .15rem .15rem 0;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    scrollbar-width: thin;
    scrollbar-color: #9fd86a #e8f0df;
}

.hm-side-scroll::-webkit-scrollbar {
    width: 7px;
}

.hm-side-scroll::-webkit-scrollbar-track {
    background: #e8f0df;
    border-radius: 999px;
}

.hm-side-scroll::-webkit-scrollbar-thumb {
    background: #9fd86a;
    border-radius: 999px;
}

.hm-side-scroll::-webkit-scrollbar-thumb:hover {
    background: #7fc945;
}

.hm-side-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    text-align: right;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 12px;
    padding: .55rem .55rem;
    cursor: pointer;
    color: #374151;
    flex: 0 0 auto;
}

.hm-side-item:hover,
.hm-side-item.is-active {
    background: #fff;
    border-color: #d8efb8;
    color: #2f6512;
}

.hm-side-item .ico {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: #eef7e6;
    color: #5aa628;
    flex: 0 0 auto;
}

.hm-side-item .ico svg {
    width: 15px;
    height: 15px;
}

.hm-side-item.is-active .ico,
.hm-side-item:hover .ico {
    background: linear-gradient(180deg, #8fd84f, #62a832);
    color: #fff;
}

.hm-side-item .meta {
    min-width: 0;
    flex: 1;
}

.hm-side-item strong {
    display: block;
    font-size: .82rem;
    font-weight: 800;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hm-side-item small {
    display: block;
    margin-top: .1rem;
    color: #8a94a6;
    font-size: .68rem;
    font-weight: 700;
}

.hm-side-item .arrow {
    opacity: .35;
    flex: 0 0 auto;
}

.hm-side-item.is-active .arrow {
    opacity: 1;
    color: #62a832;
}

.hm-main {
    padding: .9rem 1rem 1rem;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}

.hm-pane { display: none; }
.hm-pane.is-active { display: block; }

.hm-pane-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .85rem;
}

.hm-pane-head > div { min-width: 0; flex: 1; }

.hm-pane-head h3 {
    margin: 0;
    font-size: 1rem;
    color: #1f2937;
    font-weight: 800;
}

.hm-pane-head p {
    margin: .25rem 0 0;
    color: #8a8a8a;
    font-size: .8rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hm-pane-cta {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    white-space: nowrap;
    padding: .45rem .75rem;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-size: .74rem;
    font-weight: 800;
    flex: 0 0 auto;
}

.hm-pane-cta:hover { background: #243047; }

.hm-children {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .5rem;
}

.hm-child {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: .7rem .75rem;
    border-radius: 12px;
    border: 1px solid #eef2f7;
    background: #fff;
    min-height: 78px;
    min-width: 0;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.hm-child:hover {
    border-color: #d8efb8;
    background: #f7fbf2;
    transform: translateY(-1px);
}

.hm-child strong {
    color: #1f2937;
    font-size: .82rem;
    font-weight: 800;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hm-child span {
    color: #8a94a6;
    font-size: .7rem;
    font-weight: 700;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hm-child em {
    margin-top: auto;
    font-style: normal;
    color: #62a832;
    font-size: .68rem;
    font-weight: 800;
}

.hm-empty {
    border: 1px dashed #e5e7eb;
    border-radius: 14px;
    padding: 1.1rem;
    text-align: center;
    color: #8a8a8a;
    font-size: .84rem;
}

.hm-promo {
    border-right: 1px solid #eef2e8;
    padding: .9rem .8rem;
    background: linear-gradient(180deg, #111827, #1f2937);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: auto;
}

.hm-promo .tag {
    display: inline-flex;
    align-self: flex-start;
    padding: .18rem .5rem;
    border-radius: 999px;
    background: rgba(127, 201, 69, .2);
    color: #b6ef86;
    font-size: .68rem;
    font-weight: 800;
}

.hm-promo h4 {
    margin: 0;
    font-size: .92rem;
    font-weight: 800;
    line-height: 1.45;
}

.hm-promo p {
    margin: 0;
    color: rgba(255, 255, 255, .7);
    font-size: .76rem;
    line-height: 1.6;
}

.hm-promo-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .35rem;
    margin-top: .15rem;
    flex: 0 0 auto;
}

.hm-promo-stats div {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 10px;
    padding: .5rem .55rem;
}

.hm-promo-stats b {
    display: block;
    font-size: .9rem;
    font-weight: 800;
}

.hm-promo-stats span {
    display: block;
    margin-top: .1rem;
    color: rgba(255, 255, 255, .55);
    font-size: .65rem;
    font-weight: 700;
}

.hm-promo a.btn-line {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: .25rem;
    padding: .6rem .7rem;
    border-radius: 10px;
    background: linear-gradient(180deg, #8fd84f, #62a832);
    color: #fff;
    font-weight: 800;
    font-size: .78rem;
    flex: 0 0 auto;
}

html.hm-open {
    overflow: hidden;
}

/* —— Breakpoints —— */
@media (max-width: 1200px) {
    .hm-panel-inner {
        grid-template-columns: 220px minmax(0, 1fr) 190px;
        height: min(68vh, 520px);
        max-height: min(68vh, 520px);
    }
}

@media (max-width: 1100px) {
    .hm-panel-inner {
        grid-template-columns: 210px minmax(0, 1fr);
        height: min(66vh, 480px);
        max-height: min(66vh, 480px);
    }
    .hm-promo { display: none; }
    .hm-children {
        grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    }
}

@media (max-width: 900px) {
    /* Nav hidden on mobile — panel unused; keep safe defaults */
    .hm-panel,
    .hm-backdrop { display: none !important; }
}

@media (min-width: 901px) and (max-width: 992px) {
    .hm-panel {
        top: auto !important;
        bottom: 0;
        padding: 0;
        transform: translateY(105%);
    }
    .hm-panel.is-open {
        transform: none;
    }
    .hm-panel-inner {
        width: 100%;
        height: auto;
        max-height: min(78vh, 640px);
        border-radius: 18px 18px 0 0;
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .hm-panel-inner::before {
        content: "";
        display: block;
        width: 36px;
        height: 4px;
        margin: .5rem auto .2rem;
        border-radius: 999px;
        background: #d1d5db;
        grid-column: 1 / -1;
    }
    .hm-side {
        flex-direction: column;
        overflow: hidden;
        border-left: 0;
        border-bottom: 1px solid #eef2e8;
        height: auto;
        max-height: none;
        padding: .55rem .7rem;
    }
    .hm-side-label { display: none; }
    .hm-side-scroll {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: .35rem;
        scrollbar-width: none;
    }
    .hm-side-scroll::-webkit-scrollbar { display: none; }
    .hm-side-item {
        min-width: 132px;
        flex-direction: column;
        align-items: flex-start;
    }
    .hm-side-item strong {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .hm-side-item .arrow { display: none; }
    .hm-main { overflow: visible; }
    .hm-panel-inner { overflow: auto; }
    .hm-children {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .hm-pane-head { flex-wrap: wrap; }
    .hm-pane-cta { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .hm-panel,
    .hm-backdrop,
    .hm-trigger .chev,
    .hm-child {
        transition: none !important;
    }
}
