/*
Theme Name: KK Express
Author: Ajeet Jai
Description: Custom WordPress theme for KK Express blogs and post detail pages.
Version: 1.0
Design Credit: Design by Ajeet Jai
Text Domain: kk-express
*/

/* Theme styles are loaded from css/kk-style.min.css and css/kk-blog.css. */

/* =========================================================
   KK EXPRESS — FIXES
   1) Sticky blog sidebar (desktop)
   2) Hover submenu that works with the real WordPress menu
      markup (.menu-item-has-children > .sub-menu) as well as
      the Bootstrap fallback markup.
   ========================================================= */

/* ---------- 1) STICKY BLOG SIDEBAR ---------- */
@media (min-width: 992px) {
    .kk-blog-sidebar {
        position: -webkit-sticky;
        position: sticky;
        top: 24px;            /* gap from top while scrolling */
        align-self: start;    /* required so sticky can travel */
        max-height: calc(100vh - 48px);
        overflow-y: auto;     /* if the sidebar is taller than the viewport */
        scrollbar-width: thin;
    }

    .kk-blog-sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .kk-blog-sidebar::-webkit-scrollbar-thumb {
        background: rgba(16, 42, 84, 0.18);
        border-radius: 10px;
    }
}

/* ---------- 2) HOVER SUBMENU (desktop) ---------- */

/* Injected caret used as the dropdown arrow for WP parent items */
.kk-nav-list .kk-submenu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    padding: 0;
    margin-left: 4px;
    color: inherit;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.kk-nav-list .kk-submenu-toggle i {
    transition: transform 0.25s ease;
}

@media (min-width: 992px) {
    /* Parent list-item becomes the hover anchor */
    .kk-nav-list .menu-item-has-children {
        position: relative;
        /* bridge the gap between link and submenu so hover doesn't drop */
        padding-bottom: 10px;
        margin-bottom: -10px;
    }

    /* On desktop the caret is just a visual arrow; hover drives the menu */
    .kk-nav-list .menu-item-has-children > .kk-submenu-toggle {
        pointer-events: none;
    }

    /* The WordPress submenu */
    .kk-nav-list .sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 250px;
        margin: 0;
        padding: 8px 0;
        list-style: none;
        background: #ffffff;
        border-radius: 6px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
        z-index: 1000;
    }

    /* Reveal on hover / keyboard focus */
    .kk-nav-list .menu-item-has-children:hover > .sub-menu,
    .kk-nav-list .menu-item-has-children:focus-within > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* Rotate the caret while open */
    .kk-nav-list .menu-item-has-children:hover > .kk-submenu-toggle i,
    .kk-nav-list .menu-item-has-children:focus-within > .kk-submenu-toggle i {
        transform: rotate(180deg);
    }

    /* Submenu links */
    .kk-nav-list .sub-menu .nav-item {
        width: auto;
        border: 0;
    }

    .kk-nav-list .sub-menu .nav-link,
    .kk-nav-list .sub-menu a {
        display: block;
        width: 100%;
        padding: 8px 20px;
        font-size: 14px;
        font-weight: 500;
        text-transform: none;
        letter-spacing: 0;
        color: #4a4a4a;
        white-space: nowrap;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .kk-nav-list .sub-menu .nav-link:hover,
    .kk-nav-list .sub-menu a:hover,
    .kk-nav-list .sub-menu .current-menu-item > a {
        background-color: #f8f8f8;
        color: #D91D23;
    }
}

/* ---------- 2b) SUBMENU ON MOBILE / TABLET (tap to expand) ---------- */
@media (max-width: 991px) {
    .kk-nav-list .menu-item-has-children > .nav-link {
        display: inline-flex;
        width: auto;
    }

    /* Keep link + caret on one row */
    .kk-nav-list .menu-item-has-children {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .kk-nav-list .menu-item-has-children > .nav-link {
        flex: 1 1 auto;
    }

    .kk-nav-list .menu-item-has-children > .kk-submenu-toggle {
        flex: 0 0 auto;
        pointer-events: auto;
        padding: 16px 24px;
        font-size: 15px;
        color: #011843;
    }

    /* Collapsed by default */
    .kk-nav-list .sub-menu {
        flex: 1 1 100%;
        list-style: none;
        margin: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        background-color: #f8f8f8;
        transition: max-height 0.3s ease;
    }

    /* Expanded when parent is toggled open */
    .kk-nav-list .menu-item-has-children.kk-submenu-open > .sub-menu {
        max-height: 600px;
    }

    .kk-nav-list .menu-item-has-children.kk-submenu-open > .kk-submenu-toggle i {
        transform: rotate(180deg);
    }

    .kk-nav-list .sub-menu .nav-link,
    .kk-nav-list .sub-menu a {
        display: block;
        padding: 13px 24px 13px 40px;
        font-size: 13px;
        font-weight: 500;
        text-transform: none;
        letter-spacing: 0;
        color: #4a4a4a;
        border-bottom: 1px solid #eeeeee;
    }

    .kk-nav-list .sub-menu .nav-link:hover,
    .kk-nav-list .sub-menu a:hover {
        color: #D91D23;
    }
}
