/* ==================== 易算AI - 弹层等待动画 (Modal) ==================== */
/* 版本: 1.0.0 | 用途: 替代内联占位符，半透明遮罩 + 居中动画卡 */
/* 依赖: 01-design-tokens.css（仅使用 var(--*) 时需要；动画本身独立可运行） */
/* 设计: 极简白卡 + 蓝色光晕，三铜钱+卦象组合 + 阶段轮播 */

/* ==================== 遮罩 ==================== */
.yixue-modal-mask {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    /* 显隐动画 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.yixue-modal-mask.show {
    opacity: 1;
    visibility: visible;
}

/* ==================== 弹层卡 ==================== */
.yixue-modal-card {
    width: 100%;
    max-width: 320px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 16px;
    box-shadow:
        0 24px 48px rgba(15, 23, 42, 0.18),
        0 8px 16px rgba(15, 23, 42, 0.08),
        0 0 0 1px rgba(30, 159, 255, 0.08);
    padding: 28px 24px 22px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transform: scale(0.92) translateY(8px);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.yixue-modal-mask.show .yixue-modal-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* 顶部光晕（蓝色径向） */
.yixue-modal-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(30, 159, 255, 0.18) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.yixue-modal-card>* {
    position: relative;
    z-index: 1;
}

/* ==================== 弹层内的项目 Logo（替代铜钱+卦象） ==================== */
.yixue-modal-logo {
    display: block;
    width: 110px;
    height: 110px;
    margin: 4px auto 18px;
    /* 蓝色脉冲光晕（呼吸感） */
    filter: drop-shadow(0 4px 12px rgba(30, 159, 255, 0.25));
    animation:
        yixue-logo-spin 3.2s linear infinite,
        yixue-logo-breath 2.4s ease-in-out infinite;
    will-change: transform, filter;
}

/* 慢速顺时针旋转（柔和、匀速） */
@keyframes yixue-logo-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* 缩放 + 光晕交替呼吸（强化"思考中"语义） */
@keyframes yixue-logo-breath {

    0%,
    100% {
        transform: rotate(0deg) scale(1);
        filter: drop-shadow(0 4px 10px rgba(30, 159, 255, 0.22));
    }

    50% {
        transform: rotate(0deg) scale(1.06);
        filter: drop-shadow(0 8px 22px rgba(30, 159, 255, 0.45));
    }
}

/* 减少动画偏好：仅保留静态光晕，停止旋转/缩放 */
@media (prefers-reduced-motion: reduce) {
    .yixue-modal-logo {
        animation: none;
        filter: drop-shadow(0 4px 12px rgba(30, 159, 255, 0.3));
    }
}

/* ==================== 弹层内的铜钱 ==================== */
.yixue-modal-coins {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 56px;
    margin-bottom: 14px;
    perspective: 600px;
}

.yixue-modal-coins .coin {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffe199 0%, #f5b400 65%, #c08800 100%);
    box-shadow:
        inset 0 -3px 5px rgba(120, 60, 0, 0.35),
        inset 0 2px 3px rgba(255, 240, 200, 0.6),
        0 3px 8px rgba(180, 120, 0, 0.25);
    position: relative;
    transform-style: preserve-3d;
    animation: coinFlip 1.6s cubic-bezier(0.45, 0, 0.55, 1) infinite;
    will-change: transform;
}

.yixue-modal-coins .coin::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #fafbfc 0%, #e5e7eb 100%);
    transform: translate(-50%, -50%) rotate(45deg);
    box-shadow:
        inset 0 0 2px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(120, 60, 0, 0.3);
    border-radius: 2px;
}

.yixue-modal-coins .coin:nth-child(1) {
    animation-delay: 0s;
}

.yixue-modal-coins .coin:nth-child(2) {
    animation-delay: 0.2s;
}

.yixue-modal-coins .coin:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes coinFlip {
    0% {
        transform: rotateY(0deg) translateY(0);
    }

    25% {
        transform: rotateY(180deg) translateY(-5px);
    }

    50% {
        transform: rotateY(360deg) translateY(0);
    }

    75% {
        transform: rotateY(540deg) translateY(-5px);
    }

    100% {
        transform: rotateY(720deg) translateY(0);
    }
}

/* ==================== 弹层内的卦象缩略 ==================== */
.yixue-modal-gua {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin-bottom: 14px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    border: 1px solid rgba(30, 159, 255, 0.1);
}

.yixue-modal-gua .gua-line {
    width: 44px;
    height: 5px;
    background: #e5e7eb;
    border-radius: 3px;
    position: relative;
}

.yixue-modal-gua .gua-line.yang {
    background: linear-gradient(90deg, #1e9fff 0%, #0073d1 100%);
    box-shadow: 0 0 6px rgba(30, 159, 255, 0.3);
}

.yixue-modal-gua .gua-line.yin {
    background: transparent;
}

.yixue-modal-gua .gua-line.yin::before,
.yixue-modal-gua .gua-line.yin::after {
    content: '';
    position: absolute;
    top: 0;
    width: 45%;
    height: 100%;
    background: linear-gradient(90deg, #1e9fff 0%, #0073d1 100%);
    border-radius: 3px;
    box-shadow: 0 0 6px rgba(30, 159, 255, 0.3);
}

.yixue-modal-gua .gua-line.yin::before {
    left: 0;
}

.yixue-modal-gua .gua-line.yin::after {
    right: 0;
}

/* 卦象循环动画 */
.yixue-modal-gua .gua-line {
    animation: modalGuaLineCycle 3.6s ease-in-out infinite;
    opacity: 0.3;
}

.yixue-modal-gua .gua-line:nth-child(1) {
    animation-delay: 0s;
}

.yixue-modal-gua .gua-line:nth-child(2) {
    animation-delay: 0.12s;
}

.yixue-modal-gua .gua-line:nth-child(3) {
    animation-delay: 0.24s;
}

.yixue-modal-gua .gua-line:nth-child(4) {
    animation-delay: 0.36s;
}

.yixue-modal-gua .gua-line:nth-child(5) {
    animation-delay: 0.48s;
}

.yixue-modal-gua .gua-line:nth-child(6) {
    animation-delay: 0.6s;
}

@keyframes modalGuaLineCycle {

    0%,
    100% {
        opacity: 0.3;
        transform: scaleX(0.85);
    }

    20%,
    80% {
        opacity: 1;
        transform: scaleX(1);
    }
}

/* ==================== 弹层文字 ==================== */
.yixue-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.yixue-modal-hint {
    font-size: 12px;
    color: #6b7280;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
    min-height: 16px;
}

/* ==================== 阶段指示器 ==================== */
.yixue-modal-stages {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: #9ca3af;
}

.yixue-modal-stage {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 9px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.yixue-modal-stage-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #d1d5db;
    transition: all 0.3s ease;
}

.yixue-modal-stage.active {
    background: rgba(30, 159, 255, 0.12);
    color: #1e9fff;
    font-weight: 600;
}

.yixue-modal-stage.active .yixue-modal-stage-dot {
    background: #1e9fff;
    box-shadow: 0 0 6px rgba(30, 159, 255, 0.5);
    animation: modalStageDotPulse 1.2s ease-in-out infinite;
}

.yixue-modal-stage.done {
    color: #52c41a;
    background: rgba(82, 196, 26, 0.08);
}

.yixue-modal-stage.done .yixue-modal-stage-dot {
    background: #52c41a;
}

@keyframes modalStageDotPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.7);
    }
}

/* ==================== 底部进度条（点缀） ==================== */
.yixue-modal-progress {
    margin-top: 12px;
    width: 100%;
    height: 2px;
    background: rgba(30, 159, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.yixue-modal-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #1e9fff, transparent);
    animation: modalProgressSlide 1.8s ease-in-out infinite;
}

@keyframes modalProgressSlide {
    0% {
        left: -40%;
    }

    100% {
        left: 100%;
    }
}

/* ==================== 响应式 ==================== */
@media (max-width: 767px) {
    .yixue-modal-mask {
        padding: 12px;
    }

    .yixue-modal-card {
        max-width: 280px;
        padding: 24px 20px 18px;
        border-radius: 14px;
    }

    .yixue-modal-logo {
        width: 88px;
        height: 88px;
        margin: 2px auto 14px;
    }

    .yixue-modal-coins {
        height: 48px;
        gap: 10px;
        margin-bottom: 12px;
    }

    .yixue-modal-coins .coin {
        width: 28px;
        height: 28px;
    }

    .yixue-modal-coins .coin::before {
        width: 8px;
        height: 8px;
    }

    .yixue-modal-gua {
        padding: 6px 12px;
        margin-bottom: 10px;
    }

    .yixue-modal-gua .gua-line {
        width: 36px;
        height: 4px;
    }

    .yixue-modal-title {
        font-size: 15px;
    }

    .yixue-modal-hint {
        font-size: 11px;
    }

    .yixue-modal-stage {
        padding: 2px 7px;
        font-size: 11px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .yixue-modal-card {
        max-width: 300px;
    }
}

/* ==================== 触摸设备优化 ==================== */
@media (hover: none) and (pointer: coarse) {
    .yixue-modal-coins .coin {
        animation-duration: 2s;
    }
}

/* ==================== 减少动画偏好 ==================== */
@media (prefers-reduced-motion: reduce) {
    .yixue-modal-coins .coin {
        animation: coinPulse 1.6s ease-in-out infinite;
    }

    @keyframes coinPulse {

        0%,
        100% {
            transform: scale(1);
            opacity: 1;
        }

        50% {
            transform: scale(0.92);
            opacity: 0.7;
        }
    }

    .yixue-modal-gua .gua-line {
        animation: none;
        opacity: 1;
    }

    .yixue-modal-progress::after {
        animation-duration: 3s;
    }
}

/* ==================== 暗色模式预留 ==================== */
@media (prefers-color-scheme: dark) {
    .yixue-modal-mask {
        background: rgba(0, 0, 0, 0.6);
    }

    .yixue-modal-card {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    }

    .yixue-modal-gua {
        background: rgba(255, 255, 255, 0.05);
    }

    .yixue-modal-title {
        color: #f3f4f6;
    }
}