/*
 * The header: sticky at the top on every page, with the language switch "DE / EN" (block
 * katzkow/language-switch) at its end (Figma "Menu", 299:127). Up to 1024px the links, the Kontakt
 * button and the switch make way for a menu button that opens a panel below the bar with the same
 * links, the switch and the button (script.js builds it from the header; Figma "Menu Tablet"
 * 182:2770 up to 1024px, "Menu Handy" 243:97 up to 568px). Up to 768px the header folds into a round
 * menu button once the page is scrolled (is-mobile-header-collapsed).
 *
 * The header part: an outer group (the navy bar) holding an inner group (katzkow-header-inner)
 * whose first group is the logo (katzkow-header-logo). Its blocks carry Von Block classes too; where
 * this file changes what they set, its selectors are more specific than one class.
 */

.wp-site-blocks > header.wp-block-template-part {
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: -1px; /* no seam between the bar and a navy first section */
}

body.admin-bar .wp-site-blocks > header.wp-block-template-part {
    top: 32px;
}

@media (max-width: 782px) {
    body.admin-bar .wp-site-blocks > header.wp-block-template-part {
        top: 46px;
    }
}

/*
 * The bar's navy is drawn by ::before, not by the group, so that on phones it can fold away to the
 * right without taking the menu button with it.
 */
.wp-site-blocks > header.wp-block-template-part > .wp-block-group {
    position: relative;
    overflow: visible;
    background: transparent;
}

.wp-site-blocks > header.wp-block-template-part > .wp-block-group::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--mcg-color-surface-dark);
    transform: scaleX(1);
    transform-origin: right center;
    transition:
        transform 0.42s cubic-bezier(0.4, 0, 0.2, 1),
        border-radius 0.32s ease;
    pointer-events: none;
}

.wp-site-blocks > header.wp-block-template-part > .wp-block-group > * {
    position: relative;
    z-index: 1;
}

.wp-site-blocks > header.wp-block-template-part + .entry-content > .mcg-background-color-surface-dark:first-child {
    margin-top: -1px;
}

/* The language switch: the current language bold and underlined, the other light */
.katzkow-language-switch {
    color: var(--mcg-color-text-on-dark);
    font-family: 'Hanken Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

/* In the header bar: centred beside the Kontakt button, 60px from it (its own margin is 20px) */
/* (the block's own class: on the site the switch itself, in the editor its wrapper) */
.wp-block-group > .wp-block-katzkow-language-switch {
    align-self: center;
    margin-left: 40px;
}

.katzkow-language-switch a {
    color: inherit;
    font-weight: 400;
    text-decoration: none;
}

.katzkow-language-switch a.is-current {
    font-weight: 600;
    text-decoration: underline;
}

.katzkow-language-switch a:hover {
    text-decoration: underline;
}

.katzkow-mobile-menu-toggle,
.katzkow-mobile-menu {
    display: none;
}

/* Phones and tablets (Figma "Menu Tablet") */
@container (max-width: 1024px) {
    header .katzkow-header-inner {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        position: relative;
        padding-top: 24px;
        padding-bottom: 24px;
    }

    /* The links, the Kontakt button and the language switch make way */
    .katzkow-header-inner > p,
    .katzkow-header-inner > .wp-block-group:not(.katzkow-header-logo) {
        display: none;
    }

    .katzkow-header-inner > .katzkow-header-logo {
        display: block;
        width: 403px;
        max-width: calc(100% - 74px);
        margin: 0;
        flex-grow: 0;
        flex-shrink: 1;
        flex-basis: auto;
        transform: translateX(0);
        opacity: 1;
        transition:
            transform 0.42s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.24s ease;
    }

    /* Block, not WordPress's centring table and an inline link: no gap under the logo */
    .katzkow-header-logo figure.wp-block-image,
    .katzkow-header-logo a,
    .katzkow-header-logo img {
        display: block;
        width: 100%;
        max-width: 100%;
        height: auto;
        margin: 0;
    }

    /* The menu button: three lines, a cross when open */
    .katzkow-mobile-menu-toggle {
        --bar: 3px;
        display: inline-flex;
        position: relative;
        flex: 0 0 auto;
        width: 50px;
        height: 35px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: var(--mcg-color-text-on-dark);
        cursor: pointer;
        z-index: 10;
        transition:
            width 0.28s ease,
            height 0.28s ease,
            border-radius 0.28s ease,
            background-color 0.28s ease,
            border-color 0.28s ease,
            box-shadow 0.28s ease,
            transform 0.28s ease;
    }

    .katzkow-mobile-menu-toggle span {
        position: absolute;
        left: 0;
        width: 100%;
        height: var(--bar);
        background: currentColor;
        transform-origin: center;
        transition:
            top 0.22s ease,
            transform 0.22s ease,
            opacity 0.18s ease;
    }

    .katzkow-mobile-menu-toggle span:nth-child(1) {
        top: 0;
    }

    .katzkow-mobile-menu-toggle span:nth-child(2) {
        top: calc(50% - var(--bar) / 2);
    }

    .katzkow-mobile-menu-toggle span:nth-child(3) {
        top: calc(100% - var(--bar));
    }

    .katzkow-header-inner.is-mobile-menu-open .katzkow-mobile-menu-toggle span:nth-child(1),
    .katzkow-header-inner.is-mobile-menu-open .katzkow-mobile-menu-toggle span:nth-child(3) {
        top: calc(50% - var(--bar) / 2);
    }

    .katzkow-header-inner.is-mobile-menu-open .katzkow-mobile-menu-toggle span:nth-child(1) {
        transform: rotate(45deg);
    }

    .katzkow-header-inner.is-mobile-menu-open .katzkow-mobile-menu-toggle span:nth-child(2) {
        opacity: 0;
    }

    .katzkow-header-inner.is-mobile-menu-open .katzkow-mobile-menu-toggle span:nth-child(3) {
        transform: rotate(-45deg);
    }

    /*
     * The panel, sliding open below the bar, the window's whole width: its lines run from edge to
     * edge, its content keeps the page's margin (Von Block's grid variable --m1).
     */
    .katzkow-mobile-menu {
        display: block;
        flex: 0 0 auto;
        width: 100vw;
        margin: 0 calc(50% - 50vw);
        max-height: 0;
        overflow: hidden;
        visibility: hidden;
        opacity: 0;
        transform: translateY(-12px);
        pointer-events: none;
        transition:
            max-height 0.42s ease,
            opacity 0.24s ease,
            transform 0.32s ease,
            visibility 0s linear 0.42s;
    }

    .katzkow-header-inner.is-mobile-menu-open .katzkow-mobile-menu {
        max-height: 640px;
        margin-top: 24px;
        margin-bottom: -24px; /* the bar's own bottom padding is the panel's */
        visibility: visible;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
        transition:
            max-height 0.42s ease,
            opacity 0.24s ease,
            transform 0.32s ease,
            visibility 0s;
    }

    /* A link: the submenu style (mcg-typo-submenu), a white line below */
    .katzkow-mobile-menu__link.mcg-typo-submenu {
        display: block;
        padding: 24px var(--m1);
        border-bottom: 1px solid var(--mcg-color-text-on-dark);
        text-decoration: none;
    }

    .katzkow-mobile-menu__footer {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 24px;
        padding: 24px var(--m1);
    }

    .katzkow-mobile-menu__footer .katzkow-language-switch {
        font-size: 18px;
        line-height: 1.2;
    }

    .katzkow-mobile-menu__footer .katzkow-language-switch a {
        font-weight: 600;
        text-decoration: none;
    }

    /* The Kontakt button: the header's (btn btn-on-dark), with the design's padding */
    .katzkow-mobile-menu__footer .wp-block-button.mcg-typo-btn {
        padding: 8px 16px;
    }
}

/* Phones (Figma "Menu Handy") */
@container (max-width: 568px) {
    .katzkow-header-inner > .katzkow-header-logo {
        width: 230px;
    }

    .katzkow-mobile-menu-toggle {
        --bar: 2px;
        width: 30px;
        height: 20px;
    }

    /* The cross is a little smaller than the three lines */
    .katzkow-header-inner.is-mobile-menu-open .katzkow-mobile-menu-toggle span:nth-child(1),
    .katzkow-header-inner.is-mobile-menu-open .katzkow-mobile-menu-toggle span:nth-child(3) {
        left: 2px;
        width: 26px;
    }
}

/* Phones and small tablets, scrolled: the bar folds away to the right, only a round menu button stays */
@container (max-width: 768px) {
    .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed {
        pointer-events: none;
    }

    .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed > .wp-block-group::before {
        transform: scaleX(0);
        border-radius: 999px;
    }

    .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed .katzkow-header-logo {
        transform: translateX(calc(100vw - 110px)) scale(0.2);
        transform-origin: right center;
        opacity: 0;
        pointer-events: none;
    }

    .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed .katzkow-mobile-menu-toggle {
        --bar: 2px;
        position: fixed;
        top: 14px;
        right: 14px;
        width: 56px;
        height: 56px;
        border: 1px solid var(--mcg-color-text-on-dark);
        border-radius: 50%;
        background: var(--mcg-color-surface-dark);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
        transform: scale(1);
        pointer-events: auto;
    }

    body.admin-bar .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed .katzkow-mobile-menu-toggle {
        top: 60px;
    }

    .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed .katzkow-mobile-menu-toggle span {
        left: 13px;
        width: 30px;
    }

    .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed .katzkow-mobile-menu-toggle span:nth-child(1) {
        top: 17px;
    }

    .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed .katzkow-mobile-menu-toggle span:nth-child(2) {
        top: 27px;
    }

    .wp-site-blocks > header.wp-block-template-part.is-mobile-header-collapsed .katzkow-mobile-menu-toggle span:nth-child(3) {
        top: 37px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wp-site-blocks > header.wp-block-template-part > .wp-block-group::before,
    .katzkow-header-logo,
    .katzkow-mobile-menu,
    .katzkow-mobile-menu-toggle,
    .katzkow-mobile-menu-toggle span {
        transition: none !important;
    }
}
