/**
 * MyAIGRD — Global Modal Styles
 * Includes Ad Interstitial & Custom Confirm Modals
 */

/* 1. 기본 모달 베이스 */
.mp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: var(--space-md);
}

.mp-modal__content {
    position: relative;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    padding: var(--space-2xl);
    border: 1px solid var(--border-gold);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(212, 175, 55, 0.2);
    overflow-y: auto;
    animation: modalFadeIn 0.4s var(--transition-bounce);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.mp-modal__close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    transition: all var(--transition);
}

.mp-modal__close:hover {
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold-light);
    border-color: var(--gold);
    transform: rotate(90deg);
}

/* 2. 광고 인터스티셜 전용 */
.mp-modal--ad .mp-modal__content {
    max-width: 520px;
    overflow: hidden;
    /* 타이머 애니메이션 등을 위해 */
}

.mp-ad__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.mp-ad__badge {
    font-size: var(--fs-xs);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mp-ad__timer {
    position: relative;
    width: 48px;
    height: 48px;
}

.mp-ad__timer-svg {
    width: 48px;
    height: 48px;
    transform: rotate(-90deg);
}

.mp-ad__timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 2;
}

.mp-ad__timer-fill {
    fill: none;
    stroke: var(--gold);
    stroke-width: 2;
    stroke-dasharray: 100;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear;
}

.mp-ad__timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: var(--fw-bold);
    color: var(--gold-light);
}

.mp-ad__body {
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-lg);
}

.mp-ad__slot {
    width: 100%;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.mp-ad__placeholder {
    text-align: center;
    padding: var(--space-2xl);
}

.mp-ad__placeholder p {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.mp-ad__upgrade-hint {
    font-size: var(--fs-xs) !important;
    color: var(--text-secondary) !important;
    opacity: 0.7;
}

.mp-ad__footer {
    text-align: center;
}

#ad-skip-btn {
    min-width: 220px;
    border-radius: var(--radius-full);
    transition: all 0.3s ease;
}

#ad-skip-btn:not(:disabled) {
    background: var(--gradient-gold);
    color: #000;
    animation: adPulse 1.5s ease infinite;
}

@keyframes adPulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(212, 175, 55, 0);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
    }
}

/* 3. 커스텀 확인/알림 모달 (네이티브 대체) */
.mp-modal--confirm {
    z-index: 3000;
}

.mp-confirm {
    max-width: 420px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center;
    padding: var(--space-2xl) var(--space-xl) !important;
}

.mp-confirm__icon {
    font-size: 3.5rem;
    margin-bottom: var(--space-md);
    animation: adCoinSlide 0.6s var(--transition-bounce);
}

@keyframes adCoinSlide {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.mp-confirm__message {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: var(--space-xl);
    white-space: pre-line;
}

.mp-confirm__message strong {
    color: var(--gold-light);
    font-weight: var(--fw-bold);
}

.mp-confirm__actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    width: 100%;
}

.mp-confirm__actions .btn {
    flex: 1;
    max-width: 160px;
}

/* 4. 광고 모달 모바일 반응형 */
@media (max-width: 768px) {
    .mp-modal--ad .mp-modal__content {
        max-width: 95vw;
        padding: var(--space-lg) var(--space-md);
    }

    .mp-ad__body {
        min-height: 180px;
    }

    .mp-ad__slot {
        min-height: 180px;
    }

    /* 쿠팡 광고 이미지 모바일 대응 */
    .mp-ad__slot img,
    .mp-ad__slot a img {
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain;
    }

    .mp-ad__slot iframe {
        max-width: 100% !important;
    }

    /* 쿠팡 파트너스 텍스트 오버플로우 방지 */
    .mp-ad__footer,
    .mp-ad__body {
        overflow: hidden;
        word-break: keep-all;
    }

    .mp-ad__footer p,
    .mp-ad__footer small {
        font-size: 0.65rem;
        word-break: keep-all;
    }

    .mp-confirm {
        max-width: 90vw !important;
    }
}