/* Layout of the site itself (masthead menu, page scrollbar, page change), not of the extension. Included on every page of the
   site (TypoScript page.includeCSS). These rules belong to the site package (Komet2020); they stay here until they are moved there.
   The styles of the extension's own pages are in gtn_exabiscompetences_grid.css, which only the extension's pages load. */

/* the room of the scrollbar is always reserved: the page does not jump if a scrollbar appears or disappears (e.g. short / long content).
   This file is included on every page, so the rule is valid for the whole site.
   Not "overflow-y: scroll" on html: with it a body with its own overflow (e.g. body.home-page { overflow-x: hidden }) becomes a scroll box of its own
   and the mouse wheel over the fixed navbar no longer scrolls the page. */
html {
    scrollbar-gutter: stable;
}

/* the room is reserved, so the padding which bootstrap adds to the body for the scrollbar when a modal opens is too much:
   without this rule the content moves to the left by half a scrollbar while a modal is open */
body.modal-open {
    padding-right: 0 !important;
}

/* home pages (e.g. self assessment overview): the theme template renders two placeholder blocks below the hero (white featuredGrid, grey apps-cnt).
   If nothing is inside (no element, whitespace only) they are only an empty strip, so they are hidden; they show again as soon as there is content. */
body.home-page main.maincontent > .bg-white:has(#featuredGrid):not(:has(#featuredGrid *)),
body.home-page main.maincontent > .apps-cnt:not(:has(.col-sm-12 *)) {
    display: none;
}

/* same for modals: the room of their scrollbar is always reserved, so a modal does not jump to the left when its content gets higher than the window (e.g. a textarea which is pulled bigger) */
.modal {
    scrollbar-gutter: stable;
}

/* masthead menu (site package): the arrow icon of external menu items always has the same distance to the text */
.dropdown-item .nav-item-extern-icon {
    flex: 0 0 auto;
    margin-left: 1.25rem;
}

/* language switch in the masthead menu: "DE" / "EN" instead of "De" / "En" (the label is printed by the site template) */
#langNavigation > .nav-link {
    text-transform: uppercase;
}

/* dropdown items with the MDB "waves-effect" (logged in: language and profile menu) became inline-block and got the
   descender space of a text line below them: 6px more space under the last item than above the first.
   Back to the normal block of bootstrap. :where() keeps it weak, items with an own layout (flex) keep it */
:where(.dropdown-menu) .dropdown-item.waves-effect {
    display: block;
}

/* opening / closing of the dropdowns (MDB 4 "animated fadeIn" / "animated fadeOut", 0.55 s plain fade by default):
   opens quick and unfolds a little from its button, closes even quicker. MDB still closes the menu on the end of the animation.
   translate / scale are own properties, so they do not overwrite a transform of the positioning (popper) */
@keyframes exa-dropdown-in {
    from { opacity: 0; translate: 0 -4px; scale: 0.98; }
    to { opacity: 1; translate: 0 0; scale: 1; }
}

@keyframes exa-dropdown-out {
    from { opacity: 1; translate: 0 0; }
    to { opacity: 0; translate: 0 -2px; }
}

.dropdown-menu.animated.fadeIn {
    transform-origin: top center;
    animation-name: exa-dropdown-in;
    animation-duration: 0.14s;
    animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.dropdown-menu-end.animated.fadeIn,
.dropdown-menu-right.animated.fadeIn {
    transform-origin: top right;
}

.dropdown-menu.animated.fadeOut {
    animation-name: exa-dropdown-out;
    animation-duration: 0.09s;
    animation-timing-function: cubic-bezier(0.4, 0, 1, 1);
}

/* switching from one open dropdown to another: no fade out / fade in (see gtn_exabiscompetences_navbar.js "dropdown-switching").
   MDB 4 animates with "animated fadeIn" / "animated fadeOut" and closes the old menu only on the end of its animation,
   so the animations run in 1 ms instead of being switched off; bootstrap 5 menus use transitions, they are switched off */
body.dropdown-switching .dropdown-menu {
    transition: none !important;
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
}

/* masthead menu on small screens: a clean list, sub menus open inline, short animations */
@keyframes exa-menu-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* up to "xl": the menu is collapsed there too (see gtn_exabiscompetences_navbar.js) */
@media (max-width: 1199.98px) {
    .navbar-comet-top .navbar-collapse.collapsing {
        transition: height 0.2s ease;
    }

    .navbar-comet-top .navbar-collapse {
        padding: 0.5rem 0 0.75rem;
    }

    .navbar-comet-top .navbar-nav {
        width: 100%;
        padding: 0 1rem;
        align-items: stretch !important; /* the utility classes of the list (align-items-lg-center) would center the entries */
    }

    .navbar-comet-top .navbar-nav > .nav-item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .navbar-comet-top .navbar-nav > .nav-item:last-child {
        border-bottom: 0;
    }

    /* every entry the same height (easy to tap) and the same indentation */
    .navbar-comet-top .navbar-nav > .nav-item > .nav-link {
        display: flex;
        align-items: center;
        min-height: 3rem;
        margin: 0;
        padding: 0.5rem 0.25rem;
    }

    /* the green hub button: separated from the list */
    .navbar-comet-top .navbar-nav > .nav-item-backToHub {
        margin: 0.25rem 0 0.5rem;
        border-bottom: 0;
    }

    .navbar-comet-top .navbar-nav > .nav-item-backToHub > .nav-link {
        min-height: 2.75rem;
        padding: 0.5rem 1rem;
    }

    /* sub menus: indented list inside the page flow, no box, no shadow */
    nav.navbar-comet-top .navbar-nav .dropdown-menu {
        position: static !important;
        transform: none !important;
        float: none;
        width: 100%;
        min-width: 0;
        margin: 0 !important;
        padding: 0 0 0.5rem 1rem !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    /* shadow below the open menu */
    nav.navbar-comet-top:has(.navbar-collapse.show, .navbar-collapse.collapsing) {
        box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.18);
    }

    .navbar-comet-top .dropdown-menu.show {
        animation: exa-menu-fade-in 0.2s ease;
    }

    .navbar-comet-top .dropdown-menu .dropdown-item {
        display: flex;
        align-items: center;
        min-height: 2.75rem;
        padding: 0.5rem;
        white-space: normal;
    }

    /* the arrow turns while the sub menu is open */
    .navbar-comet-top .dropdown-toggle::after {
        transition: transform 0.2s ease;
    }

    .navbar-comet-top .dropdown-toggle:has(+ .dropdown-menu.show)::after {
        transform: rotate(180deg);
    }
}

/* the masthead's min-height: 75px comes from the site's custom.css; a more specific rule here removes it */
nav.navbar-comet-top {
    min-height: auto;
}

/* page change (e.g. dashboard -> themen, hub lists): soft cross-fade of the content instead of the white flash (browsers with cross-document view transitions,
   all others just load the page as before). The sidebar and the top bar have an own name: they stay in place and are not faded.
   Both pages need this rule, so it is in the css which is included on every page (TypoScript), not in a template css. Not for visitors who want less motion. */
@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }
    .side-nav-comet {
        view-transition-name: gtn-sidenav;
    }
    .navbar-comet-top {
        view-transition-name: gtn-topnav;
    }
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.15s;
    }
}

/* "lg" to "xl": gtn_exabiscompetences_navbar.js removes navbar-expand-lg there, but only after the page is loaded. Until then the wide menu showed for a moment
   (squeezed menu, small logo). The collapsed look is set here too, so the header is the same from the first paint. */
@media (min-width: 992px) and (max-width: 1199.98px) {
    nav.navbar-comet-top.navbar-expand-lg {
        flex-wrap: wrap !important;
        justify-content: space-between !important;
    }

    nav.navbar-comet-top.navbar-expand-lg .navbar-toggler {
        display: block !important;
    }

    nav.navbar-comet-top.navbar-expand-lg .navbar-collapse {
        display: none !important;
        flex-basis: 100%;
    }

    nav.navbar-comet-top.navbar-expand-lg .navbar-collapse.show,
    nav.navbar-comet-top.navbar-expand-lg .navbar-collapse.collapsing {
        display: block !important;
    }

    nav.navbar-comet-top.navbar-expand-lg .navbar-nav {
        flex-direction: column !important;
    }
}

/* phones: the site sets the logo link to 300px wide, so the hamburger button wraps under the logo */
@media (max-width: 991.98px) {
    .navbar-comet-top .navbar-brand {
        width: auto !important;
        max-width: none !important;
    }
    .navbar-comet-top .navbar-brand img#brand {
        width: auto !important;
        height: 2rem !important;
    }
}

/* low windows: smaller logo in the footer */
@media (max-height: 700px) {
    .frontend-footer .brandlink-footer img {
        width: 8rem;
        height: auto;
    }
}
