/* Do načtení stránky (viz `main.js`) se hlavička nesmí animovat. */
.bez-prechodu .topbar,
.bez-prechodu .topbar * {
    transition: none;
}

/* Ne obecné `nav`: to je i stránkování a podmenu. */
nav.standard,
.landing-page > nav {
    --nav-height: 3*var(--nav-margin);
    --total-height: calc(var(--nav-height) + 2*var(--nav-margin));
    --hamburger-margin: var(--nav-margin);
    --bun-height: calc((2.5em - var(--hamburger-margin)) / 5);

    display: flex;
    column-gap: 1em;

    transition: height 0.5s;

    a {
        text-align: center;
    }

    a, .hamburger {
        height: 2.5em;
        padding: var(--nav-margin);
        margin: var(--nav-margin);
        box-sizing: border-box;
    }

    a {
        display: grid;
        justify-content: center;
        align-content: center;
        min-width: 5em;
        border-radius: var(--nav-margin);
        transition: 0.2s background-color;

        color: inherit;
        text-decoration: none;

        &:hover {
            background-color: var(--focus);
        }
    }

    a.brand {
        grid-template-columns: 2fr 3fr;
        align-items: center;
        font-weight: bold;
        gap: 0.3em;
        margin-right: auto;

        img, svg {
            max-height: 100%;
            max-width: 100%;
            height: 1.2em;
            justify-self: right;
        }

        &:hover {
            background: var(--base);
            color: var(--text-color-inv);
            svg path {
                fill: url(#gradient) !important;
            }
        }
    }
}

/* Přechod nese obal, aby plynule pokračoval přes spodní řádky. */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 11;
    background: var(--pozadi-lista);
}


nav.standard {
    width: 100%;
    height: 3.5em;

    .title-long {
        display: none;
    }

    .dropdown {
        z-index: 10;
        position: absolute;
        right: 0;
        top: 0;
        padding-top: 3.5em;
        border-bottom-left-radius: var(--nav-margin);
        background: linear-gradient(to bottom, transparent 0, transparent calc(var(--total-height) - 0.5em), var(--blue) var(--total-height), var(--purple) 200%);

        display: none;
    }

    /* Jen vizuálně skrytý, aby šel ovládat klávesnicí; fokus ukáže hamburger. */
    #toggle {
        position: absolute;
        width: 1px;
        height: 1px;
        opacity: 0;
        margin: 0;
    }

    #toggle:focus-visible + .hamburger {
        outline: 2px solid var(--base);
        outline-offset: -2px;
        border-radius: var(--nav-margin);
    }

    .hamburger {
        width: 3em;
        z-index: 12;
        padding: var(--hamburger-margin);
        margin: var(--hamburger-margin);

        div {
            position: relative;
            width: 100%;
            height: var(--bun-height);
            border-radius: 3px;
            background-color: var(--base);
            opacity: 0.7;
            margin-bottom: var(--bun-height);
            transition: all 0.2s ease-in-out;
        }
    }

    #toggle:checked + .hamburger .top-bun {
        transform: rotate(-45deg);
        margin-top: calc(var(--bun-height) * 2);
    }
    #toggle:checked + .hamburger .bottom-bun {
        opacity: 0;
        transform: rotate(45deg);
    }
    #toggle:checked + .hamburger .meat {
        transform: rotate(45deg);
        margin-top: calc(-1 * (var(--bun-height) * 2));
    }

    #toggle:checked + .hamburger + .dropdown {
        display: block;
    }

    @media (min-width: 50rem) {
        .hamburger,
        #toggle {
            display: none;
        }

        .dropdown {
            display: flex !important;
            position: unset;
            padding-top: unset !important;
            background: unset;
            margin: var(--nav-margin);
            gap: var(--nav-margin);

            a {
                margin: 0;
            }
        }

        &.large .dropdown>* {
            flex-basis: 40%;
            flex-grow: 1;
            flex-shrink: 0;
        }
    }

    &.large {
        --nav-height: 7em;
        --nav-margin: 1em;
        --hamburger-margin: 0.5em;

        height: var(--total-height);
        grid-template-columns: 2fr 3fr;

        a.brand {
            height: var(--nav-height);
            max-width: 50%;
            /* S `2fr 3fr` by dlouhé slovo v názvu na úzkém displeji stlačilo logo. */
            grid-template-columns: auto minmax(0, 1fr);

            svg {
                height: 3.2em;
                width: auto;

                @media (min-width: 50rem) {
                    height: 5em;
                }
            }

            .short {
                display: none;
            }

            .title-long {
                display: initial;
                font-size: 1.2em;
            }
        }

        .hamburger {
            align-self: center;
        }

        .dropdown {
            max-width: 50%;
            flex-wrap: wrap;
            justify-content: center;
        }

        #toggle:checked + .hamburger + .dropdown {
            padding-top: var(--total-height);
        }
    }
}

/* Odsazení obsahu pod fixní hlavičku: změřená výška plus ~10px, v `rem`,
   protože lišta a obsah mají jinou velikost písma. Při změně hlavičky přeměřit. */
.topbar + * {
    margin-top: 12.75rem;
}

.topbar.with-member + * {
    margin-top: 13rem;
}

.topbar.with-member.with-section + * {
    margin-top: 15rem;
}

nav.standard a.active {
    background-color: var(--focus);
}

/* Aktivní sekce je záložka plynule přecházející do panelu s podmenu. */
.memberbar,
.sectionbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    font-family: var(--pismo-ui);
    font-size: 0.8rem;
    color: var(--base);
}

.memberbar {
    justify-content: space-between;
    gap: 0 1.5em;
    padding: 0.35em calc(0.75rem - 0.9em) 0;
    background: rgba(0, 0, 0, 0.14);

    .sections {
        display: flex;
        flex-wrap: wrap;
        gap: 0 0.3em;
    }

    .identity {
        margin-left: auto;
        padding: 0.6em 0.9em;
    }

    .identity a.login {
        color: inherit;
        text-decoration: underline;
    }
}

.sectionbar {
    gap: 0 0.3em;
    padding: 0.28em calc(0.75rem - 0.9em);
    background: rgba(0, 0, 0, 0.3);
}

.memberbar .sections a,
.sectionbar a {
    display: inline-block;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;

    &:hover {
        background-color: rgba(255, 255, 255, 0.12);
        color: var(--base);
    }

    &.active {
        color: var(--base);
        font-weight: 600;
    }
}

.memberbar .sections a {
    padding: 0.6em 0.9em;
    border-radius: 0.3em 0.3em 0 0;

    /* Složeno s řádkem (0.14) dá barvu panelu: 1-(1-0.14)(1-0.186) = 0.30. */
    &.active {
        background-color: rgba(0, 0, 0, 0.186);
    }
}

.sectionbar a {
    padding: 0.4em 0.9em;
    border-radius: 0.3em;

    &.active {
        background-color: rgba(255, 255, 255, 0.18);
    }
}

.topbar:not(.with-section) .memberbar .sections a.active {
    border-radius: 0.3em;
    margin-bottom: 0.3em;
}

/* Na úzkém displeji se řádek pro přihlášené zalomí na dva: identita nad sekce, aby
   záložka dál přecházela do podmenu. */
@media (max-width: 50rem) {
    .topbar.with-member + * {
        margin-top: 15rem;
    }

    .topbar.with-member.with-section + * {
        margin-top: 16.75rem;
    }

    .memberbar {
        flex-direction: column;
        align-items: stretch;

        .identity {
            order: -1;
            margin-left: 0;
            padding-inline: 0.9em;
        }
    }
}

.landing-page .memberbar {
    background-color: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    padding-left: 0;
    padding-right: 0;
}

.landing-page {
    padding: 0.5rem max(0.5rem, ((100% - var(--footer-max-width)) / 2));
    max-width: var(--footer-max-width);

    > nav {
        justify-content: center;
        background: transparent;
        flex-wrap: wrap;

        &>* {
            flex-basis: 40%;
            flex-shrink: 0;
            flex-grow: 1;

            @media (min-width: 50rem) {
                flex-basis: 20%;
            }
        }
    }

    h1 {
        margin: 0;
        padding: 1.5em 0;
        width: 100%;

        text-align: left;
        display: grid;
        grid-template-columns: 2fr 3fr;
        align-items: center;
        gap: 1em;

        font-size: 2em;

        img {
            max-height: 100%;
            height: 3.5em;
            max-width: 100%;
            justify-self: right;
        }
    }
}


.title-long {
    font-weight: normal;
    span.highlight {
        font-weight: bold;
    }
}

/* Titulka má vlastní navigaci; fixní lišta naskočí až při odrolování. */
.landing-page + .topbar {
    nav.standard.large {
        height: 0;
        visibility: hidden;
    }

    nav.standard.large ~ .memberbar {
        display: none;
    }
}

.landing-page + .topbar + * {
    margin-top: 0;
}
