/**
 * QiMeng Theme - Mobile Optimization Styles
 * 移动端优化样式（仅在 < 1024px 时生效）
 */

/* ========================================
   移动端搜索栏
   ======================================== */

.qm-mobile-search {
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 60px;
    overflow: hidden;
}

.qm-mobile-search.is-hidden {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    border-bottom-color: transparent;
}

.qm-mobile-search__wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

.qm-mobile-search__input {
    flex: 1;
    height: 2.25rem;
    padding: 0 0.875rem;
    background: #f1f5f9;
    border: none;
    border-radius: 1.125rem 0 0 1.125rem;
    font-size: 0.875rem;
    color: #374151;
    outline: none;
}

.qm-mobile-search__input::placeholder {
    color: #9ca3af;
}

.qm-mobile-search__btn {
    height: 2.25rem;
    padding: 0 1rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: none;
    border-radius: 0 1.125rem 1.125rem 0;
    color: #ffffff;
    font-size: 0.875rem;
    cursor: pointer;
}

.dark .qm-mobile-search {
    background: #1e293b;
    border-bottom-color: #334155;
}

.dark .qm-mobile-search__input {
    background: #334155;
    color: #f1f5f9;
}


/* ========================================
   移动端网格菜单
   ======================================== */

.qm-mobile-nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 100;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    padding: 1rem;
    max-height: 66vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.qm-mobile-nav__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.qm-mobile-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.25rem;
    border-radius: 0.75rem;
    text-decoration: none;
    position: relative;
}

.qm-mobile-nav__item:active {
    transform: scale(0.95);
}

.qm-mobile-nav__icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(236, 72, 153, 0.12));
    display: flex;
    align-items: center;
    justify-content: center;
}

.qm-mobile-nav__icon i {
    font-size: 1.125rem;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.qm-mobile-nav__text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4b5563;
    text-align: center;
}

.dark .qm-mobile-nav {
    background: #1e293b;
    border-bottom-color: #334155;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.dark .qm-mobile-nav__text {
    color: #94a3b8;
}


/* ========================================
   底部导航栏
   ======================================== */

.qm-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9990;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 3.5rem;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid #f1f5f9;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@supports (backdrop-filter: blur(10px)) {
    .qm-bottom-nav {
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

.qm-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.125rem;
    flex: 1;
    height: 100%;
    padding-bottom: 0.5rem;
    text-decoration: none;
    color: #6b7280;
    position: relative;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qm-bottom-nav__item i {
    font-size: 1.25rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 自定义图标样式 */
.qm-bottom-nav__custom-icon {
    width: 1.5rem;
    height: 1.5rem;
    object-fit: contain;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qm-bottom-nav__item span {
    font-size: 0.625rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* 选中状态 - 破界效果 */
.qm-bottom-nav__item.is-active {
    padding-bottom: 0.375rem;
}

.qm-bottom-nav__item.is-active i {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    border-radius: 50%;
    color: #fff !important;
    -webkit-background-clip: unset;
    background-clip: unset;
    transform: translateY(-1rem);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
    font-size: 1.125rem;
}

/* 自定义图标选中状态 */
.qm-bottom-nav__item.is-active .qm-bottom-nav__custom-icon {
    width: 2.5rem;
    height: 2.5rem;
    transform: translateY(-0.25rem);
}

.qm-bottom-nav__item.is-active span {
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transform: translateY(-0.25rem);
}

/* 移除旧的顶部指示条 */
.qm-bottom-nav__item.is-active::before {
    display: none;
}

/* 中间发布按钮 */
.qm-bottom-nav__item--publish .qm-bottom-nav__icon-wrap {
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 0.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
    transform: translateY(-0.75rem);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qm-bottom-nav__item--publish:active .qm-bottom-nav__icon-wrap {
    transform: translateY(-0.5rem) scale(0.95);
}

.qm-bottom-nav__item--publish .qm-bottom-nav__icon-wrap i {
    font-size: 1.25rem;
    color: #ffffff !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    width: auto;
    height: auto;
    box-shadow: none;
    transform: none;
}

.qm-bottom-nav__item--publish span {
    margin-top: 0;
    color: #6b7280 !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    transform: none !important;
}

/* 发布按钮选中状态 */
.qm-bottom-nav__item--publish.is-active .qm-bottom-nav__icon-wrap {
    transform: translateY(-1rem) scale(1.1);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}

.qm-bottom-nav__item--publish.is-active span {
    background: linear-gradient(135deg, #7c3aed, #ec4899) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    color: transparent !important;
}

.dark .qm-bottom-nav {
    background: rgba(30, 41, 59, 0.95);
    border-top-color: #334155;
}

@supports (backdrop-filter: blur(10px)) {
    .dark .qm-bottom-nav {
        background: rgba(30, 41, 59, 0.85);
    }
}

.dark .qm-bottom-nav__item {
    color: #94a3b8;
}

.dark .qm-bottom-nav__item--publish span {
    color: #94a3b8 !important;
}


/* ========================================
   页面适配
   ======================================== */

body.has-bottom-nav {
    padding-bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
}

body.has-bottom-nav #back-to-top,
body.has-bottom-nav .qm-back-to-top {
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)) !important;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .qm-bottom-nav {
        height: calc(3.5rem + env(safe-area-inset-bottom));
    }
}

/* ========================================
   桌面端隐藏（≥1024px）
   ======================================== */

@media (min-width: 1024px) {
    .qm-mobile-search,
    .qm-mobile-nav,
    .qm-bottom-nav {
        display: none !important;
    }
    
    body.has-bottom-nav {
        padding-bottom: 0 !important;
    }
}

/* ========================================
   小屏幕优化（≤374px）
   ======================================== */

@media (max-width: 374px) {
    .qm-mobile-nav__icon {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .qm-mobile-nav__text {
        font-size: 0.6875rem;
    }
    
    .qm-bottom-nav__item i {
        font-size: 1.125rem;
    }
    
    .qm-bottom-nav__item span {
        font-size: 0.5625rem;
    }
}


/* ========================================
   移动端页面边距优化
   ======================================== */

@media (max-width: 639px) {
    /* 减小页面容器边距 */
    .max-w-7xl {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* 主内容区域边距 */
    main.px-4,
    .px-4 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* 文章卡片网格间距 */
    .qm-article-cards {
        gap: 1rem;
    }
    
    .grid {
        gap: 0.5rem;
    }
}
