/* ==========================================================================
   Modal Styles - 模态框通用样式模块 (v4.0 - 移动端全屏适配)
   --------------------------------------------------------------------------
   职责:
   - 定义所有模态框（听力、打字、单词本等）共享的通用基础样式。
   - 移动端适配：手机屏幕上强制全屏显示。
   ========================================================================== */

/* --- 模态框: 遮罩层 (通用) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    /* 默认淡入效果 */
    animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}


/* --- 模态框: 内容容器 (通用 / PC端) --- */
.modal-content {
    background: var(--card-bg);
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-hover);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--border-color);

    /* PC端进入动画：向上浮现 */
    animation: fadeInUp 0.3s forwards;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}


/* --- 模态框: 通用元素 --- */
.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-sub);
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
    z-index: 10; /* 确保在最上层 */
}
.modal-close-btn:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}


/* --- 模态框: 控制按钮 (通用) --- */
.control-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.control-btn:active {
    transform: scale(0.98);
}

.control-btn svg {
    width: 18px;
    height: 18px;
}

.btn-reveal {
    background: var(--bg-secondary-color);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-reveal:hover {
    background: var(--border-color);
}

.btn-next,
.btn-submit {
    background: var(--theme-color);
    color: var(--text-inverse);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.btn-next:hover,
.btn-submit:hover {
    opacity: 0.9;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
.control-btn:disabled:hover {
    opacity: 0.5;
}


/* ==========================================================================
   移动端响应式适配 (Breakpoint: 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /*
       移动端全屏模态框：
       就像原生 App 的新页面一样覆盖全屏
    */
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;

        border-radius: 0;
        border: none;
        box-shadow: none;

        /* 增加内边距适配刘海屏等 */
        padding: 2rem 1.5rem;
        padding-top: calc(2rem + env(safe-area-inset-top));

        /* 移动端进入动画：从底部滑入 */
        animation: slideInUp 0.3s forwards;
    }

    @keyframes slideInUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* 调整关闭按钮位置，更易触达 */
    .modal-close-btn {
        top: calc(15px + env(safe-area-inset-top));
        right: 15px;
        padding: 10px; /* 增大点击热区 */
    }
    .modal-close-btn svg {
        width: 28px;
        height: 28px;
    }

    /* 针对特定模态框的内容滚动优化 */
    .wordbook-content, .typing-content {
        overflow-y: auto;
    }
}