/* ========== common.css - 通用样式 ========== */

/* ========== 基础变量与重置 ========== */
:root {
    --safe-bottom: env(safe-area-inset-bottom, 16px);
    --safe-top: env(safe-area-inset-top, 0px);
    --emerald: #10b981;
    --emerald-dark: #059669;
    --bg-body: linear-gradient(160deg, #05080f 0%, #0a0f1c 40%, #0d1520 100%);
    --card-bg: rgba(20, 26, 41, 0.75);
    --border-subtle: rgba(255, 255, 255, 0.06);
}

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* 允许帖子正文和评论文字被选中 */
.post-content, .comment-text, .text-content {
    -webkit-user-select: text;
    user-select: text;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding-bottom: 24px;
    padding-top: var(--safe-top);
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    color: #e2e8f0;
}

/* ========== 无障碍：键盘焦点 + 减少动画 ========== */
:focus-visible {
    outline: 2px solid var(--emerald);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== 通用隐藏类 ========== */
.hidden {
    display: none !important;
}

/* ========== 顶部导航 ========== */
#topNav {
    background: rgba(8,12,22,0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    position: sticky;
    top: 0;
    z-index: 50;
    padding-top: var(--safe-top);
}

.nav-inner {
    max-width: 1024px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--emerald), #34d399);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}

.logo-area h1 {
    font-size: 26px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.5px;
    margin: 0;
}

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

.icon-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b0bec5;
    background: rgba(255,255,255,0.04);
    border-radius: 13px;
    border: none;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.25s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* 顶部发布按钮（移动端和PC端都显示） */
.top-publish-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--emerald), var(--emerald-dark));
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 14px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s;
}

.top-publish-btn:hover {
    filter: brightness(1.1);
}

.top-publish-btn i {
    font-size: 14px;
}

/* ========== Tab 切换 ========== */
.tab-container {
    max-width: 1024px;
    margin: 0 auto;
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 0 8px;
}

.tab-btn {
    position: relative;
    color: #7c8aa0;
    transition: all 0.3s;
    font-weight: 500;
    padding: 14px 24px;
    font-size: 17px;
    white-space: nowrap;
    background: none;
    border: none;
    cursor: pointer;
}

.tab-btn.active {
    color: var(--emerald);
    font-weight: 700;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3.5px;
    background: var(--emerald);
    border-radius: 4px;
}

/* ========== 分类导航 ========== */
.category-nav {
    display: flex;
    max-width: 1024px;
    margin: 0 auto;
    padding: 8px 12px 12px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
    display: none;
}

.category-btn {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.06);
    color: #94a3b8;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 9999px;
    padding: 6px 14px;
    margin-right: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.25s;
    cursor: pointer;
    flex-shrink: 0;
}

.category-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

.category-btn.active {
    background: var(--emerald);
    color: white;
    border-color: var(--emerald);
    box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}

/* ========== 模态框通用 ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-sheet {
    background: #111827;
    border-radius: 22px;
    width: 100%;
    max-width: 500px;
    padding: 24px 20px 32px;
    animation: slideUpCenter 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.6);
    margin: 16px;
}

@keyframes slideUpCenter {
    from { 
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
}

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-sheet input {
    width: 100%;
    background: #1f2937;
    border: 1.5px solid #374151;
    border-radius: 16px;
    padding: 15px 18px;
    font-size: 16px;
    color: #f1f5f9;
    outline: none;
    transition: border-color 0.3s;
    -webkit-appearance: none;
    box-sizing: border-box;
}

.modal-sheet input:focus {
    border-color: var(--emerald);
}

/* 修复自动填充时的浅色背景 */
input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px #1f2937 inset !important;
    -webkit-text-fill-color: #f1f5f9 !important;
}

.modal-hint {
    font-size: 12px;
    color: #64748b;
    margin-top: 8px;
    padding-left: 4px;
}

.btn-row {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.25s;
}

.btn-cancel {
    background: #1f2937;
    color: #d1d5db;
    border: 1px solid #374151;
}

.btn-cancel:active {
    background: #2d3645;
}

.btn-confirm {
    background: var(--emerald);
    color: #fff;
}

.btn-confirm:active {
    background: var(--emerald-dark);
}

/* ========== 图片画廊 ========== */
.gallery-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.gallery-overlay img {
    max-width: 94vw;
    max-height: 75vh;
    border-radius: 16px;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.gallery-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: background 0.25s;
    z-index: 5;
}

.gallery-btn:active {
    background: rgba(255, 255, 255, 0.25);
}

.gallery-btn-prev { left: 12px; }
.gallery-btn-next { right: 12px; }

.gallery-close {
    position: absolute;
    top: max(16px, var(--safe-top));
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    z-index: 5;
    transition: background 0.25s;
}

.gallery-close:active {
    background: rgba(255, 255, 255, 0.25);
}

.gallery-counter {
    position: absolute;
    bottom: max(30px, calc(30px + var(--safe-bottom)));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    z-index: 5;
}

/* ========== 空状态 ========== */
#emptyState {
    text-align: center;
    padding: 60px 20px;
    color: #6b7d95;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease;
}

.empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 17px;
    font-weight: 500;
    margin-bottom: 6px;
}

.empty-desc {
    font-size: 14px;
    color: #5a6d80;
}

/* ========== 评论区域 ========== */
.comment-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.comment-section-title {
    color: #94a3b8;
    margin-bottom: 10px;
    font-size: 14px;
}

.comment-list {
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.comment-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #64748b, #94a3b8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.comment-body {
    flex: 1;
    min-width: 0;
}

.comment-author {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 4px;
}

.comment-text {
    color: #e2e8f0;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.comment-time {
    color: #64748b;
    font-size: 11px;
    margin-top: 4px;
}

.comment-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.comment-input-row input {
    flex: 1;
    background: #1a2032;
    border: 1.5px solid #2a3345;
    border-radius: 14px;
    padding: 13px 16px;
    font-size: 15px;
    color: #e2e8f0;
    outline: none;
    transition: border-color 0.3s;
}

.comment-input-row input:focus {
    border-color: var(--emerald);
}

.comment-input-row button {
    background: var(--emerald);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 13px 18px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.25s;
}

.comment-input-row button:active {
    background: var(--emerald-dark);
}

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 14px 28px;
    border-radius: 14px;
    font-size: 15px;
    z-index: 200;
    animation: toastIn 0.3s ease;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ========== 滚动条隐藏 ========== */
::-webkit-scrollbar { width: 0; height: 0; }

/* ========== 骨架屏样式 ========== */
.skeleton-card {
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 14px;
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.skeleton-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.08);
    border-radius: 14px;
}

.skeleton-info {
    flex: 1;
}

.skeleton-line {
    height: 14px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    margin-bottom: 6px;
}

.skeleton-line.short {
    width: 45%;
}

.skeleton-text {
    height: 18px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    margin-bottom: 10px;
}

.skeleton-text.short {
    width: 75%;
    height: 16px;
}

.skeleton-image {
    height: 180px;
    background: rgba(255,255,255,0.06);
    border-radius: 14px;
    margin: 12px 0;
}

.skeleton-actions {
    height: 36px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    margin-top: 8px;
}

/* 下拉刷新指示器 */
#pullToRefresh {
    position: fixed;
    top: calc(50px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 185, 129, 0.95);
    color: white;
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 14px;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 80;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    white-space: nowrap;
}

/* ========== 不支持毛玻璃的降级背景 ========== */
@supports not (backdrop-filter: blur(1px)) {
    .card,
    #topNav,
    .bottom-nav {
        background: rgba(8, 12, 22, 0.96);
    }
}
