/**
 *  The header styling.
 *
 *  The 'make it a hamburger menu when
 *  small'―sorry: 'responsive menu'―comes from
 *
 *  https://codepen.io/alvarotrigo/pen/MWEJEWG
 *
 *  The menu is implemented using <nav> around
 *  custom tags <l2sotm-menu><l2sotm-menu-item>...
 */

/**
 * fix the size of the menu
 */
:root {
    --menu-height: 4rem;
}

/**
 *  Palette: (see also l2sotm.css)
 *      background when on image: rgb(203 234 254 / 50%)
 *      background when sticky:   rgb(203 234 254)
 *      text:                     rgb(8 51 80)
 *      highlight text:           rgb(255 238 175)
 *      background when hovering: rgb(66 126 165)
 */
:root {
    --slidey-menu-background-colour:    rgb(203 234 254 / 50%);
    --sticky-menu-background-colour:    rgb(203 234 254 / 100%);
    --menu-text-colour:                 rgb(8 51 80);
    --menu-text-hover-colour:           rgb(255 238 175);
    --menu-background-hover-colour:     rgb(66 126 165);
}

/**
 * z-index trickery:
 *
 * we need the <nav> to be higher than normal
 * because it will otherwise be covered up by
 * other items (eg the route map)
 */
:root {
    --header-z-index: 200;
}

header {
    /*
     * make the header a column, starting at the bottom:
     * this will place the <nav> at the bottom of the
     * background picture
     */
    display: flex;
    flex-direction: column-reverse;
    height: 30%; width: 100%;
    /* background is set in view/html/html.php */
}

nav {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;

    position: relative;
    z-index: var(--header-z-index);
    height: var(--menu-height);
    width: 100%;
    padding: 0;
    color: var(--menu-text-colour);
    background-color: var(--slidey-menu-background-colour);
    transition: background-color 2s;
}

nav > l2sotm-logo {
    height: 100%; var(--menu-height);
    width: var(--menu-height);  /* make it square */
}

nav.sticky {
    /* when scrolled, stick to the top of the screen and go opaque */
    position: fixed;
    top: 0;
    left: 0;
    padding: var(--screen-padding);
    background-color: var(--sticky-menu-background-colour);
}

/*
 * Format the menu as a flex box.
 *
 * Initially, it lists the menu items left to right.
 *
 * The menu turns into a 'hamburger' menu if the viewport
 * is too small.
 *
 * Each menu item is itself a vertical flexbox, which lets
 * us vertically centre the menu items without padding, etc.
 */
l2sotm-menu {
    display: flex;
    flex-direction: row;
    align-items: stretch;

    margin: 0;
}
l2sotm-menu-item {
    display: flex;
    flex-direction: column;

    padding: 0 1rem;     /* original had margin: but padding: extends the highlight; */
}
l2sotm-menu-item a {
    display: flex;
    flex-direction: column;
    justify-content: center;

    color: inherit;
    text-align: center;
    text-decoration: none;
    height: 100%;
    width: 100%;
}
l2sotm-menu-item:hover {
    color: var(--menu-text-hover-colour);
    background-color: var(--menu-background-hover-colour);
}

.menu-button-container {
    display: none;
    height: 100%;
    width: 30px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#menu-toggle {
    display: none;
}

/*
 * the bars are just small, rounded rectangles
 * on top of the normal menu
 */
.menu-button,
.menu-button::before,
.menu-button::after {
    display: block;
    background-color: var(--menu-text-colour);
    position: absolute;
    height: 4px;
    width: 30px;
    transition: transform 400ms cubic-bezier(0.23, 1, 0.32, 1);
    border-radius: 2px;
}

.menu-button::before {
    content: '';
    margin-top: -8px;
}

.menu-button::after {
    content: '';
    margin-top: 8px;
}

#menu-toggle:checked + .menu-button-container .menu-button::before {
    margin-top: 0px;
    transform: rotate(405deg);
}

#menu-toggle:checked + .menu-button-container .menu-button {
    background: transparent;
}

#menu-toggle:checked + .menu-button-container .menu-button::after {
    margin-top: 0px;
    transform: rotate(-405deg);
}

@media (max-width: 1000px) {
    .menu-button-container {
        display: flex;
        z-index: calc(var(--header-z-index) + 1);
    }
    l2sotm-menu {
        position: absolute;
        top: 0;
        margin-top: 4rem;
        left: 0;
        flex-direction: column;
        width: 100%;
        justify-content: center;
        align-items: center;
        background-color: var(--sticky-menu-background-colour);
    }
    #menu-toggle ~ l2sotm-menu l2sotm-menu-item {
        display: none;
        height: 0;
        margin: 0;
        padding: 0;
        border: 0;
        transition: height 400ms cubic-bezier(0.23, 1, 0.32, 1);
    }
    #menu-toggle:checked ~ l2sotm-menu {
        background-color: var(--sticky-menu-background-colour);
    }
    #menu-toggle:checked ~ l2sotm-menu l2sotm-menu-item {
        display: flex;
        height: 2.5rem;
        padding: 0.5rem;
        transition: height 400ms cubic-bezier(0.23, 1, 0.32, 1);
    }
    l2sotm-menu-item {
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0;
        padding: 0.5rem 0;
        width: 100%;
    }
    #menu-toggle:checked ~ l2sotm-menu > l2sotm-menu-item:first-child {
        border-top: thin solid var(--menu-text-colour);
    }
    #menu-toggle:checked ~ l2sotm-menu > l2sotm-menu-item {
        border-bottom: thin solid var(--menu-text-colour);
    }
}
/* vim: set sw=4 expandtab ai: */
