/*
 * Navigation Modes Styles
 *
 * Flyout menu, overlay (fullscreen) and side navigation of [iwfdt_navigation mode="…"].
 * The dropdown mode keeps Navigation.css. Colors come from the theme tokens; child themes
 * restyle through the iw-nav-* classes. Opening needs no hover: every panel has a button.
 *
 * @package     iw-foundation-theme
 * @subpackage  style/navigation-modes
 * @since       1.5.0
 -------------------------------------------------------------- */

/* Flyout menu ------------------------------------------------- */

.iw_navigation.iw-nav-mode-flyout ul.top-level-menu {
    column-gap: 16px;
}

.iw_navigation.iw-nav-mode-flyout ul.top-level-menu > li.top-level-menu-item {
    display: inline-flex;
    align-items: center;
}

/* Disclosure button next to the top-level link: at least 24 x 24px (SC 2.5.8). */
.iw-nav-flyout__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.iw-nav-flyout__toggle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: transform .2s ease-out;
}

.iw-nav-flyout__toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* Outside the header the navigation itself anchors the panel; in the header the header row does. */
.iw-nav-mode-flyout {
    position: relative;
}

.iw_header .iw-nav-mode-flyout {
    position: static;
}

/* The panel spans the header row (or the next positioned ancestor) below the bar. Closed it is
   hidden from everyone, so focus never lands on an invisible link. */
.iw-nav-flyout {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity .2s ease-out, visibility 0s linear .2s;
}

.iw-nav-flyout.iw-nav-flyout--open {
    visibility: visible;
    opacity: 1;
    transition: opacity .2s ease-out, visibility 0s;
}

.iw-nav-flyout__box {
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding: 32px 40px;
    background: var(--iw-color-background, #fff);
    color: var(--iw-color-text, #333);
    box-shadow: 0 0 20px rgba(0, 0, 0, .1);
}

/* One column per top-level item in one row; all columns shrink alike. */
.iw_navigation.iw-nav-mode-flyout .iw-nav-flyout ul.iw-nav-flyout__columns {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 320px);
    column-gap: 40px;
}

.iw-nav-flyout__column {
    min-width: 0;
    overflow-wrap: break-word;
}

.iw_navigation.iw-nav-mode-flyout .iw-nav-flyout ul.iw-nav-flyout__links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.iw-nav-flyout a.iw-nav-flyout__heading,
.iw-nav-flyout a.iw-nav-flyout__link {
    display: inline-block;
    min-height: 24px;
    color: var(--iw-color-text, #333);
    text-decoration: none;
}

.iw-nav-flyout a.iw-nav-flyout__heading {
    font-weight: 700;
    font-size: 1.43rem;
}

.iw-nav-flyout a.iw-nav-flyout__heading:hover,
.iw-nav-flyout a.iw-nav-flyout__heading:focus-visible,
.iw-nav-flyout a.iw-nav-flyout__heading[aria-current="page"],
.iw-nav-flyout .iw-nav-flyout__column--active a.iw-nav-flyout__heading,
.iw-nav-flyout a.iw-nav-flyout__link:hover,
.iw-nav-flyout a.iw-nav-flyout__link:focus-visible,
.iw-nav-flyout a.iw-nav-flyout__link[aria-current="page"] {
    color: var(--iw-color-primary, #EF17EF);
}

.iw-nav-flyout__content {
    margin-top: 16px;
}

html.iw-a11y-contrast_mode .iw-nav-flyout a[aria-current="page"],
html.iw-a11y-contrast_mode .iw-nav-flyout a:hover {
    text-decoration: underline;
}

@media screen and (max-width: 1119px) {
    .iw-nav-flyout__box {
        padding: 24px;
    }

    .iw_navigation.iw-nav-mode-flyout .iw-nav-flyout ul.iw-nav-flyout__columns {
        grid-auto-flow: row;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        column-gap: 24px;
        row-gap: 32px;
    }
}

/* Overlay and side navigation --------------------------------- */

/* The header hides its navigation until Navigation.js shows it; these modes bring their own
   button and stay visible on every screen size. */
.iw_header_content_area .iw_foundation_theme_navigation_widget .iw_navigation.iw-nav-mode-overlay nav,
.iw_header_content_area .iw_foundation_theme_navigation_widget .iw_navigation.iw-nav-mode-sidenav nav {
    display: block;
    opacity: 1;
}

.iw-nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.iw-nav-toggle svg,
.iw-nav-panel__close svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Without JavaScript there is nothing to toggle: the button stays hidden, the panel is a plain
   navigation in the page. NavigationModes.js adds iw-nav-ready. */
.iw-nav-mode-overlay:not(.iw-nav-ready) .iw-nav-toggle,
.iw-nav-mode-sidenav:not(.iw-nav-ready) .iw-nav-toggle,
.iw-nav-mode-overlay:not(.iw-nav-ready) .iw-nav-panel__bar,
.iw-nav-mode-sidenav:not(.iw-nav-ready) .iw-nav-panel__bar {
    display: none;
}

.iw-nav-ready .iw-nav-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 1002;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--iw-color-background, #fff);
    color: var(--iw-color-text, #333);
    visibility: hidden;
    opacity: 0;
    transition: opacity .3s ease-out, transform .3s ease-out, visibility 0s linear .3s;
}

.iw-nav-ready .iw-nav-panel.iw-nav-panel--open {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity .3s ease-out, transform .3s ease-out, visibility 0s;
}

.iw-nav-ready .iw-nav-overlay {
    left: 0;
    right: 0;
    padding: 24px max(24px, env(safe-area-inset-right)) 48px max(24px, env(safe-area-inset-left));
}

.iw-nav-ready .iw-nav-sidenav {
    right: 0;
    width: min(400px, 85vw);
    padding: 24px;
    box-shadow: 0 0 20px rgba(0, 0, 0, .15);
    transform: translateX(100%);
}

.iw-nav-panel__bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}

.iw-nav-panel__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

/* The whole menu as nested list: top level large, sub-items below their parent. */
.iw_navigation.iw-nav-mode-overlay .iw-nav-panel ul,
.iw_navigation.iw-nav-mode-sidenav .iw-nav-panel ul {
    display: block;
}

.iw-nav-panel ul.top-level-menu > li.top-level-menu-item {
    margin-bottom: 16px;
}

.iw-nav-panel ul.top-level-menu > li.top-level-menu-item > a {
    font-size: 1.43rem;
    font-weight: 700;
}

.iw-nav-overlay ul.top-level-menu > li.top-level-menu-item > a {
    font-size: 2rem;
}

.iw-nav-panel ul.sub-level-menu {
    margin-top: 8px;
    padding-left: 16px;
}

.iw-nav-panel ul.sub-level-menu > li.sub-level-menu-item {
    margin-bottom: 8px;
}

.iw-nav-overlay .iw-nav-panel__bar,
.iw-nav-overlay nav {
    max-width: 1200px;
    margin: 0 auto;
}

/* The page behind the open overlay does not scroll. */
html.iw-nav-overlay-open {
    overflow: hidden;
}

/* Reduced motion: no fades and slides, also without iw-wp-utils (SC 2.3.3). */
html.iw-a11y-reduce_motion .iw-nav-flyout,
html.iw-a11y-reduce_motion .iw-nav-flyout__toggle svg,
html.iw-a11y-reduce_motion .iw-nav-panel {
    transition: none;
}

@media (prefers-reduced-motion: reduce) {
    html:not(.iw-a11y-no-reduce_motion) .iw-nav-flyout,
    html:not(.iw-a11y-no-reduce_motion) .iw-nav-flyout__toggle svg,
    html:not(.iw-a11y-no-reduce_motion) .iw-nav-panel {
        transition: none;
    }
}
