
/* ===== TOP MENU (desktop) ===== */
.top-menu-bar .top-menu {
    gap: 0;
    align-items: center;
}

.top-menu-bar .top-menu li a {
    font-size: 0.9rem;
    color: var(--wp--preset--color--dark-gray);
    text-decoration: none;
    padding: 0.5rem 1.25rem;
}

.top-menu-bar .top-menu li a:hover {
    color: var(--wp--preset--color--primary);
}


/* Separators between items */
.top-menu-bar .top-menu li + li::before {
    content: '|';
    color: rgba(0, 0, 0, 1);
    margin-right: 0;
}

@media (min-width: 992px) {
    .top-menu-bar {
        margin-top: 20px;
    }

    .top-menu-bar > .alignwide {
        border-bottom: 1px solid var(--wp--preset--color--sand-border);
        padding-bottom: 20px;
    }

    .navbar-main-row {
        background-color: var(--wp--preset--color--navbar-gray);
        padding-top: 15px;
        padding-bottom: 15px;
    }
}

/* ===== MEGAMENU ===== */

#main-navbar .dropdown-menu {
    padding: 0px 5px;
}

.dg-megamenu-content {
    width: 100%;
    max-width: var(--wp--style--global--wide-size, 1400px);
    margin-left: auto;
    margin-right: auto;
}

/* 2nd level items with children */
.dg-yamm-sub-items > ul.dropdown-menu > li.dropdown {
    position: relative;
}


/* 2nd level caret button (for items WITH children) */
.dg-caret-sub {
    display: none;
    position: absolute;
    right: 20px;
    top: 8px;
    width: 25px;
    height: 25px;
    background: none;
    border: none;
    cursor: pointer;
    background-image: url("../images/icons/icon-dropdown-toggle.svg");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
    transform: rotate(0deg);
    transition: transform .25s;
}

li.show > .dg-caret-sub {
    transform: rotate(180deg);
}

@media (min-width: 992px) {
    .dg-caret-sub {
        display: none;
    }
}

@media (min-width: 992px) {
    .yamm .dropdown.yamm-fw .dropdown-menu, .yamm .dropup.yamm-fw .dropdown-menu {
        margin-top: 0 !important;
    }
    li.yamm-fw > .dropdown-menu {
        border: none;
        border-top: 1px solid var(--wp--preset--color--black);
        background-color: var(--wp--preset--color--navbar-gray);
        /* Clip the .dg-megamenu-popular::after full-bleed pink (width:100vw) at the
           viewport edge so it does not cause horizontal page overflow on desktop.
           overflow-x:clip (not hidden) keeps overflow-y visible -> the box's
           vertical -3rem bleed survives and no inner scrollbar appears. */
        overflow-x: clip;
    }

    .dg-yamm-sub-items ul.dropdown-menu {
        margin-top: 0 !important;
        display: block;
        position: static !important;
        border: 0;
        background: transparent;
    }

    .dg-yamm-sub-items ul.dropdown-menu .dropdown-toggle {
        display: none;
    }

    .dg-yamm-sub-items > ul.dropdown-menu {
        margin: 0 20px 0 0;
        column-count: 2;
        column-gap: 20px;
        display: block;
    }

    .dg-yamm-sub-items > ul.dropdown-menu > li {
        width: 100%;
        padding: 0 0 15px 0;
        break-inside: avoid;
    }

}

/* Megamenu: append »-arrow after 2nd-level links */
.dg-yamm-sub-items a.dropdown-item::after {
    content: "\00a0\00bb";
    color: var(--wp--preset--color--black);
    font-weight: 700;
}

@media (min-width: 992px) {
    .dg-yamm-sub-items a.dropdown-item:hover {
        background-color: transparent !important;
    }
}

.dg-megamenu-popular ul.dg-megamenu-popular__list a {
    font-size: 1rem;
}

/* Megamenu popular-searches column (3rd column) */
@media (min-width: 992px) {
    .dg-megamenu-content {
        display: flex;
        gap: 40px;
        align-items: stretch;
    }
    .dg-yamm-sub-items {
        flex: 2 1 0;
        min-width: 0;
    }
    .dg-megamenu-popular {
        flex: 1 1 0;
        position: relative;                                                                    
        min-width: 260px;
        padding: 45px;                                                                                         
        align-self: stretch;
        margin: -3rem 0;                                                                                       
    }
    .dg-megamenu-popular::after {                                                                              
        content: "";                                                                                        
        position: absolute;
        top: 0;
        bottom: 0;
        left: 100%;
        width: 100vw;                                                                                          
        background-color: var(--wp--preset--color--light-pink);
        z-index: -1;                                                                                           
    } 
    .dg-megamenu-popular__title {
        font-size: 1.25rem;
        font-weight: 700;
        text-decoration: underline;
        margin: 0 0 1.25rem;
        color: var(--wp--preset--color--black);
    }
    .dg-megamenu-popular__list {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    .dg-megamenu-popular__list li {
        margin-bottom: 0.6rem;
    }
    .dg-megamenu-popular__list a {
        color: var(--wp--preset--color--black);
        text-decoration: none;
    }
}
@media (max-width: 991.98px) {
    .dg-megamenu-popular {
        display: none;
    }
}

@media (max-width: 991.98px) {
    #main-navbar ul.navbar-nav a.dropdown-item {
        font-size: 1rem;
        padding: 0.5rem 1rem;
    }

    /* Mobile top menu: same style as main menu items */
    .mobile-top-menu-area {
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        padding-top: 0.5rem;
        margin-top: 0.5rem;
    }

    .mobile-top-menu-area .top-menu {
        flex-direction: column;
        padding: 0;
    }

    .mobile-top-menu-area .top-menu li {
        list-style: none;
    }

    .mobile-top-menu-area .top-menu li a {
        display: block;
        padding: 0.5rem 0;
        font-size: 1.1rem;
        color: var(--wp--preset--color--dark-gray);
        text-decoration: none;
    }
}

/* Mobile: show dropdown-menus only on click (.show) */
@media (max-width: 991.98px) {
    /* 1st level mega dropdown: show on caret click */
    li.yamm-fw.show > .dropdown-menu {
        display: block;
    }

    /* 2nd level items inside megamenu: always visible when parent is open */
    .dg-yamm-sub-items > ul.dropdown-menu {
        display: block;
        position: static !important;
        border: 0;
        padding-left: 15px;
    }

    /* 3rd level: hidden by default */
    .dg-yamm-sub-items > ul.dropdown-menu > li > ul.dropdown-menu {
        display: none;
        position: static !important;
        border: 0;
        padding-left: 15px;
    }

    /* 3rd level: show on click */
    .dg-yamm-sub-items > ul.dropdown-menu > li.show > ul.dropdown-menu {
        display: block;
    }
}

li.yamm-fw {
    position: relative !important;
}

li.yamm-fw > .dropdown-toggle:after {
    display: none;
}

li.yamm-fw > a.nav-link {
    display: inline-block;
    padding-right: 40px;
}

li.yamm-fw > a.nav-link + .dg-caret {
    display: inline-block;
    position: absolute;
    top: 14px;
    right: 0;
    width: 30px;
    height: 30px;
    background-color: var(--wp--preset--color--warm-gray);
    background-size: 18px;
    background-position: center;
    vertical-align: middle;
    background-image: url("../images/icons/icon-dropdown-toggle.svg");
    background-repeat: no-repeat;
    border: 0;
    border-radius: 6px;
    transform: rotate(0deg);
    transition: transform .25s;
}

li.yamm-fw.show > a.nav-link + .dg-caret,
a.dg-caret.show {
    transform: rotate(180deg) !important;
}

@media (min-width: 992px) {
    li.yamm-fw.show > .dropdown-menu {
        display: flex !important;
    }

    li.yamm-fw > a.nav-link + .dg-caret {
        display: inline-block;
        top: 20px;
        right: 10px;
        width: 15px;
        height: 15px;
        margin-top: -4px;
        transform: inherit;
        position: static;
        margin-right: 1rem;
        background-color: transparent;
        background-size: 12px;
        border-radius: 0;
    }

    li.yamm-fw {
        position: static !important;
    }

    .yamm-fw.show > .dropdown-menu {
        display: flex;
    }

    .main-menu li.dropdown.yamm-fw > a.nav-link {
        padding-right: 12px;
    }
}

.dropdown-item {
    white-space: normal;
}

/* Etusivu-linkki päävalikossa: koti-ikoni ennen tekstiä */
.menu-home > a.nav-link::before {
    content: "";
    display: inline-block;
    width: 15px;
    height: 15px;
    background-image: url("../images/icon-home-black.svg");
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    vertical-align: -1px;
    margin-right: 10px;
}
