/* ==========================================================================
   Lumina · layout.css
   容器 / 顶部导航 / 主体栅格 / 页脚 / 回到顶部 / 响应式断点
   ========================================================================== */

/* ------------------------------ 容器 ------------------------------ */

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
}

/* ------------------------------ 顶部导航 ------------------------------ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.site-header.is-scrolled {
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(29, 41, 59, 0.05);
}

.header-inner {
    display: flex;
    align-items: center;
    height: var(--header-h);
    gap: 28px;
}

/* 品牌 */
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand:hover {
    color: var(--text);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 27px;
    height: 27px;
}

.brand-mark svg {
    width: 100%;
    height: 100%;
}

/* 桌面导航 */
.site-nav {
    min-width: 0;
    margin-right: auto;
    margin-left: 92px;
}

/* 菜单项较多时收紧间距，避免挤压右侧搜索与操作区 */
.site-nav--dense {
    margin-left: 48px;
}

.site-nav--dense .nav-link {
    gap: 5px;
    padding: 0 10px;
    font-size: 13.5px;
}

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

.nav-link {
    display: inline-flex;
    align-items: center;
    flex: none;
    gap: 6px;
    height: 32px;
    padding: 0 15px;
    border-radius: 16px;
    color: var(--text-2);
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-text {
    white-space: nowrap;
}

.nav-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 15px;
    height: 15px;
}

.nav-icon .icon {
    width: 15px;
    height: 15px;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-2);
}

.nav-link.is-active {
    background: var(--primary);
    color: #fff;
}

.nav-link.is-active:hover {
    background: var(--primary-dark);
    color: #fff;
}

/* 头部右侧操作区 */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

.header-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    width: 212px;
    height: 38px;
    margin-right: 6px;
    padding: 0 10px 0 16px;
    border-radius: 19px;
    background: var(--surface-2);
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

.header-search:focus-within,
.mobile-search:focus-within {
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--primary), 0 4px 14px rgba(37, 134, 254, 0.14);
}

.search-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-4);
}

.search-input::-webkit-search-cancel-button {
    display: none;
}

.search-submit {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: var(--text-3);
    transition: color 0.2s ease;
}

.search-submit:hover {
    color: var(--primary);
}

.search-submit .icon {
    width: 16px;
    height: 16px;
}

/* 图标按钮 */
.icon-button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    color: var(--text-2);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.icon-button:hover {
    background: var(--surface-2);
    color: var(--text);
}

.icon-button .icon {
    width: 17px;
    height: 17px;
}

/* 账号入口：未登录显示图标，已登录显示昵称首字 */
.account-entry {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    color: var(--text-2);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.account-entry:hover {
    border-color: var(--primary);
    background: var(--surface-2);
    color: var(--primary);
}

.account-entry .icon {
    width: 17px;
    height: 17px;
}

.account-entry.is-user {
    border-color: transparent;
    background: linear-gradient(135deg, #4f9cff, var(--primary));
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(37, 134, 254, 0.28);
}

.account-entry.is-user:hover {
    color: #fff;
    opacity: 0.92;
}

.account-entry-initial {
    line-height: 1;
}

.theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: grid;
}

.menu-button {
    display: none;
}

.menu-button .icon-close {
    display: none;
}

.site-header.is-menu-open .menu-button .icon-menu {
    display: none;
}

.site-header.is-menu-open .menu-button .icon-close {
    display: grid;
}

/* 移动端面板 */
.mobile-panel {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    overflow: hidden;
    max-height: 0;
    background: var(--surface);
    border-top: 1px solid transparent;
    box-shadow: 0 16px 30px rgba(29, 41, 59, 0.08);
    transition: max-height 0.32s ease, border-color 0.32s ease;
}

.mobile-nav-list {
    padding: 8px 0;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    padding: 0 10px;
    border-radius: 10px;
    color: var(--text-2);
    font-size: 15px;
}

.mobile-nav-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 18px;
    height: 18px;
    color: var(--text-3);
}

.mobile-nav-icon .icon {
    width: 18px;
    height: 18px;
}

.mobile-nav-link.is-active .mobile-nav-icon {
    color: var(--primary);
}

.mobile-nav-link:hover,
.mobile-nav-link.is-active {
    background: var(--surface-2);
    color: var(--text);
}

.mobile-search {
    display: flex;
    align-items: center;
    height: 42px;
    margin: 4px 0 18px;
    padding: 0 10px 0 16px;
    border-radius: 21px;
    background: var(--surface-2);
}

/* ------------------------------ 主体 ------------------------------ */

.site-main {
    padding: 16px 0 64px;
}

.layout-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--sidebar);
    align-items: start;
    gap: var(--gap);
}

.main-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

/* ------------------------------ 页脚 ------------------------------ */

.site-footer {
    border-top: 1px solid var(--border);
    padding: 26px 0;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.footer-copy {
    color: var(--text-3);
    font-size: 13px;
    line-height: 1.7;
}

.footer-copy .icp-link {
    margin-left: 8px;
    color: var(--text-3);
}

.footer-copy .icp-link:hover {
    color: var(--primary);
}

.footer-side {
    display: flex;
    align-items: center;
    gap: 26px;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.footer-links a {
    color: var(--text-2);
    font-size: 13px;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-social {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-social a {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: var(--text-2);
    transition: color 0.2s ease, background-color 0.2s ease;
}

.footer-social a:hover {
    color: var(--primary);
    background: var(--surface-2);
}

.footer-social .icon {
    width: 16px;
    height: 16px;
}

/* --------------------------- 回到顶部 --------------------------- */

.back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 90;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-2);
    box-shadow: 0 6px 20px rgba(29, 41, 59, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease,
        color 0.2s ease, background-color 0.2s ease;
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.back-to-top .icon {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   响应式断点
   ========================================================================== */

/* 1180px：收紧容器留白与侧栏宽度 */
@media (max-width: 1180px) {
    :root {
        --sidebar: 300px;
        --gap: 24px;
    }

    .header-inner {
        gap: 18px;
    }

    .site-nav {
        margin-left: 48px;
    }

    .nav-link {
        padding: 0 12px;
    }

    .header-search {
        width: 184px;
    }
}

/* 1024px：单列布局，隐藏桌面导航，展开菜单按钮 */
@media (max-width: 1024px) {
    .site-nav,
    .header-search {
        display: none;
    }

    .header-actions {
        margin-left: auto;
    }

    .menu-button {
        display: grid;
    }

    .mobile-panel {
        display: block;
        border-top-color: var(--border);
    }

    .site-header.is-menu-open .mobile-panel {
        max-height: 70vh;
    }

    .layout-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }

    .profile-card {
        grid-column: 1 / -1;
    }

    .site-main {
        padding-bottom: 48px;
    }
}

/* 768px：手机端隐藏侧栏，页脚堆叠 */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .footer-side {
        width: 100%;
        justify-content: space-between;
        gap: 16px;
    }
}

/* 640px：移动端留白与头部操作区 */
@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }

    .header-inner {
        gap: 10px;
    }

    .brand-name {
        font-size: 16px;
    }

    .site-main {
        padding-top: 12px;
    }

    .footer-links {
        gap: 16px;
        flex-wrap: wrap;
    }

    .back-to-top {
        right: 16px;
        bottom: 16px;
        width: 38px;
        height: 38px;
    }
}

/* 480px：极窄屏精简头部 */
@media (max-width: 480px) {
    .footer-side {
        flex-direction: column;
        align-items: flex-start;
    }
}
