/* ========================================
   3D地球树洞星球 - 响应式样式
   ======================================== */

/* 平板设备 (768px - 1024px) */
@media screen and (max-width: 1024px) {
    .hot-treeholes {
        width: 240px;
    }
    
    .mood-item small {
        display: none;
    }
}

/* 移动设备 (< 768px) */
@media screen and (max-width: 768px) {
    /* 统计数据面板调整 */
    .stats-panel {
        left: var(--spacing-xs);
        bottom: 80px;
        width: 140px;
    }

    .stats-header {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.6875rem;
    }

    .stats-header i {
        font-size: 0.6875rem;
    }

    .stats-content {
        padding: var(--spacing-xs);
        gap: 2px;
    }

    .stat-item {
        padding: 2px var(--spacing-xs);
    }

    .stat-icon {
        width: 20px;
        height: 20px;
        font-size: 0.625rem;
    }

    .stat-value {
        font-size: 0.75rem;
    }

    .stat-label {
        font-size: 0.5625rem;
    }

    .live-dot {
        width: 6px;
        height: 6px;
    }

    .live-text {
        font-size: 0.5rem;
    }

    /* 头部调整 */
    .header {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .logo i {
        font-size: 1.25rem;
    }
    
    .icon-btn span {
        display: none;
    }
    
    /* 顶部法律链接 */
    .header-legal-links {
        gap: 4px;
        margin-right: 4px;
    }
    
    .legal-link-mini {
        width: 32px;
        height: 32px;
    }
    
    .legal-link-mini i {
        font-size: 0.875rem;
    }
    
    /* 心情筛选栏 - 展开状态保持长条 */
    .mood-filter {
        top: 60px;
        padding: var(--spacing-xs);
        gap: var(--spacing-sm);
    }
    
    .mood-filter > span {
        font-size: 0.75rem;
    }
    
    .mood-list {
        gap: 2px;
    }
    
    .mood-item {
        padding: var(--spacing-xs);
    }
    
    .mood-item span {
        font-size: 1rem;
    }
    
    /* 热门树洞改为底部固定 */
    .hot-treeholes {
        right: auto;
        left: 0;
        top: auto;
        bottom: 80px;
        transform: none;
        width: 100%;
        max-height: 200px;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        border-bottom: none;
    }
    
    /* 移动端禁用面板拖拽 */
    .hot-treeholes .hot-header {
        cursor: default;
    }
    
    .hot-content {
        max-height: 155px;
    }
    
    /* 底部按钮调整 */
    .footer-actions {
        bottom: var(--spacing-md);
    }
    
    .primary-btn {
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: 0.9375rem;
    }
    
    /* 弹窗调整 */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: var(--spacing-sm);
    }
    
    .modal-body {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .modal-footer {
        padding: var(--spacing-sm) var(--spacing-md);
        gap: var(--spacing-sm);
    }
    
    /* Emoji 网格调整 */
    .emoji-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--spacing-xs);
    }
    
    .emoji-btn {
        padding: var(--spacing-xs);
        gap: 2px;
    }
    
    .emoji-btn span {
        font-size: 1.375rem;
    }
    
    .emoji-btn small {
        font-size: 0.625rem;
    }
    
    .emoji-section {
        margin-bottom: var(--spacing-sm);
    }
    
    .emoji-section label,
    .content-section label {
        font-size: 0.75rem;
        margin-bottom: var(--spacing-xs);
    }
    
    .location-info {
        padding: var(--spacing-xs) var(--spacing-sm);
        margin-bottom: var(--spacing-sm);
        font-size: 0.75rem;
    }
    
    .content-section textarea {
        min-height: 70px;
        font-size: 0.8125rem;
    }
    
    /* 详情弹窗调整 */
    .detail-emoji {
        font-size: 2rem;
    }
    
    .comments-list {
        max-height: 150px;
    }
    
    /* 翻译弹窗调整 */
    .translate-modal-content {
        max-width: 95%;
    }
    
    /* 详情弹窗通用移动端优化 */
    .detail-modal-content {
        display: flex;
        flex-direction: column;
    }
    
    .detail-modal-content .modal-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    /* 评论区区域优化 */
    .comments-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    .comments-list {
        flex: 1;
        overflow-y: auto;
    }
    
    /* 底部操作区域 */
    .detail-modal-content .modal-footer {
        flex-shrink: 0;
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    /* 快速回复区域 */
    .quick-reply {
        display: flex;
        align-items: center;
        gap: var(--spacing-xs);
        padding: var(--spacing-xs) 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .quick-reply::-webkit-scrollbar {
        display: none;
    }
    
    .quick-emoji {
        min-width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    /* 评论输入区域 */
    .comment-input-wrapper {
        display: flex;
        gap: var(--spacing-sm);
        align-items: center;
        width: 100%;
    }
    
    .emoji-picker-btn {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }
    
    .comment-input-wrapper input {
        flex: 1;
        height: 44px;
    }
    
    .comment-input-wrapper .primary-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Emoji 选择器弹窗 */
    .emoji-picker-popup {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: none;
        width: 100%;
        max-width: 100%;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        padding: var(--spacing-md);
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-bottom: none;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
        z-index: 2000;
    }
    
    .emoji-picker-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: var(--spacing-sm);
        max-height: 200px;
        overflow-y: auto;
    }
    
    .emoji-option {
        aspect-ratio: 1;
        font-size: 1.5rem;
        min-height: 44px;
    }
}

/* 小屏移动设备 (< 480px) */
@media screen and (max-width: 480px) {
    .header {
        padding: var(--spacing-sm);
    }

    /* 统计数据面板小屏适配 */
    .stats-panel {
        width: 130px;
        left: var(--spacing-xs);
        bottom: 75px;
    }

    .stats-header {
        padding: 2px var(--spacing-xs);
        font-size: 0.625rem;
    }

    .stats-header i {
        font-size: 0.625rem;
    }

    .stats-content {
        padding: 2px var(--spacing-xs);
        gap: 2px;
    }

    .stat-item {
        padding: 2px var(--spacing-xs);
    }

    .stat-icon {
        width: 18px;
        height: 18px;
        font-size: 0.5625rem;
    }

    .stat-value {
        font-size: 0.6875rem;
    }

    .stat-label {
        font-size: 0.5rem;
    }

    .live-dot {
        width: 5px;
        height: 5px;
    }

    .live-text {
        font-size: 0.4375rem;
    }
    
    /* 心情筛选栏 - 展开状态保持长条 */
    .mood-filter {
        left: var(--spacing-sm);
        right: var(--spacing-sm);
        transform: none;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .mood-filter::-webkit-scrollbar {
        display: none;
    }
    
    .mood-list {
        display: inline-flex;
    }
    
    /* 心情筛选收起状态 - 小气泡样式 */
    .mood-filter.collapsed {
        left: auto;
        right: var(--spacing-sm);
        top: 60px;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        overflow: hidden;
        white-space: normal;
    }
    
    .mood-filter.collapsed .mood-list {
        display: none;
    }
    
    .mood-filter.collapsed .mood-filter-header {
        display: flex;
        width: 100%;
        height: 100%;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    
    .mood-filter.collapsed .mood-filter-header > span {
        display: none;
    }
    
    .mood-filter.collapsed .filter-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        font-size: 1.25rem;
        background: none;
        border: none;
        color: var(--text-primary);
    }
    
    .mood-filter.collapsed .filter-toggle-btn i {
        display: none;
    }
    
    .mood-filter.collapsed .filter-toggle-btn::before {
        content: '🌍';
    }
    
    /* Emoji 网格改为4列 */
    .emoji-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    
    .emoji-btn {
        padding: 6px;
        gap: 2px;
    }
    
    .emoji-btn span {
        font-size: 1.25rem;
    }
    
    .emoji-btn small {
        font-size: 0.625rem;
    }
    
    .emoji-section {
        margin-bottom: var(--spacing-sm);
    }
    
    .emoji-section label,
    .content-section label {
        font-size: 0.75rem;
        margin-bottom: 4px;
    }
    
    .location-info {
        padding: 6px var(--spacing-sm);
        margin-bottom: var(--spacing-sm);
        font-size: 0.75rem;
    }
    
    .content-section textarea {
        min-height: 60px;
        font-size: 0.8125rem;
        padding: var(--spacing-sm);
    }
    
    /* 热门树洞进一步调整 */
    .hot-treeholes {
        bottom: 70px;
        max-height: 180px;
    }
    
    .hot-content {
        max-height: 135px;
    }
    
    /* 底部按钮 */
    .footer-actions {
        left: 0;
        right: 0;
        transform: none;
        padding: 0 var(--spacing-md);
    }
    
    .footer-actions .primary-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* 弹窗全屏化 */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .modal-body {
        flex: 1;
        min-height: 0;
    }
    
    .modal-footer {
        padding: var(--spacing-sm) var(--spacing-md);
        flex-shrink: 0;
    }
    
    /* 详情弹窗移动端优化 */
    .detail-modal-content {
        display: flex;
        flex-direction: column;
    }
    
    .detail-modal-content .modal-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: var(--spacing-md);
        max-height: calc(100vh - 180px);
    }
    
    /* 树洞内容区域 */
    .treehole-content-wrapper {
        padding: var(--spacing-md);
        margin-bottom: var(--spacing-md);
        border-radius: var(--border-radius);
    }
    
    .treehole-text {
        font-size: 1rem;
        line-height: 1.7;
        padding-right: 36px;
    }
    
    .translate-btn {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(74, 144, 217, 0.1);
        border-radius: var(--border-radius-sm);
    }
    
    /* 评论区区域 - 可滚动 */
    .comments-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        margin-bottom: var(--spacing-sm);
    }
    
    .comments-section h4 {
        font-size: 0.875rem;
        margin-bottom: var(--spacing-sm);
        padding-bottom: var(--spacing-xs);
        border-bottom: 1px solid var(--border-color);
    }
    
    .comments-list {
        flex: 1;
        overflow-y: auto;
        max-height: none;
        gap: var(--spacing-sm);
        padding-right: var(--spacing-xs);
    }
    
    .comment-item {
        padding: var(--spacing-sm);
        border-radius: var(--border-radius-sm);
        background: rgba(255, 255, 255, 0.03);
    }
    
    .comment-avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .comment-nickname {
        font-size: 0.875rem;
    }
    
    .comment-time {
        font-size: 0.75rem;
    }
    
    .comment-text {
        font-size: 0.9375rem;
        line-height: 1.6;
    }
    
    .comment-emoji {
        font-size: 1.125rem;
    }
    
    .no-comments {
        padding: var(--spacing-lg);
        font-size: 0.875rem;
    }
    
    /* 底部操作区域固定 */
    .detail-modal-content .modal-footer {
        flex-shrink: 0;
        flex-direction: column;
        gap: var(--spacing-sm);
        padding: var(--spacing-md);
        border-top: 1px solid var(--border-color);
        background: var(--bg-card);
    }
    
    /* 快速回复区域 */
    .quick-reply {
        display: flex;
        align-items: center;
        gap: var(--spacing-xs);
        padding: var(--spacing-xs) 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .quick-reply::-webkit-scrollbar {
        display: none;
    }
    
    .quick-reply span {
        font-size: 0.8125rem;
        white-space: nowrap;
        color: var(--text-secondary);
    }
    
    .quick-emoji {
        min-width: 40px;
        height: 40px;
        padding: var(--spacing-xs);
        font-size: 1.375rem;
        background: rgba(255, 255, 255, 0.08);
        border-radius: var(--border-radius-sm);
        transition: all 0.2s ease;
    }
    
    .quick-emoji:active {
        transform: scale(0.95);
        background: rgba(74, 144, 217, 0.2);
    }
    
    /* 评论输入区域 */
    .comment-input-wrapper {
        display: flex;
        gap: var(--spacing-sm);
        align-items: center;
        width: 100%;
    }
    
    .emoji-picker-btn {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid var(--border-color);
        font-size: 1.25rem;
    }
    
    .emoji-picker-btn:active {
        background: rgba(74, 144, 217, 0.2);
        border-color: var(--primary-color);
    }
    
    .comment-input-wrapper input {
        flex: 1;
        height: 44px;
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 1rem;
        border-radius: 22px;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid var(--border-color);
    }
    
    .comment-input-wrapper input:focus {
        border-color: var(--primary-color);
        background: rgba(255, 255, 255, 0.12);
    }
    
    .comment-input-wrapper .primary-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.125rem;
    }
    
    /* Emoji 选择器弹窗移动端优化 */
    .emoji-picker-popup {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: none;
        width: 100%;
        max-width: 100%;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        padding: var(--spacing-md);
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-bottom: none;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
        z-index: 2000;
    }
    
    .emoji-picker-header {
        margin-bottom: var(--spacing-md);
        padding-bottom: var(--spacing-sm);
    }
    
    .emoji-picker-header span {
        font-size: 1rem;
        font-weight: 600;
    }
    
    .emoji-picker-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: var(--spacing-sm);
        max-height: 200px;
        overflow-y: auto;
    }
    
    .emoji-option {
        aspect-ratio: 1;
        font-size: 1.5rem;
        padding: var(--spacing-xs);
        background: rgba(255, 255, 255, 0.05);
        border-radius: var(--border-radius-sm);
        min-height: 44px;
    }
    
    .emoji-option:active {
        background: rgba(74, 144, 217, 0.3);
        transform: scale(0.95);
    }
    
    /* 发布弹窗内联 Emoji 选择器移动端适配 */
    .emoji-picker-popup-inline {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        margin-top: 0;
        width: 100%;
        max-width: 100%;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        padding: var(--spacing-md);
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-bottom: none;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
        z-index: 2000;
    }
    
    .emoji-picker-grid-inline {
        grid-template-columns: repeat(7, 1fr);
        gap: var(--spacing-sm);
        max-height: 200px;
        overflow-y: auto;
    }
    
    .emoji-picker-grid-inline .emoji-option {
        aspect-ratio: 1;
        font-size: 1.5rem;
        padding: var(--spacing-xs);
        min-height: 44px;
    }
    
    .emoji-picker-grid-inline .emoji-option:active {
        background: rgba(74, 144, 217, 0.3);
        transform: scale(0.95);
    }
    
    /* 删除按钮 - 移动端保持小图标 */
    .content-actions .danger-btn {
        width: 28px;
        height: 28px;
        opacity: 1;
        transform: scale(1);
        pointer-events: auto;
    }
    
    /* 评论删除按钮 - 移动端优化 */
    .delete-comment-btn {
        width: 32px;
        height: 32px;
        opacity: 1;
        transform: translateX(0);
        background: rgba(220, 53, 69, 0.15);
    }
    
    .delete-comment-btn i {
        font-size: 0.875rem;
    }
    
    /* 评论区调整 */
    .comment-input-wrapper {
        flex-wrap: nowrap;
    }
    
    .comment-input-wrapper input {
        width: auto;
        order: 0;
    }
    
    .comment-input-wrapper .primary-btn {
        order: 0;
        margin-left: 0;
    }
}

/* 横屏模式 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: var(--spacing-xs) var(--spacing-md);
    }
    
    .mood-filter {
        top: 50px;
    }
    
    .hot-treeholes {
        display: none;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-body {
        max-height: calc(95vh - 120px);
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .mood-item:hover,
    .emoji-btn:hover,
    .hot-item:hover {
        transform: none;
    }
    
    .icon-btn:hover,
    .primary-btn:hover,
    .secondary-btn:hover {
        transform: none;
    }
    
    /* 增大触摸目标 */
    .mood-item,
    .emoji-btn,
    .icon-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 移动端按钮点击效果 */
    .quick-emoji:active,
    .emoji-option:active,
    .emoji-picker-btn:active {
        transform: scale(0.95);
    }
    
    /* 详情弹窗触摸优化 */
    .detail-modal-content .modal-footer {
        padding-bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
    }
    
    .emoji-picker-popup {
        padding-bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo,
    .modal-header h3,
    .treehole-text {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 深色模式系统偏好 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-card: rgba(15, 20, 35, 0.9);
    }
}

/* 打印样式 */
@media print {
    .header,
    .mood-filter,
    .hot-treeholes,
    .footer-actions,
    .modal {
        display: none !important;
    }
    
    #globe-container {
        position: static;
        width: 100%;
        height: 100vh;
    }
}
