/* ==========================================================================
   Joe floating navigation — single-row layout
   Categories move into the main navigation, login sits on the far right,
   and the old 45px second row is removed.
   ========================================================================== */

.joe_header {
    position: -webkit-sticky;
    position: sticky;
    top: 14px;
    width: calc(100% - 20px);
    max-width: 1320px;
    margin: 14px auto 16px;
    border: 1px solid var(--classC);
    border-radius: 26px;
    background: transparent;
    box-shadow: 0 12px 34px -18px rgba(0, 0, 0, .22);
    overflow: visible;
    transition: top .3s ease, box-shadow .3s ease;
}

.joe_header__above {
    border-radius: 25px;
    background: var(--background);
    background: color-mix(in srgb, var(--background) 70%, transparent);
    -webkit-backdrop-filter: blur(30px) saturate(155%);
    backdrop-filter: blur(30px) saturate(155%);
}

/* The old bottom row is removed from the markup. These rules keep old
   cached pages harmless while the header is a single compact row. */
.joe_header__below {
    display: none !important;
}

.joe_header.active {
    top: 14px;
    box-shadow: 0 16px 42px -18px rgba(0, 0, 0, .26);
}

/* --------------------------------------------------------------------------
   Compact navigation cards
   -------------------------------------------------------------------------- */

.joe_header__above-nav {
    display: flex;
    align-items: center;
    min-width: 0;
}

.joe_header__above-nav .item {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 38px;
    margin: 11px 6px 11px 0;
    padding: 0 13px;
    border-radius: 12px;
    color: var(--main);
    font-size: 14px;
    line-height: 38px;
    overflow: hidden;
    transition: color .25s ease, background .25s ease, box-shadow .25s ease;
}

/* Remove Joe's underline active treatment. */
.joe_header__above-nav .item::after {
    display: none;
}

.joe_header__above-nav .item:hover,
.joe_header__above-nav .item.active {
    color: var(--theme);
    background: var(--classD);
}

.joe_header__above-nav .item.active {
    box-shadow:
        inset 0 0 0 1px var(--classC),
        0 5px 16px -12px rgba(0, 0, 0, .45);
}

/* The selected card has a slow, soft light sweep. */
.joe_header__above-nav .item.active::before {
    position: absolute;
    top: -30%;
    bottom: -30%;
    left: -90%;
    width: 55%;
    background: linear-gradient(
        100deg,
        transparent 0%,
        rgba(255, 255, 255, .10) 30%,
        rgba(255, 255, 255, .68) 50%,
        rgba(255, 255, 255, .10) 70%,
        transparent 100%
    );
    content: "";
    pointer-events: none;
    transform: skewX(-20deg);
    animation: joe-nav-shine 3.8s ease-in-out infinite;
}

@keyframes joe-nav-shine {
    0%, 16% {
        left: -90%;
    }
    58%, 100% {
        left: 135%;
    }
}

/* Category divider between the page nav and the category entries. */
.joe_header__nav-divider {
    display: inline-block;
    flex: 0 0 auto;
    width: 1px;
    height: 18px;
    margin: 0 10px 0 2px;
    background: var(--classC);
}

/* Dropdown entries that hold a category/page also sit in the compact rail. */
.joe_header__above-nav .joe_dropdown {
    display: flex;
    align-items: center;
    height: 60px;
    margin-right: 6px;
}

.joe_header__above-nav .joe_dropdown__link {
    display: flex;
    align-items: center;
    height: 60px;
}

.joe_header__above-nav .joe_dropdown__link > a:not(.item) {
    display: inline-flex;
    align-items: center;
    height: 38px;
    padding: 0 8px 0 13px;
    border-radius: 10px;
    color: var(--main);
    font-size: 14px;
    line-height: 38px;
    transition: color .25s ease, background .25s ease;
}

.joe_header__above-nav .joe_dropdown__link > a.item {
    height: 38px;
    padding: 0 8px 0 13px;
    line-height: 38px;
}

.joe_header__above-nav .joe_dropdown__link > a:not(.item):hover {
    color: var(--theme);
    background: var(--classD);
}

/* --------------------------------------------------------------------------
   Category dropdown
   -------------------------------------------------------------------------- */

.joe_header__above-nav .joe_category-dropdown {
    position: relative;
}

.joe_header__above-nav .joe_category-dropdown .joe_dropdown__menu {
    width: 230px;
    max-height: min(70vh, 420px);
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--classC);
    border-top: 1px solid var(--classC);
    border-radius: 16px;
    background: var(--background);
    box-shadow: 0 20px 48px -22px rgba(0, 0, 0, .32);
    text-align: left;
}

.joe_header__above-nav .joe_category-dropdown .joe_dropdown__menu::-webkit-scrollbar {
    width: 4px;
}

.joe_header__above-nav .joe_category-dropdown .joe_dropdown__menu::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: var(--classC);
}

.joe_header__above-nav .joe_category-dropdown .joe_dropdown__menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--main);
    font-size: 14px;
    line-height: 40px;
    text-align: left;
    transition: color .25s ease, background .25s ease;
}

.joe_header__above-nav .joe_category-dropdown .joe_dropdown__menu a:hover,
.joe_header__above-nav .joe_category-dropdown .joe_dropdown__menu a.active {
    color: var(--theme);
    background: var(--classD);
}

.joe_category-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.joe_category-count {
    flex: 0 0 auto;
    min-width: 20px;
    margin-left: 12px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--classD);
    color: var(--minor);
    font-size: 11px;
    line-height: 20px;
    text-align: center;
}

.joe_header__above-nav .joe_category-dropdown .joe_dropdown__menu a.active .joe_category-count,
.joe_header__above-nav .joe_category-dropdown .joe_dropdown__menu a:hover .joe_category-count {
    background: var(--background);
}

.joe_category-children {
    margin: 2px 0 6px 14px;
    padding-left: 10px;
    border-left: 1px solid var(--classC);
}

.joe_header__above-nav .joe_category-dropdown .joe_category-children a {
    height: 34px;
    padding: 0 10px;
    color: var(--minor);
    font-size: 13px;
    line-height: 34px;
}

.joe_header__above-nav .joe_category-dropdown .joe_category-children a:hover,
.joe_header__above-nav .joe_category-dropdown .joe_category-children a.active {
    color: var(--theme);
}

/* --------------------------------------------------------------------------
   Login / account on the right
   -------------------------------------------------------------------------- */

.joe_header__sign {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    height: 60px;
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--classC);
}

.joe_header__sign .joe_dropdown__link,
.joe_header__sign > .item {
    display: flex;
    align-items: center;
    height: 60px;
}

.joe_header__sign .joe_dropdown__link {
    padding: 0 4px;
    border-radius: 8px;
    transition: background .25s ease, color .25s ease;
}

.joe_header__sign .joe_dropdown__link:hover {
    background: var(--classD);
}

.joe_header__sign .item a {
    color: var(--minor);
    transition: color .25s ease;
}

.joe_header__sign .item a:hover {
    color: var(--theme);
}

.joe_header__sign .item .split {
    color: var(--seat);
}

/* --------------------------------------------------------------------------
   Search panel / night mode
   -------------------------------------------------------------------------- */

.joe_header__searchout {
    top: 60px;
    border-radius: 0 0 25px 25px;
}

html[data-night="night"] .joe_header {
    border-color: var(--classB);
    box-shadow: 0 14px 38px -20px rgba(0, 0, 0, .8);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 992px) {
    .joe_header__above-nav .item {
        margin-right: 4px;
        padding: 0 10px;
        font-size: 13px;
    }

    .joe_header__above-search .input {
        width: 130px;
    }

    .joe_header__sign {
        margin-left: 5px;
        padding-left: 8px;
    }
}

@media (max-width: 900px) {
    .joe_header__above-search {
        display: none;
    }

    .joe_header__above-searchicon {
        display: block;
    }
}

@media (max-width: 768px) {
    .joe_header {
        top: 10px;
        width: calc(100% - 20px);
        margin: 10px auto 12px;
        border-radius: 20px;
    }

    .joe_header__above {
        border-radius: 19px;
    }

    .joe_header__searchout {
        top: 55px;
        border-radius: 0 0 19px 19px;
    }

    .joe_header.active {
        top: 10px;
    }

    .joe_header__sign {
        display: none;
    }

    .joe_header__above-nav {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .joe_header__above-nav .item.active::before {
        display: none;
    }
}

/* 思微随笔：亮色/暗色各使用一版 logo */
.joe_logo_dark {
    display: none;
}

.joe_logo_shine {
    position: absolute;
    top: 50%;
    left: 0;
    z-index: 2;
    width: 150px;
    height: 50px;
    overflow: hidden;
    pointer-events: none;
    transform: translateY(-50%);
    background: linear-gradient(
        105deg,
        transparent 38%,
        rgba(255, 255, 255, .08) 44%,
        rgba(255, 255, 255, .88) 50%,
        rgba(255, 255, 255, .08) 56%,
        transparent 62%
    );
    background-size: 240% 100%;
    background-position: 210% 0;
    -webkit-mask: url("../img/sakura-logo-v2.png") center / contain no-repeat;
    mask: url("../img/sakura-logo-v2.png") center / contain no-repeat;
    mix-blend-mode: screen;
    opacity: .62;
    animation: joe-logo-shine 4.8s ease-in-out infinite;
}

html[data-night="night"] .joe_logo_shine {
    background: linear-gradient(
        105deg,
        transparent 38%,
        rgba(255, 255, 255, .04) 44%,
        rgba(255, 255, 255, .46) 50%,
        rgba(255, 255, 255, .04) 56%,
        transparent 62%
    );
    -webkit-mask-image: url("../img/sakura-logo-dark-v2.png");
    mask-image: url("../img/sakura-logo-dark-v2.png");
    opacity: .72;
}

@keyframes joe-logo-shine {
    0%, 58% {
        background-position: 210% 0;
    }
    100% {
        background-position: -110% 0;
    }
}

html[data-night="night"] .joe_header__above-logo > img:not(.joe_logo_dark) {
    display: none !important;
}

html[data-night="night"] .joe_header__above-logo .joe_logo_dark {
    display: block !important;
}

html[data-night="night"] .joe_header__above-logo > svg {
    display: none !important;
}

@media (max-width: 768px) {
    .joe_logo_shine {
        height: 45px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .joe_logo_shine {
        animation: none;
        opacity: 0;
    }
}
