/* 移动端优化样式 */

/* 确保所有触摸目标至少44px */
.mobile-touch-target {
    min-height: 44px;
    min-width: 44px;
    padding: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 移动端导航优化 */
@media screen and (max-width: 768px) {
    /* 导航菜单汉堡按钮 */
    .nav-toggle {
        display: block;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-color);
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
        cursor: pointer;
    }

    .nav-toggle:focus-visible {
        outline: 2px solid var(--focus-color);
        outline-offset: 2px;
    }

    /* 移动端导航菜单 */
    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 1000;
    }

    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-menu li {
        border-bottom: 1px solid #eee;
    }

    .nav-menu a {
        display: block;
        padding: 16px 20px;
        min-height: 44px;
        line-height: 1.2;
        text-decoration: none;
        color: var(--text-color);
    }

    .nav-menu a:hover,
    .nav-menu a:focus {
        background-color: #f5f5f5;
    }

    /* 部分切换tabs优化 */
    .section-tabs {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .section-tab {
        min-height: 44px;
        min-width: 80px;
        padding: 12px 16px;
        flex: 0 1 calc(50% - 4px);
        font-size: 14px;
        border-radius: 8px;
    }

    /* 音频播放器优化 */
    .play-btn {
        min-height: 48px;
        min-width: 48px;
        font-size: 18px;
        border-radius: 50%;
        margin-right: 12px;
    }

    .progress-bar {
        flex: 1;
        margin: 0 12px;
    }

    .progress {
        height: 8px;
        background: #ddd;
        border-radius: 4px;
        -webkit-appearance: none;
        appearance: none;
        cursor: pointer;
    }

    .progress::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        height: 20px;
        width: 20px;
        border-radius: 50%;
        background: var(--primary-color);
        cursor: pointer;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }

    .progress::-moz-range-thumb {
        height: 20px;
        width: 20px;
        border-radius: 50%;
        background: var(--primary-color);
        cursor: pointer;
        border: none;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }

    /* 播放速度选择器 */
    .playback-speed {
        min-height: 44px;
        padding: 8px 12px;
        border: 2px solid #ddd;
        border-radius: 6px;
        background: #fff;
        font-size: 14px;
    }

    /* 播放时间显示 */
    .time {
        font-size: 12px;
        color: #666;
        min-width: 80px;
        text-align: center;
    }

    /* 答题输入框优化 */
    .answer-input {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 16px; /* 防止iOS自动缩放 */
        border: 2px solid #ddd;
        border-radius: 6px;
        background: #fff;
        width: 100%;
        box-sizing: border-box;
    }

    .answer-input:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(183, 28, 28, 0.1);
        outline: none;
    }

    /* 提交按钮优化 */
    .submit-btn,
    .retry-btn {
        min-height: 48px;
        padding: 14px 24px;
        font-size: 16px;
        font-weight: 600;
        border: none;
        border-radius: 8px;
        background: var(--primary-color);
        color: #fff;
        cursor: pointer;
        width: 100%;
        margin-top: 16px;
    }

    .submit-btn:hover,
    .retry-btn:hover {
        background: var(--primary-dark);
    }

    .submit-btn:focus-visible,
    .retry-btn:focus-visible {
        outline: 2px solid var(--focus-color);
        outline-offset: 2px;
    }

    /* 问题项目优化 */
    .question-item {
        padding: 16px 12px;
        margin-bottom: 16px;
        border: 1px solid #eee;
        border-radius: 8px;
        background: #fafafa;
    }

    .question-number {
        font-weight: bold;
        color: var(--primary-color);
        font-size: 16px;
        margin-bottom: 8px;
    }

    .question-text {
        margin-bottom: 12px;
        line-height: 1.5;
    }

    /* 选择题选项优化 */
    .options-list {
        flex-direction: column;
        gap: 8px;
    }

    .option-item {
        min-height: 44px;
        padding: 12px 16px;
        border: 2px solid #ddd;
        border-radius: 6px;
        background: #fff;
        cursor: pointer;
        display: flex;
        align-items: center;
        transition: all 0.2s ease;
    }

    .option-item:hover {
        border-color: var(--primary-color);
        background: #fafafa;
    }

    .option-item.selected {
        border-color: var(--primary-color);
        background: rgba(183, 28, 28, 0.05);
    }

    .option-radio {
        margin-right: 12px;
        min-height: 20px;
        min-width: 20px;
    }

    /* 结果显示优化 */
    .result-modal {
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .score-circles {
        flex-direction: column;
        gap: 16px;
        align-items: center;
    }

    .score-circle {
        min-width: 120px;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        border: 4px solid #ddd;
        background: #fff;
    }

    .score-value {
        font-size: 24px;
        font-weight: bold;
        color: var(--primary-color);
    }

    .score-label {
        font-size: 12px;
        color: #666;
        margin-top: 4px;
    }

    /* 模态框关闭按钮 */
    .close-btn {
        position: absolute;
        top: 12px;
        right: 12px;
        min-height: 44px;
        min-width: 44px;
        background: none;
        border: none;
        font-size: 24px;
        color: #666;
        cursor: pointer;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .close-btn:hover {
        background: #f0f0f0;
    }

    .close-btn:focus-visible {
        outline: 2px solid var(--focus-color);
        outline-offset: 2px;
    }
}

/* 超小屏幕优化 (480px及以下) */
@media screen and (max-width: 480px) {
    .section-tab {
        flex: 1 1 100%;
        margin-bottom: 8px;
    }

    .player-main {
        flex-direction: column;
        gap: 12px;
    }

    .progress-bar {
        order: 2;
        margin: 0;
        width: 100%;
    }

    .time {
        order: 3;
        margin-top: 8px;
    }

    .speed-control {
        margin-top: 12px;
        width: 100%;
    }

    .playback-speed {
        width: 100%;
    }

    .answer-input {
        padding: 16px;
        font-size: 18px; /* 更大的字体防止缩放 */
    }
}

/* 横屏模式优化 */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .section-tabs {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
    }

    .section-tab {
        flex: 0 0 auto;
        min-width: 100px;
    }

    .player-main {
        flex-direction: row;
        align-items: center;
    }

    .progress-bar {
        flex: 1;
        margin: 0 12px;
    }
}

/* 触摸设备特定优化 */
@media (hover: none) and (pointer: coarse) {
    /* 移除hover效果，使用active状态 */
    .section-tab:hover {
        background-color: initial;
    }

    .section-tab:active {
        background-color: rgba(183, 28, 28, 0.1);
        transform: scale(0.98);
    }

    .play-btn:hover {
        background-color: initial;
    }

    .play-btn:active {
        transform: scale(0.95);
    }

    .option-item:hover {
        border-color: #ddd;
        background: #fff;
    }

    .option-item:active {
        border-color: var(--primary-color);
        background: rgba(183, 28, 28, 0.05);
        transform: scale(0.98);
    }
}