/* =========================
   NAV
========================= */

.nav {
    position: fixed;
    top: 0;
    left: 0;

    width: 100%;
    height: 80px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 24px var(--gutter-page);

    z-index: 100;

    /*
     * Estado inicial.
     * hero-intro.js revela a Nav
     * somente depois da animação da Hero.
     */
    opacity: 0;
    visibility: hidden;
}


/* =========================
   LOGO
========================= */

.nav__logo {
    display: block;
    width: 48px;
}

.nav__logo img {
    display: block;
    width: 100%;
    height: auto;
}


/* =========================
   RIGHT SIDE
========================= */

.nav__right {
    display: flex;
    align-items: center;

    gap: var(--space-32);
}


/* =========================
   NAV LINKS
========================= */

.nav__links {
    display: flex;
    align-items: center;

    gap: var(--space-40);

    pointer-events: none;
}

.nav__links.is-open {
    pointer-events: auto;
}


.nav__link {
    color: var(--color-text);

    font-family: var(--font-mono);
    font-size: min(
        var(--font-label-desktop),
        1.56svh
    );
    font-weight: var(--weight-regular);

    line-height: 1;
    text-decoration: none;

    white-space: nowrap;

    opacity: 0;
    visibility: hidden;

    transition: opacity 250ms ease;
}


.nav__link:hover {
    opacity: 0.5 !important;
}


/* =========================
   MENU BUTTON
========================= */

.nav__menu {
    position: relative;

    width: 32px;
    height: 32px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background-color: var(--color-text);
    color: var(--color-background);

    cursor: pointer;
}


/* =========================
   PLUS / MINUS ICON
========================= */

.nav__menu-icon {
    position: relative;

    width: 12px;
    height: 12px;

    display: block;

    transition:
        transform 500ms
        cubic-bezier(0.22, 1, 0.36, 1);
}


/* Horizontal line */

.nav__menu-icon::before {
    content: "";

    position: absolute;
    top: 50%;
    left: 0;

    width: 100%;
    height: 1.5px;

    background-color: currentColor;

    transform: translateY(-50%);
}


/* Vertical line */

.nav__menu-icon::after {
    content: "";

    position: absolute;
    top: 0;
    left: 50%;

    width: 1.5px;
    height: 100%;

    background-color: currentColor;

    transform:
        translateX(-50%)
        scaleY(1);

    transform-origin: center;

    transition:
        transform 350ms
        cubic-bezier(0.22, 1, 0.36, 1);
}


/* =========================
   HOVER
========================= */

.nav__menu:not(.is-open):hover
.nav__menu-icon {
    transform: rotate(90deg);
}


/* =========================
   OPEN STATE
========================= */

/*
 * Vertical line disappears,
 * leaving only the minus.
 */

.nav__menu.is-open
.nav__menu-icon::after {
    transform:
        translateX(-50%)
        scaleY(0);
}


/*
 * Ensures the icon returns
 * to a neutral orientation
 * when opened.
 */

.nav__menu.is-open
.nav__menu-icon {
    transform: rotate(0deg);
}


/* =========================
   CONTROLS
========================= */

/*
 * The motion toggle sits beside
 * the menu button, as a pair.
 */

.nav__controls {
    display: flex;
    align-items: center;
    gap: var(--space-12);
}


/* =========================
   MOTION TOGGLE
========================= */

/*
 * Pauses and plays the decorative loops
 * (js/motion-toggle.js). Same circle as the
 * menu button; the hit area grows to 44px.
 */

.nav__motion {
    position: relative;

    width: 32px;
    height: 32px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background-color: var(--color-text);
    color: var(--color-background);

    cursor: pointer;
}

.nav__motion::before {
    content: "";

    position: absolute;
    inset: -6px;
}

.nav__motion-icon {
    width: 12px;
    height: 12px;

    display: block;
}

.nav__motion-icon--play,
.nav__motion.is-paused .nav__motion-icon--pause {
    display: none;
}

.nav__motion.is-paused .nav__motion-icon--play {
    display: block;
}


/*
 * High contrast (forced colors): keep the circles,
 * the menu icon and the logo visible. Nothing here
 * applies in normal light or dark mode.
 */

@media (forced-colors: active) {
    .nav__motion,
    .nav__menu {
        border: 1px solid ButtonText;
    }

    /*
     * The plus/minus lines are backgrounds, which
     * forced colors paint in the page colour. Draw
     * them in the button text colour instead.
     */

    .nav__menu-icon::before,
    .nav__menu-icon::after {
        forced-color-adjust: none;

        background-color: ButtonText;
    }

    /*
     * The logo is a black image, which disappears on
     * a dark theme. Its shape is redrawn on top in
     * the theme's link colour, with the same SVG as
     * a mask. A layer, not the link itself, is
     * masked, so the link's focus ring still shows.
     */

    .nav__logo {
        position: relative;
    }

    .nav__logo img {
        opacity: 0;
    }

    .nav__logo::after {
        content: "";

        position: absolute;
        inset: 0;

        forced-color-adjust: none;

        background-color: LinkText;

        -webkit-mask: url("../assets/logo/GM_SVG.svg") center / contain no-repeat;
        mask: url("../assets/logo/GM_SVG.svg") center / contain no-repeat;
    }
}

/* =========================
   TABLET
========================= */

@media (min-width: 768px) and (max-width: 1024.98px) {

    .nav {
        height: 72px;
        padding: 20px var(--gutter-page);
    }

    .nav__logo {
        width: 44px;
    }

    .nav__right {
        gap: var(--space-24);
    }

    .nav__menu {
        width: 28px;
        height: 28px;
    }

    .nav__menu-icon {
        width: 10px;
        height: 10px;
    }

    .nav__motion {
        width: 28px;
        height: 28px;
    }

    .nav__motion::before {
        inset: -8px;
    }

    .nav__motion-icon {
        width: 10px;
        height: 10px;
    }

    .nav__link {
        font-size: var(--font-label-tablet);
    }
}

/* =========================
   MOBILE
========================= */

@media (max-width: 767.98px) {

    /* =========================
       NAV
    ========================= */

    .nav {
        position: fixed;

        top: 0;
        left: 0;
        right: 0;

        width: auto;
        max-width: 100vw;
        height: 64px;

        box-sizing: border-box;

        padding: 16px var(--gutter-page);

        align-items: center;
        justify-content: space-between;
    }


    /* =========================
       LOGO
    ========================= */

    .nav__logo {
        width: 40px;
    }


    /* =========================
       RIGHT SIDE
    ========================= */

    .nav__right {
        position: relative;

        gap: 0;
    }


    /* =========================
       NAV LINKS
    ========================= */

    /*
     * The open list hangs under the buttons, aligned
     * right: 22px below them here, 46px in portrait
     * (MOBILE — PORTRAIT, at the end). 15px links,
     * 20px apart, on the full-screen layer, so
     * nothing on the page needs to make room for it.
     */

    .nav__links {
        position: absolute;

        top: 50px;
        right: 0;

        width: max-content;

        flex-direction: column;
        align-items: flex-end;

        gap: var(--space-20);
    }


    .nav__link {
        font-size: 15px;
        line-height: 1;
    }


    /* =========================
       MENU BUTTON
    ========================= */

    .nav__menu {
        width: 28px;
        height: 28px;
    }


    /* =========================
       PLUS / MINUS ICON
    ========================= */

    .nav__menu-icon {
        width: 10px;
        height: 10px;
    }


    /* =========================
       MOTION TOGGLE
    ========================= */

    .nav__motion {
        width: 28px;
        height: 28px;
    }

    .nav__motion::before {
        inset: -8px;
    }

    .nav__motion-icon {
        width: 10px;
        height: 10px;
    }


    /* =========================
       OPEN MENU — FULL SCREEN
    ========================= */

    /*
     * While the menu is open (js/nav-menu.js puts
     * .is-menu-open on <html>), a layer in the page
     * colour covers the whole screen just under the
     * nav, so the logo and both buttons stay where
     * they are, above it, with the links.
     *
     * The layer belongs to the body, not to the nav:
     * the nav slides away on scroll (a transform),
     * and the layer must stay put while it fades.
     * It is 100lvh tall, so it still reaches the
     * bottom when the browser bars are hidden.
     *
     * It fades on the links' curves (GSAP power2,
     * as cubic-beziers): in over 0.35s, ahead of
     * the links, and out over 0.7s, so the page
     * shows through as the last link goes (their
     * 250ms CSS transition makes the links fade
     * out over about 0.75s in all).
     */

    body::before {
        content: "";

        position: fixed;
        top: 0;
        left: 0;
        z-index: 99;

        width: 100%;
        height: 100vh;
        height: 100lvh;

        background-color: var(--color-background);

        opacity: 0;
        visibility: hidden;

        transition:
            opacity 0.7s cubic-bezier(0.55, 0.055, 0.675, 0.19),
            visibility 0s linear 0.7s;
    }

    .is-menu-open body::before {
        opacity: 1;
        visibility: visible;

        transition:
            opacity 0.35s cubic-bezier(0.215, 0.61, 0.355, 1);
    }


    /*
     * The page under the layer stops scrolling and
     * keeps its place; nothing in it moves or
     * resizes. The page's scrolling is set on the
     * body (global.css), so the lock goes there too.
     * touch-action covers older iOS, which ignored
     * overflow: hidden for touch, and the gutter
     * keeps a desktop scrollbar's width in narrow
     * windows.
     */

    .is-menu-open {
        overscroll-behavior: none;
        scrollbar-gutter: stable;
    }

    .is-menu-open body {
        overflow: hidden;
        touch-action: none;
    }
}


/* =========================
   MOBILE — PORTRAIT
========================= */

/*
 * Held upright, the open list sits 24px lower:
 * 46px under the buttons. A phone held sideways
 * keeps it 22px under them.
 */

@media (max-width: 767.98px) and (orientation: portrait) {

    .nav__links {
        top: 74px;
    }
}