:root {
    --navbar-height: 64px;
}

/* Self-contained: this file is also loaded on the rules page without site.css. */
.navbar,
.mobile-menu {
    --nav-ink: #f4f1ea;
    --nav-ink-dim: #b4b0a8;
    --nav-line: rgba(255, 255, 255, .12);
    --nav-rule: rgba(244, 241, 234, .55);
    --nav-red: #cf1020;
    --nav-title: 'Lino', 'Hapna', sans-serif;
    --nav-body: 'Hapna', Georgia, serif;
    --nav-stroke: url('../img/kit-row.png') center / 100% 100% no-repeat;
    --nav-stroke-hover: url('../img/kit-row-hover.png') center / 100% 100% no-repeat;
    --nav-mask: url('../img/kit-blot.png') 70 fill / 1.6rem / 0 stretch;
    --nav-ease: cubic-bezier(.22, 1, .36, 1);
}

.navbar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1000;
    height: var(--navbar-height);
    border-bottom: 1px solid var(--nav-line);
    background: #000;
    color: var(--nav-ink);
    font: 400 18px/1.2 var(--nav-title);
    font-synthesis: none;
    letter-spacing: .05em;
    transition: background-color .45s ease, border-color .45s ease;
}

.navbar.is-top {
    border-bottom-color: transparent;
    background-color: transparent;
}

.navbar a {
    color: inherit;
    text-decoration: none;
}

.navbar :focus-visible {
    outline: 2px solid var(--nav-ink);
    outline-offset: 2px;
}

.nav-container {
    display: flex;
    align-items: center;
    gap: clamp(20px, 3vw, 40px);
    height: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 clamp(16px, 3vw, 32px);
}

.nav-logo {
    flex: none;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding-top: 3px;
    font-size: 24px;
    letter-spacing: .03em;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    flex: 1;
    gap: 4px;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 3px 12px 0;
    color: var(--nav-ink-dim);
    white-space: nowrap;
    transition: color .15s;
}

.nav-link::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 5px;
    height: 2px;
    background: var(--nav-ink);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform .25s var(--nav-ease);
}

.nav-link:hover {
    color: var(--nav-ink);
}

.nav-link:hover::after {
    transform: scaleX(1);
}

.nav-link.active {
    color: var(--nav-ink);
}

.nav-link.active::after {
    background: var(--nav-red);
    transform: none;
}

.nav-login {
    flex: none;
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 4px 24px 0;
    background: var(--nav-stroke);
    color: var(--nav-ink);
    white-space: nowrap;
    transition: background .15s;
}

.nav-login:hover {
    background: var(--nav-stroke-hover);
}

.nav-user {
    position: relative;
    flex: none;
}

.nav-user summary,
.nav-burger {
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.nav-user summary::-webkit-details-marker,
.nav-burger::-webkit-details-marker {
    display: none;
}

.nav-user summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 4px;
    color: var(--nav-ink-dim);
    transition: color .15s;
}

.nav-user summary:hover,
.nav-user[open] summary {
    color: var(--nav-ink);
}

.nav-avatar {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 0;
    background: #1a1918;
    outline: 1px solid var(--nav-line);
    object-fit: cover;
    filter: grayscale(.35);
}

.nav-user-name {
    max-width: 180px;
    padding-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: -12px;
    display: grid;
    gap: 2px;
    min-width: 220px;
    padding: 22px 18px;
    background: rgba(0, 0, 0, .97);
    -webkit-mask-box-image: var(--nav-mask);
}

.nav-dropdown form {
    margin: 0;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 4px 16px 0;
    border: 0;
    background: none;
    color: var(--nav-ink);
    font: inherit;
    letter-spacing: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s;
}

.nav-dropdown-item:hover,
.nav-dropdown-item.active {
    background: var(--nav-stroke);
}

.nav-dropdown-item.active {
    outline: 2px solid var(--nav-red);
    outline-offset: -2px;
}

.nav-menu {
    display: none;
}

.nav-burger {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-right: -8px;
}

.nav-burger span {
    position: absolute;
    left: 11px;
    width: 22px;
    height: 2px;
    background: var(--nav-ink);
    transition: transform .25s var(--nav-ease), opacity .2s;
}

.nav-burger span:nth-child(1) {
    top: 15px;
}

.nav-burger span:nth-child(2) {
    top: 21px;
}

.nav-burger span:nth-child(3) {
    top: 27px;
}

.nav-menu[open] .nav-burger span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.nav-menu[open] .nav-burger span:nth-child(2) {
    opacity: 0;
}

.nav-menu[open] .nav-burger span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.mobile-menu {
    position: fixed;
    inset: var(--navbar-height) 0 0;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 20px clamp(16px, 5vw, 32px) max(28px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-top: 1px solid var(--nav-line);
    background: #000;
    color: var(--nav-ink);
    font: 400 34px/1.1 var(--nav-title);
    letter-spacing: .03em;
    animation: mobile-menu-in .32s var(--nav-ease);
}

@keyframes mobile-menu-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
}

.mobile-links {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mobile-links li + li {
    border-top: 1px solid var(--nav-line);
}

.mobile-link {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 68px;
    padding: 6px 0 0 22px;
    color: var(--nav-ink-dim);
    font: inherit;
    transition: color .15s;
}

.mobile-link:hover,
.mobile-link.active {
    color: var(--nav-ink);
}

.mobile-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 9px;
    height: 9px;
    margin-top: -3px;
    border: 1.5px solid currentColor;
    opacity: .5;
    transform: rotate(45deg);
}

.mobile-link.active::before {
    border-color: var(--nav-red);
    background: var(--nav-red);
    opacity: 1;
}

.mobile-user {
    display: grid;
    gap: 6px;
    padding-top: 22px;
    border-top: 2px solid var(--nav-rule);
}

.mobile-user-name {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    color: var(--nav-ink-dim);
    font: 400 20px/1.2 var(--nav-title);
}

.mobile-menu .nav-dropdown-item {
    min-height: 52px;
    padding: 5px 22px 0;
    background: var(--nav-stroke);
    font: 400 22px/1.1 var(--nav-title);
}

.mobile-menu .nav-dropdown-item:hover {
    background: var(--nav-stroke-hover);
}

.mobile-user form {
    margin: 0;
}

html.menu-open {
    overflow: hidden;
}

html.menu-open .navbar {
    border-bottom-color: transparent;
    background-color: #000;
}

@media (max-width: 860px) {
    :root {
        --navbar-height: 58px;
    }

    .nav-container {
        justify-content: space-between;
        gap: 12px;
    }

    .nav-logo {
        font-size: 22px;
    }

    .nav-links,
    .nav-user,
    .navbar > .nav-container > .nav-login {
        display: none;
    }

    .nav-menu {
        display: block;
    }
}

@media (prefers-reduced-motion: reduce) {
    .navbar,
    .nav-link::after,
    .nav-burger span {
        transition: none;
    }

    .mobile-menu {
        animation: none;
    }
}
