/* ============================================
   glow.css — 全局样式 + Reveal UI 模块
   ============================================
   配合 glow.js 使用, 提供:
   - 全局基础样式
   - 导航栏 / 通用组件
   - 光晕 / 光束 / 涟漪 / Toast

   用法: <link rel="stylesheet" href="glow.css">
   ============================================ */

/* ===== 0. 全局基础样式 ===== */
* { margin:0; padding:0; box-sizing:border-box; }
body { background:#1a1a1e; color:#fff; font-family:'Segoe UI',system-ui,sans-serif; min-height:100vh; }

/* ===== 0a. 导航栏通用样式 ===== */
.header { background:#2d2d30; border-bottom:1px solid rgba(255,255,255,0.06); padding:14px 0; position:sticky; top:0; z-index:100; }
.header-inner { max-width:1000px; margin:0 auto; padding:0 20px; display:flex; align-items:center; justify-content:space-between; }
.header h1 { font-size:1.1rem; font-weight:500; }
.header h1 a { color:#4da6ff; text-decoration:none; }
.header-right { display:flex; gap:10px; align-items:center; }
.header-right a { color:#888; text-decoration:none; font-size:0.85rem; }
.header-right a:hover { color:#4da6ff; }

/* 汉堡菜单按钮 */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #aaa;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 6px 14px;
    line-height: 1;
    font-family: inherit;
    transition: color 0.15s;
    min-height: 40px;
}
.nav-toggle:hover { color: #fff; }
.nav-toggle.active { color: #4da6ff; }

/* ===== 侧边栏遮罩 ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===== 响应式：侧边栏 ===== */
@media (max-width: 820px) {
    .nav-toggle { display: block; }
    .header-right {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        height: 100vh;
        height: 100dvh;
        background: #252528;
        border-right: 1px solid rgba(255,255,255,0.06);
        z-index: 200;
        flex-direction: column;
        gap: 2px;
        padding: 60px 10px 20px;
        overflow-y: auto;
        transition: left 0.25s ease;
        -webkit-overflow-scrolling: touch;
    }
    .header-right.open { left: 0; }
    .header-right a {
        display: block;
        padding: 12px 14px;
        border-radius: 8px;
        font-size: 0.95rem;
        color: #ccc;
    }
    .header-right a:hover,
    .header-right a:active { background: rgba(255,255,255,0.06); }
}

.main { max-width:1000px; margin:0 auto; padding:24px 20px; }

.section-title { font-size:1rem; font-weight:500; color:#aaa; margin-bottom:12px; padding-bottom:6px; border-bottom:1px solid rgba(255,255,255,0.06); }

/* ===== 0b. 返回顶部按钮 ===== */
.back-to-top {
    position: fixed; bottom: 24px; right: 24px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(77,166,255,0.15);
    border: 1px solid rgba(77,166,255,0.25);
    color: #4da6ff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-family: inherit;
}
.back-to-top:hover {
    background: rgba(77,166,255,0.25);
    transform: scale(1.1);
}
.back-to-top.visible { display: flex; }

/* ===== 1. 光效容器 ===== */
.reveal {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* ===== 2. 背景光晕 (全局鼠标追踪) =====
   触屏设备（手机/平板）不显示光效 */
@media (hover: hover) {
.reveal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        400px circle at var(--mx, 50%) var(--my, 50%),
        rgba(77, 166, 255, 0.14) 0%,
        rgba(77, 166, 255, 0.05) 30%,
        transparent 60%
    );
    pointer-events: none;
    z-index: 0;
    opacity: 1;
}
}

/* ===== 3. 内容层 (在光晕之上) ===== */
.reveal > * {
    position: relative;
    z-index: 1;
}

/* ===== 4. 扫描光束 (触屏隐藏) =====
   仅按钮/btn 元素使用, JS 动态创建
   垂直蓝线, 右倾 22deg, 跟随鼠标 X 轴移动
   点击时上下扩散
   mix-blend-mode: difference → 划过文字时颜色反转      */
@media (hover: hover) {
.reveal > .reveal-beam {
    position: absolute;
    background: #4da6ff;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    mix-blend-mode: difference;
}
.reveal > .reveal-beam.active {
    opacity: 1;
}
}

/* ===== 5. 点击涟漪 (非按钮元素, 触屏隐藏) ===== */
@media (hover: hover) {
.reveal > .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(77, 166, 255, 0.30);
    transform: scale(0);
    animation: ripple-pulse 0.6s ease-out;
    pointer-events: none;
    z-index: 1;
}
}
@keyframes ripple-pulse {
    to { transform: scale(4); opacity: 0; }
}

/* ===== 5b. @Mention 样式 ===== */
.mention { color:#4da6ff;text-decoration:none;font-weight:500; }
.mention:hover { text-decoration:underline; }
.mention-observer { color:#adb5bd;cursor:default;font-weight:400;border-bottom:1px dashed rgba(173,181,189,0.3); }
.mention-banned { color:#868e96;text-decoration:none; }
.mention-banned:hover { text-decoration:underline;color:#ff6b6b; }

/* ===== 6. Toast 通知 ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.85rem;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
    max-width: 360px;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast-info  { background: #2d8f5e; border-left: 4px solid #51cf66; }
.toast-warn  { background: #b8860b; border-left: 4px solid #ffd43b; color:#fff; }
.toast-error { background: #c0392b; border-left: 4px solid #ff6b6b; }
.toast .toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    flex-shrink: 0;
}
.toast .toast-close:hover { color: #fff; }
@keyframes toast-in {
    from { transform: translateX(100px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100px); opacity: 0; }
}

/* ===== 7. 通用响应式 ===== */
@media (max-width: 768px) {
    body { font-size: 15px; }
    .main { padding: 16px 12px; }
    .header { padding: 10px 0; }
    .header h1 { font-size: 1rem; }
    .section-title { font-size: 0.9rem; }
    .back-to-top { width: 38px; height: 38px; font-size: 1rem; bottom: 16px; right: 16px; }
    .toast { max-width: calc(100vw - 32px); font-size: 0.82rem; padding: 10px 16px; }
    .toast-container { bottom: 16px; right: 16px; left: 16px; }
    /* 防止 iOS 输入自动缩放 */
    input, textarea, select { font-size: 16px !important; }
    /* 更好的触控反馈 */
    .header-right a:active { background: rgba(255,255,255,0.06); }
}

/* ===== 8. 安全区域 (刘海屏) ===== */
@supports (padding: max(0px)) {
    .toast-container {
        bottom: max(16px, env(safe-area-inset-bottom, 16px));
        right: max(16px, env(safe-area-inset-right, 16px));
        left: max(16px, env(safe-area-inset-left, 16px));
    }
    .back-to-top {
        bottom: max(16px, env(safe-area-inset-bottom, 16px));
        right: max(16px, env(safe-area-inset-right, 16px));
    }
    .ann-btn {
        bottom: max(80px, calc(env(safe-area-inset-bottom, 0px) + 80px));
        right: max(24px, env(safe-area-inset-right, 24px));
    }
    .ann-panel {
        right: max(24px, env(safe-area-inset-right, 24px));
    }
}

/* ===== 9. 移动端滚动条优化 ===== */
@media (max-width: 768px) {
    ::-webkit-scrollbar { width: 3px; height: 3px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
    /* iOS 弹性滚动 */
    .conv-items, .g-items, .poll-items, .chat-messages,
    .member-list, .ann-panel {
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================
   通用组件样式（共用，页面内联样式可覆盖）
   ========================================== */

/* 模态框 */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    width: 100%;
    max-width: 480px;
    background: #2d2d30;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 2rem;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h2 { font-size: 1.15rem; font-weight: 500; margin-bottom: 1rem; }

.modal .form-group { margin-bottom: 1rem; }
.modal .form-group label {
    display: block;
    color: #aaa;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}
.modal .form-group input,
.modal .form-group textarea,
.modal .form-group select {
    width: 100%;
    padding: 9px 12px;
    background: #3a3a3d;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: #fff;
    font-size: 0.85rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}
.modal .form-group input:focus,
.modal .form-group textarea:focus,
.modal .form-group select:focus {
    border-color: #4da6ff;
}
.modal .form-group textarea { min-height: 60px; resize: vertical; }

.modal .modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 1rem;
}
.modal .modal-actions button {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
}
.modal .modal-actions .btn-primary { background: #4da6ff; color: #fff; }
.modal .modal-actions .btn-primary:hover { background: #3d8fe0; }
.modal .modal-actions .btn-danger  { background: #ff6b6b; color: #fff; }
.modal .modal-actions .btn-danger:hover  { background: #e05555; }
.modal .modal-actions .btn-cancel  { background: #3a3a3d; color: #aaa; }
.modal .modal-actions .btn-cancel:hover  { color: #fff; }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #555;
    font-size: 0.85rem;
}

/* Action 按钮 */
.action-btn {
    padding: 5px 14px;
    background: #3a3a3d;
    color: #aaa;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.action-btn:hover { background: #4a4a4d; color: #fff; }

/* 错误消息 */
.error-msg {
    color: #ff6b6b;
    font-size: 0.82rem;
    padding: 8px 12px;
    background: rgba(255,107,107,0.1);
    border-radius: 6px;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .modal {
        margin: 10px;
        padding: 1.2rem;
        width: auto;
    }
    .modal .modal-actions {
        flex-direction: column;
        gap: 6px;
    }
    .modal .modal-actions button {
        width: 100%;
        padding: 10px;
    }
    .modal .form-group input,
    .modal .form-group textarea,
    .modal .form-group select {
        font-size: 16px; /* iOS 防缩放 */
    }
}

/* ===== 4. Mobile 增强适配 ===== */
@media (max-width: 400px) {
  .main { padding: 12px 8px !important; }
  body.bb { font-size: 14px; }
  h1 { font-size: 1.15rem !important; }
  h2 { font-size: 1.05rem !important; }
  h3 { font-size: 0.95rem !important; }
  input, textarea, select, button { font-size: 16px !important; }
  .post-card, .comment-card, .board-card, .hub-card, .login-card { border-radius: 8px !important; }
  .pagination a, .pagination span { padding: 6px 10px !important; font-size: 0.72rem !important; min-width: 32px !important; }
  .modal { left: 4px !important; right: 4px !important; width: auto !important; }
}

/* 代码块 / 表格水平滚动 */
pre, .post-content pre, #preview pre { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
pre code, .post-content pre code, #preview pre code { white-space: pre !important; word-break: normal !important; }
table, .post-content table, #preview table { overflow-x: auto !important; display: block !important; }

/* 图片容器限制 */
.post-content img, #preview img { height: auto !important; }
.post-content a > img, #preview a > img { display: block; max-width: 100%; }

/* 触摸目标最小尺寸 */
.nav-toggle, .btn, button, a.btn, .like-btn, .action-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

/* 防止 iOS 上输入缩放 */
input, textarea, select { font-size: 16px !important; }

/* Safe area 支持 */
.main, .nav-panel, .ann-panel { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
