/* 全局设计令牌（主题色/间距/字体）—— 全站统一风格来源 */
@import 'themes/colors.css';
@import 'themes/spacing.css';
@import 'themes/typography.css';
/* 备案信息栏组件（国家标准，全站统一） */
@import 'components/footer.css';

/* 移动端优化样式 - 增强触摸体验和交互 */

/* ====== 全局触摸优化 ====== */
* {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* h1语义化：保持原div标题布局不变 */
h1.header-title,
h1.poet-name,
h1.main-title,
h1.name,
h1.cover-title,
h1.intro-title {
    margin-top: 0;
}

button, a {
    cursor: pointer;
    touch-action: manipulation;
}

/* ====== 全局工具类 ====== */
/* JS 显隐切换（替代内联 display:none） */
.is-hidden {
    display: none !important;
}

/* ====== 移动端地图交互优化 ====== */
@media (max-width: 768px) {
    /* 地图容器 */
    #map-container,
    .map-container {
        height: 400px !important;
        touch-action: pan-x pan-y pinch-zoom;
    }
    
    /* 灯笼标记 - 增大点击区域 */
    .lantern-marker {
        font-size: 32px !important;
        padding: 8px !important;
        margin: -8px !important;
    }
    
    .lantern-marker.lit {
        font-size: 56px !important;
    }
    
    /* 马匹标记 - 增大点击区域 */
    .horse-marker {
        font-size: 48px !important;
        padding: 10px !important;
        margin: -10px !important;
    }
    
    /* 地点标签 - 更大字号 */
    .location-label {
        font-size: 14px !important;
        padding: 6px 12px !important;
        max-width: 120px !important;
    }
    
    /* 灯笼诗句浮窗 - 适配小屏 */
    .lantern-poem-container {
        min-width: 160px !important;
        max-width: 280px !important;
        padding: 12px 16px !important;
    }
    
    .lantern-poem-text {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }
    
    /* 马匹注释 - 适配小屏 */
    .horse-comment {
        max-width: 80vw !important;
        font-size: 12px !important;
        padding: 8px 12px !important;
    }
}

/* ====== 移动端底部导航优化（含安全区） ====== */
@media (max-width: 768px) {
    .tang-bottom-nav {
        padding: 6px 0 !important;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
        height: auto !important;
        min-height: calc(48px + env(safe-area-inset-bottom, 0px));
    }

    .bottom-nav-container {
        gap: 4px !important;
        padding: 0 5px !important;
    }

    .nav-item {
        padding: 6px 8px !important;
        border-radius: 6px !important;
        min-width: 56px;
        min-height: 44px;
    }

    .nav-icon {
        font-size: 16px !important;
    }

    .nav-text {
        font-size: 10px !important;
    }

    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* 悬浮按钮统一抬升到导航+安全区之上 */
    .scroll-to-top,
    .back-to-top,
    #backToTop {
        bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ====== 移动端卡片触摸效果 ====== */
@media (max-width: 768px) {
    .poem-card,
    .stat-card,
    .info-card {
        transition: all 0.2s ease !important;
    }
    
    .poem-card:active,
    .stat-card:active,
    .info-card:active {
        transform: scale(0.98) !important;
        background: rgba(139, 69, 19, 0.05) !important;
    }
    
    .tab:active {
        transform: scale(0.95) !important;
    }
}

/* ====== 移动端字体优化 ====== */
@media (max-width: 768px) {
    body {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }
    
    h1 {
        font-size: 22px !important;
    }
    
    h2 {
        font-size: 18px !important;
    }
    
    h3 {
        font-size: 16px !important;
    }
    
    .poem-title {
        font-size: 16px !important;
    }
    
    .poem-preview {
        font-size: 14px !important;
    }
}

/* ====== 移动端输入框优化 ====== */
@media (max-width: 768px) {
    input,
    select,
    textarea {
        font-size: 16px !important;
        padding: 10px 12px !important;
    }
    
    .search-box {
        width: 90% !important;
        max-width: none !important;
    }
}

/* ====== 横屏模式优化 ====== */
@media (orientation: landscape) and (max-width: 900px) {
    #map-container,
    .map-container {
        height: 300px !important;
    }
    
    .info-card {
        max-height: 50vh !important;
    }
}

/* ====== 高DPI屏幕优化 ====== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .lantern-marker,
    .horse-marker {
        image-rendering: crisp-edges;
    }
}

/* ====== 触摸反馈动画 ====== */
@keyframes touchRipple {
    0% {
        transform: scale(0);
        opacity: 0.5;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.touch-ripple {
    position: relative;
    overflow: hidden;
}

.touch-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: rgba(218, 165, 32, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
}

.touch-ripple:active::after {
    animation: touchRipple 0.4s ease-out;
}

/* ====== 波纹点击效果 ====== */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(218, 165, 32, 0.3);
    transform: scale(0);
    animation: rippleAnim 0.6s ease-out;
    pointer-events: none;
    z-index: 1000;
}

@keyframes rippleAnim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ====== 下拉刷新指示器 ====== */
.pull-refresh-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    background: linear-gradient(135deg, #fff, #FAF3E0);
    border: 2px solid var(--secondary-color, #DAA520);
    border-radius: 30px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.2);
}

.pull-refresh-indicator.refreshing .pull-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pull-icon {
    font-size: 18px;
}

.pull-text {
    color: var(--primary-color, #8B4513);
    font-size: 14px;
}

/* ====== 长按菜单 ====== */
.long-press-menu {
    position: fixed;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10002;
    overflow: hidden;
    min-width: 120px;
    animation: menuPop 0.2s ease-out;
}

@keyframes menuPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.lp-menu-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    text-align: left;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

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

.lp-menu-item:active {
    background: #FAF3E0;
}

/* ====== Toast提示 ====== */
.mobile-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 10003;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.mobile-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ====== 移动端点击态优化 ====== */
@media (max-width: 768px) {
    button:active,
    .btn:active,
    a:active {
        transform: scale(0.96);
        opacity: 0.85;
    }

    .poem-card:active,
    .sub-item:active,
    .info-card:active,
    .stat-card:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(139, 69, 19, 0.1);
    }

    button,
    .btn,
    .nav-link,
    .tab,
    .filter-btn,
    .dynasty-btn,
    .category-tab,
    .city-tab,
    .checkin-btn,
    .action-btn,
    .gallery-nav,
    .cross-link-btn,
    .page-btn,
    .scroll-to-top,
    .back-to-top,
    .back-link {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    input[type="text"],
    input[type="search"],
    textarea {
        font-size: 16px !important;
    }
}

/* ====== 防抖动优化（收窄禁选范围，放行诗文长按复制） ====== */
@media (max-width: 768px) {
    .tang-bottom-nav,
    .bottom-nav-container,
    .mobile-ui-toggle,
    button,
    .btn {
        -webkit-user-select: none;
        user-select: none;
    }

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

    .poem-content,
    .poem-original,
    .poem-translation,
    article,
    p {
        -webkit-user-select: text;
        user-select: text;
    }
}

/* ====== 安全区域适配 ====== */
@supports (padding: max(0px)) {
    .checkin-widget {
        bottom: calc(220px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .engagement-bar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* 刘海屏顶部安全区（固定顶栏） */
    .ih-1u1kjbr,
    body.mobile-fast-mode header {
        padding-top: env(safe-area-inset-top, 0px);
    }
}

/* ====== hover 依赖降级（触屏设备） ====== */
@media (hover: none) and (max-width: 768px) {
    /* 注释气泡改由 JS tap 切换（.popup-open 类驱动） */
    .annotated-word .annotation-popup {
        display: none;
    }
    .annotated-word.popup-open .annotation-popup {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    /* 3D 翻面卡禁用 hover 翻面，改 .flipped 类驱动 */
    .poem-item:hover .poem-item-inner {
        transform: none;
    }
    .poem-item.flipped .poem-item-inner {
        transform: rotateY(180deg);
    }

    /* 触摸反馈替代悬浮 */
    .poet-card:active,
    .feature-card:active,
    .route-item:active {
        transform: scale(0.98);
        background: rgba(218, 165, 32, 0.08);
    }
}

/* ====== 横向溢出防护 ====== */
@media (max-width: 768px) {
    html, body {
        overflow-x: clip;
        /* m3: 阻止Android原生下拉刷新与自定义下拉刷新竞争 */
        overscroll-behavior-y: contain;
    }

    img, video, canvas, svg {
        max-width: 100%;
        height: auto;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    pre, .annotation-popup {
        white-space: normal;
        max-width: 92vw;
    }
}

/* ====== m2 交互增强(滑动感知) ====== */
/* D3 底部导航智能隐藏 */
@media (max-width: 768px) {
    .tang-bottom-nav {
        transition: transform .28s ease;
        will-change: transform;
    }
    .tang-bottom-nav.m2-nav-hidden {
        transform: translateY(102%);
    }
}

/* D2 横滑卡片(scroll-snap): 仅移动端生效 */
@media (max-width: 768px) {
    .m2-hscroll {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 12px;
        padding: 4px 6px 12px;
        scrollbar-width: none;
    }
    .m2-hscroll::-webkit-scrollbar {
        display: none;
    }
    .m2-hscroll > * {
        flex: 0 0 76%;
        max-width: 76%;
        scroll-snap-align: start;
    }
}

/* D7 滑动点指示器 */
.m2-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 2px 0 10px;
}
.m2-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(139, 69, 19, 0.22);
    transition: all .25s ease;
}
.m2-dot.active {
    width: 16px;
    border-radius: 3px;
    background: var(--secondary-color, #DAA520);
}

/* D6 长列表渐入 */
.m2-reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .45s ease, transform .45s ease;
}
.m2-reveal.m2-visible {
    opacity: 1;
    transform: none;
}

/* D5 滑动翻页提示条 */
.m2-swipe-hint {
    position: fixed;
    left: 50%;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(12px);
    background: rgba(44, 36, 22, 0.86);
    color: #F5E6C8;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 999px;
    letter-spacing: 1px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s ease, transform .35s ease;
    z-index: 9500;
}
.m2-swipe-hint.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* D5 翻页卡片过渡安全(桌面端不受影响, 移动端顺滑) */
@media (max-width: 768px) {
    #poem-detail-card {
        will-change: transform;
    }
}

/* 降级: 用户偏好减少动画时全部关闭 */
@media (prefers-reduced-motion: reduce) {
    .m2-reveal {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    .tang-bottom-nav {
        transition: none !important;
    }
    .m2-dot, .m2-swipe-hint {
        transition: none !important;
    }
}

/* ====== 可视化面包屑(唐风, 全站注入) ====== */
.m2-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 1080px;
    margin: 0 auto;
    padding: 10px 18px 0;
    font-size: 13px;
    line-height: 1.8;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}
.m2-breadcrumb::-webkit-scrollbar {
    display: none;
}
.m2-crumb-link {
    color: var(--primary-color, #8B4513);
    text-decoration: none;
    opacity: 0.85;
    transition: opacity .2s;
}
.m2-crumb-link:hover {
    opacity: 1;
    text-decoration: underline;
}
.m2-crumb-sep {
    color: #B8935F;
    margin: 0 8px;
    font-weight: bold;
}
.m2-crumb-current {
    color: #6B5B3E;
    font-weight: 500;
}
@media (max-width: 768px) {
    .m2-breadcrumb {
        font-size: 12px;
        padding: 8px 14px 0;
    }
}

/* ====== m3 转场与反馈动画令牌 ====== */
@keyframes m3FadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}
@keyframes m3FadeOut {
    from { opacity: 1; transform: none; }
    to { opacity: 0; transform: translateY(12px); }
}
@keyframes m3PulseGold {
    0% { box-shadow: 0 0 0 0 rgba(218, 165, 32, 0.6); }
    100% { box-shadow: 0 0 0 18px rgba(218, 165, 32, 0); }
}
@keyframes m3Shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}
.m3-page-enter {
    animation: m3FadeIn .2s ease-out;
}
.m3-page-exit {
    animation: m3FadeOut .2s ease-in forwards;
}
.m3-pulse-gold {
    animation: m3PulseGold .5s ease-out;
}
.m3-shake {
    animation: m3Shake .36s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
    .m3-page-enter, .m3-page-exit, .m3-pulse-gold, .m3-shake {
        animation: none !important;
    }
}

/* ====== m3 全局Toast(自 global-enhance.js 迁出, 视觉1:1) ====== */
.tscc-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    color: #fff;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 99999;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Microsoft YaHei', sans-serif;
    white-space: nowrap;
}
.tscc-toast-success { background: linear-gradient(135deg, #52c41a, #73d13d); }
.tscc-toast-error   { background: linear-gradient(135deg, #ff4d4f, #ff7875); }
.tscc-toast-warning { background: linear-gradient(135deg, #faad14, #ffc53d); }
.tscc-toast-info    { background: linear-gradient(135deg, var(--primary-color, #8B4513), var(--secondary-color, #DAA520)); }

/* ====== m3 页面加载进度条(自 global-enhance.js 迁出) ====== */
.page-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color, #8B4513), var(--secondary-color, #DAA520));
    z-index: 999999;
    transition: width 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

/* ====== m3 触摸波纹反馈(自 global-enhance.js 迁出) ====== */
.touch-feedback {
    position: relative;
    overflow: hidden;
}
.touch-feedback::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}
.touch-feedback:active::after {
    width: 200%;
    height: 200%;
}

/* ====== m3 快捷键帮助弹窗(自 global-enhance.js 迁出) ====== */
.shortcuts-help-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 999999;
    max-width: 400px;
    width: 90%;
    font-family: 'Microsoft YaHei', sans-serif;
}
.shortcuts-help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999998;
}

/* ====== m3 备案兜底页脚(自 global-enhance.js 迁出, 视觉1:1) ====== */
.tscc-beian-footer {
    text-align: center;
    padding: 12px 8px;
    font-size: 13px;
    color: #999;
    background: #f8f5f0;
    border-top: 1px solid #e0d6c8;
    line-height: 1.6;
}


/* ====== m15 全站通用 SEO 散文内容块(零内联样式, 唐风) ====== */
.seo-prose {
    max-width: 860px;
    margin: 36px auto;
    padding: 28px 26px;
    background: #fdfaf5;
    border: 1px solid #e8dcc8;
    border-radius: 10px;
    color: #5a4a3a;
    line-height: 2;
    font-size: 15px;
}
.seo-prose h2 {
    font-size: 20px;
    color: #8B4513;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #DAA520;
    font-weight: 700;
}
.seo-prose h3 {
    font-size: 16px;
    color: #8B4513;
    margin: 20px 0 8px;
    font-weight: 700;
}
.seo-prose p { margin: 0 0 12px; }
.seo-prose ul { margin: 0 0 12px; padding-left: 22px; }
.seo-prose li { margin-bottom: 6px; }
.seo-prose a { color: #a0622d; text-decoration: none; border-bottom: 1px dashed #DAA520; }
.seo-prose a:hover { color: #8B4513; }
.seo-prose .lead { font-size: 16px; color: #6b5439; }
@media (max-width: 640px) {
    .seo-prose { margin: 24px 12px; padding: 20px 16px; font-size: 14px; }
}

/* ====== m16 诗集图书馆组件补充样式(零内联, 唐风) ====== */
.poem-tags {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.poem-tag {
    display: inline-block;
    padding: 2px 10px;
    font-size: 12px;
    color: #8B4513;
    background: #fdf6e8;
    border: 1px solid #e8dcc8;
    border-radius: 999px;
}
.page-btn.disabled {
    opacity: .45;
    pointer-events: none;
}
.page-ellipsis {
    border: none !important;
    background: transparent !important;
    cursor: default;
}
.poem-count {
    text-align: center;
    color: #a08060;
    font-size: 13px;
    margin: 10px 0 0;
}
.poem-card .action-btn.reading {
    background: linear-gradient(135deg, #b8632a, #8B4513);
    color: #fff;
}
@media (max-width: 640px) {
    .poem-tag { font-size: 11px; padding: 1px 8px; }
    .pagination .page-btn { padding: 6px 10px; font-size: 13px; }
}
