.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 48px 48px 16px;
    max-width: 1200px;
    margin: 0 auto;
    position: sticky;
    top: 0;
    z-index: 900;
    background-color: var(--cream);
    isolation: isolate;
    transition: padding-bottom 0.2s ease;
}

.header::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    width: 100vw;
    height: 100%;
    background-color: var(--cream);
    transform: translateX(-50%);
    z-index: -1;
    pointer-events: none;
}

.header::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 100vw;
    height: 1px;
    background-color: transparent;
    transform: translateX(-50%);
    transition: background-color 0.2s ease;
    pointer-events: none;
}

.header.scrolled {
    padding-bottom: 10px;
}

.header.scrolled::after {
    background-color: rgba(46, 25, 31, 0.12);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logo:hover .logo-icon img {
    transform: rotate(180deg);
}

.logo-text {
    font-family: "swear-display", serif;
    font-weight: 800;
    font-size: 40px;
    letter-spacing: 3.2px;
    color: var(--brown);
    line-height: 1;
    transform: translateY(-2px);
    transition: color 0.3s ease;
}

.logo:hover .logo-text {
    color: #5a3340;
}

.nav {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav a {
    font-family: "swear-display", serif;
    font-weight: 700;
    font-size: 24px;
    color: var(--red);
    text-decoration: none;
    transition: color 0.2s ease;
    position: relative;
    padding-bottom: 8px;
    line-height: 1;
}

.nav a::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 3px;
    background-color: var(--red-hover, #b8391f);
    transition: width 0.3s ease, left 0.3s ease;
}

.nav a:hover,
.nav a.active {
    color: var(--red-hover, #b8391f);
}

.nav a:hover::after,
.nav a.active::after {
    width: 100%;
    left: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
    position: relative;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.menu-toggle-bar {
    display: block;
    width: 28px;
    height: 2px;
    background-color: var(--brown);
    border-radius: 2px;
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.3s ease, background-color 0.3s ease;
}

.menu-toggle-bar + .menu-toggle-bar {
    margin-top: 7px;
}

.menu-toggle.active .menu-toggle-bar:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
    background-color: var(--brown);
}

.menu-toggle.active .menu-toggle-bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.menu-toggle.active .menu-toggle-bar:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
    background-color: var(--brown);
}

.mobile-menu {
    display: none;
    position: fixed;
    inset: 0;
    background-color: var(--brown);
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1), visibility 0.4s;
}

.mobile-menu.open {
    opacity: 1;
    visibility: visible;
}

.mobile-menu a {
    font-family: "swear-display", serif;
    font-weight: 800;
    font-size: 48px;
    letter-spacing: 1px;
    color: var(--cream);
    text-decoration: none;
    padding: 16px 0;
    transform: translateY(30px);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.4s ease, color 0.2s ease;
}

.mobile-menu.open a {
    transform: translateY(0);
    opacity: 1;
}

.mobile-menu.open a:nth-of-type(1) { transition-delay: 0.1s; }
.mobile-menu.open a:nth-of-type(2) { transition-delay: 0.18s; }

.mobile-menu a:hover,
.mobile-menu a.active {
    color: var(--red);
}

body.menu-open {
    overflow: hidden;
}

body.menu-open .header {
    z-index: 1102;
}

body.menu-open .menu-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1103;
    background-color: var(--cream);
}

@media (max-width: 1040px) {
    .nav {
        display: none;
    }

    .menu-toggle {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 999px;
    }

    .mobile-menu {
        display: flex;
    }

    .header {
        padding: 24px 24px 8px;
    }
}

@media (prefers-color-scheme: dark) {
    .header.scrolled::after {
        background-color: rgba(255, 240, 230, 0.12);
    }

    .mobile-menu,
    body.menu-open .menu-toggle {
        background-color: #161314;
    }

    .mobile-menu a {
        color: #f2efea;
    }

    .mobile-menu a:hover,
    .mobile-menu a.active {
        color: var(--red);
    }

    body.menu-open .menu-toggle {
        background-color: #f2efea;
    }
}
